package com.tmerclub.cloud.systemtest.data.platform;

import com.tmerclub.cloud.api.delivery.dto.DeliveryOrderDTO;
import com.tmerclub.cloud.api.delivery.dto.DeliveryOrderItemDTO;
import com.tmerclub.cloud.common.order.vo.OrderItemVO;
import com.tmerclub.cloud.common.order.vo.OrderVO;
import com.moyuer.cloud.systemtest.api.platform.ScoreOrderApi;

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

/**
 * @author lpj
 */
public class DeliveryScoreOrderDtoData {
    /**
     * 积分订单快递发货数据
     */
    public static DeliveryOrderDTO getDeliveryScoreOrderDtoData(Long orderNum) {
        DeliveryOrderDTO deliveryOrderDTO = new DeliveryOrderDTO();
        deliveryOrderDTO.setOrderId(orderNum);
        deliveryOrderDTO.setOrderAddrId(orderNum);
        deliveryOrderDTO.setDeliveryCompanyId(16L);
        deliveryOrderDTO.setDeliveryNo("123456789");
        deliveryOrderDTO.setDeliveryType(1);

        OrderItemVO orderItem = ScoreOrderApi.getScoreOrderItemAndAddress(orderNum).getOrderItems().get(0);

        OrderVO address = ScoreOrderApi.getScoreOrderItemAndAddress(orderNum);

        List<DeliveryOrderItemDTO> deliveryOrderItemDTOList = new ArrayList<>();
        DeliveryOrderItemDTO deliveryOrderItemDTO = new DeliveryOrderItemDTO();
        deliveryOrderDTO.setDeliveryOrderId(orderItem.getOrderItemId());
        deliveryOrderItemDTO.setOrderItemId(orderItem.getOrderItemId());
        deliveryOrderItemDTO.setChangeNum(1);
        deliveryOrderItemDTOList.add(deliveryOrderItemDTO);
        deliveryOrderDTO.setSelectOrderItems(deliveryOrderItemDTOList);
        deliveryOrderDTO.setOrderAddrId(address.getOrderAddrId());
        return deliveryOrderDTO;
    }

    /**
     * 积分订单无需快递发货数据
     */
    public static DeliveryOrderDTO getNoDeliveryScoreOrderDtoData(Long orderNum) {
        DeliveryOrderDTO deliveryOrderDTO = new DeliveryOrderDTO();
        deliveryOrderDTO.setOrderId(orderNum);
        deliveryOrderDTO.setOrderAddrId(orderNum);
        deliveryOrderDTO.setDeliveryType(3);

        List<DeliveryOrderItemDTO> deliveryOrderItemDTOList = new ArrayList<>();
        DeliveryOrderItemDTO deliveryOrderItemDTO = new DeliveryOrderItemDTO();
        OrderItemVO orderItem = ScoreOrderApi.getScoreOrderItemAndAddress(orderNum).getOrderItems().get(0);
        OrderVO address = ScoreOrderApi.getScoreOrderItemAndAddress(orderNum);
        deliveryOrderDTO.setDeliveryOrderId(orderItem.getOrderItemId());
        deliveryOrderItemDTO.setOrderItemId(orderItem.getOrderItemId());
        deliveryOrderItemDTO.setChangeNum(1);
        deliveryOrderItemDTOList.add(deliveryOrderItemDTO);
        deliveryOrderDTO.setSelectOrderItems(deliveryOrderItemDTOList);
        deliveryOrderDTO.setOrderAddrId(address.getOrderAddrId());
        return deliveryOrderDTO;
    }
}
