|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.luoo.user.service;
|
|
|
|
package com.luoo.user.service;
|
|
|
|
|
|
|
|
|
|
|
|
import api.PageResult;
|
|
|
|
import api.PageResult;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.luoo.user.dao.LotteryUserDao;
|
|
|
|
import com.luoo.user.dao.LotteryUserDao;
|
|
|
|
import com.luoo.user.dao.TaskPointDao;
|
|
|
|
import com.luoo.user.dao.TaskPointDao;
|
|
|
@ -185,12 +186,15 @@ public class UserPointLogService {
|
|
|
|
|
|
|
|
|
|
|
|
if (taskPointId != null) {
|
|
|
|
if (taskPointId != null) {
|
|
|
|
TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId);
|
|
|
|
TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId);
|
|
|
|
if (taskPoint == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果不存在于数据库,就是后台控制的积分,如取消抽奖的返还的积分
|
|
|
|
|
|
|
|
// 积分
|
|
|
|
|
|
|
|
Integer score = taskPoint == null ? userPointLog.getScore() : taskPoint.getScore();
|
|
|
|
// 获取积分任务类型
|
|
|
|
// 获取积分任务类型
|
|
|
|
Integer type = taskPoint.getType();
|
|
|
|
Integer type = taskPoint == null ? userPointLog.getType() : taskPoint.getType();
|
|
|
|
|
|
|
|
// 描述
|
|
|
|
|
|
|
|
String description = taskPoint == null ? userPointLog.getDescription() : taskPoint.getDescription();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 对于新手任务,只允许完成一次,如果用户已经完成过,则直接返回,不重复添加积分
|
|
|
|
// 对于新手任务,只允许完成一次,如果用户已经完成过,则直接返回,不重复添加积分
|
|
|
|
if (Objects.equals(type, PointEnums.TASK_TYPE_NEW.getCode())) {
|
|
|
|
if (Objects.equals(type, PointEnums.TASK_TYPE_NEW.getCode())) {
|
|
|
@ -201,21 +205,23 @@ public class UserPointLogService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
userPointLog.setScore(taskPoint.getScore());
|
|
|
|
userPointLog.setScore(score);
|
|
|
|
userPointLog.setDescription(taskPoint.getDescription());
|
|
|
|
userPointLog.setDescription(description);
|
|
|
|
|
|
|
|
|
|
|
|
// 保存用户积分记录
|
|
|
|
// 保存用户积分记录
|
|
|
|
userPointLogDao.save(userPointLog);
|
|
|
|
userPointLogDao.save(userPointLog);
|
|
|
|
log.info("用户 {} 添加积分记录 {} 成功", userPointLog.getUserId(), userPointLog.getId());
|
|
|
|
log.info("用户 {} 添加积分记录 {} 成功", userPointLog.getUserId(), userPointLog.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果id不存在,按传入的增加积分,如取消抽奖返还用户积分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新用户积分,获取用户信息并累加积分得分
|
|
|
|
// 更新用户积分,获取用户信息并累加积分得分
|
|
|
|
// 对用户进行积分计算
|
|
|
|
// 对用户进行积分计算
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userPointLog.getUserId()).get();
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userPointLog.getUserId()).get();
|
|
|
|
Integer point = userInfo.getPoint() == null ? 0 : userInfo.getPoint();
|
|
|
|
Integer point = 0;
|
|
|
|
|
|
|
|
if (ObjectUtil.equals(PointEnums.TASK_POINT_TYPE_ADD.getCode(), userPointLog.getType())) {
|
|
|
|
|
|
|
|
point += userInfo.getPoint() == null ? 0 : userInfo.getPoint();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
point -= userInfo.getPoint() == null ? 0 : userInfo.getPoint();
|
|
|
|
|
|
|
|
}
|
|
|
|
point += userPointLog.getScore();
|
|
|
|
point += userPointLog.getScore();
|
|
|
|
userInfo.setPoint(point);
|
|
|
|
userInfo.setPoint(point);
|
|
|
|
// 更新用户积分信息
|
|
|
|
// 更新用户积分信息
|
|
|
|