2026-01-09 12:20:24 +08:00
|
|
|
|
package com.xjhs.findmemerchant.entity;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xjhs.findmemerchant.common.jpa.AbstractBaseEntity;
|
|
|
|
|
|
import com.xjhs.findmemerchant.types.WithdrawalStatus;
|
|
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
|
import lombok.Setter;
|
|
|
|
|
|
import org.hibernate.annotations.Comment;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 提现申请
|
|
|
|
|
|
* 对应表:withdrawals
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Getter
|
|
|
|
|
|
@Setter
|
|
|
|
|
|
@Entity
|
|
|
|
|
|
@Table(
|
|
|
|
|
|
name = "withdrawals",
|
|
|
|
|
|
indexes = {
|
|
|
|
|
|
@Index(name = "idx_withdrawals_merchant_id", columnList = "merchant_id"),
|
|
|
|
|
|
@Index(name = "idx_withdrawals_wallet_id", columnList = "wallet_id"),
|
|
|
|
|
|
@Index(name = "idx_withdrawals_status", columnList = "status"),
|
|
|
|
|
|
@Index(name = "idx_withdrawals_created_at", columnList = "created_at")
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
public class Withdrawal extends AbstractBaseEntity {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 提现金额
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "amount", precision = 12, scale = 2)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("提现金额")
|
|
|
|
|
|
private BigDecimal amount;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 手续费
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "fee", precision = 10, scale = 2)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("提现手续费")
|
|
|
|
|
|
private BigDecimal fee = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 实际到账金额
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "actual_amount", precision = 12, scale = 2)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("实际到账金额")
|
|
|
|
|
|
private BigDecimal actualAmount;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 银行名称
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "bank_name", length = 50)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("银行名称")
|
|
|
|
|
|
private String bankName;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 银行账号(加密存储)
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "bank_account", length = 30)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("银行账号(加密)")
|
|
|
|
|
|
private String bankAccount;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 户名
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "account_name", length = 50)
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("开户人姓名")
|
|
|
|
|
|
private String accountName;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 状态:0-待审核 1-处理中 2-已完成 3-已拒绝 4-已取消
|
|
|
|
|
|
*/
|
2026-01-09 12:20:44 +08:00
|
|
|
|
@Column(name = "status")
|
2026-01-09 12:20:24 +08:00
|
|
|
|
@Comment("提现状态")
|
|
|
|
|
|
private Byte status = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 拒绝原因
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Column(name = "reject_reason", length = 200)
|
|
|
|
|
|
@Comment("拒绝原因")
|
|
|
|
|
|
private String rejectReason;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 审核/处理时间
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Column(name = "processed_at")
|
|
|
|
|
|
@Comment("审核/处理时间")
|
|
|
|
|
|
private LocalDateTime processedAt;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 完成时间
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Column(name = "completed_at")
|
|
|
|
|
|
@Comment("完成时间")
|
|
|
|
|
|
private LocalDateTime completedAt;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 银行流水号
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Column(name = "transaction_no", length = 64)
|
|
|
|
|
|
@Comment("银行流水号")
|
|
|
|
|
|
private String transactionNo;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 备注
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Column(name = "remark", length = 200)
|
|
|
|
|
|
@Comment("备注")
|
|
|
|
|
|
private String remark;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-01-09 12:20:44 +08:00
|
|
|
|
* 商家
|
2026-01-09 12:20:24 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
|
|
|
|
@JoinColumn(name = "merchant_id", insertable = false, updatable = false)
|
|
|
|
|
|
private Merchant merchant;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 钱包
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
|
|
|
|
@JoinColumn(name = "wallet_id", insertable = false, updatable = false)
|
|
|
|
|
|
private Wallet wallet;
|
|
|
|
|
|
|
|
|
|
|
|
// ========= 业务方法 =========
|
|
|
|
|
|
|
|
|
|
|
|
public WithdrawalStatus getStatusEnum() {
|
|
|
|
|
|
return WithdrawalStatus.fromCode(this.status);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setStatusEnum(WithdrawalStatus statusEnum) {
|
|
|
|
|
|
this.status = statusEnum == null ? null : statusEnum.code();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getStatusText() {
|
|
|
|
|
|
WithdrawalStatus e = getStatusEnum();
|
|
|
|
|
|
return e != null ? e.getDesc() : "未知";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 是否待审核
|
|
|
|
|
|
*/
|
|
|
|
|
|
public boolean isPending() {
|
|
|
|
|
|
return getStatusEnum() == WithdrawalStatus.PENDING;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 是否已完成
|
|
|
|
|
|
*/
|
|
|
|
|
|
public boolean isCompleted() {
|
|
|
|
|
|
return getStatusEnum() == WithdrawalStatus.COMPLETED;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 是否可以取消
|
|
|
|
|
|
*/
|
|
|
|
|
|
public boolean canCancel() {
|
|
|
|
|
|
return getStatusEnum() == WithdrawalStatus.PENDING;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 脱敏银行卡号
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String getMaskedBankAccount() {
|
|
|
|
|
|
if (bankAccount == null || bankAccount.length() <= 8) {
|
|
|
|
|
|
return bankAccount;
|
|
|
|
|
|
}
|
|
|
|
|
|
return bankAccount.substring(0, 4) + "****" + bankAccount.substring(bankAccount.length() - 4);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|