package cn.pluss.platform.util;

import cn.pluss.platform.config.ParameterConfig;
import com.alibaba.fastjson.JSONObject;

/**
 * 瑞银信配置信息
 * @author DJH
 */
public class RyxConfig {
    
    /**
     * 进件链接前缀
     */
    public static String auditDomain;
    /**
     * 支付链接前缀
     */
    public static String payDomain;
    /**
     * 机构id
     */
    public static String accessId;

    /**
     * 商服宝机构id
     */
    public static String subAccessId;
    /**
     * 私钥用于签名，对应的公钥给到瑞银信
     */
    public static String cooperatorPriKey;
    /**
     * 公钥用于加密
     */
    public static String cooperatorPubKey;

    /**
     * 瑞银信的进件/入网公钥
     */
    public static String accessPubKey;

    /**
     * 商服宝进件入网公钥
     */
    public static String subAccessPubKey;

    /**
     * 瑞银信的支付RSA公钥
     */
    public static String smzfPubKey;

    /**
     * 瑞银信交易上送的机构号
     */
    public static String payCooperator;
    /**
     * 进件URL
     */
    public static String merchantIncome = "ims/merch/simpleApply";

    /**
     * 修改结算卡URL
     */
    public static String updateSettleCard = "/ims/merch/updateSettleCard";

    /**
     * 终端列表
     */
    public static String termList = "/ims/work/list";

    /**
     * 修改费率URL
     */
    public static String changeRate = "/ims/merch/updateRate";

    /**
     * 查询结算数据
     */
    public static String tranSt = "/ims/tranSt/tranStList";

    /**
     * 查询结算数据
     */
    public static String tranStToday = "/ims/tranSt/tranStTodayList";

    /**
     * 支付请求地址
     */
    public static String payUrl = "/ydzf/ydzf-smzf";

    /**
     * 退款请求地址
     */
    public static String refundUrl = "/ydzf/admin/ydzf-smzf001";

    /**
     * 公众号配置相关接口
     */
    public static String wxPublicConfigUrl = "/ydzf/wechat/gateway";

    /**
     * 扫码支付tradeCode
     */
    public static String qrActiveCodePay = "SMZF002";
    /**
     * 条码支付tradeCode
     */
    public static String barCodePayWay = "SMZF003";

    /**
     * 交易查询tradeCode
     */
    public static String barCodePayQuery = "SMZF006";
    /**
     * 获取openid tradeCode
     */
    public static String barCodeGetOpenid = "SMZF032";

    /**
     * 获取银联用户标识
     */
    public static String barCodeUnionPayUserId = "SMZF019";

    /**
     * 获取用户信息
     * @date: 2021/12/28 17:26
     */
    public static String barCodeUnionJsPay = "SMZF017";

    /**
     * 获取openid tradeCode
     */
    public static String barCodePayRefund = "SMZF004";

    /**
     * 关闭订单 tradeCode
     */
    public static String barCodeCloseOrder = "SMZF015";
    /**
     * 服务窗支付 tradeCode
     */
    public static String barCodePayService = "SMZF016";
    /**
     * 小程序支付 tradeCode
     */
    public static String barCodePayApplets = "SMZF018";

    /**
     * 异步通知 tradeCode
     */
    public static String barCodeNotify = "SMZF008";

    /**
     * 请求成功code
     */
    public static String PAY_SUCCESS_CODE = "000000";

    /**
     * 订单待确认支付code
     */
    public static String PAY_AWAIT_CODE = "200002";

    /**
     * 获取商户信息
     */
    public static String merchantInfo = "/ims/merch/getById";

    /**
     * 查询瑞银信进件结果的链接
     */
    public static String auditResult = "/ims/merch/queryMerchResult";

    /**
     * 获取merInId
     */
    public static String getMerInId = "/ims/merch/getMerInId";

    private RyxConfig() {}

    /** 从yml中读取静态配置数据 */
    public static void init(ParameterConfig parameterConfig) {
        auditDomain = parameterConfig.ryxAuditDomain;
        payDomain = parameterConfig.ryxPayDomain;
        accessId = parameterConfig.ryxAccessId;
        cooperatorPriKey = parameterConfig.ryxCooperatorPriKey;
        smzfPubKey = parameterConfig.ryxSmzfPubKey;
        accessPubKey = parameterConfig.ryxAccessPubKey;
        cooperatorPubKey = parameterConfig.ryxCooperatorPubKey;
        merchantIncome = auditDomain + merchantIncome;
        updateSettleCard = auditDomain + updateSettleCard;
        changeRate = auditDomain + changeRate;
        payUrl = payDomain + payUrl;
        refundUrl = payDomain + refundUrl;
        wxPublicConfigUrl = payDomain + wxPublicConfigUrl;
        payCooperator = parameterConfig.ryxPayCooperator;
        merchantInfo = auditDomain + merchantInfo;
        subAccessId = parameterConfig.ryxSubAccessId;
        subAccessPubKey = parameterConfig.ryxSubAccessPubKey;
        termList = auditDomain + termList;
        tranSt = auditDomain + tranSt;
        tranStToday = auditDomain + tranStToday;
        getMerInId = auditDomain + getMerInId;
        auditResult = auditDomain + auditResult;
    }

    /**
     * 回调处理成功通知
     * @return 处理成功通知
     */
    public static JSONObject ok() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", "0");
        jsonObject.put("msg", "通知成功");

        return jsonObject;
    }
}
