From f72ae151cc12b219cb5f39eea3ec0ea089a6ef2a Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 27 八月 2025 23:53:05 +0800
Subject: [PATCH] 修改bug

---
 UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java |   61 ++++++++++++++++++++----------
 1 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
index dab81c8..a32508d 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -25,10 +25,7 @@
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
@@ -51,6 +48,8 @@
 	private IOrderPrivateCarService orderPrivateCarService;
 	@Autowired
 	private IPaymentRecordService paymentRecordService;
+	@Autowired
+	private IIncomeService incomeService;
 	
 	
 	@Autowired
@@ -80,12 +79,12 @@
 	@Scheduled(fixedRate = 1000 * 60)
 	public void taskMinute() {
 		try {
+			//处理超时未支付的订单
+			timoutNoPayment();
 			//修改过期的优惠券
 			userCouponRecordService.updateTimeOut();
 			//修改过期的商家优惠券
 			userMerchantCouponService.updateExpired();
-			//处理超时未支付的订单
-			timoutNoPayment();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -108,7 +107,7 @@
 		try {
 			List<OrderPrivateCar> orderPrivateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("isDelete", 1)
 					.eq("state", 7).eq("abnormal", 1)
-					.last(" and now() > DATE_ADD(endServiceTime, INTERVAL 24 HOUR)"));
+					.last(" and now() > DATE_ADD(endServiceTime, INTERVAL 1 HOUR)"));
 			for (OrderPrivateCar orderPrivateCar : orderPrivateCars) {
 				UserInfo userInfo = userInfoService.selectById(orderPrivateCar.getUserId());
 				SendSmsRequest request = new SendSmsRequest();
@@ -121,7 +120,7 @@
 			}
 			List<OrderTaxi> orderTaxis = orderTaxiService.selectList(new EntityWrapper<OrderTaxi>().eq("isDelete", 1)
 					.eq("state", 7).eq("abnormal", 1)
-					.last(" and now() > DATE_ADD(endServiceTime, INTERVAL 24 HOUR)"));
+					.last(" and now() > DATE_ADD(endServiceTime, INTERVAL 1 HOUR)"));
 			for (OrderTaxi orderTaxi : orderTaxis) {
 				UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
 				SendSmsRequest request = new SendSmsRequest();
@@ -143,18 +142,23 @@
 	 */
 	public void timoutNoPayment() {
 		List<OrderPrivateCar> orderPrivateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("state", 7)
-				.eq("isDelete", 1).eq("recoveryOrder", 0).last(" and now() >= DATE_ADD(insertTime, INTERVAL 72 HOUR)"));
+				.eq("isDelete", 1).eq("recoveryOrder", 0).eq("abnormal", 1).last(" and now() >= DATE_ADD(insertTime, INTERVAL 10 MINUTE)"));
+		List<OrderPrivateCar> orderPrivateCars1 = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("state", 7)
+				.eq("isDelete", 1).eq("recoveryOrder", 0).eq("abnormal", 2).last(" and now() >= DATE_ADD(abnormalTime, INTERVAL 10 MINUTE)"));
+		orderPrivateCars.addAll(orderPrivateCars1);
 		for (OrderPrivateCar orderPrivateCar : orderPrivateCars) {
 			try {
 				Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
 				Company company = companyService.selectById(driver.getCompanyId());
 				UserInfo userInfo = userInfoService.selectById(orderPrivateCar.getUserId());
+				Double orderMoney = (1 == orderPrivateCar.getAbnormal() ? orderPrivateCar.getOrderMoney() : orderPrivateCar.getResponsibilityMoney().doubleValue());
+
 				if(null == orderPrivateCar.getIsCreated()){
 					//先调中台创建订单
 					CreateOrderRequest createOrderRequest = new CreateOrderRequest();
 					createOrderRequest.setTreatShopId(driver.getEmpId().toString());
 					createOrderRequest.setField1("{\"profitSharing\":\"1\",\"isPromote\":\"" + (orderPrivateCar.getPromotion() == 2 ? 1 : 0) + "\"}");
-					createOrderRequest.setCharge(new BigDecimal(orderPrivateCar.getOrderMoney()));
+					createOrderRequest.setCharge(new BigDecimal(orderMoney));
 					createOrderRequest.setOrderNo("PR" + orderPrivateCar.getId());
 					createOrderRequest.setOrderId(orderPrivateCar.getTravelId());
 					createOrderRequest.setCustomerId(userInfo.getOnconUUID());
@@ -166,7 +170,7 @@
 				//使用备付金进行支付订单
 				TradePayOffData tradePayOffData = new TradePayOffData();
 				tradePayOffData.setPartnerPayId(orderPrivateCar.getTravelId());
-				tradePayOffData.setTotalFee(Double.valueOf(orderPrivateCar.getOrderMoney() * 100).intValue() + "");
+				tradePayOffData.setTotalFee(Double.valueOf(orderMoney * 100).intValue() + "");
 				tradePayOffData.setOrderDesc("完成订单");
 				PayInfo payInfo = OrderUtil.tradePayOff(tradePayOffData);
 				String retCode = payInfo.getRetCode();
@@ -195,7 +199,7 @@
 					paymentOrderRequest.setPayItemId(paymentInfo.getPayItemId());
 					paymentOrderRequest.setPaymentInfo(JSON.toJSONString(payInfoData.getPaymentInfos()));
 					paymentOrderRequest.setOrderId(orderPrivateCar.getTravelId());
-					paymentOrderRequest.setCharge(BigDecimal.valueOf(orderPrivateCar.getOrderMoney()));
+					paymentOrderRequest.setCharge(BigDecimal.valueOf(orderMoney));
 					paymentOrderRequest.setPayTime(data.getPayTime());
 					paymentOrderRequest.setPaymentSerialNumber(payInfoData.getPayId());
 					OrderInfo orderInfo1 = OrderUtil.paymentOrder(paymentOrderRequest);
@@ -220,17 +224,25 @@
 					BeanUtils.copyProperties(orderPrivateCar, orderPrivateCar1);
 					orderPrivateCar1.setId(null);
 					orderPrivateCar1.setRecoveryOrder(1);
+					orderPrivateCar1.setIsGenerateRecoveryOrder(0);
+					orderPrivateCar1.setOldOrderId(orderPrivateCar.getId());
+					orderPrivateCar1.setRecoveryOrderCreateDate(new Date());
 					
 					//修改原始订单为支付状态
 					orderPrivateCar.setState(9);
 					orderPrivateCar.setPayType(5);
-					orderPrivateCar.setPayMoney(orderPrivateCar.getOrderMoney());
+					orderPrivateCar.setPayMoney(orderMoney);
+					orderPrivateCar.setPayTime(new Date());
+					orderPrivateCar.setIsGenerateRecoveryOrder(1);
+					//添加收入
+					Map<String, Object> map = incomeService.saveIncome(orderPrivateCar.getId(), 1, orderMoney);
+					orderPrivateCar.setSplitAllocation(JSON.toJSONString(map));
 					orderPrivateCarService.updateById(orderPrivateCar);
 					//保存追缴单
 					orderPrivateCarService.insert(orderPrivateCar1);
 					//添加三方支付记录
 					try {
-						paymentRecordService.saveData(1, orderPrivateCar.getUserId(), 1, orderPrivateCar.getId(), 1, 3, orderPrivateCar.getOrderMoney(), payId, 2);
+						paymentRecordService.saveData(1, orderPrivateCar.getUserId(), 1, orderPrivateCar.getId(), 1, 3, orderMoney, payId, 2);
 					} catch (Exception e) {
 						throw new RuntimeException(e);
 					}
@@ -269,18 +281,22 @@
 		
 		//出租车
 		List<OrderTaxi> orderTaxis = orderTaxiService.selectList(new EntityWrapper<OrderTaxi>().eq("state", 7)
-				.eq("isDelete", 1).eq("recoveryOrder", 0).last(" and now() >= DATE_ADD(insertTime, INTERVAL 24 HOUR)"));
+				.eq("isDelete", 1).eq("recoveryOrder", 0).eq("abnormal", 1).last(" and now() >= DATE_ADD(insertTime, INTERVAL 10 MINUTE)"));
+		List<OrderTaxi> orderTaxis1 = orderTaxiService.selectList(new EntityWrapper<OrderTaxi>().eq("state", 7)
+				.eq("isDelete", 1).eq("recoveryOrder", 0).eq("abnormal", 2).last(" and now() >= DATE_ADD(abnormalTime, INTERVAL 10 MINUTE)"));
+		orderTaxis.addAll(orderTaxis1);
 		for (OrderTaxi orderTaxi : orderTaxis) {
 			try {
 				Driver driver = driverService.selectById(orderTaxi.getDriverId());
 				Company company = companyService.selectById(driver.getCompanyId());
 				UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
+				Double orderMoney = (1 == orderTaxi.getAbnormal() ? orderTaxi.getOrderMoney() : orderTaxi.getResponsibilityMoney().doubleValue());
 				if(null == orderTaxi.getIsCreated()){
 					//先调中台创建订单
 					CreateOrderRequest createOrderRequest = new CreateOrderRequest();
 					createOrderRequest.setTreatShopId(driver.getEmpId().toString());
 					createOrderRequest.setField1("{\"profitSharing\":\"1\",\"isPromote\":\"" + (orderTaxi.getPromotion() == 2 ? 1 : 0) + "\"}");
-					createOrderRequest.setCharge(new BigDecimal(orderTaxi.getOrderMoney()));
+					createOrderRequest.setCharge(new BigDecimal(orderMoney));
 					createOrderRequest.setOrderNo("TA" + orderTaxi.getId());
 					createOrderRequest.setOrderId(orderTaxi.getTravelId());
 					createOrderRequest.setCustomerId(userInfo.getOnconUUID());
@@ -292,7 +308,7 @@
 				//使用备付金进行支付订单
 				TradePayOffData tradePayOffData = new TradePayOffData();
 				tradePayOffData.setPartnerPayId(orderTaxi.getTravelId());
-				tradePayOffData.setTotalFee(Double.valueOf(orderTaxi.getOrderMoney() * 100).intValue() + "");
+				tradePayOffData.setTotalFee(Double.valueOf(orderMoney * 100).intValue() + "");
 				tradePayOffData.setOrderDesc("完成订单");
 				PayInfo payInfo = OrderUtil.tradePayOff(tradePayOffData);
 				String retCode = payInfo.getRetCode();
@@ -321,7 +337,7 @@
 					paymentOrderRequest.setPayItemId(paymentInfo.getPayItemId());
 					paymentOrderRequest.setPaymentInfo(JSON.toJSONString(payInfoData.getPaymentInfos()));
 					paymentOrderRequest.setOrderId(orderTaxi.getTravelId());
-					paymentOrderRequest.setCharge(BigDecimal.valueOf(orderTaxi.getOrderMoney()));
+					paymentOrderRequest.setCharge(BigDecimal.valueOf(orderMoney));
 					paymentOrderRequest.setPayTime(data.getPayTime());
 					paymentOrderRequest.setPaymentSerialNumber(payInfoData.getPayId());
 					OrderInfo orderInfo1 = OrderUtil.paymentOrder(paymentOrderRequest);
@@ -346,17 +362,22 @@
 					BeanUtils.copyProperties(orderTaxi, orderTaxi1);
 					orderTaxi1.setId(null);
 					orderTaxi1.setRecoveryOrder(1);
+					orderTaxi1.setIsGenerateRecoveryOrder(0);
+					orderTaxi1.setOldOrderId(orderTaxi.getId());
+					orderTaxi1.setRecoveryOrderCreateDate(new Date());
 					
 					//修改原始订单为支付状态
 					orderTaxi.setState(9);
 					orderTaxi.setPayType(5);
-					orderTaxi.setPayMoney(orderTaxi.getOrderMoney());
+					orderTaxi.setPayMoney(orderMoney);
+					orderTaxi.setPayTime(new Date());
+					orderTaxi.setIsGenerateRecoveryOrder(1);
 					orderTaxiService.updateById(orderTaxi);
 					//保存追缴单
 					orderTaxiService.insert(orderTaxi1);
 					//添加三方支付记录
 					try {
-						paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderTaxi.getId(), 2, 3, orderTaxi.getOrderMoney(), payId, 2);
+						paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderTaxi.getId(), 2, 3, orderMoney, payId, 2);
 					} catch (Exception e) {
 						throw new RuntimeException(e);
 					}

--
Gitblit v1.7.1