package com.jeesharp.business.modules.finance.payrefund.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_pay_refund_order}。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("biz_pay_refund_order")
@Schema(description = "支付退款单")
public class PayRefundOrder extends BaseEntity<PayRefundOrder> {

    @Schema(description = "平台退款单号")
    private String refundNo;

    @Schema(description = "商户退款单号（微信 out_refund_no）")
    private String outRefundNo;

    @Schema(description = "财务支付单ID")
    private String financePayOrderId;

    @Schema(description = "商城合并支付批次ID")
    private String payBatchId;

    @Schema(description = "商城子订单ID")
    private String mallOrderId;

    @Schema(description = "关联售后单ID")
    private String afterSaleId;

    /**
     * @see com.jeesharp.business.modules.finance.paymentrecord.enums.PayRecordBizSceneEnum
     */
    @Schema(description = "业务场景")
    private String bizScene;

    @Schema(description = "子单商户租户ID")
    private String merchantTenantId;

    @Schema(description = "微信特约子商户号")
    private String subMchId;

    @Schema(description = "微信 transaction_id")
    private String transactionId;

    @Schema(description = "原支付商户单号")
    private String outTradeNo;

    @Schema(description = "本次退款金额（元）")
    private BigDecimal refundAmount;

    @Schema(description = "原支付单总金额（元）")
    private BigDecimal orderPayAmount;

    /**
     * @see com.jeesharp.business.modules.finance.payrefund.enums.PayRefundOrderStatusEnum
     */
    @Schema(description = "退款状态")
    private String status;

    @Schema(description = "微信退款单号")
    private String wxRefundId;

    @Schema(description = "退款原因")
    private String reason;

    @Schema(description = "退款回调地址")
    private String notifyUrl;

    @Schema(description = "退款成功时间")
    private LocalDateTime refundTime;

    @Schema(description = "重试次数")
    private Integer retryCount;

    @Schema(description = "下次重试时间")
    private LocalDateTime nextRetryTime;

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

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

    @Schema(description = "渠道请求原文")
    private String rawRequest;

    @Schema(description = "渠道响应原文")
    private String rawResponse;
}
