券 失效定时任务 领取列表 头像 名称

This commit is contained in:
2025-09-26 11:31:15 +08:00
parent 60bcef1e9b
commit e18dbe51d6
4 changed files with 92 additions and 9 deletions

View File

@@ -1,7 +1,10 @@
package com.czg.config;
import com.czg.account.service.ShopTableService;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.order.service.OrderInfoService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
@@ -29,6 +32,8 @@ public class RedisKeyExpirationListener implements MessageListener {
private OrderInfoService orderInfoService;
@DubboReference
private ShopTableService tableService;
@Resource
private MkShopCouponRecordService mkShopCouponRecordService;
//redis key失效监听
@@ -50,10 +55,17 @@ public class RedisKeyExpirationListener implements MessageListener {
log.info("监听到订单过期,订单Id: {}", expiredKey);
String orderId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_ORDER.length());
orderInfoService.expired(Long.parseLong(orderId));
}else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_TABLE)) {
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_TABLE)) {
log.info("监听到台桌清台过期,台桌Id: {}", expiredKey);
String tableId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_TABLE.length());
tableService.expiredTable(Long.parseLong(tableId));
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_COUPON)) {
log.info("监听到优惠券过期,优惠券Id: {}", expiredKey);
String couponId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_COUPON.length());
mkShopCouponRecordService.update(MkShopCouponRecord.builder().status(2).build(), new QueryWrapper()
.eq(MkShopCouponRecord::getStatus, 0)
.eq(MkShopCouponRecord::getId, Long.parseLong(couponId))
);
}
}
}