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; //收货信息

    1. private static DateTimeFormatter _dtfOrderDate _= DateTimeFormatter._ofPattern_("yyyy-MM-dd"); //订单日期的格式<br /> private static DateTimeFormatter _dtfPayTime _= DateTimeFormatter._ofPattern_("yyyy-MM-dd HH:mm:ss"); //支付时间的格式
    2. //支付时间在创建订单之后<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 /> }
    3. //备忘可以修改和补充<br /> public void setMemo(String memo) {<br /> this.memo = memo;<br /> }
    4. //支付时间<br /> public void setPayTime(LocalDateTime payTime) {<br /> this.payTime = payTime;<br /> }
    5. public String getID() {<br /> return ID;<br /> }
    6. public LocalDate getDate() {<br /> return date;<br /> }
    7. public Commodity getCommodity() {<br /> return commodity;<br /> }
    8. public Seller getSeller() {<br /> return seller;<br /> }
    9. public String getMemo() {<br /> return memo;<br /> }
    10. public BigDecimal getPayAmount() {<br /> return payAmount;<br /> }
    11. public LocalDateTime getPayTime() {<br /> return payTime;<br /> }
    12. public Buyer getBuyer() {<br /> return buyer;<br /> }
    13. public Consignee getConsignee() {<br /> return consignee;<br /> }
    14. //以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 />}