/*
*  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 lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;

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

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "`sku_id`")
    @ApiModelProperty(value = "skuId")
    private String skuId;

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

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

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

    @Column(name = "`spec_snap`")
    @ApiModelProperty(value = "规格")
    private String specSnap;

    @Column(name = "`unit_name`")
    @ApiModelProperty(value = "商品单位")
    private String unitName;

    @Column(name = "`shop_id`")
    @ApiModelProperty(value = "店铺Id")
    private String shopId;
    /**
     * 操作日志id
     */
    @Column(name = "`record_id`")
    @ApiModelProperty(value = "recordId")
    private String recordId;

    @Column(name = "`batch_number`")
    @ApiModelProperty(value = "操作批次号")
    private String batchNumber;

    @Column(name = "`source_path`")
    @ApiModelProperty(value = "库存操作来源：收银端调用 CASHIER   系统后台调用SHOP")
    private String sourcePath;

    @Column(name = "`order_id`")
    @ApiModelProperty(value = "关联订单Id")
    private String orderId;

    @Column(name = "`sub_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = " 1入库 -1出库")
    private Integer subType;

    @Column(name = "`type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "purchase采购入库 transfer调拔入库 ")
    private String type;

    @Column(name = "`left_number`")
    @ApiModelProperty(value = "上次剩余数量")
    private Integer leftNumber;

    @Column(name = "`stock_time`")
    @ApiModelProperty(value = "出入库时间")
    private Long stockTime;

    @Column(name = "`stock_number`")
    @ApiModelProperty(value = "本次操作库存数量")
    private Double stockNumber;

    @Column(name = "`cost_amount`")
    @ApiModelProperty(value = "入库合计成本金额")
    private BigDecimal costAmount;

    @Column(name = "`sales_amount`")
    @ApiModelProperty(value = "出售合计金额")
    private BigDecimal salesAmount;

    @Column(name = "`operator`")
    @ApiModelProperty(value = "操作人")
    private String operator;

    @Column(name = "`remark`")
    @ApiModelProperty(value = "备注")
    private String remark;

    @Column(name = "`stock_snap`")
    @ApiModelProperty(value = "库存镜像")
    private String stockSnap;

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

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

    @Column(name = "`created_at`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "createdAt")
    private Long createdAt;

    @Column(name = "`updated_at`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "updatedAt")
    private Long updatedAt;

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