From 99eddbebf80c5549a7487caed95b041abdc9bb5f Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 14 七月 2025 14:06:40 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java | 75 ++++++++++++++++++++++++++----------- 1 files changed, 53 insertions(+), 22 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java index fdab12e..5d21287 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java @@ -32,6 +32,7 @@ import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; import com.ruoyi.integration.api.feignClient.*; import com.ruoyi.integration.api.model.*; +import com.ruoyi.integration.api.vo.ChargingOrderVo; import com.ruoyi.integration.api.vo.GetPlatformStopChargingReply; import com.ruoyi.integration.api.vo.StartChargeResult; import com.ruoyi.order.api.dto.SettlementConfirmAdd; @@ -229,6 +230,9 @@ @Autowired private RedissonClient redissonClient; + + @Resource + private ChargingMessageClient chargingMessageClient; @@ -451,7 +455,7 @@ //检查当前枪是否是正在使用中 TChargingOrder one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getChargingGunId, addChargingOrder.getId()) - .in(TChargingOrder::getStatus, Arrays.asList(1, 2, 3)).eq(TChargingOrder::getDelFlag, 0)); + .in(TChargingOrder::getStatus, Arrays.asList(3)).eq(TChargingOrder::getDelFlag, 0)); if(null != one){ return AjaxResult.error("充电枪正在充电中,启动失败"); } @@ -807,24 +811,30 @@ //清除计时器中的无效数据 counter_map.remove(code); - TChargingOrder order = new TChargingOrder(); - order.setId(id); - order.setAppUserId(chargingOrder.getAppUserId()); if(0 == startup_result){ //启动失败 preChargeCheck1.setStartupSuccess(3); preChargeCheck1.setFailureCause(failure_cause); //启动失败后取消订单,退款操作 refund(code); - order.setStatus(-1); - order.setEndMode(0); + chargingOrder.setStatus(-1); + chargingOrder.setEndMode(0); }else{ //启动成功 preChargeCheck1.setStartupSuccess(2); - order.setStatus(3); - order.setStartTime(LocalDateTime.now()); + chargingOrder.setStatus(3); + chargingOrder.setStartTime(LocalDateTime.now()); } - this.updateById(order); + this.updateById(chargingOrder); + if(chargingOrder.getStatus() == 3){ + //推送监管平台订单状态 + new Thread(()->{ + ChargingOrderVo chargingOrderVo = new ChargingOrderVo(); + BeanUtils.copyProperties(chargingOrder, chargingOrderVo); + chargingMessageClient.pushOrderStatus(chargingOrderVo); + }).start(); + } + redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); //推送三方平台订单状态 if(2 == chargingOrder.getOrderSource()){ @@ -928,6 +938,15 @@ } redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); this.updateById(order); + + if(3 == order.getStatus()){ + //推送监管平台订单状态 + new Thread(()->{ + ChargingOrderVo chargingOrderVo = new ChargingOrderVo(); + BeanUtils.copyProperties(order, chargingOrderVo); + chargingMessageClient.pushOrderStatus(chargingOrderVo); + }).start(); + } //推送三方平台启动充电结果 if(2 == order.getOrderSource()){ StartChargeResult result = new StartChargeResult(); @@ -1040,7 +1059,7 @@ dto.setRefundAmount(rechargeAmount.toString()); dto.setRefundReason("充电失败,取消充电订单"); RefundResp resp = h5AliPaymentClient.refund(dto).getData(); - if(null != resp){ + if(null != resp && "10000".equals(resp.getCode())){ chargingOrderRefundService.save(chargingOrderRefund); //回退会员折扣次数 if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ @@ -1137,7 +1156,7 @@ dto.setRefundAmount(money.toString()); dto.setRefundReason("充电完成退款"); RefundResp resp = h5AliPaymentClient.refund(dto).getData(); - if(null != resp){ + if(null != resp && "10000".equals(resp.getCode())){ chargingOrderRefundService.save(chargingOrderRefund); try { Thread.sleep(1000); @@ -1245,13 +1264,11 @@ if(!order.getAppUserId().equals(userId)){ return AjaxResult.error("权限不足"); } - TChargingOrder chargingOrder = new TChargingOrder(); - chargingOrder.setId(Long.valueOf(id)); - chargingOrder.setAppUserId(order.getAppUserId()); - chargingOrder.setEndTime(LocalDateTime.now()); - chargingOrder.setStatus(4); - chargingOrder.setEndMode(1); - this.updateById(chargingOrder); + order.setEndTime(LocalDateTime.now()); + order.setStatus(4); + order.setEndMode(1); + this.updateById(order); + String code1 = order.getCode(); TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData(); //异步线程处理停机 @@ -1265,6 +1282,12 @@ sendMessageClient.platformStopCharging(platformStopCharging); log.info(code1 + ":-------------------远程停止充电请求-------------------"); log.info(platformStopCharging.toString()); + + //推送监管平台订单状态和订单详情 + ChargingOrderVo chargingOrderVo = new ChargingOrderVo(); + BeanUtils.copyProperties(order, chargingOrderVo); + chargingMessageClient.pushOrderInfo(chargingOrderVo); + chargingMessageClient.pushOrderStatus(chargingOrderVo); }); //推送三方平台 if(2 == order.getOrderSource()){ @@ -2250,7 +2273,7 @@ } chargingOrder.setChargingCapacity(query.getCharging_degree()); chargingOrder.setElectricity(query.getCharging_degree()); - chargingOrder.setTotalElectricity(new BigDecimal(100 - query.getSoc())); + chargingOrder.setTotalElectricity(new BigDecimal(query.getSoc())); this.updateById(chargingOrder); } } @@ -2318,6 +2341,9 @@ //获取订单的计费策略 List<AccountingStrategyDetailOrder> accountingStrategyDetailOrderList = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); + if(accountingStrategyDetailOrderList.isEmpty()){ + return R.fail("计费策略为空,无法计算费用"); + } accountingStrategyDetailOrderList.get(accountingStrategyDetailOrderList.size() - 1).setEndTime("23:59"); //开始处理计费明细数据和优惠数据 chargingOrderAccountingStrategyService.remove(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); @@ -2737,7 +2763,7 @@ dto.setRefundAmount(refundAmount.toString()); dto.setRefundReason("充电完成退款"); RefundResp resp = h5AliPaymentClient.refund(dto).getData(); - if(null != resp){ + if(null != resp && "10000".equals(resp.getCode())){ chargingOrderRefundService.save(chargingOrderRefund); this.chargingOrderStartupFailureWxRefund(chargingOrderRefund.getRefundCode(), resp.getTradeNo(), "SUCCESS", null); } @@ -2954,7 +2980,7 @@ dto.setRefundAmount(payOrderQueryDto.getRefundAmount().toString()); dto.setRefundReason("取消订单"); RefundResp resp = h5AliPaymentClient.refund(dto).getData(); - if(null != resp){ + if(null != resp && "10000".equals(resp.getCode())){ chargingOrderRefund.setRefundStatus(2); chargingOrderRefund.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); this.baseMapper.updateById(tChargingOrder); @@ -4131,7 +4157,6 @@ chargingOrder.setStatus(4); chargingOrder.setEndMode(1); this.updateById(chargingOrder); - tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId()); String code1 = order.getCode(); @@ -4147,6 +4172,12 @@ sendMessageClient.platformStopCharging(platformStopCharging); log.info(code1 + ":-------------------远程停止充电请求-------------------"); log.info(platformStopCharging.toString()); + + //推送监管平台订单状态和订单详情 + ChargingOrderVo chargingOrderVo = new ChargingOrderVo(); + BeanUtils.copyProperties(chargingOrder, chargingOrderVo); + chargingMessageClient.pushOrderInfo(chargingOrderVo); + chargingMessageClient.pushOrderStatus(chargingOrderVo); }); return R.ok(); } -- Gitblit v1.7.1