用户等级-定时任务-每日更新

This commit is contained in:
khalil
2025-06-09 16:09:03 +08:00
parent 13317737dc
commit db9340ebd8
4 changed files with 54 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
package com.accompany.scheduler.task;
import com.accompany.business.mybatismapper.DiamondGiveHistoryMapper;
import com.accompany.payment.service.UserRechargeLevelService;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
@Component
public class UserRechargeLevelTask {
@Autowired
private UserRechargeLevelService service;
@Autowired
private DiamondGiveHistoryMapper diamondGiveHistoryMapper;
@Resource(name = "bizExecutor")
private ThreadPoolExecutor bizExecutor;
@Scheduled(cron = "1 0 0 * * ?")
public void updateUserRechargeLevel(){
List<Long> uidList = service.getBaseMapper().listUpdateUid();
if (CollectionUtils.isEmpty(uidList)){
return;
}
List<List<Long>> uidListList = Lists.partition(uidList, 500);
for (List<Long> uidListPartition : uidListList){
bizExecutor.execute(() -> {
for (Long uid : uidListPartition){
BigDecimal totalReceiveGoldNum = diamondGiveHistoryMapper.getUserTotalReceiveGold(uid);
BigDecimal last60TotalReceiveGoldNum = diamondGiveHistoryMapper.getUserLast60TotalReceiveGold(uid);
service.statistics(uid, totalReceiveGoldNum, last60TotalReceiveGoldNum);
}
});
}
}
}