| | |
| | | |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.system.api.constant.DelayTaskEnum; |
| | | import com.ruoyi.system.api.service.RemoteConfigService; |
| | | import com.ruoyi.system.api.service.RemoteCouponService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.connection.Message; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | |
| | | |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | private RemoteConfigService remoteConfigService; |
| | | |
| | | private RemoteCouponService remoteCouponService; |
| | | |
| | | public RedisListener(RedisMessageListenerContainer listenerContainer, |
| | | RedisTemplate redisTemplate) { |
| | |
| | | if(expiredKey.contains("-")){ |
| | | String[] split = expiredKey.split("-"); |
| | | String operation=split[0]; |
| | | |
| | | if(DelayTaskEnum.COUPON_SEND_DELAY_TASK.getCode().equals(operation)){ |
| | | //自动关闭订单 |
| | | autoTimeSendCoupon(split[1]); |
| | | } |
| | | //删除失效的key |
| | | redisTemplate.delete(expiredKey); |
| | | } |
| | |
| | | } |
| | | |
| | | //延时任务表 |
| | | |
| | | |
| | | //自动定时发送优惠券 |
| | | private void autoTimeSendCoupon(String couponId){ |
| | | log.info("autoTimeSendCoupon scheduler task is running :" + couponId); |
| | | remoteCouponService.autoTimeSendCoupon(couponId); |
| | | //删除定时任务 |
| | | remoteConfigService.deleteDelayTask(DelayTaskEnum.COUPON_SEND_DELAY_TASK.getCode()+"-"+couponId); |
| | | } |
| | | |
| | | |
| | | } |