package com.jeesharp.business.modules.finance.payorder.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_order}；一笔业务订单可对应多条支付单（多次发起支付）。
 *
 * @author jeesharp
 * @since 2026-05-08
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("biz_finance_pay_order")
@Schema(description = "支付单")
public class PayOrder extends BaseEntity<PayOrder> {

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

    @Schema(description = "业务订单主键")
    private String bizOrderId;

    @Schema(description = "商户侧支付单号（微信 out_trade_no）")
    private String outTradeNo;

    @Schema(description = "微信 prepay_id")
    private String prepayId;

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

    @Schema(description = "应付金额（元）")
    private BigDecimal payAmount;

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

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

    @Schema(description = "标题")
    private String subject;

    @Schema(description = "描述")
    private String description;

    @Schema(description = "支付渠道")
    private String payChannel;

    @Schema(description = "支付类型编码")
    private String payType;

    /**
     * @see com.jeesharp.business.modules.finance.merchantsettle.enums.SettleModeEnum
     */
    @Schema(description = "结算模式：PLATFORM_COLLECT、WECHAT_PROFIT_SHARING")
    private String settleMode;

    @Schema(description = "下单时是否标记微信分账：0-否 1-是")
    private Integer needProfitSharing;

    /**
     * @see com.jeesharp.business.modules.pay.paywechatconfig.enums.WechatPayModeEnum
     */
    @Schema(description = "微信支付模式快照：DIRECT、PARTNER")
    private String wechatPayMode;

    /**
     * @see com.jeesharp.business.modules.pay.paywechatconfig.enums.WechatPayRouteTypeEnum
     */
    @Schema(description = "支付路由：DIRECT、PARTNER、COMBINE")
    private String payRouteType;

    @Schema(description = "特约子商户号（partner 单商户）")
    private String subMchId;

    @Schema(description = "合单商户订单号")
    private String combineOutTradeNo;

    @Schema(description = "异步通知地址")
    private String notifyUrl;

    /**
     * @see com.jeesharp.business.modules.finance.payorder.enums.FinancePayNotifyStatusEnum
     */
    @Schema(description = "回调状态：0-未回调 1-已回调")
    private String notifyStatus;

    @Schema(description = "回调通知时间")
    private LocalDateTime notifyTime;

    @Schema(description = "渠道用户标识（如 openid）")
    private String channelUserId;

    @Schema(description = "用户下单 IP")
    private String userIp;

    @Schema(description = "物业公司/企业 ID")
    private String companyId;

    @Schema(description = "支付商户编号")
    private String merchantId;

    @Schema(description = "订单二维码 URL")
    private String qrCodeUrl;

    @Schema(description = "订单失效时间")
    private LocalDateTime expireTime;

    @Schema(description = "退款状态")
    private String refundStatus;

    @Schema(description = "退款次数")
    private Integer refundTimes;

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

    @Schema(description = "支付成功时间")
    private LocalDateTime payTime;

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

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