/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package cn.ysk.cashier.pojo.product;

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

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

/**
 * @website https://eladmin.vip
 * @description /
 * @author lyf
 * @date 2023-12-11
 **/
@Entity
@Data
@Table(name="tb_product")
@TableName("tb_product")
public class TbProductAndSku implements Serializable {

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

    @Column(name = "`source_path`")
    @ApiModelProperty(value = "商品来源 NORMAL普通商品 --,SCORE积分商品")
    private String sourcePath="NORMAL";

    @Column(name = "`merchant_id`")
    @ApiModelProperty(value = "商户Id")
    private String merchantId = "PLANT_ID";

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

    @Column(name = "`name`")
    @ApiModelProperty(value = "商品名称")
    private String name;

    @Column(name = "`type`")
    @ApiModelProperty(value = "商品类型（属性）:REAL- 实物商品 VIR---虚拟商品")
    private String type = "REAL";

    @Column(name = "`pack_fee`")
    @ApiModelProperty(value = "包装费")
    private BigDecimal packFee;

    @Column(name = "`low_price`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "商品最低价")
    private BigDecimal lowPrice;

    @Column(name = "`unit_id`")
    @ApiModelProperty(value = "单位Id")
    private Integer unitId;

    @Column(name = "`cover_img`")
    @ApiModelProperty(value = "商品封面图")
    private String coverImg;

    @Column(name = "`category_id`")
    @ApiModelProperty(value = "categoryId")
    private String categoryId;

    @Column(name = "`spec_id`")
    @ApiModelProperty(value = "商品规格")
    private Integer specId;

    @Column(name = "`brand_id`")
    @ApiModelProperty(value = "品牌Id")
    private Integer brandId;

    @Column(name = "`short_title`")
    @ApiModelProperty(value = "短标题--促销语")
    private String shortTitle;

    @Column(name = "`low_member_price`")
    @ApiModelProperty(value = "lowMemberPrice")
    private BigDecimal lowMemberPrice;

    @Column(name = "`unit_snap`")
    @ApiModelProperty(value = "单位镜像")
    private String unitSnap;

    @Column(name = "`share_img`")
    @ApiModelProperty(value = "商品分享图")
    private String shareImg;

    @Column(name = "`images`")
    @ApiModelProperty(value = "商品图片（第一张为缩略图，其他为详情）")
    private String images;

    @Column(name = "`video`")
    @ApiModelProperty(value = "商品视频URL地址")
    private String video;

    @Column(name = "`video_cover_img`")
    @ApiModelProperty(value = "视频封面图")
    private String videoCoverImg;

    @Column(name = "`sort`")
    @ApiModelProperty(value = "排序")
    private Integer sort = 0;

    @Column(name = "`limit_number`")
    @ApiModelProperty(value = "0-不限购")
    private Integer limitNumber = 0;

    @Column(name = "`product_score`")
    @ApiModelProperty(value = "商品赚送积分")
    private Integer productScore;

    @Column(name = "`status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "0--待审核 1审核通过 -1审核失败  -2违规下架")
    private Integer status = 0;

    @Column(name = "`fail_msg`")
    @ApiModelProperty(value = "审核失败原因")
    private String failMsg;

    @Column(name = "`is_recommend`")
    @ApiModelProperty(value = "是否推荐,店铺推荐展示")
    private Integer isRecommend = 0;

    @Column(name = "`is_hot`")
    @ApiModelProperty(value = "是否热销")
    private Integer isHot = 0;

    @Column(name = "`is_new`")
    @ApiModelProperty(value = "是否新品")
    private Integer isNew;

    @Column(name = "`is_on_sale`")
    @ApiModelProperty(value = "是否促销1-是0-否")
    private Integer isOnSale = 0;

    @Column(name = "`is_show`")
    @ApiModelProperty(value = "是否展示0-下架 1上架---废弃")
    private Integer isShow = 0;

    @Column(name = "`type_enum`")
    @ApiModelProperty(value = "商品规格：0-单规格 1多规格")
    private String typeEnum;

    @Column(name = "`is_distribute`")
    @ApiModelProperty(value = "是否共享库存")
    private Integer isDistribute = 0;

    @Column(name = "`is_del`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否回收站 0-否，1回收站")
    private Integer isDel = 0;

    @Column(name = "`is_stock`")
    @ApiModelProperty(value = "是否开启库存")
    private Integer isStock = 1;

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

    @Column(name = "`is_free_freight`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否免邮1-是 0-否")
    private Integer isFreeFreight=1;

    @Column(name = "`freight_id`")
    @ApiModelProperty(value = "邮费模版")
    private Long freightId;

    @Column(name = "`strategy_type`")
    @ApiModelProperty(value = "商品当前生效策略")
    private String strategyType;

    @Column(name = "`strategy_id`")
    @ApiModelProperty(value = "策略Id")
    private Integer strategyId = 1;

    @Column(name = "`is_vip`")
    @ApiModelProperty(value = "vip专属")
    private Integer isVip = 0;

    @Column(name = "`is_delete`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "是否删除")
    private Integer isDelete = 0;

    @Column(name = "`notice`")
    @ApiModelProperty(value = "购买须知")
    private String notice;

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

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

    @Column(name = "`base_sales_number`")
    @ApiModelProperty(value = "基础出售数量")
    private Double baseSalesNumber =0.00;

    @Column(name = "`real_sales_number`")
    @ApiModelProperty(value = "实际销量")
    private Double realSalesNumber = (double) 0;

    @Column(name = "`sales_number`")
    @ApiModelProperty(value = "合计销量")
    private Integer salesNumber = 0;

    @Column(name = "`thumb_count`")
    @ApiModelProperty(value = "点赞次数")
    private Integer thumbCount = 0;

    @Column(name = "`store_count`")
    @ApiModelProperty(value = "收藏次数")
    private Integer storeCount = 0;

    @Column(name = "`furnish_meal`")
    @ApiModelProperty(value = "支持堂食")
    private Integer furnishMeal = 0;

    @Column(name = "`furnish_express`")
    @ApiModelProperty(value = "支持配送")
    private Integer furnishExpress = 0;

    @Column(name = "`furnish_draw`")
    @ApiModelProperty(value = "支持自提")
    private Integer furnishDraw = 0;

    @Column(name = "`furnish_vir`")
    @ApiModelProperty(value = "支持虚拟")
    private Integer furnishVir = 0;

    @Column(name = "`is_combo`")
    @ApiModelProperty(value = "是否套餐")
    private Integer isCombo =0;

    @Column(name = "`group_snap`")
    @ApiModelProperty(value = "套餐内容")
    private String groupSnap;

    @Column(name = "`is_show_cash`")
    @ApiModelProperty(value = "isShowCash")
    private Integer isShowCash =0;

    @Column(name = "`is_show_mall`")
    @ApiModelProperty(value = "isShowMall")
    private Integer isShowMall = 0;

    @Column(name = "`is_need_examine`")
    @ApiModelProperty(value = "是否需要审核")
    private Integer isNeedExamine = 0;

    @Column(name = "`show_on_mall_status`")
    @ApiModelProperty(value = "线上商城展示状态0待审核 -1 异常 1正常")
    private Integer showOnMallStatus = 1;

    @Column(name = "`show_on_mall_time`")
    @ApiModelProperty(value = "提交审核时间")
    private Long showOnMallTime;

    @Column(name = "`show_on_mall_error_msg`")
    @ApiModelProperty(value = "线上商城展示失败原因")
    private String showOnMallErrorMsg;

    @Column(name = "`enable_label`")
    @ApiModelProperty(value = "使用标签打印 选择 是 并在 前台>本机设置 勾选打印标签后，收银完成后会自动打印对应数量的标签数")
    private Integer enableLabel = 0;

    @Column(name = "`tax_config_id`")
    @ApiModelProperty(value = "税率")
    private String taxConfigId;

    @Column(name = "spec_info")
    @ApiModelProperty(value = "specInfo")
    private String specInfo;

    @Column(name = "select_spec")
    @ApiModelProperty(value = "selectSpec")
    private String selectSpec;

    @Column(name = "spec_table_headers")
    @ApiModelProperty(value = "specTableHeaders")
    private String specTableHeaders;

    @Column(name = "group_category_id")
    @ApiModelProperty(value = "团购卷分类Id")
    private String groupCategoryId;

    @Column(name = "stock_number")
    @ApiModelProperty("库存数量")
    private Double stockNumber = (double) 0;


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