package com.jeequan.jeepay.core.model.params.lklspay;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.annotate.ChannelMchId;
import com.jeequan.jeepay.core.constants.ChannelMchIdTypeEnum;
import com.jeequan.jeepay.core.model.params.IsvParams;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 拉卡拉 isv参数定义
 *
 * @author xiaoyu
 *
 * @date 2022/4/13 17:08
 */
@Data
public class LklspayIsvParams extends IsvParams {

    /**
     * 拉卡拉平台公钥, 这里暂时写死
     */
    public static final String PUB_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXCrnI36j2nBpZhbHvgrMZdsGOYSWigvuVaDm/FEHPcQJJsYrs/eK3Vs7XtFSezaIf95r+YD0fewLOgw31FuZOcraf5P0I/BGuvpWfstwuI28UfzNld+XzXy0YHsmo010VgwkGJrKFezQHjKD85HT57iBoEQiUt+00+X0D/rJ2MQIDAQAB";

    /** 是否沙箱环境 */
    private Byte sandbox;

    /** appId */
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String appId;

    /** 合作方编号 */
    private String userNo;

    /** 微信开通意愿二维码url */
    private String wxOpenUrl;

    /** 支付宝开通意愿二维码url */
    private String aliChannelExtUrl;

    /** 用户名 */
    private String clientId;

    /** 密码 */
    private String clientSecret;

    /** APP用户名 */
    private String appUserName;

    /** APP密码 */
    private String appPassword;

    /** 归属活动信息 拓客SAAS分配 */
    private String activityId;

    /** RSA私钥 */
    private String rsaPrivateKey;

    /** RSA公钥 */
    private String rsaPublicKey;

    /** 证书序列号 */
    private String serialNo;

    /** 私钥证书 */
    private String privateCert;

    /** 公钥证书 */
    private String publicCert;

    /** 机构号 */
    private String orgCode;

    private String settType;

    /**
     * 微信渠道号
     */
    private String wxChannelId;

    @Override
    public String deSenData() {
        LklspayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(this.rsaPrivateKey)) {
            isvParams.setRsaPrivateKey(StringKit.autoDesensitization(this.rsaPrivateKey));
        }
        if (StringUtils.isNotBlank(this.rsaPublicKey)) {
            isvParams.setRsaPublicKey(StringKit.autoDesensitization(this.rsaPublicKey));
        }
        return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
    }
}
