package cn.ysk.cashier.pojo.product;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.math.BigDecimal;

/**
* @website https://eladmin.vip
* @description /
* @author lyf
* @date 2024-01-03
**/
@Entity
@Data
@Table(name="tb_product_sku")
@TableName("tb_product_sku")
public class TbProductSku implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "自增id")
    @TableId(type = IdType.AUTO)
    private Integer id;

    @Column(name = "`shop_id`")
    @ApiModelProperty(value = "shopId")
    private String shopId;

    @Column(name = "`bar_code`")
    @ApiModelProperty(value = "条形码")
    private String barCode;

    @Column(name = "`product_id`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "商品Id")
    private String productId;

    @Column(name = "`origin_price`")
    @ApiModelProperty(value = "原价")
    private BigDecimal originPrice = new BigDecimal("0.00");

    @Column(name = "`cost_price`")
    @ApiModelProperty(value = "成本价")
    private BigDecimal costPrice = new BigDecimal("0.00");

    @Column(name = "`member_price`")
    @ApiModelProperty(value = "会员价")
    private BigDecimal memberPrice;

    @Column(name = "`meal_price`")
    @ApiModelProperty(value = "mealPrice")
    private BigDecimal mealPrice = new BigDecimal("0.00");

    @Column(name = "`sale_price`")
    @ApiModelProperty(value = "售价")
    private BigDecimal salePrice = new BigDecimal("0.00");

    @Column(name = "`guide_price`")
    @ApiModelProperty(value = "进货参考价")
    private BigDecimal guidePrice;

    @ApiModelProperty(value = "起售数量 默认为1")
    private Integer suit = 1;

    @Column(name = "`strategy_price`")
    @ApiModelProperty(value = "strategyPrice")
    private BigDecimal strategyPrice;

    @Column(name = "`stock_number`")
    @ApiModelProperty(value = "库存数量")
    private Double stockNumber = 0.00;

    @Column(name = "`spec_snap`")
    @ApiModelProperty(value = "标签镜像")
    private String specSnap;

    @Column(name = "`cover_img`")
    @ApiModelProperty(value = "coverImg")
    private String coverImg;

    @Column(name = "`warn_line`")
    @ApiModelProperty(value = "库存警戒线")
    private Integer warnLine;

    @Column(name = "`weight`")
    @ApiModelProperty(value = "weight")
    private Double weight;

    @Column(name = "`volume`")
    @ApiModelProperty(value = "volume")
    private Float volume;

    @Column(name = "`real_sales_number`")
    @ApiModelProperty(value = "销量")
    private Double realSalesNumber = 0.00;

    @Column(name = "`first_shared`")
    @ApiModelProperty(value = "一级分销金额")
    private BigDecimal firstShared;

    @Column(name = "`second_shared`")
    @ApiModelProperty(value = "二级分销金额")
    private BigDecimal secondShared;

    @Column(name = "`created_at`")
    @ApiModelProperty(value = "createdAt")
    private Long createdAt;

    @Column(name = "`updated_at`")
    @ApiModelProperty(value = "updatedAt")
    private Long updatedAt;

    @Column(name = "`is_del`")
    private Integer isDel = 0;

    @Column(name = "`is_pause_sale`")
    @ApiModelProperty(value = "是否暂停销售")
    private Integer isPauseSale = 0;

    @Column(name = "`is_grounding`")
    @ApiModelProperty(value = "是否上架")
    private Integer isGrounding = 1;

    public void setIsDel(Integer isDel) {
        if(isDel!=null){
            this.isDel = isDel;
        }
    }

    public void copy(TbProductSku source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }


}
