package com.cyksj.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.ejlchina.searcher.bean.DbField;
import com.ejlchina.searcher.bean.SearchBean;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author chan
 * @date 2022/11/7 1:57 PM
 */
@Getter
@Setter
@SearchBean(tables = "register_order_don rd left join apple_auto_register_data ad on ad.order_id = rd.id" +
        " left join user u on rd.user_id = u.id")
public class RegisterOrderDon{

    @TableId(value = "id",type = IdType.AUTO)
    @DbField("rd.id")
    private Long id;

    @DbField("rd.platform")
    private String platform;

    @DbField("rd.nickname")
    private String nickname;

    @DbField("rd.username")
    private String username;

    @DbField("rd.password")
    private String password;

    @DbField("rd.email")
    private String email;

    @DbField("rd.birth_year")
    private String birthYear;

    @DbField("rd.birth_month")
    private String birthMonth;

    @DbField("rd.birth_day")
    private String birthDay;

    @DbField("rd.gender")
    private String gender;

    @DbField("rd.phone")
    private String phone;

    @DbField("rd.country")
    private String country;

    @DbField("rd.order_no")
    private String orderNo;

    @DbField("rd.goods_id")
    private Long goodsId;

    @DbField("money")
    private BigDecimal money;

    @DbField("rd.refund_money")
    private BigDecimal refundMoney;

    /**
     * 微信订单号
     */
    private String transactionId;


    /** 用户id */
    @DbField("rd.user_id")
    private Long userId ;

    /**
     * 用户昵称
     */
    @DbField("u.nickname")
    @TableField(exist = false)
    private String userNickname;

    /**
     * openId
     */
    @DbField("rd.open_id")
    private String openId;

    /** 支付状态 */
    @DbField("rd.status")
    private Status status ;

    /**
     * 支付时间
     */
    @DbField("rd.pay_time")
    private Date payTime;

    @DbField("rd.shop_id")
    private String shopId;

    @DbField("rd.is_free")
    private Boolean isFree;

    @DbField("rd.type")
    private Type type;

    @DbField("rd.error_msg")
    private String errorMsg;

    @DbField("ad.id")
    @TableField(exist = false)
    private Long appleAutoId;

    @DbField("if(ad.id is null,false,true)")
    @TableField(exist = false)
    private Boolean appleIsAutoType;

    @DbField("ad.apple_pwd_id")
    @TableField(exist = false)
    private String applePwdId;

    @DbField("ad.country_or_area")
    @TableField(exist = false)
    private AppleAutoRegisterData.CountryOrArea countryOrArea;

    @DbField("ad.remark")
    @TableField(exist = false)
    private String remark;

    /**
     * 创建时间
     */
    @DbField("rd.created_time")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    /**
     * 修改时间
     */
    @DbField("rd.update_time")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    public enum Type {
        WeChat("微信支付"),
        ALI_PAY("支付宝"),
        ;
        private String desc;

        Type(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }
    }

    public enum Status {
        /**
         * 订单状态
         */
        close("关闭订单"),
        noPayment("待付款"),
        hasPayment("已付款"),
        error("注册失败"),
        complete("已完成"),
        refund("已退款"),
        ;

        private String desc;

        Status(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }
    }
}
