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

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 yr
 *
 * @date 2022/9/16 11:16
 */
@Data
public class MbpayNormalMchParams extends NormalMchParams {

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

    /** 商户标识 */
    @ChannelMchId(type = ChannelMchIdTypeEnum.MCH_NO)
    private String merAccount;

    /** 用户编号 */
    private String merNo;

    /** 私钥 */
    private String privateKey;

    /** 公钥 */
    private String mbPublicKey;

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