package com.jeesharp.business.modules.finance.paymentrecord.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.jeesharp.framework.mybatis.core.dataobject.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 支付流水实体，映射表 {@code biz_finance_pay_record}，用于后台对账、退款追溯与回调留痕。
 *
 * @author jeesharp
 * @since 2026-05-09
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("biz_finance_pay_record")
@Schema(description = "支付记录")
public class PayRecord extends BaseEntity<PayRecord> {

    @Schema(description = "支付完成时间（成功/关单时间，失败可为空）")
    private LocalDateTime payTime;

    @Schema(description = "金额（元）；退款记录一般为正数，业务含义由 bizKind 区分")
    private BigDecimal payAmount;

    @Schema(description = "会员/用户ID")
    private String memberId;

    @Schema(description = "用户姓名")
    private String memberName;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "登录账号")
    private String loginAccount;

    /**
     * @see com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordStatusEnum
     */
    @Schema(description = "支付状态：0-待支付 1-成功 2-失败 3-已关闭")
    private Integer payStatus;

    /**
     * @see com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordPayTypeEnum
     */
    @Schema(description = "支付类型编码，如 WECHAT_MINI")
    private String payType;

    @Schema(description = "回调报文原文")
    private String callbackBody;

    @Schema(description = "商户侧订单号/业务单号")
    private String merchantOrderNo;

    @Schema(description = "第三方支付流水号")
    private String payOrderNo;

    /**
     * @see com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordBizKindEnum
     */
    @Schema(description = "业务区分：0-支付 2-退款")
    private Integer bizKind;

    @Schema(description = "业务类型：如 ORDER、RECHARGE")
    private String bizType;

    @Schema(description = "业务主键ID")
    private String bizId;

    /**
     * @see com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordBizSceneEnum
     */
    @Schema(description = "业务场景编码，如 MALL_ORDER、SCENIC_TICKET")
    private String bizScene;

    @Schema(description = "商品/订单标题")
    private String subject;

    @Schema(description = "支付渠道：WECHAT、ALIPAY、UNION 等")
    private String payChannel;

    @Schema(description = "币种，默认 CNY")
    private String currency;

    @Schema(description = "回调到达时间")
    private LocalDateTime callbackTime;

    @Schema(description = "退款时关联的原第三方支付流水号")
    private String relatedPayOrderNo;

    @Schema(description = "渠道错误码")
    private String errorCode;

    @Schema(description = "渠道错误说明")
    private String errorMsg;

    @Schema(description = "发起端 IP")
    private String clientIp;
}
