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 org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.sql.Date;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;

@Entity
@Data
@Table(name = "tb_group_order_info")
public class TbGroupOrderInfo implements Serializable {

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

    @Column(name = "`order_no`")
    @ApiModelProperty(value = "订单编号")
    private String orderNo;

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

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

    @Column(name = "`user_id`")
    @ApiModelProperty(value = "用户id")
    private Integer userId;

    @Column(name = "`pro_id`")
    @ApiModelProperty(value = "商品id")
    private Integer proId;

    @Column(name = "`pro_img`")
    @ApiModelProperty(value = "商品图")
    private String proImg;

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

    @Column(name = "`exp_date`")
    @ApiModelProperty(value = "团购卷到期日期")
    private Timestamp  expDate;

    @Column(name = "`order_type`")
    @ApiModelProperty(value = "订单类型 预留字段")
    private String orderType;

    @Column(name = "`pay_type`")
    @ApiModelProperty(value = "支付方式 wechatPay微信支付，aliPay支付宝支付")
    private String payType;

    @Column(name = "`order_amount`")
    @ApiModelProperty(value = "订单金额")
    private BigDecimal orderAmount;

    @Column(name = "`save_amount`")
    @ApiModelProperty(value = "优惠金额")
    private BigDecimal saveAmount;

    @Column(name = "`pay_amount`")
    @ApiModelProperty(value = "实付金额")
    private BigDecimal payAmount;

    @Column(name = "`refund_amount`")
    @ApiModelProperty(value = "退单金额")
    private BigDecimal refundAmount;

    @Column(name = "`refund_number`")
    @ApiModelProperty(value = "退单数量")
    private Integer refundNumber;

    @Column(name = "`number`")
    @ApiModelProperty(value = "数量")
    private Integer number;

    @Column(name = "`status`")
    @ApiModelProperty(value = "订单状态 状态: unpaid-待付款;unused-待使用;closed-已完成;refunding-退款中;refund-已退款;cancelled-已取消;")
    private String status;

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

    @Column(name = "`phone`")
    @ApiModelProperty(value = "手机号")
    private String phone;

    @Column(name = "`pay_time`")
    @ApiModelProperty(value = "付款时间")
    private Timestamp payTime;

    @Column(name = "`refund_able`")
    @ApiModelProperty(value = "是否支持退款 0：不支持 1：支持")
    private Integer refundAble;

    @Column(name = "`create_time`")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @Column(name = "`verifier`")
    @ApiModelProperty(value = "卷码核销员")
    private String verifier;

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

    @Column(name = "`pay_order_no`")
    @ApiModelProperty(value = "支付订单号")
    private String payOrderNo;

    @Column(name = "`trade_day`")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date tradeDay;

    @Column(name = "`source`")
    @ApiModelProperty(value = "原订单id 退单")
    private Integer source;

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