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

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

/**
 * PayerMax支付 普通商户参数定义
 *
 * @author zx
 *
 * @date 2022/9/16 11:16
 */
@Data
public class PmpayNormalMchParams extends NormalMchParams {

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

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

    /** 商户应用AppId */
    private String appId;

    /** 商户私钥 */
    private String privateKey;

    /** PayerMax平台公钥 */
    private String publicKey;

    @Override
    public String deSenData() {
        PmpayNormalMchParams mchParams = this;
        if (StringUtils.isNotBlank(this.privateKey)) {
            mchParams.setPrivateKey(StringKit.autoDesensitization(this.privateKey));
        }
        if (StringUtils.isNotBlank(this.publicKey)) {
            mchParams.setPublicKey(StringKit.autoDesensitization(this.publicKey));
        }
        return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
    }
}
