package com.izouma.jiashanxia.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.izouma.jiashanxia.annotations.Searchable;
import com.izouma.jiashanxia.enums.PayMethod;
import com.izouma.jiashanxia.enums.WithdrawStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

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

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "提现申请表")
@Where(clause = "del = 0")
public class Withdraw extends BaseEntity implements Serializable {

    @ApiModelProperty(value = "用户ID", name = "userId")
    private Long userId;

    @ApiModelProperty(value = "提现金额", name = "amount")
    private BigDecimal amount;

    @ApiModelProperty(value = "剩余金额", name = "balance")
    private BigDecimal balance;

    @ApiModelProperty(value = "审核时间", name = "auditTime")
    private LocalDateTime auditTime;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "提现方式", name = "payMethod")
    private PayMethod payMethod;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "提现状态", name = "status")
    private WithdrawStatus status;

    @Searchable
    @ApiModelProperty(value = "账号", name = "account")
    private String account;

    @Searchable
    @ApiModelProperty(value = "真实姓名", name = "realName")
    private String realName;

//    @ApiModelProperty(value = "是否成功", name = "consent")
//    @Column(nullable = false)
//    private Boolean consent;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "userId", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @NotFound(action = NotFoundAction.IGNORE)
    @ExcelIgnore
    private User user;

//    @ApiModelProperty(value = "是否经销商流水", name = "isDealer")
//    private Boolean isDealer;
}
