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

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;

/**
 * 服务商配置参数
 *
 * @author xiaoyu
 *
 * @date 2022/12/15 9:40
 */
@Data
public class BcmpayIsvParams extends IsvParams {

    /** 环境配置 1-沙箱环境  0-生产环境 **/
    private Byte sandbox;

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

    /** APP_ID */
    private String appId;

    /** 公众号appid **/
    private String wxAppId;

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

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

    /** 应用私钥 **/
    private String privateKey;

    /** 交行公钥 **/
    private String publicKey;

    @Override
    public String deSenData() {

        BcmpayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(isvParams.privateKey)) {
            isvParams.setPrivateKey(StringKit.autoDesensitization(isvParams.privateKey));
        }
        if (StringUtils.isNotBlank(isvParams.publicKey)) {
            isvParams.setPublicKey(StringKit.autoDesensitization(isvParams.publicKey));
        }

        return JSONObject.toJSONString(isvParams);
    }

}
