|
@@ -21,6 +21,7 @@ import com.fs.company.vo.RedPacketMoneyVO;
|
|
|
import com.fs.course.dto.BatchSendCourseAllDTO;
|
|
import com.fs.course.dto.BatchSendCourseAllDTO;
|
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
|
|
+import com.fs.course.service.IFsUserCourseOrderService;
|
|
|
import com.fs.course.service.ITencentCloudCosService;
|
|
import com.fs.course.service.ITencentCloudCosService;
|
|
|
import com.fs.erp.domain.ErpDeliverys;
|
|
import com.fs.erp.domain.ErpDeliverys;
|
|
|
import com.fs.erp.domain.ErpOrder;
|
|
import com.fs.erp.domain.ErpOrder;
|
|
@@ -49,6 +50,7 @@ import com.fs.his.enums.FsStoreOrderLogEnum;
|
|
|
import com.fs.his.enums.FsStoreOrderStatusEnum;
|
|
import com.fs.his.enums.FsStoreOrderStatusEnum;
|
|
|
import com.fs.his.mapper.*;
|
|
import com.fs.his.mapper.*;
|
|
|
import com.fs.his.param.FsInquiryOrderFinishParam;
|
|
import com.fs.his.param.FsInquiryOrderFinishParam;
|
|
|
|
|
+import com.fs.his.param.FsPackageOrderCancelParam;
|
|
|
import com.fs.his.service.*;
|
|
import com.fs.his.service.*;
|
|
|
import com.fs.his.service.impl.FsPackageOrderServiceImpl;
|
|
import com.fs.his.service.impl.FsPackageOrderServiceImpl;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
@@ -65,6 +67,7 @@ import com.fs.sop.domain.QwSopTempVoice;
|
|
|
import com.fs.sop.service.IQwSopTempVoiceService;
|
|
import com.fs.sop.service.IQwSopTempVoiceService;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -73,12 +76,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -140,7 +145,7 @@ public class Task {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CompanyVoiceLogsMapper companyVoiceLogsMapper;
|
|
private CompanyVoiceLogsMapper companyVoiceLogsMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- FsPackageOrderServiceImpl packageOrderService;
|
|
|
|
|
|
|
+ IFsPackageOrderService packageOrderService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStoreOrderLogsService fsStoreOrderLogsService;
|
|
private IFsStoreOrderLogsService fsStoreOrderLogsService;
|
|
|
org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
|
|
org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
|
|
@@ -200,6 +205,14 @@ public class Task {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStorePaymentService fsStorePaymentService;
|
|
private IFsStorePaymentService fsStorePaymentService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsStoreOrderService orderService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* sop任务token消耗统计
|
|
* sop任务token消耗统计
|
|
|
*/
|
|
*/
|
|
@@ -1538,5 +1551,80 @@ public class Task {
|
|
|
fsStorePaymentService.synchronizePayStatus();
|
|
fsStorePaymentService.synchronizePayStatus();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 超时取消订单
|
|
|
|
|
+ */
|
|
|
|
|
+ public void cancelOrder(){
|
|
|
|
|
+ //查询超时订单
|
|
|
|
|
+ SysConfig sysConfig= sysConfigService.selectConfigByConfigKey("his.store");
|
|
|
|
|
+ StoreConfig config= JSONUtil.toBean(sysConfig.getConfigValue(),StoreConfig.class);
|
|
|
|
|
+ Integer unPayTime = config.getUnPayTime(); //分钟
|
|
|
|
|
+ if (unPayTime == null){
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ //1.处方订单
|
|
|
|
|
+ //查询超时未支付订单
|
|
|
|
|
+ List<FsStoreOrder> orderList = orderService.selectOutTimeOrderList(unPayTime);
|
|
|
|
|
+ //取消订单
|
|
|
|
|
+ List<CompletableFuture<Void>> orderFutures = cancelOrdersAsync(orderList, order -> {
|
|
|
|
|
+ orderService.cancelOrder(order.getOrderId());
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+// //2.课程订单
|
|
|
|
|
+// //查询超时未支付订单
|
|
|
|
|
+// List<FsUserCourseOrder> courseOrderlist = userCourseOrderService.selectOutTimeOrderList(unPayTime);
|
|
|
|
|
+// //取消订单
|
|
|
|
|
+// courseOrderlist.forEach(order->{
|
|
|
|
|
+// userCourseOrderService.cancelOrder(order.getOrderId());
|
|
|
|
|
+// });
|
|
|
|
|
+ //3.服务包订单
|
|
|
|
|
+ //查询超时未支付订单
|
|
|
|
|
+ List<FsPackageOrder> packageOrderList = packageOrderService.selectOutTimeOrderList(unPayTime);
|
|
|
|
|
+ //取消订单
|
|
|
|
|
+ List<CompletableFuture<Void>> packageOrderFutures = cancelOrdersAsync(packageOrderList, order -> {
|
|
|
|
|
+ FsPackageOrderCancelParam param = new FsPackageOrderCancelParam();
|
|
|
|
|
+ param.setOrderId(order.getOrderId());
|
|
|
|
|
+ packageOrderService.cancel(param);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 等待所有任务完成
|
|
|
|
|
+ waitForAllTasksToComplete(orderFutures);
|
|
|
|
|
+ waitForAllTasksToComplete(packageOrderFutures);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 异步取消订单
|
|
|
|
|
+ * @param orders 订单列表
|
|
|
|
|
+ * @param cancelAction 取消订单的逻辑
|
|
|
|
|
+ * @param <T> 订单类型
|
|
|
|
|
+ * @return CompletableFuture列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private <T> List<CompletableFuture<Void>> cancelOrdersAsync(List<T> orders, Consumer<T> cancelAction) {
|
|
|
|
|
+ List<CompletableFuture<Void>> futures = new ArrayList<>();
|
|
|
|
|
+ for (T order : orders) {
|
|
|
|
|
+ CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ cancelAction.accept(order);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 记录异常日志
|
|
|
|
|
+ System.err.println("Failed to cancel order: " + order + ", Error: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
|
|
+ futures.add(future);
|
|
|
|
|
+ }
|
|
|
|
|
+ return futures;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 等待所有任务完成
|
|
|
|
|
+ * @param futures CompletableFuture列表
|
|
|
|
|
+ */
|
|
|
|
|
+ private void waitForAllTasksToComplete(List<CompletableFuture<Void>> futures) {
|
|
|
|
|
+ CompletableFuture<Void> allFutures = CompletableFuture.allOf(
|
|
|
|
|
+ futures.toArray(new CompletableFuture[0])
|
|
|
|
|
+ );
|
|
|
|
|
+ allFutures.join(); // 等待所有任务完成
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|