会员功能
This commit is contained in:
parent
b1ff08d49b
commit
173c77762c
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.task.vip;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import com.ruoyi.ss.vipLevel.domain.enums.VipLevelLimitType;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class VipTask {
|
||||
|
||||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
/**
|
||||
* 每天执行一次,刷新今天需要刷新的VIP周期计数
|
||||
*/
|
||||
public void resetVipRoundCount() {
|
||||
|
||||
// 查询今天需要刷新的VIP周期计数
|
||||
VipQuery query = new VipQuery();
|
||||
query.setNextResetDate(LocalDate.now());
|
||||
query.setLimitTypes(VipLevelLimitType.needReset());
|
||||
query.setInValid(true);
|
||||
List<VipVO> vipList = vipService.selectVipList(query);
|
||||
|
||||
if (CollectionUtils.isEmpty(vipList)) {
|
||||
log.info("今天没有需要刷新的VIP周期计数");
|
||||
return;
|
||||
}
|
||||
|
||||
// 清除今天需要刷新的VIP周期计数
|
||||
for (VipVO vip : vipList) {
|
||||
try {
|
||||
int result = vipService.resetVipRoundCount(vip);
|
||||
ServiceUtil.assertion(result != 1, "刷新VIP周期计数失败,VIPID:{}", vip.getId());
|
||||
} catch (Exception e) {
|
||||
log.error("刷新VIP周期计数失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user