From f10b01a8840d0b1f384b54aa81079e15ebda510e Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Fri, 27 Jun 2025 10:23:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B8=B8=E7=95=85=E5=85=85?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=89=A9=E5=B1=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/thirdparty/ChangZhouController.java | 35 +++++++ .../src/main/resources/application-pre.yml | 24 ++--- .../common/NotificationService.java | 2 + .../platform/domain/PayOrderInfo.java | 59 ++++++++++++ .../platform/dto/RetryOrderDTO.java | 20 ++++ .../service/ThirdPartyPlatformService.java | 17 ++++ .../impl/ChangZhouPlatformServiceImpl.java | 94 +++++++++++++++++++ 7 files changed, 239 insertions(+), 12 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/PayOrderInfo.java create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/RetryOrderDTO.java diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java index 2d62bac9c..221849401 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChangZhouController.java @@ -10,6 +10,7 @@ import com.jsowell.common.response.RestApiResponse; import com.jsowell.pile.dto.*; import com.jsowell.pile.thirdparty.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.common.CommonResult; +import com.jsowell.thirdparty.platform.dto.RetryOrderDTO; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -468,4 +469,38 @@ public class ChangZhouController extends ThirdPartyBaseController { return response; } + /** + * 获取充电订单信息 + * retry_notification_order_info + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/retry_notification_order_info") + public CommonResult retry_notification_order_info(HttpServletRequest request , @RequestBody CommonParamsDTO dto) { + logger.info("{}-获取充电订单信息 params:{}" , platformName , JSON.toJSONString(dto)); + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + // 解析入参 + RetryOrderDTO retryOrderDTO = parseParamsDTO(dto , RetryOrderDTO.class); + // 执行逻辑 + Map map = platformLogic.retryNotificationOrderInfo(retryOrderDTO.getStartChargeSeqs()); + logger.info("{}-获取充电订单信息 result:{}" , platformName , map); + return CommonResult.success(0 , "获取充电订单信息成功!" , map.get("Data") , map.get("Sig")); + } catch (Exception e) { + logger.error("{}-获取充电订单信息 error" , platformName , e); + } + return CommonResult.failed("{}-获取充电订单信息发生异常"); + + } + } diff --git a/jsowell-admin/src/main/resources/application-pre.yml b/jsowell-admin/src/main/resources/application-pre.yml index 690bbf530..90f0eed99 100644 --- a/jsowell-admin/src/main/resources/application-pre.yml +++ b/jsowell-admin/src/main/resources/application-pre.yml @@ -8,17 +8,17 @@ spring: # redis 配置 redis: # 地址 - host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com -# host: 106.14.94.149 +# host: r-uf6k0uet7mihr5z78f.redis.rds.aliyuncs.com + host: 106.14.94.149 # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 账号 - username: jsowell - # 密码 - password: js@160829 -# password: js160829 +# username: jsowell +# # 密码 +# password: js@160829 + password: js160829 # 连接超时时间 timeout: 10s lettuce: @@ -38,12 +38,12 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: jsowell - password: js@160829 -# url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# username: jsowell_pre -# password: Js@160829 +# url: jdbc:mysql://rm-uf6ra51u33dc3798l.mysql.rds.aliyuncs.com:3306/jsowell_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: jsowell +# password: js@160829 + url: jdbc:mysql://106.14.94.149:3306/jsowell_pre?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: jsowell_pre + password: Js@160829 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java index 0f324720a..6fe108dec 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/NotificationService.java @@ -175,6 +175,8 @@ public class NotificationService { platformService.notificationStopChargeResult(orderCode); //推送充换电站用能统计信息 platformService.notificationOperationStatsInfo(stationId); + //推送充电账单信息 + platformService.notificationPayOrderInfo(orderCode); } catch (Exception e) { logger.error("充电订单信息推送error", e); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/PayOrderInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/PayOrderInfo.java new file mode 100644 index 000000000..9563bc204 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/PayOrderInfo.java @@ -0,0 +1,59 @@ +package com.jsowell.thirdparty.platform.domain; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class PayOrderInfo { + + /** + * 充电订单号 + */ + @JSONField(name = "StartChargeSeq") + private String startChargeSeq; + + /** + * 总电费(优惠前) 保2 + */ + @JSONField(name = "ElecTotal") + private BigDecimal elecTotal; + + /** + * 总服务费(优惠前) 保2 + */ + @JSONField(name = "ServiceTotal") + private BigDecimal serviceTotal; + + /** + * 累计总金额(优惠前) 保2 + */ + @JSONField(name = "Total") + private BigDecimal total; + + /** + * 总电费(实际支付) + */ + @JSONField(name = "ElecPaid") + private BigDecimal elecPaid; + + /** + * 总服务费(实际支付) + */ + @JSONField(name = "ServicePaid") + private BigDecimal servicePaid; + + /** + * 累计总金额(实际支付) + */ + @JSONField(name = "Paid") + private BigDecimal paid; + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/RetryOrderDTO.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/RetryOrderDTO.java new file mode 100644 index 000000000..ba01479e3 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/dto/RetryOrderDTO.java @@ -0,0 +1,20 @@ +package com.jsowell.thirdparty.platform.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class RetryOrderDTO { + + /** + * 充电订单号 + */ + @JsonProperty(value = "StartChargeSeqs") + private String startChargeSeqs; +} 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 bca65c880..5007c4980 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 @@ -271,6 +271,15 @@ public interface ThirdPartyPlatformService extends InitializingBean { } + /** + * 获取充电订单信息 + * retry_notification_order_info + */ + default Map retryNotificationOrderInfo(String orderCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + + // =================================================================================== // // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由对方平台实现此接口,我方平台调用的通知接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ // // =================================================================================== // @@ -474,6 +483,14 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + /** + * 推送充电账单信息 + * notification_pay_order_info + */ + default String notificationPayOrderInfo(String orderCode) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + // -------------------------------------- 以下是公用方法 --------------------------------------- // /** diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java index 222fe0951..4af81590c 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChangZhouPlatformServiceImpl.java @@ -33,6 +33,7 @@ import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo; import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo; import com.jsowell.thirdparty.lianlian.vo.*; import com.jsowell.thirdparty.platform.common.ChargeDetail; +import com.jsowell.thirdparty.platform.domain.PayOrderInfo; import com.jsowell.thirdparty.platform.domain.SupChargeDetails; import com.jsowell.thirdparty.platform.domain.SupStationInfo; import com.jsowell.thirdparty.platform.factory.ThirdPartyPlatformFactory; @@ -789,6 +790,99 @@ public class ChangZhouPlatformServiceImpl implements ThirdPartyPlatformService { } + /** + * 推送充电账单信息 + * notification_pay_order_info + * @param orderCode + * @return + */ + @Override + public String notificationPayOrderInfo(String orderCode){ + //获取订单信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + return "没有此订单信息"; + } + //获取订单详情信息 + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); + String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + //《***优惠前***》 + //电费 + BigDecimal electricityAmount = orderDetail.getTotalElectricityAmount(); + //服务费 + BigDecimal serviceAmount = orderDetail.getTotalServiceAmount(); + //订单金额 + BigDecimal orderAmount = orderDetail.getTotalOrderAmount(); + + + //《***优惠金额***》 + //优惠电费 + BigDecimal discountElectricityAmount = orderDetail.getDiscountElectricityAmount(); + //优惠服务费 + BigDecimal discountServiceAmount = orderDetail.getDiscountServiceAmount(); + + //《***优惠后***》 + //电费 + BigDecimal afterDiscountElectricityAmount = electricityAmount.subtract(discountElectricityAmount); + //服务费 + BigDecimal afterDiscountServiceAmount = serviceAmount.subtract(discountServiceAmount); + //订单金额 + BigDecimal afterDiscountOrderAmount = orderAmount.subtract(discountElectricityAmount).subtract(discountServiceAmount); + + + PayOrderInfo payOrderInfo = PayOrderInfo.builder() + .startChargeSeq(orderCode) + .elecTotal(electricityAmount) + .serviceTotal(serviceAmount) + .total(orderAmount) + .elecPaid(afterDiscountElectricityAmount) + .servicePaid(afterDiscountServiceAmount) + .paid(afterDiscountOrderAmount) + .build(); + + String url = urlAddress + "notification_pay_order_info"; + + String jsonString = JSON.toJSONString(payOrderInfo); + log.info("请求参数:{}", jsonString); + + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + + return result; + } + + + + /** + * 获取充电订单信息 retry_notification_order_info + * @param orderCode + * @return + */ + @Override + public Map retryNotificationOrderInfo(String orderCode) { + Map map = new LinkedHashMap<>(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getChangZhouSecretInfo(); + int Success = 0; + //查询订单信息 + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + if (orderBasicInfo == null) { + Success = 1; + } + map.put("Success", Success); + return ThirdPartyPlatformUtils.generateResultMap(map, thirdPartySecretInfoVO); + + } + + + /** * 转换时段充电明细 *