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

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.util.ArrayList;
import java.util.List;

/**
 * @author Tu
 */
public class SpuData {
    public static SpuDTO getRealSpu(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(88L);
        spuDTO.setPriceFee(priceFee);
        spuDTO.setHasSkuImg(0);
        spuDTO.setSkuList(getSkuList(priceFee));
        spuDTO.setSupplierSpuType(0);

        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.setPreSaleType(-1);
        spuDTO.setSpuOrigin(0);

        return spuDTO;
    }
    public static SpuDTO getUnRealSpu(Long categoryId,Long shopCategoryId,Long priceFee,Integer writeOffNum){
        SpuDTO spuDTO = new SpuDTO();
        spuDTO.setCategoryId(categoryId);
        spuDTO.setShopCategoryId(shopCategoryId);
        spuDTO.setName("接口自动化虚拟商品");
        spuDTO.setSellingPoint("虚拟商品卖点");
        spuDTO.setDetail("虚拟测试商品详情");
        spuDTO.setMainImgUrl("/test.png");
        spuDTO.setImgUrls("/test.png");
        spuDTO.setMarketPriceFee(88L);
        spuDTO.setPriceFee(priceFee);
        spuDTO.setHasSkuImg(0);
        spuDTO.setSkuList(getSkuList(priceFee));

        spuDTO.setSpuMold(1);
        spuDTO.setIsRefund(1);
        spuDTO.setPreSaleType(-1);
        spuDTO.setSpuOrigin(0);


        List<SpuLangDTO> spuLangDTOList = new ArrayList<>();
        SpuLangDTO spuLangDTO = new SpuLangDTO();
        spuLangDTO.setLang(1);
        spuLangDTO.setSpuName("接口自动化虚拟商品");
        spuLangDTOList.add(spuLangDTO);
        spuDTO.setSpuLangList(spuLangDTOList);
        spuDTO.setSkuList(getSkuList(priceFee));

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

        spuDTO.setWriteOffNum(writeOffNum);
        int writeOffMultipleCount = 3;
        if(writeOffNum == -1){spuDTO.setWriteOffMultipleCount(writeOffMultipleCount);}
        if(writeOffNum != 0){spuDTO.setWriteOffTime(-1);}
        return spuDTO;
    }



    public static SpuDTO getSupplierSpu(Long categoryId,Long deliveryTemplateId,Long priceFee){
        SpuDTO spuDTO = new SpuDTO();
        spuDTO.setCategoryId(categoryId);
        spuDTO.setName("供应商商品-接口自动化");
        spuDTO.setSellingPoint("商品卖点");
        spuDTO.setDetail("测试商品详情-供应商");
        spuDTO.setDeliveryTemplateId(deliveryTemplateId);
        spuDTO.setMainImgUrl("/test.png");
        spuDTO.setImgUrls("/test.png");
        spuDTO.setMarketPriceFee(88L);
        spuDTO.setPriceFee(priceFee);
        spuDTO.setHasSkuImg(0);
        spuDTO.setSkuList(getSkuList(priceFee));
        spuDTO.setSupplierSpuType(0);

        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.setPreSaleType(-1);
        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(88L);
        skuDTO.setStock(100);
        skuDTO.setStatus(1);
        skuDTO.setWeight(1.0);
        skuDTO.setVolume(1.0);
        skuList.add(skuDTO);
        return skuList;
    }
}
