From 7e383cd9001f48141449c2f4e7e007348217f4f8 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 31 十月 2024 16:11:14 +0800
Subject: [PATCH] merge

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |   61 +++++++++++++++++++++++++-----
 1 files changed, 50 insertions(+), 11 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 7dac1d8..f631356 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
@@ -387,7 +387,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));
 		if(null != one){
-			return AjaxResult.error("充电枪正在充电桩中,启动失败");
+			return AjaxResult.error("充电枪正在充电中,启动失败");
 		}
 		//查询当前充电枪是否有正在支付的订单
 		one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getChargingGunId, addChargingOrder.getId())
@@ -447,6 +447,7 @@
 		chargingOrder.setVipDiscountAmount(BigDecimal.ZERO);
 		chargingOrder.setOrderSource(0);
 		chargingOrder.setTitle("【充电桩充电】" + chargingPile.getNumber() + "号桩/" + tChargingGun.getCode() + "号枪");
+		chargingOrder.setStatus(1);
 		
 		Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData().get(0);
 		Integer accountingStrategyId = tChargingGun.getAccountingStrategyId();
@@ -685,9 +686,6 @@
 		String code = chargingOrder.getCode();
 		String key = "AQJC_" + chargingOrder.getChargingGunId();
 		List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData();
-		if(null == data || data.size() == 0){
-			return false;
-		}
 		log.error(code + ":-------------------开始检查调起充电结果-------------------" + data.toString());
 		if(data.size() != 0){
 			PlatformStartChargingReply platformStartChargingReply = data.get(1);
@@ -737,7 +735,7 @@
 				counter = (null == counter ? 0 : counter) + 1;
 				boot_failed_map.put(code, counter);
 				//启动失败
-				preChargeCheck1.setStartupSuccess(3);
+				preChargeCheck1.setStartupSuccess(1);
 				preChargeCheck1.setFailureCause(0);
 				redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
 				return false;
@@ -981,6 +979,7 @@
 		chargingOrder.setId(Long.valueOf(id));
 		chargingOrder.setAppUserId(order.getAppUserId());
 		chargingOrder.setEndTime(LocalDateTime.now());
+		chargingOrder.setStatus(4);
 		chargingOrder.setEndMode(1);
 		this.updateById(chargingOrder);
 		
@@ -1772,7 +1771,7 @@
 	public void endChargeBillingCharge(TransactionRecordMessageVO vo) {
 		TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number()));
 		Integer status = chargingOrder.getStatus();
-		if(status == 4 || status == 5){
+		if(status == 5){
 			return;
 		}
 		
@@ -2108,7 +2107,7 @@
 			chargingOrderRefund.setRefundTitle("充电完成退款");
 			chargingOrderRefund.setRefundContent("充电完成退款");
 			chargingOrderRefund.setRefundReason("充电完成退款");
-			chargingOrderRefund.setRefundRemark("实际充电消费金额:" + refundAmount);
+			chargingOrderRefund.setRefundRemark("实际充电消费金额:" + chargingOrder.getPaymentAmount());
 			chargingOrderRefund.setRefundTotalAmount(refundAmount);
 			chargingOrderRefund.setPayAmount(rechargeAmount);
 			if(1 == rechargePaymentType){
@@ -2241,6 +2240,9 @@
 				if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){
 					return R.fail("退款金额需小于支付金额");
 				}
+				if ((tChargingOrder.getRechargeAmount().subtract(payOrderQueryDto.getRefundAmount()).compareTo(tChargingOrder.getPaymentAmount()))==0){
+					tChargingOrder.setStatus(5);
+				}
 
 
 				TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund();
@@ -2307,6 +2309,10 @@
 				if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){
 					return R.fail("退款金额需小于支付金额");
 				}
+				if ((tChargingOrder.getPaymentAmount().subtract(payOrderQueryDto.getRefundAmount()).compareTo(tChargingOrder.getPaymentAmount()))==0){
+					tChargingOrder.setStatus(5);
+				}
+
 				TShoppingOrderRefund chargingOrderRefund = new TShoppingOrderRefund();
 				chargingOrderRefund.setShoppingOrderId(tChargingOrder.getId());
 				chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount());
@@ -2357,9 +2363,7 @@
 						tChargingOrder.setRefundStatus(2);
 						tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount()));
 
-						if (payOrderQueryDto.getRefundAmount().compareTo(tChargingOrder.getPaymentAmount())==0){
-							tChargingOrder.setStatus(5);
-						}
+
 						shoppingOrderService.updateById(tChargingOrder);
 
 						shoppingOrderRefundService.save(chargingOrderRefund);
@@ -2374,6 +2378,8 @@
 			if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){
 				return R.fail("退款金额需小于支付金额");
 			}
+
+
 			TVipOrderRefund chargingOrderRefund = new TVipOrderRefund();
 			chargingOrderRefund.setVipOrderId(tChargingOrder.getId());
 			chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount());
@@ -2453,7 +2459,7 @@
 		}
 		TChargingOrder one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserCarId, appUserCar.getId())
 				.eq(TChargingOrder::getDelFlag, 0).gt(TChargingOrder::getStartTime, query.getStartTime())
-				.eq(TChargingOrder::getRechargePaymentStatus, 2).ne(TChargingOrder::getStatus, -1));
+				.eq(TChargingOrder::getRechargePaymentStatus, 2).ne(TChargingOrder::getStatus, 5));
 		return one;
 	}
 
@@ -2969,4 +2975,37 @@
 	public Long countNoTag() {
 		return this.baseMapper.countNoTag();
 	}
+	
+	
+	@Override
+	public List<TChargingOrder> getChargingOrder(TChargingOrderVo order) {
+		LambdaQueryWrapper<TChargingOrder> queryWrapper = new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getDelFlag, 0);
+		if(null != order.getChargingPileId()){
+			queryWrapper.eq(TChargingOrder::getChargingPileId, order.getChargingPileId());
+		}
+		if(null != order.getChargingGunId()){
+			queryWrapper.eq(TChargingOrder::getChargingGunId, order.getChargingGunId());
+		}
+		if(null != order.getStatus()){
+			queryWrapper.eq(TChargingOrder::getStatus, order.getStatus());
+		}
+		if(null != order.getAppUserId()){
+			queryWrapper.eq(TChargingOrder::getAppUserId, order.getAppUserId());
+		}
+		if(null != order.getAppUserId()){
+			queryWrapper.eq(TChargingOrder::getAppUserId, order.getAppUserId());
+		}
+		if(null != order.getStatusList()){
+			queryWrapper.in(TChargingOrder::getAppUserId, order.getStatusList());
+		}
+		if(null != order.getEndMode()){
+			queryWrapper.eq(TChargingOrder::getEndMode, order.getEndMode());
+		}
+		return this.list(queryWrapper.orderByDesc(TChargingOrder::getCreateTime));
+	}
+
+	@Override
+	public Long countCar(List<String> brands) {
+		return this.baseMapper.countCar(brands);
+	}
 }

--
Gitblit v1.7.1