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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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 zx
 *
 * @date 2023/5/30 10:09
 */
@Data
public class CibpayIsvParams extends IsvParams {

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

    /**
     * 响应报文验签开关，1-将进行验签，0-不进行验签
     */
    private Byte respSignSwitch;

    /** KeyId **/
    private String keyId;

    /** PriKey **/
    private String priKey;

    /** RespPubKey **/
    private String respPubKey;

    /** ReqParamEncryptKey
     *  字段加密密钥
     * */
    private String reqParamEncryptKey;

    /** 微信公众号appid **/
    private String wxSubAppid;

    /** 微信小程序appid **/
    private String wxLiteSubAppid;



    @Override
    public String deSenData() {

        CibpayIsvParams isvParams = this;
       if (StringUtils.isNotBlank(this.priKey)) {
           isvParams.setPriKey(StringKit.autoDesensitization(this.priKey));
       }
       if (StringUtils.isNotBlank(this.respPubKey)) {
           isvParams.setRespPubKey(StringKit.autoDesensitization(this.respPubKey));
       }
       if (StringUtils.isNotBlank(this.reqParamEncryptKey)) {
           isvParams.setReqParamEncryptKey(StringKit.autoDesensitization(this.reqParamEncryptKey));
       }
        return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
    }

}
