2 Incheckningar eddf290e19 ... 43caad9993

Upphovsman SHA1 Meddelande Datum
  jinshihui 43caad9993 Merge remote-tracking branch 'origin/point_dev' into point_dev 15 timmar sedan
  jinshihui 2f5cbe8d72 开发了取消未支付的商品订单定时任务 15 timmar sedan

+ 9 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/enums/ProductOrderStatusEnum.java

@@ -50,6 +50,11 @@ public enum ProductOrderStatusEnum {
         this.info = info;
     }
 
+    /**
+     * 根据状态码获取描述
+     * @param code 状态码
+     * @return String描述信息
+     */
     public static String getDescByCode(Integer code) {
         if (code == null) {
             return StringUtils.EMPTY;
@@ -62,6 +67,10 @@ public enum ProductOrderStatusEnum {
         return StringUtils.EMPTY;
     }
 
+    /**
+     * 获取商品订单状态枚举列表
+     * @return List<EnumProject> 商品订单状态枚举列表
+     */
     public static List<EnumProject> getStatusEnum() {
         List<EnumProject> list = new ArrayList<>();
         for (ProductOrderStatusEnum value : ProductOrderStatusEnum.values()) {

+ 2 - 2
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/AfterSaleOrderServiceImpl.java

@@ -59,8 +59,8 @@ public class AfterSaleOrderServiceImpl extends ServiceImpl<AfterSaleOrderMapper,
         if (orderStatus == 11) {
             throw new ServiceException("已取消订单不支持售后");
         }
-        // 只允许 3(已收货)发起售后,如需支持2则加上
-        if (orderStatus != 3 || orderStatus != 2) {
+        // 只允许 2(待发货)或者3(已收货)发起售后
+        if (orderStatus != 2 && orderStatus != 3) {
             throw new ServiceException("当前订单状态不支持发起售后");
         }
 

+ 55 - 6
nightFragrance-massage/src/main/java/com/ylx/massage/task/massageTask.java

@@ -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);