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

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

/**
 * @author yangjun
 * @version CloudpayIsvParam.java, v 0.1 2022-09-27 21:13 yangjun
 */
@Data
public class CloudpayIsvParams extends IsvParams {

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

    /**
     * 云支付分配给开发者的应用ID
     */
    @ChannelMchId(type = ChannelMchIdTypeEnum.ISV_NO)
    private String bAppId;

    /**
     * 网关加签私钥
     */
    private String priKey;

    /**
     * 网关验签公钥
     */
    private String pubKey;

    /**
     * 公众号appid
     **/
    private String wxAppid;

    /**
     * 小程序appid
     **/
    private String wxLiteAppid;

    @Override
    public String deSenData() {
        CloudpayIsvParams isvParams = this;
        if (StringUtils.isNotBlank(isvParams.priKey)) {
            isvParams.setPriKey(StringKit.str2Star(isvParams.priKey, 4, 4, 6));
        }
        if (StringUtils.isNotBlank(isvParams.pubKey)) {
            isvParams.setPubKey(StringKit.str2Star(isvParams.pubKey, 6, 6, 6));
        }
        return JSONObject.toJSONString(isvParams);
    }
}