diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java index 39bf2d366..683982795 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/LianLianController.java @@ -593,4 +593,40 @@ public class LianLianController extends ThirdPartyBaseController { return response; } + + /** + * 查询订单结算信息 + * @param request + * @param dto + * @return + */ + @PostMapping("/v1/query_order_settlement_info") + public CommonResult query_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) { + try { + // 校验令牌 + if (!verifyToken(request.getHeader("Authorization"))) { + // 校验失败 + return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR); + } + + // 校验签名 + if (!verifySignature(dto)) { + // 签名错误 + return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR); + } + + // 解析入参 + PushOrderSettlementDTO pushOrderSettlementDTO = parseParamsDTO(dto, PushOrderSettlementDTO.class); + + // 执行逻辑 + Map map = platformLogic.queryOrderSettlementInfo(pushOrderSettlementDTO); + logger.info("查询订单结算信息 result:{}", JSON.toJSONString(map)); + return CommonResult.success(0, "查询订单结算信息成功!", map.get("Data"), map.get("Sig")); + } catch (Exception e) { + logger.error("查询订单结算信息 error:", e); + } + return CommonResult.failed("查询订单结算信息发生异常"); + + } + } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/vo/OrderSettlementVO.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/vo/OrderSettlementVO.java new file mode 100644 index 000000000..b8b848598 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/vo/OrderSettlementVO.java @@ -0,0 +1,62 @@ +package com.jsowell.thirdparty.lianlian.vo; + +import com.alibaba.fastjson2.annotation.JSONField; +import lombok.Builder; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Builder +public class OrderSettlementVO { + + /** + * 充电订单号 + */ + @JSONField(name = "StartChargeSeq") + private String startChargeSeq; + + /** + * 充电设备接口编码 + */ + @JSONField(name = "ConnectorID") + private String connectorID; + + /** + * 累计充电量 + */ + @JSONField(name = "TotalPower") + private BigDecimal totalPower; + + /** + * 累计总金额 + */ + @JSONField(name = "TotalMoney") + private BigDecimal totalMoney; + + /** + * 是否出租车订单 + */ + @JSONField(name = "TaxiOrder") + private int taxiOrder; + + /** + * 结算金额 + */ + @JSONField(name = "SettlementMoney") + private BigDecimal settlementMoney; + + /** + * 优惠类型 + */ + @JSONField(name = "DiscountType") + private int discountType; + + /** + * 优惠金额 + */ + @JSONField(name = "DiscountMoney") + private BigDecimal discountMoney; + + +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/OrderInfo.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/OrderInfo.java index a9c6d4898..9ec8cb504 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/OrderInfo.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/common/OrderInfo.java @@ -188,6 +188,14 @@ public class OrderInfo { @JSONField(name = "SumPeriod") private Integer sumPeriod; + /** + * 订单类型 Y + * 1,充电订单 + * 2,放电订单 + */ + @JSONField(name = "OrderType") + private Integer orderType; + /** * 充电明细信息 Y */ 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 f2cd0280c..31fffc67e 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 @@ -251,6 +251,15 @@ public interface ThirdPartyPlatformService extends InitializingBean { throw new UnsupportedOperationException("This method is not yet implemented"); } + /** + * 查询订单结算信息 query_order_settlement_info + * @param dto + * @return + */ + default Map queryOrderSettlementInfo(PushOrderSettlementDTO dto) { + throw new UnsupportedOperationException("This method is not yet implemented"); + } + // =================================================================================== // // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 由对方平台实现此接口,我方平台调用的通知接口 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ // diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java index d9a044287..dafff5d8a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java @@ -915,21 +915,21 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { * @throws UnsupportedOperationException 未实现异常 */ @Override - public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { + public String notificationChargeOrderInfo(String orderCode) { // 根据订单号查询出信息 OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); // 通过站点id查询相关配置信息 - // ThirdPartySecretInfoVO thirdPartySecretInfoVO = getLianLianPlatformSecretInfo(); + ThirdPartySecretInfoVO thirdPartySecretInfoVO = getLianLianPlatformSecretInfo(); String operatorId = Constants.OPERATORID_LIANLIAN; - String operatorSecret = secretInfoVO.getTheirOperatorSecret(); - String signSecret = secretInfoVO.getTheirSigSecret(); - String dataSecret = secretInfoVO.getTheirDataSecret(); - String dataSecretIv = secretInfoVO.getTheirDataSecretIv(); - String urlAddress = secretInfoVO.getTheirUrlPrefix(); + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); String url = urlAddress + "notification_orderInfo"; @@ -949,6 +949,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { .startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime())) .endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime())) .paymentAmount(orderBasicInfo.getPayAmount()) + .orderType(Constants.one) // .payChannel() .stopReason(0) // .chargeDetails() @@ -1040,6 +1041,52 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + /** + * 6.9 推送充电订单信息 + * @param orderCode + * @param thirdPartySecretInfoVO + * @return + */ + public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO thirdPartySecretInfoVO) { + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + String operatorId = Constants.OPERATORID_LIANLIAN; + String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); + String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); + String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret(); + String dataSecretIv = thirdPartySecretInfoVO.getTheirDataSecretIv(); + String urlAddress = thirdPartySecretInfoVO.getTheirUrlPrefix(); + + String url = urlAddress + BusinessInformationExchangeEnum.NOTIFICATION_CHARGE_ORDER_INFO.getValue(); + Date chargeStartTime = orderBasicInfo.getChargeStartTime(); + if (chargeStartTime == null) { + chargeStartTime = orderBasicInfo.getCreateTime(); + } + Date chargeEndTime = orderBasicInfo.getChargeEndTime(); + if (chargeEndTime == null) { + chargeEndTime = orderBasicInfo.getCreateTime(); + } + + JSONObject json = new JSONObject(); + json.put("StartChargeSeq", orderCode); + json.put("ConnectorID", orderBasicInfo.getPileConnectorCode()); + json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeStartTime)); + json.put("EndTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, chargeEndTime)); + json.put("TotalPower", orderDetail.getTotalUsedElectricity().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalElecMoney", orderDetail.getTotalElectricityAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalSeviceMoney", orderDetail.getTotalServiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("TotalMoney", orderDetail.getTotalOrderAmount().setScale(2, BigDecimal.ROUND_HALF_UP)); + json.put("StopReason", 2); // 2:BMS 停止充电 + + String jsonString = JSON.toJSONString(json); + 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; + } // @Override // public String notificationChargeOrderInfo(String orderCode, ThirdPartySecretInfoVO secretInfoVO) { // @@ -1155,6 +1202,9 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { // return result; // } + //TODO 5.10 推送站点累计电量接口( notification_station_electStatsInfo) + + /** * 站点费率变化推送 notification_stationFee * @@ -1279,6 +1329,41 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { return result; } + /** + * 查询订单结算信息 query_order_settlement_info + * @param dto + * @return + */ + @Override + public Map queryOrderSettlementInfo(PushOrderSettlementDTO dto) { + String orderCode = dto.getStartChargeSeq(); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + + if (orderInfo == null || orderDetail == null) { + return null; + } + + ThirdPartySecretInfoVO lianLianPlatformSecretInfo = getLianLianPlatformSecretInfo(); + + // 封装数据 + OrderSettlementVO vo = OrderSettlementVO.builder() + .startChargeSeq(orderCode) + .connectorID(orderInfo.getPileConnectorCode()) + .totalPower(orderDetail.getTotalUsedElectricity()) //累计电量 + .totalMoney(orderDetail.getTotalOrderAmount()) //累计金额 + .taxiOrder(Constants.zero) //是否为出租车,默认0不是 + .settlementMoney(orderInfo.getSettleAmount()) //结算金额 + .discountType(Constants.zero) // 优惠类型 + .discountMoney(BigDecimal.ZERO) // 优惠金额 + .build(); + // 加密数据 + Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, lianLianPlatformSecretInfo.getOurDataSecret(), + lianLianPlatformSecretInfo.getOurDataSecretIv(), lianLianPlatformSecretInfo.getTheirSigSecret()); + return resultMap; + + } + /** * 推送订单结算信息 notification_order_settlement_info */