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