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

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/6/6 10:31
 */
@Data
public class DgpayNormalMchParams extends NormalMchParams {

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

    /** 产品ID **/
    private String productId;

    /** rsaPrivateKey **/
    private String rsaPrivateKey;

    /** publicKey 汇付公钥 **/
    private String rsaPublicKey;

    /** 支付场景类型 **/
    private String payScene;

    @Override
    public String deSenData() {

        DgpayNormalMchParams params = this;
        if (StringUtils.isNotBlank(this.rsaPublicKey)) {
            params.setRsaPublicKey(StringKit.autoDesensitization(this.rsaPublicKey));
        }
        if (StringUtils.isNotBlank(this.rsaPrivateKey)) {
            params.setRsaPrivateKey(StringKit.autoDesensitization(this.rsaPrivateKey));
        }
        return ((JSONObject) JSON.toJSON(params)).toJSONString();
    }

}
