From 424d94d8a5c8bb758a9a486ebd9f59eed7f2c631 Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 16 Dec 2024 16:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E5=AE=81=E6=B3=A2?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=A1=A5=E6=8E=A8=E8=AE=A2=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsowell/api/thirdparty/ZDLController.java | 14 ++++-- .../service/ThirdPartyPlatformService.java | 4 ++ .../impl/GuiZhouPlatformServiceImpl.java | 8 ++-- .../ZhongDianLianPlatformServiceImpl.java | 44 ++++++++++++++----- .../util/ThirdPartyPlatformUtils.java | 24 ++++++++-- 5 files changed, 71 insertions(+), 23 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java index 28a40af2b..098c2d9cb 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ZDLController.java @@ -11,14 +11,12 @@ import com.jsowell.common.exception.BusinessException; import com.jsowell.common.response.RestApiResponse; import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.StringUtils; -import com.jsowell.pile.dto.PushInfoParamDTO; -import com.jsowell.pile.dto.PushRealTimeInfoDTO; -import com.jsowell.pile.dto.PushStationInfoDTO; -import com.jsowell.pile.dto.QueryStationInfoDTO; +import com.jsowell.pile.dto.*; import com.jsowell.thirdparty.lianlian.common.CommonResult; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.impl.ZhongDianLianPlatformServiceImpl; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; @@ -383,4 +381,12 @@ public class ZDLController extends ThirdPartyBaseController { logger.info("宁波平台推送订单信息 result:{}", response); return response; } + + @PostMapping("/tempPushHistoryOrderInfo") + public RestApiResponse tempPushHistoryOrderInfo(@RequestBody QueryOrderDTO dto) { + RestApiResponse response = null; + String result = platformLogic.pushOrderInfo(dto); + response = new RestApiResponse<>(result); + return response; + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java index 4d9cc7e87..07c749298 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/ThirdPartyPlatformService.java @@ -415,6 +415,10 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + default String pushOrderInfo(com.jsowell.pile.dto.QueryOrderDTO dto){ + throw new UnsupportedOperationException("This method is not yet implemented"); + } + // -------------------------------------- 以下是公用方法 --------------------------------------- // /** * 从联联平台获取令牌 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java index df185e4f3..83a2f643d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/GuiZhouPlatformServiceImpl.java @@ -149,7 +149,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { vo.setFailReason(failReason); vo.setSuccStat(succStat); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.useOurSigSecretGenerateResultMap(vo, thirdPartySecretInfoVO); return resultMap; } @@ -187,7 +187,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { map.put("ItemSize", pageInfo.getTotal()); map.put("OperatorInfos", operatorInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.useOurSigSecretGenerateResultMap(map, thirdPartySecretInfoVO); return resultMap; } @@ -280,7 +280,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { map.put("PageCount", pageInfo.getPages()); map.put("ItemSize", pageInfo.getTotal()); map.put("StationInfos", resultList); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.useOurSigSecretGenerateResultMap(map, thirdPartySecretInfoVO); return resultMap; } @@ -426,7 +426,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService { Map map = new LinkedHashMap<>(); map.put("StationStatusInfos", stationStatusInfos); - Map resultMap = ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + Map resultMap = ThirdPartyPlatformUtils.useOurSigSecretGenerateResultMap(map, thirdPartySecretInfoVO); return resultMap; } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java index 9aa2cc150..b70fcd075 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ZhongDianLianPlatformServiceImpl.java @@ -1,15 +1,12 @@ package com.jsowell.thirdparty.platform.service.impl; -import cn.hutool.core.util.PageUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum; -import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum; import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.ykc.OrderStatusEnum; import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; @@ -25,9 +22,9 @@ import com.jsowell.pile.vo.ThirdPartySecretInfoVO; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO; -import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO; +import com.jsowell.pile.vo.web.OrderListVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; @@ -40,10 +37,10 @@ import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.HttpRequestUtil; import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils; import com.jsowell.thirdparty.service.ThirdpartySecretInfoService; -import com.jsowell.thirdparty.yongchengboche.dto.YCBCGetTokenDTO; -import com.jsowell.thirdparty.zhongdianlian.dto.ZDLGetTokenDTO; import org.apache.commons.collections4.CollectionUtils; import org.bouncycastle.crypto.CryptoException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -62,6 +59,8 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi // 平台类型 private final String thirdPlatformType = ThirdPlatformTypeEnum.NING_BO_PLATFORM.getTypeCode(); + Logger logger = LoggerFactory.getLogger(QingHaiPlatformServiceImpl.class); + @Autowired private ThirdpartySecretInfoService thirdpartySecretInfoService; @@ -169,7 +168,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi // 查询相关配置信息 ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); - String operatorId = ningBoSecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); @@ -474,7 +473,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi public String notificationStationStatus(String stationId, String pileConnectorCode, String status, ThirdPartySecretInfoVO secretInfoVO) { ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); - String operatorId = ningBoSecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); @@ -510,7 +509,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); - String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); @@ -788,7 +787,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi return null; } ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); - String operatorId = ningBoSecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); @@ -825,7 +824,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi return null; } ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); - String operatorId = ningBoSecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); @@ -863,7 +862,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi // 查询相关配置信息 ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); - String operatorId = ningBoSecretInfoVO.getOurOperatorId(); + String operatorId = Constants.OPERATORID_JIANG_SU; String operatorSecret = ningBoSecretInfoVO.getTheirOperatorSecret(); String signSecret = ningBoSecretInfoVO.getTheirSigSecret(); String dataSecret = ningBoSecretInfoVO.getTheirDataSecret(); @@ -970,6 +969,27 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi return resultList; } + @Override + public String pushOrderInfo(QueryOrderDTO dto) { + ThirdPartySecretInfoVO ningBoSecretInfoVO = getNingBoSecretInfoVO(); + + // 根据站点id, 开始时间,结束时间查询出所有的订单信息 + List orderListVOS = orderBasicInfoService.selectOrderBasicInfoList(dto); + if (CollectionUtils.isEmpty(orderListVOS)) { + return "订单信息为空"; + } + List orderCodeList = orderListVOS.stream().map(OrderListVO::getOrderCode).collect(Collectors.toList()); + for (String orderCode : orderCodeList) { + try { + String result = notificationChargeOrderInfo(orderCode, ningBoSecretInfoVO); + logger.info("订单:{} 推送结果:{}", orderCode, result); + }catch (Exception e) { + logger.error("订单:{} 推送error, ", orderCode, e); + } + } + return "Success"; + } + /** * 获取宁波平台密钥信息 * @return diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java index 8d324ad50..4058da38f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/util/ThirdPartyPlatformUtils.java @@ -16,7 +16,7 @@ import java.util.regex.Pattern; public class ThirdPartyPlatformUtils { /** - * 生成结果集 + * 生成结果集(使用对方SigSecret) * @param obj 需要返回的数据 * @param secretInfo 密钥配置信息对象 * @return 结果集 @@ -25,6 +25,16 @@ public class ThirdPartyPlatformUtils { return generateResultMap(obj, secretInfo.getOurDataSecret(), secretInfo.getOurDataSecretIv(), secretInfo.getTheirSigSecret()); } + /** + * 生成结果集(使用我方SigSecret) + * @param obj + * @param secretInfo + * @return + */ + public static Map useOurSigSecretGenerateResultMap(Object obj, ThirdPartySecretInfoVO secretInfo) { + return generateResultMap(obj, secretInfo.getOurDataSecret(), secretInfo.getOurDataSecretIv(), secretInfo.getOurSigSecret()); + } + /** * 生成结果集 * @param obj 需要返回的数据 @@ -36,11 +46,11 @@ public class ThirdPartyPlatformUtils { } /** - * 生成结果集 + * 生成结果集(仅加密Data生成签名) * @param obj 需要返回的数据 * @param dataSecret 消息密钥 * @param dataSecretIv 消息密钥初始化向量 - * @param signSecret 签名密钥 + * @param signSecret 对方签名密钥 * @return 结果集 */ public static Map generateResultMap(Object obj, String dataSecret, String dataSecretIv, String signSecret) { @@ -54,6 +64,14 @@ public class ThirdPartyPlatformUtils { return resultMap; } + /** + * 生成结果集(将 Ret、Msg、Data进行加密生成签名) + * @param obj + * @param dataSecret + * @param dataSecretIv + * @param signSecret 对方签名密钥 + * @return + */ public static Map generateResultMapV2(Object obj, String dataSecret, String dataSecretIv, String signSecret) { Map resultMap = Maps.newHashMap(); // 加密数据