package com.zhongshu.card.client.model.paySetting.paySetting;

import com.github.microservice.types.payment.PaymentChannelType;
import com.github.microservice.types.payment.PaymentType;
import com.zhongshu.card.client.type.paySetting.RegularType;
import com.zhongshu.card.client.type.paySetting.SettlementRulesType;
import com.zhongshu.card.client.type.paySetting.WithdrawMethodType;
import com.zhongshu.card.client.type.paySetting.WithdrawType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

import java.math.BigDecimal;

/**
 * @author TRX
 * @date 2024/11/5
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProjectMainPaySettingModel {

    @Schema(description = "所属项目oid")
    private String projectOid;

    @Schema(description = "选择的机构主支付配置数据id")
    private String paySettingInfoId;

    @Schema(description = "选择的机构主支付配置数据id")
    private String paySettingInfoName;

    @Schema(description = "选中的机构支付配置")
    private ProjectPaySettingInfoModel settingInfoModel;

    @Schema(description = "所属机构oid")
    private String belongOig;

    @Schema(description = "所属机构名称")
    private String belongOrgName;

    @Schema(description = "所属主账户二级信息")
    private ProjectPaySettingInfoModel childPaySettingInfo;

    @Schema(description = "主商户的子商户")
    private String childPaySettingInfoId;

    public String getChildPaySettingInfoId() {
        if (ObjectUtils.isNotEmpty(childPaySettingInfo)) {
            return childPaySettingInfo.getId();
        }
        return "";
    }

    @Schema(description = "项目的支付渠道设置：微信支付、银联支付")
    private PaymentType channelType;

    @Schema(description = "支付产品")
    private PaymentChannelType paymentChannelType;

    //----------------------- 结算规则 start -----------------

    @Schema(description = "结算规则")
    private SettlementRulesType settlementRulesType;

    @Schema(description = "提现方式")
    private WithdrawMethodType withdrawMethodType;

    @Schema(description = "最小的提现额度")
    private Long minWithdraw = 0L;

    @Schema(description = "最大的提现额度")
    private Long maxWithdraw = 0L;

    //---------------D+N结算 设置
    @Schema(description = "天数，>= 1")
    @Min(value = 1)
    @Max(value = 100)
    private Integer days;

    @Schema(description = "d+N的时间")
    private String dnTimeStr;

    //---------------定期结算 设置

    @Schema(description = "定期类型")
    private RegularType regularType;

    @Schema(description = "定期结算时间")
    private String regularTimeStr;

    @Schema(description = "当前的时间，如：12:30")
    @NotEmpty
    private String timeStr;

    //----------------------------提现规则 start --------------

    @Schema(description = "提现规则类型")
    private WithdrawType withdrawType;

    //---------------------------分账规则配置 start ------------
    @Schema(description = "最小分账金额, 单位分")
    private Long minSharing = 0L;

    @Schema(description = "全局项目分账比例，0-100")
    private BigDecimal projectScale = BigDecimal.ZERO;

    @Schema(description = "全局机构分账比例，0-100")
    private BigDecimal orgScale = BigDecimal.ZERO;

}
