package com.ff.weijinxiao.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.weijinxiao.util.jsonfilter.DateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 会员升级订单
 */
@Data
@Entity
@Table(name = "tb_member_order")
public class MemberOrder implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int COMMENT '主键'")
    private Integer id;

    @Column(name = "order_sn", columnDefinition = "varchar(100) COMMENT '订单编号'")
    @ApiModelProperty(value = "订单编号")
    private String orderSn;

    @Column(name = "transaction_id", columnDefinition = "varchar(100) COMMENT '微信支付成功返回流水号'")
    @ApiModelProperty(value = "微信支付成功返回流水号")
    private String transactionId;

    @Column(name = "wechat_sn", columnDefinition = "varchar(100) COMMENT '微信支付成功返回流水号'")
    @ApiModelProperty(value = "微信支付流水号")
    private String wechatSn;

    @OneToOne
    @JoinColumn(name = "package_id", referencedColumnName = "id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "套餐信息")
    private MemberPackage memberPackage;

    @Column(name = "package_years", columnDefinition = "int COMMENT '订单包含记账年数'")
    @ApiModelProperty(value = "订单包含记账年数")
    private Integer packageYears;

    @Column(name = "package_num", columnDefinition = "int COMMENT '订单包含记账人数'")
    @ApiModelProperty(value = "订单包含记账人数")
    private Integer packageNum;

    @Column(name = "amount", columnDefinition = "decimal(10,2) COMMENT '订单金额'")
    @ApiModelProperty(value = "订单金额")
    private BigDecimal amount;

    @Column(name = "uid", columnDefinition = "varchar(100) COMMENT '用户登录uid'")
    @ApiModelProperty(value = "用户登录uid")
    private String uid;

    @Column(name = "phone", columnDefinition = "varchar(30) COMMENT '电话号码'")
    @ApiModelProperty(value = "电话号码")
    private String phone;

    @Transient
    @ApiModelProperty(value = "创建者姓名")
    private String userName;

    @Column(name = "status", columnDefinition = "int COMMENT '状态 0=待支付 1=已支付 2=已关闭 3=已退款'")
    @ApiModelProperty(value = "状态 0=待支付 1=已支付 2=已关闭 3=已退款")
    private Integer status = 0;

    @Column(name = "is_delete", columnDefinition = "int COMMENT '是否是删除状态(0:否；1:是)'")
    @ApiModelProperty(value = "是否是删除状态(0:否；1:是)")
    private Integer isDelete = 0;

    @Column(name = "payment_time",columnDefinition = "datetime COMMENT '订单支付时间'")
    @ApiModelProperty(value = "订单支付时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date paymentTime;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date createTime;

    @Column(name = "modify_time")
    @ApiModelProperty(value = "更新时间")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date modifyTime;

}
