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.model.base.SuperModel;
import com.zhongshu.card.client.type.DataState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

/**
 * @author TRX
 * @date 2024/10/22
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProjectPaySettingInfoModel extends SuperModel {

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

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

    //----------------------------------业务数据 -------------------

    @Schema(description = "支付产品的logo")
    private String payLogo;

    @Schema(description = "账户/名称")
    private String name;

    @Schema(description = "商户ID")
    private String mchId;

    @Schema(description = "银行账号")
    private String bankAccountNumber;

    @Schema(description = "开户行")
    private String bankName;

    @Schema(description = "开户支行")
    private String bankSubName;

    @Schema(description = "显示的")
    private String code = "";

    public String getCode() {
        if (payConfig != null) {
            if (channelType == PaymentType.WeChat) {
                try {
                    WxPayConfigModel configModel = (WxPayConfigModel) payConfig;
                    if (ObjectUtils.isNotEmpty(configModel)) {
                        return configModel.getMchId();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return "";
    }

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

    private String channelTypeStr;

    public String getChannelTypeStr() {
        if (channelType != null) {
            return channelType.getRemark();
        }
        return "";
    }

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

    private String paymentChannelTypeStr;

    public String getPaymentChannelTypeStr() {
        if (paymentChannelType != null) {
            return paymentChannelType.getRemark();
        }
        return "";
    }

    @Schema(description = "支付渠道的参数配置")
    private Object payConfig;

    @Schema(description = "是否可用")
    private DataState state = DataState.Enable;

    @Schema(description = "是否是默认的")
    private Boolean isDefault = Boolean.FALSE;

    private String defaultStr = "";

    public String getDefaultStr() {
        if (isDefault != null) {
            if (isDefault) {
                return "主账户";
            }
            return "子账户";
        }
        return "";
    }
}
