package com.izouma.dingdong.domain;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.izouma.dingdong.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.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Where(clause = "enabled = 1")
@ApiModel(value = "提现申请", description = "提现申请")
public class WithdrawApply extends BaseEntity {
    @ApiModelProperty(value = "用户ID", name = "userId")
    private Long userId;

    //商户或骑手提现
//    @ApiModelProperty(value = "其他ID", name = "otherId")
//    private Long otherId;

//    @ApiModelProperty(value = "工号", name = "jobNumber")
//    private String jobNumber;

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

    private Long bankCardId;

//    @Searchable
//    @ApiModelProperty(value = "卡号", name = "cardId")
//    private String cardNo;

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

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

    @ApiModelProperty(value = "提现时间", name = "withdrawTime")
    private LocalDateTime withdrawTime;

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

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "bankCardId", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @NotFound(action = NotFoundAction.IGNORE)
//    @Transient
    @ExcelIgnore
    private BankCard bankCard;

    @Builder.Default
    @Column(nullable = false)
    private Boolean enabled = true;

}
