package com.izouma.nineth.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.izouma.nineth.dto.userfund.BalanceInfoDTO;
import com.izouma.nineth.enums.AccountStatus;
import com.izouma.nineth.enums.AccountType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 用户资金账户
 */
@Data
@Entity
@Table(indexes = {
        @Index(columnList = "userId,accountType", unique = true),
        @Index(columnList = "orderNo", unique = true),
})
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("用户资金账户")
public class UserFundAccount extends BaseEntity{

    @ApiModelProperty("用户ID")
    private Long userId;

    @ApiModelProperty("账户类型")
    @Enumerated(EnumType.STRING)
    private AccountType accountType;

    @JsonIgnore
    @ApiModelProperty("账号")
    private String accountNo;

    @JsonIgnore
    @ApiModelProperty("账户真实姓名")
    private String accountName;

    @ApiModelProperty("首选账户")
    private boolean primaryFlag;

    /**
     * user_bank_card的绑卡id
     */
    @ApiModelProperty("用户绑卡ID")
    private Long userBankCardId;

    @ApiModelProperty("第三方用户ID")
    private String thirdUserId;

    @ApiModelProperty("第三方绑卡ID")
    private String thirdBankId;

    /**
     * 合作子账户，很重要
     */
    @ApiModelProperty("第三方银行账户")
    private String thirdBankNo;

    @ApiModelProperty("账户状态")
    @Enumerated(EnumType.STRING)
    private AccountStatus accountStatus;

    @ApiModelProperty("账户错误信息")
    private String accountError;

    @ApiModelProperty("开户订单编号")
    private String orderNo;

    @ApiModelProperty("开户令牌")
    private String token;

    @ApiModelProperty("通知时间")
    private LocalDateTime notifyTime;

    @ApiModelProperty("申请时间")
    private LocalDateTime applyTime;

    @ApiModelProperty("注册手机号")
    private String registerPhone;

    @ApiModelProperty("开户网关地址")
    private String gatewayUrl;

    @ApiModelProperty("销户时间")
    private LocalDateTime cancelTime;

    @ApiModelProperty("到期时间")
    private LocalDateTime expireTime;


    /**
     * 是否需要续费
     */
    @Transient
    private boolean needRenew;

    /**
     * 续费金额
     */
    @Transient
    private BigDecimal manageCost;

}
