package com.ms.api.dto.dsapi.request;

import lombok.Data;

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

@Data
public class BatchCreateDistributionOrdersRequestDTO {
    private List<PlatformOrderDTO> platformOrders;
    private boolean isRepurchase;
    private String actionSource;
    private String purchaseSource;
    private HashMap<String, String> platformOrderIdAndPurchaseConfirmLogIdMap;
    private Integer isAutoPay;
    private String platform;
    private OperateInfoDTO operateInfo;

    public List<String> getOrderIds() {
        List<String> orderIds = new ArrayList<>();
        for (PlatformOrderDTO platformOrder: getPlatformOrders()) {
            orderIds.add(platformOrder.getPlatformOrderId());
        }
        return orderIds;
    }

    public List<PlatformOrderItemDTO> getAllItems() {
        List<PlatformOrderItemDTO> items = new ArrayList<>();
        for (PlatformOrderDTO platformOrder: getPlatformOrders()) {
            items.addAll(platformOrder.getItems());
        }
        return items;
    }
}
