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

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 lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * 服务商参数定义
 *
 * @author xiaoyu
 * 
 * @date 2022/12/6 11:10
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class HnapayIsvParams extends IsvParams {

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

    /** 服务商编号 **/
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String orgNo;

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

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

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

    /** 小程序appid **/
    private String wxLiteAppid;

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

    /** 新生公钥 **/
    private String publicKey;

    @Override
    public String deSenData() {
        HnapayIsvParams 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) JSON.toJSON(isvParams)).toJSONString();
    }
}
