添加 开展活动接口

This commit is contained in:
2024-07-19 15:40:54 +08:00
parent aa1eb7411e
commit c46f65600f
7 changed files with 165 additions and 18 deletions

View File

@@ -1,11 +1,13 @@
package com.ai.da.common.task;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
@Slf4j
@@ -22,10 +24,37 @@ public class AccountTask {
accountService.refreshCreditsWeekly();
}
// todo 多久执行一次?
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void getPaidUser(){
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
accountService.extendValidityForCC();
}
// 每天凌晨0点执行一次
// @Scheduled(cron = "0 0 0 * * ?")
public void cancelActivityBenefits(){
// 1、查询当前所有参与了活动且过期的用户
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
// 2、将到期用户置为游客
for(Account account : accountList){
log.info("参与活动的用户到期,置为游客");
accountService.toVisitor(account);
}
}
// 每天检测正式用户到期情况每天凌晨0点执行
// @Scheduled(cron = "0 0 0 * * ?")
public void paidUserToVisitor(){
// 1、查询当前已过期正式用户或试用用户
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
accountList.addAll(accountService.getExpiredUserBySystemUser(2));
accountList.addAll(accountService.getExpiredUserBySystemUser(3));
// 2、将到期用户置为游客
for(Account account : accountList){
log.info("用户有效期到期,置为游客");
accountService.toVisitor(account);
}
}
}