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

import cn.hutool.core.date.DateUtil;
import com.tmerclub.cloud.common.order.bo.DeliveryModeBO;
import com.tmerclub.cloud.common.product.dto.SkuDTO;
import com.tmerclub.cloud.common.product.dto.SpuDTO;
import com.tmerclub.cloud.common.product.dto.SpuLangDTO;
import com.tmerclub.cloud.common.util.Json;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lpj
 */
public class PreSaleSpuData {
    public static SpuDTO getDepositPreSaleSpu(Long categoryId, Long shopCategoryId, Long deliveryTemplateId, Long priceFee){
        SpuDTO spuDTO = new SpuDTO();
        spuDTO.setCategoryId(categoryId);
        spuDTO.setShopCategoryId(shopCategoryId);
        spuDTO.setName("接口自动化定金预售商品");
        spuDTO.setSellingPoint("商品卖点");
        spuDTO.setDetail("测试商品详情");
        spuDTO.setDeliveryTemplateId(deliveryTemplateId);
        spuDTO.setMainImgUrl("/test.png");
        spuDTO.setImgUrls("/test.png");
        spuDTO.setMarketPriceFee(8800L);
        spuDTO.setPriceFee(priceFee);
        spuDTO.setHasSkuImg(0);
        spuDTO.setSkuList(getSkuList(priceFee));
        spuDTO.setSupplierSpuType(0);

        spuDTO.setPreSaleType(1);
        spuDTO.setDepositType(1);
        spuDTO.setDepositValue(BigDecimal.valueOf(8));
        spuDTO.setDepositExpansionValue(BigDecimal.valueOf(18));
        spuDTO.setDepositStartTime(DateUtil.parse("2023-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));
        spuDTO.setDepositEndTime(DateUtil.parse("2026-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));
        spuDTO.setBalanceStartTime(DateUtil.parse("2023-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));
        spuDTO.setBalanceEndTime(DateUtil.parse("2026-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));

        spuDTO.setPreSaleDeliveryType(-1);
        spuDTO.setPreSaleDeliveryTime(DateUtil.parse("2026-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));

        List<SpuLangDTO> spuLangDTOList = new ArrayList<>();
        SpuLangDTO spuLangDTO = new SpuLangDTO();
        spuLangDTO.setLang(1);
        spuLangDTO.setSpuName("接口自动化定金预售商品");
        spuLangDTOList.add(spuLangDTO);
        spuDTO.setSpuLangList(spuLangDTOList);

        spuDTO.setTotalStock(100);
        DeliveryModeBO deliveryModeBO = new DeliveryModeBO();
        deliveryModeBO.setHasShopDelivery(true);
        deliveryModeBO.setHasUserPickUp(true);
        deliveryModeBO.setHasCityDelivery(true);
        spuDTO.setDeliveryMode(Json.toJsonString(deliveryModeBO));

        spuDTO.setSpuMold(0);
        spuDTO.setSpuOrigin(0);

        return spuDTO;
    }

    public static SpuDTO getFullPreSaleSpu(Long categoryId, Long shopCategoryId, Long deliveryTemplateId, Long priceFee){
        SpuDTO spuDTO = new SpuDTO();
        spuDTO.setCategoryId(categoryId);
        spuDTO.setShopCategoryId(shopCategoryId);
        spuDTO.setName("接口自动化全款预售商品");
        spuDTO.setSellingPoint("商品卖点");
        spuDTO.setDetail("测试商品详情");
        spuDTO.setDeliveryTemplateId(deliveryTemplateId);
        spuDTO.setMainImgUrl("/test.png");
        spuDTO.setImgUrls("/test.png");
        spuDTO.setMarketPriceFee(8800L);
        spuDTO.setPriceFee(priceFee);
        spuDTO.setHasSkuImg(0);
        spuDTO.setSkuList(getSkuList(priceFee));
        spuDTO.setSupplierSpuType(0);

        spuDTO.setPreSaleType(0);
        spuDTO.setPreSaleDeliveryType(2);

        List<SpuLangDTO> spuLangDTOList = new ArrayList<>();
        SpuLangDTO spuLangDTO = new SpuLangDTO();
        spuLangDTO.setLang(1);
        spuLangDTO.setSpuName("接口自动化全款预售商品");
        spuLangDTOList.add(spuLangDTO);
        spuDTO.setSpuLangList(spuLangDTOList);

        spuDTO.setTotalStock(100);
        DeliveryModeBO deliveryModeBO = new DeliveryModeBO();
        deliveryModeBO.setHasShopDelivery(true);
        deliveryModeBO.setHasUserPickUp(true);
        deliveryModeBO.setHasCityDelivery(true);
        spuDTO.setDeliveryMode(Json.toJsonString(deliveryModeBO));

        spuDTO.setSpuMold(0);
        spuDTO.setSpuOrigin(0);

        return spuDTO;
    }

    public static List<SkuDTO> getSkuList(Long priceFee){
        List<SkuDTO> skuList = new ArrayList<>();
        SkuDTO skuDTO = new SkuDTO();
        skuDTO.setChangeStock(100);
        skuDTO.setPriceFee(priceFee);
        skuDTO.setMarketPriceFee(8800L);
        skuDTO.setStock(100);
        skuDTO.setStatus(1);
        skuDTO.setWeight(0.0);
        skuDTO.setVolume(0.0);
        skuList.add(skuDTO);
        return skuList;
    }
}
