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

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/9/13 15:39
 */
@Data
public class AllinpayIsvParams extends IsvParams {

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

    /** 签名类型 RSA2 SM2 **/
    private String signType;

    /** 服务商id */
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String orgid;

    /** appid */
    private String appId;

    /** 银联pid */
    private String unpid;

    /** 拓展人 */
    private String expandUser;

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

    /** 通联公钥 **/
    private String publicKey;

    @Override
    public String deSenData() {

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

}
