|
|
|
@ -204,30 +204,22 @@ public class UserPointLogService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void executeDraw(DrawDTO drawDTO) {
|
|
|
|
|
|
|
|
|
|
String taskPointId = drawDTO.getTaskPointId();
|
|
|
|
|
if (taskPointId != null) {
|
|
|
|
|
TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId);
|
|
|
|
|
if(taskPoint == null) {
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调整用户积分
|
|
|
|
|
UserInfo userInfo = userInfoDao.findById(drawDTO.getUserId()).get();
|
|
|
|
|
int point = userInfo.getPoint() == null ? 0 : userInfo.getPoint();
|
|
|
|
|
if(point < taskPoint.getScore()) {
|
|
|
|
|
if(point < drawDTO.getScore()) {
|
|
|
|
|
throw new BizException(ErrorConstants.POINT_NOT_ENOUGH);
|
|
|
|
|
}
|
|
|
|
|
userInfo.setPoint(point - taskPoint.getScore());
|
|
|
|
|
userInfo.setPoint(point - drawDTO.getScore());
|
|
|
|
|
userInfoDao.save(userInfo);
|
|
|
|
|
|
|
|
|
|
UserPointLog userPointLog = UserPointLog.builder()
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
.type(PointEnums.TASK_POINT_TYPE_REDUCE.getCode())
|
|
|
|
|
.createUser(drawDTO.getUserId())
|
|
|
|
|
.taskPointId(null)
|
|
|
|
|
.description(LOTTERY_POINTS_TYPE)
|
|
|
|
|
.userId(drawDTO.getUserId())
|
|
|
|
|
.score(point)
|
|
|
|
|
.score(drawDTO.getScore())
|
|
|
|
|
.build();
|
|
|
|
|
userPointLogDao.save(userPointLog);
|
|
|
|
|
|
|
|
|
@ -244,7 +236,6 @@ public class UserPointLogService {
|
|
|
|
|
|
|
|
|
|
lotteryUserDao.save(lotteryUser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 每日签到
|
|
|
|
|