Просмотр исходного кода

支持互联互通多平台改造支持互联互通多平台改造支持互联互通多平台改造

skyline 1 год назад
Родитель
Сommit
209132912f

+ 2 - 2
common/src/main/java/com/kym/common/handler/ResponseResultHandler.java

@@ -1,7 +1,7 @@
 package com.kym.common.handler;
 package com.kym.common.handler;
 
 
 import com.kym.common.R;
 import com.kym.common.R;
-import com.kym.entity.enplus.response.EnResponse;
+import com.kym.entity.enplus.response.PlatformResponse;
 import org.springframework.core.MethodParameter;
 import org.springframework.core.MethodParameter;
 import org.springframework.http.MediaType;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -36,7 +36,7 @@ public class ResponseResultHandler implements ResponseBodyAdvice {
                                   Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
                                   Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
 
 
         // 响应给en+,微信的信息不做处理
         // 响应给en+,微信的信息不做处理
-        if (body instanceof R<?> || body instanceof EnResponse || body instanceof ResponseEntity) {
+        if (body instanceof R<?> || body instanceof PlatformResponse || body instanceof ResponseEntity) {
             return body;
             return body;
         } else if (body == null) {
         } else if (body == null) {
             return R.success();
             return R.success();

+ 5 - 12
common/src/main/java/com/kym/common/utils/PlatformAesUtil.java

@@ -2,7 +2,6 @@ package com.kym.common.utils;
 
 
 
 
 import com.kym.entity.admin.Platform;
 import com.kym.entity.admin.Platform;
-import lombok.NoArgsConstructor;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.codec.binary.Base64;
 
 
 import javax.crypto.Cipher;
 import javax.crypto.Cipher;
@@ -19,7 +18,6 @@ import java.util.logging.Logger;
  *
  *
  * @author skyline
  * @author skyline
  */
  */
-@NoArgsConstructor
 public class PlatformAesUtil {
 public class PlatformAesUtil {
 
 
     //编码方式
     //编码方式
@@ -29,20 +27,14 @@ public class PlatformAesUtil {
     private static final String AES = "AES";
     private static final String AES = "AES";
 
 
 
 
-    static Platform config;
-
-    public static PlatformAesUtil getUtil(Platform config) {
-        PlatformAesUtil.config = config;
-        return new PlatformAesUtil();
-    }
-
     /**
     /**
      * AES 加密操作
      * AES 加密操作
      *
      *
+     * @param config  互联互通平台配置
      * @param content 待加密内容
      * @param content 待加密内容
      * @return 返回Base64转码后的加密数据
      * @return 返回Base64转码后的加密数据
      */
      */
-    public static String encrypt(String content) {
+    public static String encrypt(Platform config, String content) {
 
 
         if (content == null || content.isEmpty()) {
         if (content == null || content.isEmpty()) {
             return content;
             return content;
@@ -82,11 +74,12 @@ public class PlatformAesUtil {
     /**
     /**
      * AES 解密操作
      * AES 解密操作
      *
      *
+     * @param config  互联互通平台配置
      * @param content
      * @param content
      * @return
      * @return
      */
      */
-    public static String decrypt(String content) {
-        if (content == null || "".equals(content)) {
+    public static String decrypt(Platform config, String content) {
+        if (content == null || content.isEmpty()) {
             return content;
             return content;
         }
         }
 
 

+ 3 - 4
entity/src/main/java/com/kym/entity/enplus/response/EnResponse.java → entity/src/main/java/com/kym/entity/enplus/response/PlatformResponse.java

@@ -6,12 +6,11 @@ import lombok.NoArgsConstructor;
 
 
 /**
 /**
  * @author skyline
  * @author skyline
- * @description en+接口返回数据
- * @date 2023-07-31 11:59
+ * 互联互通接口返回数据
  */
  */
 @Data
 @Data
 @NoArgsConstructor
 @NoArgsConstructor
-public class EnResponse {
+public class PlatformResponse {
     @JsonProperty("Ret")
     @JsonProperty("Ret")
     private int Ret;
     private int Ret;
     @JsonProperty("Msg")
     @JsonProperty("Msg")
@@ -22,7 +21,7 @@ public class EnResponse {
     private String Sig;
     private String Sig;
 
 
 
 
-    public EnResponse(String data) {
+    public PlatformResponse(String data) {
         this.Ret = 0;
         this.Ret = 0;
         this.Msg = "";
         this.Msg = "";
         this.Data = data;
         this.Data = data;

+ 11 - 11
miniapp/src/main/java/com/kym/miniapp/controller/ChargerController.java

@@ -7,7 +7,7 @@ import com.kym.common.annotation.ApiLog;
 import com.kym.common.config.WxConfig;
 import com.kym.common.config.WxConfig;
 import com.kym.common.enums.WxApi;
 import com.kym.common.enums.WxApi;
 import com.kym.common.utils.HttpUtil;
 import com.kym.common.utils.HttpUtil;
-import com.kym.entity.enplus.response.EnResponse;
+import com.kym.entity.enplus.response.PlatformResponse;
 import com.kym.entity.miniapp.ChargeOrder;
 import com.kym.entity.miniapp.ChargeOrder;
 import com.kym.entity.miniapp.queryParams.OrderQueryParams;
 import com.kym.entity.miniapp.queryParams.OrderQueryParams;
 import com.kym.service.admin.StationService;
 import com.kym.service.admin.StationService;
@@ -205,8 +205,8 @@ public class ChargerController {
     @ApiLog("推送场站设备状态变化")
     @ApiLog("推送场站设备状态变化")
     @PostMapping("/{platformName}/notification_stationStatus")
     @PostMapping("/{platformName}/notification_stationStatus")
     //todo 通知en+更新推送地址,加上platformName
     //todo 通知en+更新推送地址,加上platformName
-    EnResponse notificationStationStatus(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
-        return new EnResponse(enNotifyService.handleNotificationStationStatus(platformName, json));
+    PlatformResponse notificationStationStatus(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
+        return new PlatformResponse(enNotifyService.handleNotificationStationStatus(platformName, json));
     }
     }
 
 
     /**
     /**
@@ -217,8 +217,8 @@ public class ChargerController {
      */
      */
     @ApiLog("推送启动充电结果")
     @ApiLog("推送启动充电结果")
     @PostMapping("/{platformName}/notification_start_charge_result")
     @PostMapping("/{platformName}/notification_start_charge_result")
-    EnResponse notificationStartChargeResult(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
-        return new EnResponse(enNotifyService.handleNotificationStartChargeResult(platformName, json));
+    PlatformResponse notificationStartChargeResult(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
+        return new PlatformResponse(enNotifyService.handleNotificationStartChargeResult(platformName, json));
     }
     }
 
 
     /**
     /**
@@ -229,8 +229,8 @@ public class ChargerController {
      */
      */
     @ApiLog("推送充电状态")
     @ApiLog("推送充电状态")
     @PostMapping("/{platformName}/notification_equip_charge_status")
     @PostMapping("/{platformName}/notification_equip_charge_status")
-    EnResponse notificationEquipChargeStatus(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
-        return new EnResponse(enNotifyService.handleNotificationEquipChargeStatus(platformName, json));
+    PlatformResponse notificationEquipChargeStatus(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
+        return new PlatformResponse(enNotifyService.handleNotificationEquipChargeStatus(platformName, json));
     }
     }
 
 
     /**
     /**
@@ -241,8 +241,8 @@ public class ChargerController {
      */
      */
     @ApiLog("推送停止充电结果")
     @ApiLog("推送停止充电结果")
     @PostMapping("/{platformName}/notification_stop_charge_result")
     @PostMapping("/{platformName}/notification_stop_charge_result")
-    EnResponse notificationStopChargeResult(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
-        return new EnResponse(enNotifyService.handleNotificationStopChargeResult(platformName, json));
+    PlatformResponse notificationStopChargeResult(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
+        return new PlatformResponse(enNotifyService.handleNotificationStopChargeResult(platformName, json));
     }
     }
 
 
     /**
     /**
@@ -253,8 +253,8 @@ public class ChargerController {
      */
      */
     @ApiLog("推送充电订单信息")
     @ApiLog("推送充电订单信息")
     @PostMapping("/{platformName}/notification_charge_order_info")
     @PostMapping("/{platformName}/notification_charge_order_info")
-    EnResponse notificationChargeOrderInfo(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
-        return new EnResponse(enNotifyService.handleNotificationChargeOrderInfo(platformName, json));
+    PlatformResponse notificationChargeOrderInfo(@PathVariable(value = "platformName", required = false) String platformName, @RequestBody JSONObject json) {
+        return new PlatformResponse(enNotifyService.handleNotificationChargeOrderInfo(platformName, json));
     }
     }
 
 
 
 

+ 8 - 7
service/src/main/java/com/kym/service/admin/impl/StationServiceImpl.java

@@ -17,12 +17,12 @@ import com.kym.entity.admin.vo.LocalStationVo;
 import com.kym.entity.admin.vo.StationVo;
 import com.kym.entity.admin.vo.StationVo;
 import com.kym.entity.enplus.EnStationStatsInfo;
 import com.kym.entity.enplus.EnStationStatsInfo;
 import com.kym.entity.enplus.EnStationStatusInfo;
 import com.kym.entity.enplus.EnStationStatusInfo;
-import com.kym.entity.enplus.response.EnResponse;
+import com.kym.entity.enplus.response.PlatformResponse;
 import com.kym.mapper.admin.StationMapper;
 import com.kym.mapper.admin.StationMapper;
 import com.kym.service.admin.*;
 import com.kym.service.admin.*;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.PlatformCache;
 import com.kym.service.cache.PlatformCache;
-import com.kym.service.enplus.EnPlusService;
+import com.kym.service.enplus.PlatformApiService;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
 import com.kym.service.mybatisplus.MyBaseServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.aop.framework.AopContext;
 import org.springframework.aop.framework.AopContext;
@@ -48,14 +48,14 @@ import java.util.stream.Stream;
 @Slf4j
 @Slf4j
 public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station> implements StationService {
 public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station> implements StationService {
 
 
-    private final EnPlusService enPlusService;
+    private final PlatformApiService enPlusService;
     private final EquipmentInfoService equipmentInfoService;
     private final EquipmentInfoService equipmentInfoService;
     private final ConnectorInfoService connectorInfoService;
     private final ConnectorInfoService connectorInfoService;
     private final EquipmentRelationService equipmentRelationService;
     private final EquipmentRelationService equipmentRelationService;
     private final ActivityStationService activityStationService;
     private final ActivityStationService activityStationService;
     private final ActivityService activityService;
     private final ActivityService activityService;
 
 
-    public StationServiceImpl(EnPlusService enPlusService, EquipmentInfoService equipmentInfoService,
+    public StationServiceImpl(PlatformApiService enPlusService, EquipmentInfoService equipmentInfoService,
                               ConnectorInfoService connectorInfoService, EquipmentRelationService equipmentRelationService,
                               ConnectorInfoService connectorInfoService, EquipmentRelationService equipmentRelationService,
                               ActivityStationService activityStationService, @Lazy ActivityService activityService) {
                               ActivityStationService activityStationService, @Lazy ActivityService activityService) {
         this.enPlusService = enPlusService;
         this.enPlusService = enPlusService;
@@ -115,12 +115,13 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
 
 
     /**
     /**
      * 解析平台返回数据为JSONObject
      * 解析平台返回数据为JSONObject
+     *
      * @param response
      * @param response
      * @param platformName
      * @param platformName
      * @return
      * @return
      */
      */
-    JSONObject parsePlatformResponseData(EnResponse response, String platformName){
-        return JSONObject.parseObject(PlatformAesUtil.getUtil(PlatformCache.INSTANCE.getPlatformByName(platformName)).decrypt(response.getData()));
+    JSONObject parsePlatformResponseData(PlatformResponse response, String platformName) {
+        return JSONObject.parseObject(PlatformAesUtil.decrypt(PlatformCache.INSTANCE.getPlatformByName(platformName), response.getData()));
     }
     }
 
 
     /**
     /**
@@ -239,7 +240,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
                     }
                     }
                     """.formatted(String.join("\",\"", ids));
                     """.formatted(String.join("\",\"", ids));
             var response = enPlusService.platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_STATION_STATUS.getApi(), enPlusService.buildPlatformParams(platformName, param));
             var response = enPlusService.platformPost(platformName, EnPlusApi.EN_PLUS_QUERY_STATION_STATUS.getApi(), enPlusService.buildPlatformParams(platformName, param));
-            var enStationStatus = JSONObject.parseObject(PlatformAesUtil.getUtil(PlatformCache.INSTANCE.getPlatformByName(platformName)).decrypt(response.getData()));
+            var enStationStatus = JSONObject.parseObject(PlatformAesUtil.decrypt(PlatformCache.INSTANCE.getPlatformByName(platformName),response.getData()));
             res.addAll(enStationStatus.getJSONArray("StationStatusInfos").toJavaList(EnStationStatusInfo.class));
             res.addAll(enStationStatus.getJSONArray("StationStatusInfos").toJavaList(EnStationStatusInfo.class));
         });
         });
         return res;
         return res;

+ 1 - 2
service/src/main/java/com/kym/service/cache/PlatformCache.java

@@ -1,6 +1,5 @@
 package com.kym.service.cache;
 package com.kym.service.cache;
 
 
-import com.kym.common.utils.CommUtil;
 import com.kym.entity.admin.Platform;
 import com.kym.entity.admin.Platform;
 
 
 import java.util.Map;
 import java.util.Map;
@@ -62,7 +61,7 @@ public enum PlatformCache {
 
 
     public Platform getPlatformByName(String... platformName) {
     public Platform getPlatformByName(String... platformName) {
         var name = "EN_PLUS";
         var name = "EN_PLUS";
-        if (CommUtil.isNotEmptyAndNull(platformName)) {
+        if (platformName.length > 0 && platformName[0] != null) {
             name = platformName[0];
             name = platformName[0];
         }
         }
         return PLATFORM_CONFIG_MAPPING.get(name);
         return PLATFORM_CONFIG_MAPPING.get(name);

+ 3 - 3
service/src/main/java/com/kym/service/enplus/EnPlusService.java → service/src/main/java/com/kym/service/enplus/PlatformApiService.java

@@ -2,16 +2,16 @@ package com.kym.service.enplus;
 
 
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONObject;
 import com.kym.common.annotation.DynamicCache;
 import com.kym.common.annotation.DynamicCache;
-import com.kym.entity.enplus.response.EnResponse;
+import com.kym.entity.enplus.response.PlatformResponse;
 
 
 /**
 /**
  * @author skyline
  * @author skyline
  * @description
  * @description
  * @date 2023-07-31 14:13
  * @date 2023-07-31 14:13
  */
  */
-public interface EnPlusService {
+public interface PlatformApiService {
 
 
-    EnResponse platformPost(String platformName, String url, String params);
+    PlatformResponse platformPost(String platformName, String url, String params);
 
 
     String queryPlatformToken(String platformName);
     String queryPlatformToken(String platformName);
 
 

+ 3 - 3
service/src/main/java/com/kym/service/enplus/impl/EnNotifyServiceImpl.java

@@ -18,7 +18,7 @@ import com.kym.service.admin.EquipmentInfoService;
 import com.kym.service.admin.MonitorLogService;
 import com.kym.service.admin.MonitorLogService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.KymCache;
 import com.kym.service.enplus.EnNotifyService;
 import com.kym.service.enplus.EnNotifyService;
-import com.kym.service.enplus.EnPlusService;
+import com.kym.service.enplus.PlatformApiService;
 import com.kym.service.factory.DiscountStrategyFactory;
 import com.kym.service.factory.DiscountStrategyFactory;
 import com.kym.service.miniapp.*;
 import com.kym.service.miniapp.*;
 import jakarta.annotation.PostConstruct;
 import jakarta.annotation.PostConstruct;
@@ -45,7 +45,7 @@ import java.util.stream.Collectors;
 public class EnNotifyServiceImpl implements EnNotifyService {
 public class EnNotifyServiceImpl implements EnNotifyService {
     private static final Logger LOGGER = LoggerFactory.getLogger(EnNotifyServiceImpl.class);
     private static final Logger LOGGER = LoggerFactory.getLogger(EnNotifyServiceImpl.class);
     public final StringRedisTemplate redisTemplate;
     public final StringRedisTemplate redisTemplate;
-    private final EnPlusService enPlusService;
+    private final PlatformApiService enPlusService;
     private final ChargeOrderService chargeOrderService;
     private final ChargeOrderService chargeOrderService;
     private final ChargeService chargeService;
     private final ChargeService chargeService;
     private final AccountService accountService;
     private final AccountService accountService;
@@ -59,7 +59,7 @@ public class EnNotifyServiceImpl implements EnNotifyService {
     @Value("${kym.notify-email}")
     @Value("${kym.notify-email}")
     private String notifyEmail;
     private String notifyEmail;
 
 
-    public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService,
+    public EnNotifyServiceImpl(PlatformApiService enPlusService, ChargeOrderService chargeOrderService,
                                ChargeService chargeService, AccountService accountService, WalletDetailService walletDetailService,
                                ChargeService chargeService, AccountService accountService, WalletDetailService walletDetailService,
                                MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
                                MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
                                ConnectorInfoService connectorInfoService, StringRedisTemplate redisTemplate, UserStationService userStationService) {
                                ConnectorInfoService connectorInfoService, StringRedisTemplate redisTemplate, UserStationService userStationService) {

+ 25 - 27
service/src/main/java/com/kym/service/enplus/impl/EnPlusServiceImpl.java → service/src/main/java/com/kym/service/enplus/impl/PlatformApiServiceImpl.java

@@ -14,12 +14,11 @@ import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.PlatformAesUtil;
 import com.kym.common.utils.PlatformAesUtil;
 import com.kym.entity.common.RedisKeys;
 import com.kym.entity.common.RedisKeys;
 import com.kym.entity.enplus.EnRespQueryToken;
 import com.kym.entity.enplus.EnRespQueryToken;
-import com.kym.entity.enplus.response.EnResponse;
+import com.kym.entity.enplus.response.PlatformResponse;
 import com.kym.service.cache.PlatformCache;
 import com.kym.service.cache.PlatformCache;
-import com.kym.service.enplus.EnPlusService;
+import com.kym.service.enplus.PlatformApiService;
+import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
 import okhttp3.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -30,14 +29,13 @@ import java.util.concurrent.TimeUnit;
 
 
 /**
 /**
  * @author skyline
  * @author skyline
- * @description EN+平台接口服务
- * @date 2023-07-29 14:43
+ * 互联互通平台接口服务
  */
  */
 @Service
 @Service
-public class EnPlusServiceImpl implements EnPlusService {
+@Slf4j
+public class PlatformApiServiceImpl implements PlatformApiService {
 
 
     public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
     public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
-    private static final Logger LOGGER = LoggerFactory.getLogger(EnPlusServiceImpl.class);
     static OkHttpClient HTTP_CLIENT = new OkHttpClient.Builder().build();
     static OkHttpClient HTTP_CLIENT = new OkHttpClient.Builder().build();
     private final RedisTemplate<String, String> redisTemplate;
     private final RedisTemplate<String, String> redisTemplate;
 
 
@@ -48,7 +46,7 @@ public class EnPlusServiceImpl implements EnPlusService {
     @Value("${en-plus.sigSecret}")
     @Value("${en-plus.sigSecret}")
     private String SigSecret;
     private String SigSecret;
 
 
-    public EnPlusServiceImpl(RedisTemplate<String, String> redisTemplate) {
+    public PlatformApiServiceImpl(RedisTemplate<String, String> redisTemplate) {
         this.redisTemplate = redisTemplate;
         this.redisTemplate = redisTemplate;
     }
     }
 
 
@@ -74,7 +72,7 @@ public class EnPlusServiceImpl implements EnPlusService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    public EnResponse platformPost(String platformName, String url, String params) {
+    public PlatformResponse platformPost(String platformName, String url, String params) {
         // token获取
         // token获取
         var token = queryPlatformToken(platformName);
         var token = queryPlatformToken(platformName);
         Headers headers = Headers.of("Authorization", "Bearer ".concat(token));
         Headers headers = Headers.of("Authorization", "Bearer ".concat(token));
@@ -84,12 +82,12 @@ public class EnPlusServiceImpl implements EnPlusService {
                 .post(requestBody)
                 .post(requestBody)
                 .url(url)
                 .url(url)
                 .build();
                 .build();
-        var response = parse(synchronizedCall(request), EnResponse.class);
+        var response = parse(synchronizedCall(request), PlatformResponse.class);
 
 
         if (0 == response.getRet()) {
         if (0 == response.getRet()) {
             return response;
             return response;
         } else {
         } else {
-            LOGGER.error(":url:{}\n params:{}\ntoken:{}\n返回信息:{}", url, params, token, response);
+            log.error(":url:{}\n params:{}\ntoken:{}\n返回信息:{}", url, params, token, response);
             if (4002 == response.getRet()) {
             if (4002 == response.getRet()) {
                 // 如果返回Ret=4002,token错误的情况下,删除redis中的token,如果是预约订单则将此订单设置为延迟启动
                 // 如果返回Ret=4002,token错误的情况下,删除redis中的token,如果是预约订单则将此订单设置为延迟启动
                 redisTemplate.delete(RedisKeys.EN_PLUS_TOKEN + platformName);
                 redisTemplate.delete(RedisKeys.EN_PLUS_TOKEN + platformName);
@@ -106,8 +104,8 @@ public class EnPlusServiceImpl implements EnPlusService {
      * @param platformName
      * @param platformName
      * @return
      * @return
      */
      */
-    JSONObject parsePlatformResponseData(EnResponse response, String platformName) {
-        return JSONObject.parseObject(PlatformAesUtil.getUtil(PlatformCache.INSTANCE.getPlatformByName(platformName)).decrypt(response.getData()));
+    JSONObject parsePlatformResponseData(PlatformResponse response, String platformName) {
+        return JSONObject.parseObject(PlatformAesUtil.decrypt(PlatformCache.INSTANCE.getPlatformByName(platformName), response.getData()));
     }
     }
 
 
 
 
@@ -119,11 +117,11 @@ public class EnPlusServiceImpl implements EnPlusService {
      */
      */
     @Override
     @Override
     public String queryPlatformToken(String platformName) {
     public String queryPlatformToken(String platformName) {
-        LOGGER.info("查询互联互通平台token:{}", platformName);
+        log.info("查询互联互通平台token:{}", platformName);
         var token = redisTemplate.opsForValue().get(RedisKeys.EN_PLUS_TOKEN + platformName);
         var token = redisTemplate.opsForValue().get(RedisKeys.EN_PLUS_TOKEN + platformName);
         if (CommUtil.isNotEmptyAndNull(token)) {
         if (CommUtil.isNotEmptyAndNull(token)) {
             // 不同平台不同key
             // 不同平台不同key
-            LOGGER.debug("从缓存中查询到token:{},ttl:{}", token, redisTemplate.getExpire(RedisKeys.EN_PLUS_TOKEN + platformName));
+            log.debug("从缓存中查询到token:{},ttl:{}", token, redisTemplate.getExpire(RedisKeys.EN_PLUS_TOKEN + platformName));
             return token;
             return token;
         }
         }
         var data = """
         var data = """
@@ -135,36 +133,36 @@ public class EnPlusServiceImpl implements EnPlusService {
 
 
         var requestParams = buildPlatformParams(platformName, data);
         var requestParams = buildPlatformParams(platformName, data);
 
 
-        var response = enGetToken(EnPlusApi.EN_PLUS_QUERY_TOKEN.getApi(), requestParams);
+        var response = platformGetToken(EnPlusApi.EN_PLUS_QUERY_TOKEN.getApi(), requestParams);
 
 
         if (response != null && 0 == response.getRet()) {
         if (response != null && 0 == response.getRet()) {
             // 解密Data获取token
             // 解密Data获取token
             var jsonObject = parsePlatformResponseData(response, platformName);
             var jsonObject = parsePlatformResponseData(response, platformName);
-            var platformRespQueryToken = parse(jsonObject.getString("Data"), EnRespQueryToken.class);
-            LOGGER.debug("{}接口AccessToken:{}", platformName, platformRespQueryToken.toString());
+            var platformRespQueryToken = parse(jsonObject.toJSONString(), EnRespQueryToken.class);
+            log.debug("{}接口AccessToken:{}", platformName, platformRespQueryToken.toString());
             // 缓存token不同平台不同key,有效期7天(我们这里每次请求en+获取token的有效期并不是从7天开始,有效期是在en+的剩余有效时间)
             // 缓存token不同平台不同key,有效期7天(我们这里每次请求en+获取token的有效期并不是从7天开始,有效期是在en+的剩余有效时间)
             redisTemplate.opsForValue().set(RedisKeys.EN_PLUS_TOKEN + platformName, platformRespQueryToken.getAccessToken(), platformRespQueryToken.getTokenAvailableTime(), TimeUnit.SECONDS);
             redisTemplate.opsForValue().set(RedisKeys.EN_PLUS_TOKEN + platformName, platformRespQueryToken.getAccessToken(), platformRespQueryToken.getTokenAvailableTime(), TimeUnit.SECONDS);
             return platformRespQueryToken.getAccessToken();
             return platformRespQueryToken.getAccessToken();
         } else {
         } else {
             // 记录错误码,返回错误信息
             // 记录错误码,返回错误信息
-            LOGGER.error("{}接口错误:接口名{}:返回信息:{}", platformName, "query_token", response);
+            log.error("{}接口错误:接口名{}:返回信息:{}", platformName, "query_token", response);
             throw new BusinessException(ResponseEnum.EN_PLUS_QUERY_TOKEN_ERROR);
             throw new BusinessException(ResponseEnum.EN_PLUS_QUERY_TOKEN_ERROR);
         }
         }
     }
     }
 
 
-    public EnResponse enGetToken(String url, String params) {
+    public PlatformResponse platformGetToken(String url, String params) {
         // token获取
         // token获取
         RequestBody requestBody = RequestBody.create(params, JSON);
         RequestBody requestBody = RequestBody.create(params, JSON);
         Request request = new Request.Builder()
         Request request = new Request.Builder()
                 .post(requestBody)
                 .post(requestBody)
                 .url(url)
                 .url(url)
                 .build();
                 .build();
-        var response = parse(synchronizedCall(request), EnResponse.class);
+        var response = parse(synchronizedCall(request), PlatformResponse.class);
 
 
         if (response != null && 0 == response.getRet()) {
         if (response != null && 0 == response.getRet()) {
             return response;
             return response;
         } else {
         } else {
-            LOGGER.error("EN+接口数据异常:url:{}\n params:{}\n返回信息:{}", url, params, response);
+            log.error("互联互通接口数据异常:url:{}\n params:{}\n返回信息:{}", url, params, response);
             throw new BusinessException(ResponseEnum.EN_PLUS_API_EXCEPTION);
             throw new BusinessException(ResponseEnum.EN_PLUS_API_EXCEPTION);
         }
         }
     }
     }
@@ -180,7 +178,7 @@ public class EnPlusServiceImpl implements EnPlusService {
     @Override
     @Override
     public String buildPlatformParams(String platformName, String params) {
     public String buildPlatformParams(String platformName, String params) {
         // 使用DataSecret对data加密
         // 使用DataSecret对data加密
-        var dataStr = PlatformAesUtil.getUtil(PlatformCache.INSTANCE.getPlatformByName(platformName)).encrypt(params);
+        var dataStr = PlatformAesUtil.encrypt(PlatformCache.INSTANCE.getPlatformByName(platformName), params);
         // 时间戳
         // 时间戳
         var timeStamp = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
         var timeStamp = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
         // 自增序列
         // 自增序列
@@ -222,13 +220,13 @@ public class EnPlusServiceImpl implements EnPlusService {
         var sign = mac.digestHex(signString).toUpperCase();
         var sign = mac.digestHex(signString).toUpperCase();
         if (sign.equals(Sig)) {
         if (sign.equals(Sig)) {
             // 解密数据
             // 解密数据
-            return PlatformAesUtil.getUtil(PlatformCache.INSTANCE.getPlatformByName(platformName)).decrypt(Data);
+            return PlatformAesUtil.decrypt(PlatformCache.INSTANCE.getPlatformByName(platformName), Data);
         } else {
         } else {
             // 验签失败
             // 验签失败
-            EnResponse enResponse = new EnResponse();
+            PlatformResponse enResponse = new PlatformResponse();
             enResponse.setRet(4001);
             enResponse.setRet(4001);
             enResponse.setMsg(ResponseEnum.EN_PLUS_PUSH_SIGN_FAIL.getMessage());
             enResponse.setMsg(ResponseEnum.EN_PLUS_PUSH_SIGN_FAIL.getMessage());
-            LOGGER.error("EN+推送数据验签失败,数据:{}", json);
+            log.error("{}推送数据验签失败,数据:{}", platformName, json);
             throw new EnPushException(ResponseEnum.EN_PLUS_PUSH_SIGN_FAIL, enResponse);
             throw new EnPushException(ResponseEnum.EN_PLUS_PUSH_SIGN_FAIL, enResponse);
         }
         }
 
 

+ 3 - 3
service/src/main/java/com/kym/service/miniapp/impl/ChargeServiceImpl.java

@@ -22,7 +22,7 @@ import com.kym.service.admin.EquipmentInfoService;
 import com.kym.service.admin.EquipmentRelationService;
 import com.kym.service.admin.EquipmentRelationService;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.KymCache;
 import com.kym.service.cache.PlatformCache;
 import com.kym.service.cache.PlatformCache;
-import com.kym.service.enplus.EnPlusService;
+import com.kym.service.enplus.PlatformApiService;
 import com.kym.service.jobs.DelayService;
 import com.kym.service.jobs.DelayService;
 import com.kym.service.miniapp.*;
 import com.kym.service.miniapp.*;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
@@ -59,7 +59,7 @@ public class ChargeServiceImpl implements ChargeService {
     private final UserCouponService userCouponService;
     private final UserCouponService userCouponService;
     private final OrderCouponService orderCouponService;
     private final OrderCouponService orderCouponService;
     private final AccountService accountService;
     private final AccountService accountService;
-    private final EnPlusService enPlusService;
+    private final PlatformApiService enPlusService;
     private final EnPlusConfig enPlusConfig;
     private final EnPlusConfig enPlusConfig;
     private final DelayService<DelayChargeOrder> startDelayService;
     private final DelayService<DelayChargeOrder> startDelayService;
     private final DelayService<DelayChargeOrder> stopDelayService;
     private final DelayService<DelayChargeOrder> stopDelayService;
@@ -67,7 +67,7 @@ public class ChargeServiceImpl implements ChargeService {
     public ChargeServiceImpl(EquipmentRelationService equipmentRelationService, EquipmentInfoService equipmentInfoService,
     public ChargeServiceImpl(EquipmentRelationService equipmentRelationService, EquipmentInfoService equipmentInfoService,
                              ConnectorInfoService connectorInfoService, ChargeOrderService chargeOrderService,
                              ConnectorInfoService connectorInfoService, ChargeOrderService chargeOrderService,
                              OrderRechargeRightsService orderRechargeRightsService, UserRechargeRightsService userRechargeRightsService, UserCouponService userCouponService, OrderCouponService orderCouponService,
                              OrderRechargeRightsService orderRechargeRightsService, UserRechargeRightsService userRechargeRightsService, UserCouponService userCouponService, OrderCouponService orderCouponService,
-                             AccountService accountService, EnPlusService enPlusService, EnPlusConfig enPlusConfig,
+                             AccountService accountService, PlatformApiService enPlusService, EnPlusConfig enPlusConfig,
                              @Qualifier("StartChargeDelayJob") @Lazy DelayService<DelayChargeOrder> startDelayService,
                              @Qualifier("StartChargeDelayJob") @Lazy DelayService<DelayChargeOrder> startDelayService,
                              @Qualifier("StopChargeDelayJob") @Lazy DelayService<DelayChargeOrder> stopDelayService, StringRedisTemplate redisTemplate) {
                              @Qualifier("StopChargeDelayJob") @Lazy DelayService<DelayChargeOrder> stopDelayService, StringRedisTemplate redisTemplate) {
         this.equipmentRelationService = equipmentRelationService;
         this.equipmentRelationService = equipmentRelationService;

+ 4 - 6
service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -11,7 +11,6 @@ import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
-import com.google.common.util.concurrent.AtomicDouble;
 import com.kym.common.config.WxFapiaoConfig;
 import com.kym.common.config.WxFapiaoConfig;
 import com.kym.common.config.WxPayConfig;
 import com.kym.common.config.WxPayConfig;
 import com.kym.common.constant.ResponseEnum;
 import com.kym.common.constant.ResponseEnum;
@@ -19,14 +18,13 @@ import com.kym.common.exception.BusinessException;
 import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.CommUtil;
 import com.kym.common.utils.LambadaTools;
 import com.kym.common.utils.LambadaTools;
 import com.kym.common.utils.OrderUtils;
 import com.kym.common.utils.OrderUtils;
-import com.kym.entity.admin.InvoiceDetail;
 import com.kym.entity.miniapp.Account;
 import com.kym.entity.miniapp.Account;
 import com.kym.entity.miniapp.*;
 import com.kym.entity.miniapp.*;
 import com.kym.entity.wechat.*;
 import com.kym.entity.wechat.*;
 import com.kym.service.admin.ActivityService;
 import com.kym.service.admin.ActivityService;
 import com.kym.service.admin.InvoiceDetailService;
 import com.kym.service.admin.InvoiceDetailService;
 import com.kym.service.cache.PlatformCache;
 import com.kym.service.cache.PlatformCache;
-import com.kym.service.enplus.EnPlusService;
+import com.kym.service.enplus.PlatformApiService;
 import com.kym.service.miniapp.*;
 import com.kym.service.miniapp.*;
 import com.kym.service.wechat.WxPayService;
 import com.kym.service.wechat.WxPayService;
 import com.wechat.pay.java.core.Config;
 import com.wechat.pay.java.core.Config;
@@ -107,7 +105,7 @@ public class WxPayServiceImpl implements WxPayService {
 
 
     private final InvoiceTitleService invoiceTitleService;
     private final InvoiceTitleService invoiceTitleService;
 
 
-    private final EnPlusService enPlusService;
+    private final PlatformApiService enPlusService;
 
 
     private final ActivityService activityService;
     private final ActivityService activityService;
 
 
@@ -125,7 +123,7 @@ public class WxPayServiceImpl implements WxPayService {
     public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService,
     public WxPayServiceImpl(WxPayConfig conf, WxFapiaoConfig fapiaoConfig, WalletDetailService walletDetailService,
                             PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService,
                             PayLogService payLogService, AccountService accountService, ChargeOrderService chargeOrderService,
                             RefundLogService refundLogService, InvoiceService invoiceService, InvoiceTitleService invoiceTitleService,
                             RefundLogService refundLogService, InvoiceService invoiceService, InvoiceTitleService invoiceTitleService,
-                            EnPlusService enPlusService, ActivityService activityService, UserRechargeRightsService userRechargeRightsService, InvoiceDetailService invoiceDetailService) {
+                            PlatformApiService enPlusService, ActivityService activityService, UserRechargeRightsService userRechargeRightsService, InvoiceDetailService invoiceDetailService) {
         this.conf = conf;
         this.conf = conf;
         this.fapiaoConfig = fapiaoConfig;
         this.fapiaoConfig = fapiaoConfig;
         this.walletDetailService = walletDetailService;
         this.walletDetailService = walletDetailService;
@@ -363,7 +361,7 @@ public class WxPayServiceImpl implements WxPayService {
                 if (chargingOrder != null) {
                 if (chargingOrder != null) {
                     var account = accountService.getAccountByUserId(walletDetail.getUserId());
                     var account = accountService.getAccountByUserId(walletDetail.getUserId());
                     // TODO: 2023-11-30 快充这里考虑过充的金额要提高
                     // TODO: 2023-11-30 快充这里考虑过充的金额要提高
-                    var res = enPlusService.updateBalanceByQueryEquipChargeStatus(PlatformCache.INSTANCE.getPlatformNameByConnectorId(chargingOrder.getConnectorId()),chargingOrder.getStartChargeSeq(), account.getBalance() - 50);
+                    var res = enPlusService.updateBalanceByQueryEquipChargeStatus(PlatformCache.INSTANCE.getPlatformNameByConnectorId(chargingOrder.getConnectorId()), chargingOrder.getStartChargeSeq(), account.getBalance() - 50);
                     LOGGER.info("用户:{}充电过程中充值,已更新en+充电金额,en+返回数据:{}", account.getUserId(), res);
                     LOGGER.info("用户:{}充电过程中充值,已更新en+充电金额,en+返回数据:{}", account.getUserId(), res);
                 }
                 }
                 return ResponseEntity.status(HttpStatus.OK).build();
                 return ResponseEntity.status(HttpStatus.OK).build();