package com.ruoyi.api.fake;

import com.ruoyi.api.pojo.bo.ProductsBO;
import com.ruoyi.common.utils.uuid.IdUtils;

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

public class PushProductFake {

    /**
     * 推送商品Fake数据
     * @return
     */
    public static ProductsBO productsBO() {
        ProductsBO productsBO = new ProductsBO();
        productsBO.setTitle("测试商品" + IdUtils.fastUUID().toString());
        productsBO.setDetailImages("<figure class=\"image\"><img src=\"https://img.yunzhonghe.com/image/1570588776975JFmOBwQXph.jpg\"></figure>");
        productsBO.setCategory1Id(4L);
        productsBO.setCategory2Id(6L);
        productsBO.setCategory3Id(7L);
        productsBO.setStock(10000L);
        productsBO.setPrice(6666L);
        productsBO.setGuidePrice(7777L);
        productsBO.setOriginPrice(8000L);
        productsBO.setCostPrice(5555L);
        productsBO.setFreight(0L);
        productsBO.setFreightTemplateId(0L);
        productsBO.setFreightType(2);
        productsBO.setUnit("个");
        productsBO.setImageUrl("http://img.limofang.cn//2021/2/1570869704680QazgQpvuHF.jpg");

        // 组图
        List<ProductsBO.ProductsGalleryBO> gallery = new ArrayList<>();
        List<String> srcList = Arrays.asList("http://img.limofang.cn//2021/2/1570869704669UWFHzwIMIn.jpg", "http://img.limofang.cn//2021/2/1570869704688uYGRoXrfAH.jpg", "http://img.limofang.cn//2021/2/1570869704680QazgQpvuHF.jpg", "http://img.limofang.cn//2021/2/1570869706317wpCRqaHaNw.jpg", "http://img.limofang.cn//2021/2/1570869706339pKSzOYmWaS.jpg");
        for (String src : srcList) {
            ProductsBO.ProductsGalleryBO productsGalleryBO = productsBO.new ProductsGalleryBO();
            productsGalleryBO.setType(1);
            productsGalleryBO.setSrc(src);
            gallery.add(productsGalleryBO);
        }
        productsBO.setGallery(gallery);

        // 属性
        List<ProductsBO.ProductsAttrsBO> attrList = new ArrayList<>();
        ProductsBO.ProductsAttrsBO productsAttrsBO = productsBO.new ProductsAttrsBO();
        productsAttrsBO.setName("颜色");
        productsAttrsBO.setValue("白");
        attrList.add(productsAttrsBO);
        productsBO.setAttrs(attrList);

        // 规格
        ArrayList<ProductsBO.ProductsSkusBO> skuList = new ArrayList<>();
        ProductsBO.ProductsSkusBO productsSkusBO = productsBO.new ProductsSkusBO();
        productsSkusBO.setTitle("新款+超辣");
        productsSkusBO.setCostPrice(1L);
        productsSkusBO.setOriginPrice(3L);
        productsSkusBO.setGuidePrice(3L);
        productsSkusBO.setActivityPrice(0L);
        productsSkusBO.setStock(99L);
        // 规格详情
        List<ProductsBO.ProductsSkusBO.SkusOptions> optionList = new ArrayList<>();
        ProductsBO.ProductsSkusBO.SkusOptions skusOptions = productsSkusBO.new SkusOptions();
        skusOptions.setSpecName("规格");
        skusOptions.setSpecItemName("默认");
        optionList.add(skusOptions);
        productsSkusBO.setOptions(optionList);
        productsSkusBO.setPrice(1L);
        productsSkusBO.setWeight(500L);
        productsSkusBO.setCode("");
        productsSkusBO.setSn("0001");
        skuList.add(productsSkusBO);
        productsBO.setSkus(skuList);

        productsBO.setSingleOption(1);
        productsBO.setCode("");
        return productsBO;
    }
}
