|
|
@@ -1,25 +1,28 @@
|
|
|
-package com.kym.service.enplus.impl;
|
|
|
+package com.kym.service.platform.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.crypto.digest.HMac;
|
|
|
import cn.hutool.crypto.digest.HmacAlgorithm;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.kym.common.annotation.ConnectorID;
|
|
|
import com.kym.common.annotation.DynamicCache;
|
|
|
+import com.kym.common.annotation.PlatformConvert;
|
|
|
+import com.kym.common.annotation.PlatformName;
|
|
|
import com.kym.common.constant.ResponseEnum;
|
|
|
-import com.kym.service.enplus.EnPlusApi;
|
|
|
import com.kym.common.exception.BusinessException;
|
|
|
import com.kym.common.exception.EnPushException;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.common.utils.PlatformAesUtil;
|
|
|
+import com.kym.common.utils.PlatformConvertUtil;
|
|
|
import com.kym.entity.common.RedisKeys;
|
|
|
import com.kym.entity.enplus.EnRespQueryToken;
|
|
|
import com.kym.entity.enplus.response.PlatformResponse;
|
|
|
import com.kym.service.cache.PlatformCache;
|
|
|
-import com.kym.service.enplus.PlatformApiService;
|
|
|
+import com.kym.service.platform.CommonApi;
|
|
|
+import com.kym.service.platform.PlatformApiService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.*;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -126,7 +129,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
|
|
|
var requestParams = buildPlatformParams(platformName, data);
|
|
|
|
|
|
- var response = platformGetToken(EnPlusApi.EN_PLUS_QUERY_TOKEN.getApi(platformName), requestParams);
|
|
|
+ var response = platformGetToken(CommonApi.EN_PLUS_QUERY_TOKEN.getApi(platformName), requestParams);
|
|
|
|
|
|
if (response != null && 0 == response.getRet()) {
|
|
|
// 解密Data获取token
|
|
|
@@ -237,15 +240,16 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
* @param equipAuthSeq 格式:运营商ID+唯一编码 27字符
|
|
|
* @return
|
|
|
*/
|
|
|
+ @PlatformConvert
|
|
|
@Override
|
|
|
- public JSONObject queryEquipAuth(String platformName, String connectorId, String equipAuthSeq) {
|
|
|
+ public JSONObject queryEquipAuth(@PlatformName String platformName, @ConnectorID String connectorId, String equipAuthSeq) {
|
|
|
var param = """
|
|
|
{
|
|
|
"EquipAuthSeq":"%s",
|
|
|
"ConnectorID":"%s"
|
|
|
}
|
|
|
- """.formatted(equipAuthSeq, connectorId);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_EQUIP_AUTH.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ """.formatted(equipAuthSeq, PlatformConvertUtil.convert2LongshineConnectorId(connectorId));
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_EQUIP_AUTH.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
@@ -268,7 +272,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
"ConnectorID":"%s"
|
|
|
}
|
|
|
""".formatted(equipBizSeq, connectorId);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_EQUIP_BUSINESS_POLICY.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_EQUIP_BUSINESS_POLICY.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
|
|
|
@@ -289,10 +293,10 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
"StartChargeSeq":"%s",
|
|
|
"ConnectorID":"%s",
|
|
|
"QRCode":"%s",
|
|
|
- "amount":"%d"
|
|
|
}
|
|
|
- """.formatted(startChargeSeq, connectorId, qrCode, amount);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_START_CHARGE.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ """.formatted(startChargeSeq, PlatformConvertUtil.convert2LongshineConnectorId(connectorId), qrCode);
|
|
|
+ var completeParams = PlatformConvertUtil.queryStartChargeParamsConvert(platformName, param, amount);
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_START_CHARGE.getApi(platformName), buildPlatformParams(platformName, completeParams));
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
|
|
|
@@ -310,7 +314,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
"StartChargeSeq":"%s"
|
|
|
}
|
|
|
""".formatted(startChargeSeq);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_EQUIP_CHARGE_STATUS.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_EQUIP_CHARGE_STATUS.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
|
|
|
@@ -330,7 +334,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
"amount":%d
|
|
|
}
|
|
|
""".formatted(startChargeSeq, amount);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_EQUIP_CHARGE_STATUS.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_EQUIP_CHARGE_STATUS.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
|
|
|
@@ -350,7 +354,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
"ConnectorID":"%s"
|
|
|
}
|
|
|
""".formatted(startChargeSeq, connectorId);
|
|
|
- var response = platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_STOP_CHARGE.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
+ var response = platformPost(platformName, CommonApi.EN_PLUS_QUERY_STOP_CHARGE.getApi(platformName), buildPlatformParams(platformName, param));
|
|
|
return parsePlatformResponseData(response, platformName);
|
|
|
}
|
|
|
|