package com.slodon.b2b2c.vo.goods;

import com.slodon.b2b2c.goods.pojo.GoodsPlatform;
import com.slodon.b2b2c.goods.pojo.ProductPlatform;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

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

/**
 *
 * 封装商户端商品库详情VO对象
 * @author wuxy
 * @date 2021.10.27 11:09
 */
@Data
public class SellerGoodsPlatformDetailVO {

    @ApiModelProperty("平台库商品ID")
    private Long platformGoodsId;

    @ApiModelProperty("商品名称")
    private String goodsName;

    @ApiModelProperty("商品广告语")
    private String goodsBrief;

    @ApiModelProperty("最低价")
    private BigDecimal minPrice;

    @ApiModelProperty("最高价")
    private BigDecimal maxPrice;

    @ApiModelProperty("是否是虚拟商品：1-实物商品；2-虚拟商品")
    private Integer isVirtualGoods;

    @ApiModelProperty(value = "商品详情信息")
    private String goodsDetails;

    @ApiModelProperty("商品图片列表")
    private List<String> imageList;

    @ApiModelProperty("规格列表")
    private List<SellerProductPlatformVO> productList;

    public SellerGoodsPlatformDetailVO(GoodsPlatform goodsPlatform) {
        this.platformGoodsId = goodsPlatform.getPlatformGoodsId();
        this.goodsName = goodsPlatform.getGoodsName();
        this.goodsBrief = goodsPlatform.getGoodsBrief();
        this.isVirtualGoods = goodsPlatform.getIsVirtualGoods();
        this.goodsDetails = goodsPlatform.getGoodsDetails();
    }

    @Data
    public static class SellerProductPlatformVO {
        @ApiModelProperty("平台库货品id")
        private Long platformProductId;

        @ApiModelProperty("平台库商品ID")
        private Long platformGoodsId;

        @ApiModelProperty("规格值，用逗号分隔")
        private String specValues;

        @ApiModelProperty("货品价格")
        private BigDecimal productPrice;

        @ApiModelProperty("是否默认货品：0-否；1-是")
        private Integer isDefault;

        public SellerProductPlatformVO(ProductPlatform productPlatform) {
            this.platformProductId = productPlatform.getPlatformProductId();
            this.platformGoodsId = productPlatform.getPlatformGoodsId();
            this.specValues = StringUtils.isEmpty(productPlatform.getSpecValues()) ? "默认" : productPlatform.getSpecValues().replaceAll(",", " ");
            this.productPrice = productPlatform.getProductPrice();
            this.isDefault = productPlatform.getIsDefault();
        }
    }
}
