package com.ms.api.dto.dsorder;

import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class PurchaseOrderDTO {
    private Long purchaseOrderId;
    private String platformOrderId;
    private String purchasePlatform;
    private String purchaseOrderSn;
    private String purchaseOrderBuyer;
    private String purchaseOrderSeller;
    private String purchaseOrderPayment;
    private String purchaseOrderFullname;
    private String purchaseOrderMobile;
    private String purchaseOrderFullAddress;
    private String purchaseOrderStartTime;
    private String platformPushStatus;
    private String purchaseOrderLogisticsName;
    private String purchaseOrderWaybillCode;
    private String purchaseOrderUpdateTime;
    private String purchaseOrderPayTime;
    private String purchaseOrderStatus;
    private String purchaseOrderFlow;
    private String alibabaOrderStatus;
    private Boolean isUseManualConsignee;
    private List<PurchaseOrderItemDTO> items;
    private String checkReason;
    private String checkStatus;
    private Integer logisticsIsAccept;
    private String purchaseOrderSendTime;
    private Boolean isFirstPurchase = false;
    private String purchaseAlipayMerchantNo;
    private Integer isDsEncryptOrder;
    private Integer isSupportEncryptOrder;
    private List<Long> mergePurchasePlatformOrderIds;
    private String notFirst1688OrderType;
    private Map<String, RefundInfoDTO> refundInfo;

    public List<Long> getSkuIds() {
        List<Long> skuIds = new ArrayList<>();
        for (PurchaseOrderItemDTO item: this.items) {
            skuIds.add(item.getSkuId());
        }
        return skuIds;
    }

    public Map<Long, PurchaseOrderItemDTO> getSkuIdAndItemMap() {
        Map<Long, PurchaseOrderItemDTO> skuIdAndItemMap = new HashMap<>();
        for (PurchaseOrderItemDTO item: this.items) {
            skuIdAndItemMap.put(item.getSkuId(), item);
        }
        return skuIdAndItemMap;
    }
}
