/**
 * cljpay.com
 * Copyright (C) 2015-2022 All Rights Reserved.
 */package com.jeequan.jeepay.core.model.params.leshuapay;

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;

/**
 * @author yangjun
 * @version LeshuapayIsvParams.java, v 0.1 2022-10-26 17:28 yangjun
 */
@Data
public class LeshuapayIsvParams extends IsvParams {

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

    /**
     * 商户网关服务商ID(服务商编号)
     */
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String merchantGatewayAgentId;

    /**
     * 商户网关(进件)密钥
     */
    private String merchantGatewayPrivateKey;

    /**
     * 交易密钥
     */
    private String payGatewayPrivateKey;

    /**
     * 通知密钥
     */
    private String noticeGatewayPrivateKey;

    /** 微信开户意愿地址 */
    private String wxUrl;

    /** 支付宝商家认证地址 */
    private String aliUrl;


    @Override
    public String deSenData() {
        LeshuapayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(this.merchantGatewayPrivateKey)) {
            isvParams.setMerchantGatewayPrivateKey(StringKit.autoDesensitization(this.merchantGatewayPrivateKey));
        }
        if (StringUtils.isNotBlank(this.payGatewayPrivateKey)) {
            isvParams.setPayGatewayPrivateKey(StringKit.autoDesensitization(this.payGatewayPrivateKey));
        }
        if (StringUtils.isNotBlank(this.noticeGatewayPrivateKey)) {
            isvParams.setNoticeGatewayPrivateKey(StringKit.autoDesensitization(this.noticeGatewayPrivateKey));
        }
        return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
    }
}
