新增常畅充对接扩展接口

This commit is contained in:
YAS\29473
2025-06-27 10:23:51 +08:00
parent ee733ff8e0
commit f10b01a884
7 changed files with 239 additions and 12 deletions

View File

@@ -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<String, String> 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("{}-获取充电订单信息发生异常");
}
}

View File

@@ -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:
# 从数据源开关/默认关闭

View File

@@ -175,6 +175,8 @@ public class NotificationService {
platformService.notificationStopChargeResult(orderCode);
//推送充换电站用能统计信息
platformService.notificationOperationStatsInfo(stationId);
//推送充电账单信息
platformService.notificationPayOrderInfo(orderCode);
} catch (Exception e) {
logger.error("充电订单信息推送error", e);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -271,6 +271,15 @@ public interface ThirdPartyPlatformService extends InitializingBean {
}
/**
* 获取充电订单信息
* retry_notification_order_info
*/
default Map<String, String> 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");
}
// -------------------------------------- 以下是公用方法 --------------------------------------- //
/**

View File

@@ -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<String ,String> retryNotificationOrderInfo(String orderCode) {
Map<String, Object> 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);
}
/**
* 转换时段充电明细
*