|
|
|
@ -9,6 +9,7 @@ import com.luoo.user.dao.LotteryDao;
|
|
|
|
|
import com.luoo.user.dao.LotteryRegionDao;
|
|
|
|
|
import com.luoo.user.dao.LotteryUserDao;
|
|
|
|
|
import com.luoo.user.dao.UserInfoDao;
|
|
|
|
|
import com.luoo.user.dao.UserPointLogDao;
|
|
|
|
|
import com.luoo.user.dto.point.DrawDTO;
|
|
|
|
|
import com.luoo.user.dto.point.LotteryParticipatedSearchDto;
|
|
|
|
|
import com.luoo.user.dto.point.LotterySearchDto;
|
|
|
|
@ -29,6 +30,7 @@ import enums.UserBetaEnum;
|
|
|
|
|
import enums.UserTypeEnum;
|
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
|
import exception.BizException;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
@ -93,7 +95,10 @@ public class LotteryService {
|
|
|
|
|
|
|
|
|
|
private final UserPointLogService userPointLogService;
|
|
|
|
|
|
|
|
|
|
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService, UserPointLogService userPointLogService) {
|
|
|
|
|
private final UserPointLogDao userPointLogDao;
|
|
|
|
|
|
|
|
|
|
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService, UserPointLogService userPointLogService,
|
|
|
|
|
UserPointLogDao userPointLogDao) {
|
|
|
|
|
this.lotteryDao = lotteryDao;
|
|
|
|
|
this.jwtUtil = jwtUtil;
|
|
|
|
|
this.idWorker = idWorker;
|
|
|
|
@ -108,6 +113,7 @@ public class LotteryService {
|
|
|
|
|
this.envConfig = envConfig;
|
|
|
|
|
this.userinfoShippingAddressService = userinfoShippingAddressService;
|
|
|
|
|
this.userPointLogService = userPointLogService;
|
|
|
|
|
this.userPointLogDao = userPointLogDao;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -920,4 +926,27 @@ public class LotteryService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void recalculate() {
|
|
|
|
|
List<String> allUserId = userPointLogDao.findAllUserId();
|
|
|
|
|
allUserId.forEach(userId -> {
|
|
|
|
|
log.info("用户:{},积分重算开始", userId);
|
|
|
|
|
// 查询userId对应所有的积分记录
|
|
|
|
|
List<UserPointLog> userPointLogList = userPointLogDao.findUserPointLogByUserId(userId);
|
|
|
|
|
AtomicReference<Integer> totalScore = new AtomicReference<>(0);
|
|
|
|
|
userPointLogList.forEach(userPointLog -> {
|
|
|
|
|
if (userPointLog.getType().equals(PointEnums.TASK_POINT_TYPE_ADD.getCode())) {
|
|
|
|
|
totalScore.updateAndGet(v -> v + userPointLog.getScore());
|
|
|
|
|
} else {
|
|
|
|
|
totalScore.updateAndGet(v -> v - userPointLog.getScore());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userId).orElse(null);
|
|
|
|
|
assert userInfo != null;
|
|
|
|
|
userInfo.setPoint(totalScore.get());
|
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|