/*
*  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.order;

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.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

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

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

    @Column(name = "`order_id`")
    @ApiModelProperty(value = "订单id")
    private Integer orderId;

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

    @Column(name = "`product_id`")
    @ApiModelProperty(value = "productId")
    private Integer productId;

    @Column(name = "`product_sku_id`")
    @ApiModelProperty(value = "productSkuId")
    private Integer productSkuId;

    @Column(name = "`num`")
    @ApiModelProperty(value = "num")
    private Integer num;

    @Column(name = "`product_name`")
    @ApiModelProperty(value = "productName")
    private String productName;

    @Column(name = "`product_sku_name`")
    @ApiModelProperty(value = "productSkuName")
    private String productSkuName;

    @Column(name = "`product_img`")
    @ApiModelProperty(value = "productImg")
    private String productImg;

    @Column(name = "`create_time`")
    @ApiModelProperty(value = "createTime")
    private Timestamp createTime;

    @Column(name = "`update_time`")
    @ApiModelProperty(value = "updateTime")
    private Timestamp updateTime;

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

    @Column(name = "`price_amount`")
    @ApiModelProperty(value = "priceAmount")
    private BigDecimal priceAmount;

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

    @Column(name = "`pack_amount`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "打包费")
    private BigDecimal packAmount;

    @Transient
    @ApiModelProperty(value = "退单数量")
    private Integer refundNumber;

    @Column(name = "`is_vip`")
    @ApiModelProperty(value = "isVip")
    private Integer isVip;

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