|
|
@@ -8,9 +8,7 @@ import com.ylx.common.core.domain.entity.SysDept;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
import com.ylx.massage.domain.*;
|
|
|
-import com.ylx.massage.enums.BillTypeEnum;
|
|
|
-import com.ylx.massage.enums.JsStatusEnum;
|
|
|
-import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
+import com.ylx.massage.enums.*;
|
|
|
import com.ylx.massage.mapper.TConsumptionLogMapper;
|
|
|
import com.ylx.massage.service.*;
|
|
|
import com.ylx.massage.utils.DateTimeUtils;
|
|
|
@@ -23,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -37,6 +36,9 @@ public class massageTask {
|
|
|
@Resource
|
|
|
private TOrderService orderService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IProductOrderInfoService productOrderInfoService;
|
|
|
+
|
|
|
@Resource
|
|
|
private LocationUtil locationUtil;
|
|
|
|
|
|
@@ -67,10 +69,9 @@ public class massageTask {
|
|
|
private WeChatUtil weChatUtil;
|
|
|
|
|
|
/**
|
|
|
- * 取消超时未支付订单
|
|
|
+ * 取消超时未支付的订单
|
|
|
*/
|
|
|
public void cancelOrder() {
|
|
|
-
|
|
|
Date nowDate = new Date();
|
|
|
log.info("开始执行取消订单任务,当前时间:{}", nowDate);
|
|
|
|
|
|
@@ -82,6 +83,25 @@ public class massageTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消超时未支付的商品订单
|
|
|
+ */
|
|
|
+ public void cancelProductOrder() {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ String currentTime = DateTimeUtils.formatDate(nowDate, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ log.info("开始执行取消商品订单任务,当前时间:{}", currentTime);
|
|
|
+
|
|
|
+ Date date = DateTimeUtils.addMinute(nowDate, -5);
|
|
|
+ String dateStr = DateTimeUtils.formatDate(date, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ log.info("开始执行取消商品订单任务,当前时间减5分钟:{}", dateStr);
|
|
|
+ long total = 1L;
|
|
|
+ while (total > 0L) {
|
|
|
+ total = extractedProduct(date);
|
|
|
+ log.info("取消商品订单任务,当前时间减5分钟,共取消{}条商品订单", total);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 取消超时未支付订单
|
|
|
* @param nowDate
|
|
|
@@ -111,8 +131,37 @@ public class massageTask {
|
|
|
return resPage.getTotal();
|
|
|
}
|
|
|
|
|
|
- public void timeoutNotOrder() {
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消超时未支付的商品订单
|
|
|
+ * @param nowDate
|
|
|
+ * @return Long
|
|
|
+ */
|
|
|
+ private Long extractedProduct(Date nowDate) {
|
|
|
+ LambdaQueryWrapper<ProductOrderInfo> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ objectLambdaQueryWrapper.eq(ProductOrderInfo::getOrderStatus, ProductOrderStatusEnum.WAIT_PAY.getCode()).
|
|
|
+ eq(ProductOrderInfo::getPayStatus, PaymentStatusEnum.UNPAID.getCode()).
|
|
|
+ lt(ProductOrderInfo::getPayExpireTime, LocalDateTime.now());
|
|
|
+
|
|
|
+ Page<ProductOrderInfo> page = new Page<>();
|
|
|
+ page.setSize(MassageConstants.TWO_HUNDRED);
|
|
|
+
|
|
|
+ Page<ProductOrderInfo> resPage = productOrderInfoService.page(page, objectLambdaQueryWrapper);
|
|
|
+ if (CollectionUtil.isNotEmpty(resPage.getRecords())) {
|
|
|
+ resPage.getRecords().forEach(order -> {
|
|
|
+ ProductOrderInfo productOrderInfo = new ProductOrderInfo();
|
|
|
+ productOrderInfo.setId(order.getId());
|
|
|
+ productOrderInfo.setOrderStatus(ProductOrderStatusEnum.CANCELLED.getCode());
|
|
|
+ productOrderInfoService.updateById(productOrderInfo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return resPage.getTotal();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 超时未接单
|
|
|
+ */
|
|
|
+ public void timeoutNotOrder() {
|
|
|
Date nowDate = new Date();
|
|
|
log.info("开始执行超时未接单任务,{}", nowDate);
|
|
|
|