package com.ruoyi.system.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.time.LocalDateTime; /** * 支付记录实体类 */ @Data public class PaymentRecord { /** * 主键ID */ @TableId(type = IdType.AUTO) private Integer id; /** * 用户ID */ private Integer userId; // 邀请码 private String invitationCode; // 姓名 private String name; // 账号(唯一) private String account; // 产品名称 private String productName; /** * 产品ID */ private Integer productId; /** * 订单ID */ private Integer orderId; /** * 支付状态 */ private Integer paymentStatus; /** * 支付订单号 */ private String payOrdeNo; /** * 新增时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; /** * 修改时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; /** * 支付状态枚举 */ public enum PaymentStatus { FAILED(0, "拉取失败"), PENDING(1, "待支付"), PAID(2, "已支付"), EXPIRED(3, "超时/过期"); private final Integer code; private final String description; PaymentStatus(Integer code, String description) { this.code = code; this.description = description; } public Integer getCode() { return code; } public String getDescription() { return description; } public static PaymentStatus getByCode(Integer code) { for (PaymentStatus status : values()) { if (status.getCode().equals(code)) { return status; } } return null; } public static String getDescriptionByCode(Integer code) { PaymentStatus status = getByCode(code); return status != null ? status.getDescription() : "未知状态"; } } /** * 获取支付状态描述 */ public String getPaymentStatusDesc() { return PaymentStatus.getDescriptionByCode(this.paymentStatus); } /** * 判断是否已支付 */ public boolean isPaid() { return PaymentStatus.PAID.getCode().equals(this.paymentStatus); } /** * 判断是否待支付 */ public boolean isPending() { return PaymentStatus.PENDING.getCode().equals(this.paymentStatus); } }