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

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;

/**
 * 浦发银行 普通商户参数定义
 *
 * @author xiaoyu
 *
 * @date 2022/5/9 14:16
 */
@Data
public class PfpayNormalMchParams extends NormalMchParams {

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

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

    /** 门店编号 */
    private String storeNo;

    /** 终端号 */
    private String terminalNo;

    /** 应用标识 */
    private String appClientId;

    /** 请求秘钥 */
    private String clientSecret;

    /** 商户RSA私钥 **/
    private String mchPrivateKey;

    /** 浦发公钥 */
    private String pfpayPublicKey;

    @Override
    public String deSenData() {
        PfpayNormalMchParams mchParams = this;
        if (StringUtils.isNotBlank(this.mchPrivateKey)) {
            mchParams.setMchPrivateKey(StringKit.autoDesensitization(this.mchPrivateKey));
        }
        if (StringUtils.isNotBlank(this.pfpayPublicKey)) {
            mchParams.setPfpayPublicKey(StringKit.autoDesensitization(this.pfpayPublicKey));
        }
        if (StringUtils.isNotBlank(this.clientSecret)) {
            mchParams.setClientSecret(StringKit.autoDesensitization(this.clientSecret));
        }

        return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
    }
}
