package edu.mama.ls16.homework;
// 尽管用户可能维护多个收货信息,但下单只能对应一个收货信息,且用户修改保存的收货信息不会影响订单中的收货信息————收货信息直接为Order属性
// 商品和卖家可以有2种关系:1.每个商品只对应一个卖家 2.一个商品对应多个卖家;本题使用的是后者————卖家作为Order属性
import java.math.BigDecimal;
import java.time.*;
import java.time.format.DateTimeFormatter;
public class Order {
private String ID; //订单编号
private LocalDate date; //订单日期
private Commodity commodity; //订单商品
private Seller seller; //卖家
private String memo; //订单备注
private BigDecimal payAmount; //支付金额
private LocalDateTime payTime; //支付时间
private Buyer buyer; //买家
private Consignee consignee; //收货信息
private static DateTimeFormatter _dtfOrderDate _= DateTimeFormatter._ofPattern_("yyyy-MM-dd"); //订单日期的格式<br /> private static DateTimeFormatter _dtfPayTime _= DateTimeFormatter._ofPattern_("yyyy-MM-dd HH:mm:ss"); //支付时间的格式
//支付时间在创建订单之后<br /> public Order(String ID, LocalDate date, Commodity commodity, Seller seller, String memo, BigDecimal payAmount, Buyer buyer, Consignee consignee) {<br /> this.ID = ID;<br /> this.date = date;<br /> this.commodity = commodity;<br /> this.seller = seller;<br /> this.memo = memo;<br /> this.payAmount = payAmount;<br /> this.buyer = buyer;<br /> this.consignee = consignee;<br /> }
//备忘可以修改和补充<br /> public void setMemo(String memo) {<br /> this.memo = memo;<br /> }
//支付时间<br /> public void setPayTime(LocalDateTime payTime) {<br /> this.payTime = payTime;<br /> }
public String getID() {<br /> return ID;<br /> }
public LocalDate getDate() {<br /> return date;<br /> }
public Commodity getCommodity() {<br /> return commodity;<br /> }
public Seller getSeller() {<br /> return seller;<br /> }
public String getMemo() {<br /> return memo;<br /> }
public BigDecimal getPayAmount() {<br /> return payAmount;<br /> }
public LocalDateTime getPayTime() {<br /> return payTime;<br /> }
public Buyer getBuyer() {<br /> return buyer;<br /> }
public Consignee getConsignee() {<br /> return consignee;<br /> }
//以sep为分隔符,将Order内容拼接成字符串<br /> public String toString(String sep) {<br /> StringBuilder sb=new StringBuilder();<br /> sb.append(this.ID).append(sep).append(_dtfOrderDate_.format(this.date)).append(sep);<br /> sb.append(this.commodity.toString(sep)).append(sep).append(this.memo).append(sep);<br /> sb.append(this.payAmount.toString()).append(sep).append(_dtfPayTime_.format(this.payTime)).append(sep);<br /> sb.append(this.seller.toString(sep)).append(sep).append(this.buyer.toString(sep)).append(sep);<br /> sb.append(this.consignee.toString(sep));<br /> return sb.toString();<br /> }<br />}