package com.jeesharp.business.modules.finance.profitsharing.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_profit_sharing_order}；按商城子单逐笔分账。
 *
 * @author jeesharp
 * @since 2026-06-11
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("biz_profit_sharing_order")
@Schema(description = "微信分账单")
public class ProfitSharingOrder extends BaseEntity<ProfitSharingOrder> {

    @Schema(description = "分账请求单号")
    private String sharingNo;

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

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

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

    @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 = "微信 out_trade_no")
    private String outTradeNo;

    @Schema(description = "锁定支付基数（元）")
    private BigDecimal payAmount;

    @Schema(description = "锁定佣金比例")
    private BigDecimal commissionRate;

    @Schema(description = "平台佣金金额（元）")
    private BigDecimal commissionAmount;

    @Schema(description = "商户分账金额（元）")
    private BigDecimal merchantAmount;

    @Schema(description = "实际请求分账金额（分）")
    private Integer sharingAmountFen;

    /**
     * @see com.jeesharp.business.modules.finance.profitsharing.enums.ProfitSharingStatusEnum
     */
    @Schema(description = "分账状态")
    private String status;

    @Schema(description = "微信分账单号")
    private String wxOrderId;

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

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

    @Schema(description = "是否已完结分账：0-否 1-是")
    private Integer finishStatus;

    @Schema(description = "分账成功时间")
    private LocalDateTime sharingTime;

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

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