套餐推广订单取消定时任务
This commit is contained in:
@@ -7,7 +7,6 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* market服务 任务总调度
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Component
|
||||
public class AAMarketTasks {
|
||||
@@ -74,5 +73,16 @@ public class AAMarketTasks {
|
||||
smsShopMoneyTask.task();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private PpPackageTask ppPackageTask;
|
||||
|
||||
/**
|
||||
* 套餐推广订单 过期
|
||||
* 每两小时 触发一次
|
||||
*/
|
||||
@Scheduled(cron = "0 24 0/2 * * ?")
|
||||
public void ppOrderExpire() {
|
||||
ppPackageTask.ppOrderExpire();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.czg.task;
|
||||
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.PpPackageConstants;
|
||||
import com.czg.market.entity.PpPackageOrder;
|
||||
import com.czg.market.service.PpPackageOrderService;
|
||||
import com.czg.order.entity.GbOrder;
|
||||
import com.czg.service.RedisService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 套餐推广定时任务
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/19 10:05
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PpPackageTask {
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Resource
|
||||
private PpPackageOrderService ppPackageOrderService;
|
||||
|
||||
/**
|
||||
* 订单 过期
|
||||
* 每两小时 触发一次
|
||||
*/
|
||||
public void ppOrderExpire() {
|
||||
// 当前系统时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 过期时间下限:当前时间往前推4小时(只查最近4小时内过期的)
|
||||
LocalDateTime expire4HoursAgo = now.minusHours(4);
|
||||
List<PpPackageOrder> expiredOrderList = ppPackageOrderService.list(QueryWrapper.create()
|
||||
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
|
||||
.le(PpPackageOrder::getExpireTime, now)
|
||||
.ge(PpPackageOrder::getExpireTime, expire4HoursAgo));
|
||||
|
||||
// 处理已过期订单
|
||||
for (PpPackageOrder expiredOrder : expiredOrderList) {
|
||||
//退款
|
||||
ppPackageOrderService.expiredOrder(expiredOrder.getId());
|
||||
}
|
||||
|
||||
//查询【当前时间往后2小时内】将要过期的订单
|
||||
LocalDateTime willExpire2HoursLater = now.plusHours(2);
|
||||
List<PpPackageOrder> willExpireOrderList = ppPackageOrderService.list(QueryWrapper.create()
|
||||
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
|
||||
.ge(PpPackageOrder::getExpireTime, now)
|
||||
.le(PpPackageOrder::getExpireTime, willExpire2HoursLater));
|
||||
// 处理将要过期订单(如推送提醒、催参团等)
|
||||
for (PpPackageOrder willExpireOrder : willExpireOrderList) {
|
||||
LocalDateTime endTime = willExpireOrder.getExpireTime();
|
||||
Duration duration = Duration.between(now, endTime);
|
||||
long seconds = duration.getSeconds();
|
||||
redisService.set(RedisCst.classKeyExpired.EXPIRED_PP_ORDER + willExpireOrder.getId(), willExpireOrder.getId(), seconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.czg.account.service.ShopTableService;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.service.AcPushEventService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.PpPackageOrderService;
|
||||
import com.czg.market.service.SmsPushEventService;
|
||||
import com.czg.order.service.GbOrderService;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
@@ -43,6 +44,8 @@ public class RedisKeyExpirationListener implements MessageListener {
|
||||
private AcPushEventService acPushEventService;
|
||||
@Resource
|
||||
private GbOrderService gbOrderService;
|
||||
@DubboReference
|
||||
private PpPackageOrderService ppPackageOrderService;
|
||||
|
||||
|
||||
//redis key失效监听
|
||||
@@ -79,6 +82,10 @@ public class RedisKeyExpirationListener implements MessageListener {
|
||||
log.info("监听到拼团任务过期,gb_order任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_GB_ORDER.length());
|
||||
gbOrderService.expireRefund(Long.parseLong(eventId), null);
|
||||
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_PP_ORDER)) {
|
||||
log.info("监听到套餐推广任务过期,pp_order任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_PP_ORDER.length());
|
||||
ppPackageOrderService.expiredOrder(Long.parseLong(eventId));
|
||||
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_SMS)) {
|
||||
log.info("监听到短信定时发放优惠券,sms_push_event任务Id: {}", expiredKey);
|
||||
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_SMS.length());
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PpOrderController {
|
||||
//退钱
|
||||
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REPP);
|
||||
payService.unifyRefund(detail.getShopId(), detail.getId(), detail.getPayOrderId(), refPayOrderNo,
|
||||
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "拼团退款" : detail.getRefundReason(), detail.getFinalPrice());
|
||||
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "套餐推广退款" : detail.getRefundReason(), detail.getFinalPrice());
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
@@ -70,6 +70,7 @@ public class PpOrderController {
|
||||
|
||||
/**
|
||||
* 套餐推广-核销
|
||||
* 参数: {"verifyCode": "123456"}
|
||||
*/
|
||||
@PostMapping("checkout")
|
||||
@OperationLog("套餐推广-核销")
|
||||
|
||||
@@ -109,7 +109,11 @@ public class OTimeTask {
|
||||
@Scheduled(cron = "0 50 23 * * ? ")
|
||||
public void refundCompensate() {
|
||||
//积分 和 拼团
|
||||
List<String> ware = List.of(PayTypeConstants.SourceType.WARE, PayTypeConstants.SourceType.POINT);
|
||||
List<String> ware = List.of(
|
||||
PayTypeConstants.SourceType.WARE,
|
||||
PayTypeConstants.SourceType.POINT,
|
||||
PayTypeConstants.SourceType.PP
|
||||
);
|
||||
|
||||
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
|
||||
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
|
||||
|
||||
Reference in New Issue
Block a user