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.NormalMchParams;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 普通商户参数定义
 *
 * @author xiaoyu
 * 
 * @date 2022/9/14 9:57
 */
@Data
public class AllinpayNormalMchParams extends NormalMchParams {

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

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

    /** 商户ID */
    @ChannelMchId(type = ChannelMchIdTypeEnum.MCH_NO)
    private String cusid;

    /** appid */
    private String appId;

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

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

    @Override
    public String deSenData() {

        AllinpayNormalMchParams mchParams = this;
        if (StringUtils.isNotBlank(mchParams.privateKey)) {
            mchParams.setPrivateKey(StringKit.autoDesensitization(mchParams.privateKey));
        }
        if (StringUtils.isNotBlank(mchParams.publicKey)) {
            mchParams.setPublicKey(StringKit.autoDesensitization(mchParams.publicKey));
        }

        return JSONObject.toJSONString(mchParams);
    }

}
