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

import com.tmerclub.cloud.common.order.dto.DvyTypeDTO;
import com.tmerclub.cloud.common.order.dto.OrderDTO;
import com.tmerclub.cloud.common.order.dto.ShopCartItemDTO;
import com.tmerclub.cloud.common.product.vo.app.SpuAppVO;
import com.moyuer.cloud.systemtest.api.login.UserApi;
import com.moyuer.cloud.systemtest.api.platform.ScoreProductApi;

import java.util.ArrayList;

/**
 * @author lpj
 */
public class ScoreOrderDtoData {
    /**
     * 立即购买积分商品
     */
    public static OrderDTO getScoreOrderDtoData(Long spuId, Integer count) {
        OrderDTO orderDTO = new OrderDTO();
        Long userId = UserApi.getUserInfo().getUserId();
        SpuAppVO product = ScoreProductApi.getScoreProductInfo(spuId, userId);
        orderDTO.setAddrId(0L);
        orderDTO.setCouponIds(new ArrayList<>());

        DvyTypeDTO dvyTypeDTO = new DvyTypeDTO();
        dvyTypeDTO.setDvyType(1);
        dvyTypeDTO.setShopId(product.getShopId());
        ArrayList<DvyTypeDTO> dvyTypeDTOList = new ArrayList<>();
        dvyTypeDTOList.add(dvyTypeDTO);
        orderDTO.setDvyTypes(dvyTypeDTOList);

        orderDTO.setIsScorePay(1);
        orderDTO.setUserChangeCoupon(0);
        orderDTO.setUserUseScore(0L);

        ShopCartItemDTO shopCartItemDTO = new ShopCartItemDTO();
        shopCartItemDTO.setCount(count);
        shopCartItemDTO.setDistributionUserId(0L);
        shopCartItemDTO.setShopId(product.getShopId());
        shopCartItemDTO.setSkuId(product.getSkus().get(0).getSkuId());
        shopCartItemDTO.setSpuId(spuId);

        orderDTO.setShopCartItem(shopCartItemDTO);

        return orderDTO;
    }
}
