package com.liquidnet.service.goblin.dto.manage;

import com.liquidnet.commons.lang.constant.LnsRegex;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.dto.GoblinGoodsSpecDto;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@ApiModel(value = "GoblinStoreMgtGoodsEditSkuParam", description = "商品管理:编辑商品:编辑/添加SKU入参")
@Data
public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
    private static final long serialVersionUID = 6657596593310537491L;
    @ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
    private String storeId;
    @ApiModelProperty(position = 11, required = false, value = "单品ID[编辑时必传]")
    private String skuId;
    @ApiModelProperty(position = 12, required = true, value = "单品默认图片的url[256]")
    private String skuPic;
    @ApiModelProperty(position = 13, required = true, value = "单品规格信息")
    private List<GoblinGoodsSpecDto> skuSpecList;
    @ApiModelProperty(position = 14, required = false, value = "单品销售价[20,2]")
    private BigDecimal sellPrice;
    @ApiModelProperty(position = 15, required = true, value = "单品价格[20,2]")
    private BigDecimal price;
    @ApiModelProperty(position = 16, required = true, value = "单品会员价格[20,2]")
    private BigDecimal priceMember;
    @ApiModelProperty(position = 17, required = false, value = "单品的重量[20,2]")
    private BigDecimal weight;
    @ApiModelProperty(position = 18, required = true, value = "总库存")
    private Integer stock;
    @ApiModelProperty(position = 19, required = true, value = "SKU库存")
    private Integer skuStock;
    @ApiModelProperty(position = 20, required = false, value = "预警库存")
    private Integer warningStock;
    @ApiModelProperty(position = 21, value = "自定义展示[0-默认展示|1-隐藏不可购买]")
    private String skuAppear;
    @ApiModelProperty(position = 22, required = false, value = "ISBN，针对CD/图书等[100]")
    private String skuIsbn;
    @ApiModelProperty(position = 23, required = true, value = "购买限制[0-全部用户|1-仅会员|2-指定用户]")
    private String buyFactor;
    @ApiModelProperty(position = 24, required = false, value = "购买限制人员名单[购买限制为2-指定用户时必填]")
    private String buyRoster;
    @ApiModelProperty(position = 25, required = false, value = "限量[0-无限制|X:限购数量]")
    private Integer buyLimit;
    @ApiModelProperty(position = 26, required = false, value = "单品有效期[yyyy-MM-dd HH:mm:ss]")
    @Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "单品有效期格式有误")
    private String skuValidity;


    @ApiModelProperty(position = 27, required = false, value = "加减库存")
    private Integer operStock;

    public GoblinGoodsSkuInfoVo initEditGoodsSkuInfoVo() {
        GoblinGoodsSkuInfoVo vo = GoblinGoodsSkuInfoVo.getNew();
        vo.setSkuId(this.getSkuId());
        vo.setSkuPic(this.getSkuPic());
        vo.setSkuSpecList(this.getSkuSpecList());
        vo.setSellPrice(this.getSellPrice());
        vo.setPrice(this.getPrice());
        vo.setPriceMember(this.getPriceMember());
        vo.setWeight(this.getWeight());
        vo.setStock(this.getStock());
        vo.setSkuStock(this.getSkuStock());
        vo.setWarningStock(this.getWarningStock());
        vo.setSkuAppear(this.getSkuAppear());
        vo.setSkuIsbn(this.getSkuIsbn());
        vo.setBuyFactor(this.getBuyFactor());
        vo.setBuyRoster(this.getBuyRoster());
        vo.setBuyLimit(this.getBuyLimit());
        vo.setSkuValidity(DateUtil.Formatter.yyyyMMddHHmmss.parse(this.getSkuValidity()));
        return vo;
    }
}
