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

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author TRX
 * @date 2024/7/26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WxPayConfigModel {

    @Schema(description = "项目id")
    private String projectOid;

    @Schema(description = "项目名称")
    private String projectName;

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

    @Schema(description = "appid")
    private String appId;

    @Schema(description = "商户证书序列号")
    private String mchSerialNo;

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

    @Schema(description = "API V3密钥")
    private String apiV3Key;

    @Schema(description = "认证类型")
    private String authenticationType = "WECHATPAY2-SHA256-RSA2048";

    @Schema(description = "key文件地址类型，oss、local、str")
    private String privateKeyType = "";

    @Schema(description = "私钥地址")
    private String privateKeyPath;

    @Schema(description = "证书字符串")
    private String privateKeyStr;

    @Schema(description = "文件名称")
    private String privateKeyFile;

    @Schema(description = "支付成功回调地址")
    private String notifyUrl;

    @Schema(description = "支付证书是否配置")
    private Boolean privateKeyIsComplete = Boolean.FALSE;

    public Boolean getPrivateKeyIsComplete() {
        if (privateKeyType != null) {
            if ("str".equals(privateKeyType) && StringUtils.isNotEmpty(privateKeyStr)) {
                return Boolean.TRUE;
            }
        }
        return Boolean.FALSE;
    }

}
