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

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 2023/1/3 16:18
 */
@Data
public class IcbcpayIsvParams extends IsvParams {

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

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

    /** 收单产品协议编号 */
    private String merPrtclNo;

    /** 微信appId */
    private String wxAppId;

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

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

    @Override
    public String deSenData() {

        IcbcpayIsvParams 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);
    }

}
