Commit 8b70a7be authored by zhangfeng's avatar zhangfeng

积分规则定时任务

parent d0ab099d
......@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.dal.redis.scoreRule.ScoreRuleRedisDao;
import cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum;
import cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
......@@ -15,7 +16,7 @@ import java.util.Date;
import java.util.List;
/**
* 会员积分过期定时任务
* 积分规则过期定时任务
*/
@Component
@Slf4j
......@@ -30,6 +31,8 @@ public class ScoreRuleExpireTask implements JobHandler {
@Resource
private ScoreRuleService scoreRuleService;
@Resource
private ScoreRuleRedisDao scoreRuleRedisDao;
@Override
public String execute(String param) throws Exception {
......@@ -42,8 +45,11 @@ public class ScoreRuleExpireTask implements JobHandler {
if (CollectionUtils.isEmpty(todoList)) {
return "success";
} else {
todoList.forEach(scoreRuleDO -> scoreRuleDO.setStatus(ScoreRuleStatusEnum.EXPIRED.getValue()));
scoreRuleService.updateBatch(todoList);
todoList.forEach(scoreRuleDO -> {
scoreRuleDO.setStatus(ScoreRuleStatusEnum.EXPIRED.getValue());
scoreRuleRedisDao.deleteEnableScoreRule(scoreRuleDO.getType());
scoreRuleService.updateById(scoreRuleDO);
});
}
return "success";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment