|
@@ -116,7 +116,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
|
|
|
|
|
PointActivity pointActivity = this.pointActivityMapper.selectPointActivityById(id);
|
|
PointActivity pointActivity = this.pointActivityMapper.selectPointActivityById(id);
|
|
|
if (ObjectUtil.isNull(pointActivity)) {
|
|
if (ObjectUtil.isNull(pointActivity)) {
|
|
|
- throw new BaseException("参数有误,活动不存在");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("参数有误,活动不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Integer activityType = pointActivity.getActivityType();
|
|
Integer activityType = pointActivity.getActivityType();
|
|
@@ -157,18 +157,18 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
// 校验参数
|
|
// 校验参数
|
|
|
Long id = dto.getId();
|
|
Long id = dto.getId();
|
|
|
if (ObjectUtil.isNull(id)) {
|
|
if (ObjectUtil.isNull(id)) {
|
|
|
- throw new BaseException("活动主键id不能为空");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("活动主键id不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 根据id获取活动详情
|
|
// 根据id获取活动详情
|
|
|
PointActivity entity = this.pointActivityMapper.selectPointActivityById(id);
|
|
PointActivity entity = this.pointActivityMapper.selectPointActivityById(id);
|
|
|
if (ObjectUtil.isNull(entity)) {
|
|
if (ObjectUtil.isNull(entity)) {
|
|
|
- throw new BaseException("参数有误,活动不存在");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("参数有误,活动不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 校验活动状态
|
|
// 校验活动状态
|
|
|
if (PointActivityStatusEnum.IN_PROGRESS.getCode().equals(entity.getStatus())) {
|
|
if (PointActivityStatusEnum.IN_PROGRESS.getCode().equals(entity.getStatus())) {
|
|
|
- throw new BaseException("活动进行中,不可编辑");
|
|
|
|
|
|
|
+ throw new ServiceException("活动进行中,不可编辑");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
updateActivity(entity, dto);
|
|
updateActivity(entity, dto);
|
|
@@ -184,7 +184,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
// 根据id获取活动详情
|
|
// 根据id获取活动详情
|
|
|
PointActivity entity = this.pointActivityMapper.selectPointActivityById(id);
|
|
PointActivity entity = this.pointActivityMapper.selectPointActivityById(id);
|
|
|
if (ObjectUtil.isNull(entity)) {
|
|
if (ObjectUtil.isNull(entity)) {
|
|
|
- throw new BaseException("参数有误,活动不存在");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("参数有误,活动不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PointActivityStatVo vo = new PointActivityStatVo();
|
|
PointActivityStatVo vo = new PointActivityStatVo();
|
|
@@ -220,7 +220,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
boolean hasOngoingActivity = activityList.stream()
|
|
boolean hasOngoingActivity = activityList.stream()
|
|
|
.anyMatch(activity -> PointActivityStatusEnum.IN_PROGRESS.getCode().equals(activity.getStatus()));
|
|
.anyMatch(activity -> PointActivityStatusEnum.IN_PROGRESS.getCode().equals(activity.getStatus()));
|
|
|
if (hasOngoingActivity) {
|
|
if (hasOngoingActivity) {
|
|
|
- throw new BaseException("存在进行中的活动,无法修改有效期");
|
|
|
|
|
|
|
+ throw new ServiceException("存在进行中的活动,无法修改有效期");
|
|
|
}
|
|
}
|
|
|
// 更新积分活动过期策略表
|
|
// 更新积分活动过期策略表
|
|
|
this.saveOrUpdatePointActivityExpirePolicy(expirePolicy, dto);
|
|
this.saveOrUpdatePointActivityExpirePolicy(expirePolicy, dto);
|
|
@@ -251,7 +251,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
return result;
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("查询积分活动有效期详情失败", e);
|
|
log.error("查询积分活动有效期详情失败", e);
|
|
|
- throw new BaseException("查询积分活动有效期详情失败");
|
|
|
|
|
|
|
+ throw new ServiceException("查询积分活动有效期详情失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -264,10 +264,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
public Page<UserPointActivityVo> getUserPointActivityList(Page<PointActivity> page, UserPointActivityPageDTO dto) {
|
|
public Page<UserPointActivityVo> getUserPointActivityList(Page<PointActivity> page, UserPointActivityPageDTO dto) {
|
|
|
|
|
|
|
|
// 当前登录用户信息
|
|
// 当前登录用户信息
|
|
|
- WxLoginUser wxLoginUser = SecurityUtils.getWxLoginUser();
|
|
|
|
|
- if (ObjectUtil.isNull(wxLoginUser)) {
|
|
|
|
|
- throw new RuntimeException("用户不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ WxLoginUser wxLoginUser = getCurrentWxLoginUser();
|
|
|
String openId = wxLoginUser.getCOpenid();
|
|
String openId = wxLoginUser.getCOpenid();
|
|
|
dto.setOpenId(openId);
|
|
dto.setOpenId(openId);
|
|
|
return pointActivityMapper.selectTaskWithProgress(page, dto);
|
|
return pointActivityMapper.selectTaskWithProgress(page, dto);
|
|
@@ -277,10 +274,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
public List<UserPointActivityVo> activityList() {
|
|
public List<UserPointActivityVo> activityList() {
|
|
|
|
|
|
|
|
// 当前登录用户信息
|
|
// 当前登录用户信息
|
|
|
- WxLoginUser wxLoginUser = SecurityUtils.getWxLoginUser();
|
|
|
|
|
- if (ObjectUtil.isNull(wxLoginUser)) {
|
|
|
|
|
- throw new RuntimeException("用户不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ WxLoginUser wxLoginUser = getCurrentWxLoginUser();
|
|
|
String openId = wxLoginUser.getCOpenid();
|
|
String openId = wxLoginUser.getCOpenid();
|
|
|
|
|
|
|
|
List<UserPointActivityVo> resultList = new ArrayList<>();
|
|
List<UserPointActivityVo> resultList = new ArrayList<>();
|
|
@@ -322,11 +316,9 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<SignDayVo> getSignInfo(SignDTO dto) {
|
|
public List<SignDayVo> getSignInfo(SignDTO dto) {
|
|
|
- // ... (前面获取用户、任务、奖励配置的代码保持不变) ...
|
|
|
|
|
|
|
|
|
|
- // 1. 获取用户信息 & 任务 & 奖励列表
|
|
|
|
|
- WxLoginUser wxLoginUser = SecurityUtils.getWxLoginUser();
|
|
|
|
|
- if (ObjectUtil.isNull(wxLoginUser)) throw new ServiceException("用户不存在");
|
|
|
|
|
|
|
+ // 当前登录用户信息
|
|
|
|
|
+ WxLoginUser wxLoginUser = getCurrentWxLoginUser();
|
|
|
String openId = wxLoginUser.getCOpenid();
|
|
String openId = wxLoginUser.getCOpenid();
|
|
|
|
|
|
|
|
PointSignTask task = getEnabledTask(dto.getCityCode());
|
|
PointSignTask task = getEnabledTask(dto.getCityCode());
|
|
@@ -355,9 +347,8 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
|
|
|
|
|
// 定义“过期”判定阈值:例如,超过 7 天未签视为过期
|
|
// 定义“过期”判定阈值:例如,超过 7 天未签视为过期
|
|
|
// 注意:这里的逻辑是,如果是“本周”的视图,通常只有“断签”和“未签”。
|
|
// 注意:这里的逻辑是,如果是“本周”的视图,通常只有“断签”和“未签”。
|
|
|
- // 但如果你的业务是“补签卡”界面,或者需要展示历史状态,这个逻辑才有意义。
|
|
|
|
|
- // 这里演示:如果漏签日期距离今天超过 7 天,标记为 4。
|
|
|
|
|
- int expireThresholdDays = 7;
|
|
|
|
|
|
|
+ // 如果漏签日期距离今天超过 2 天,标记为 4。
|
|
|
|
|
+ int expireThresholdDays = 1;
|
|
|
|
|
|
|
|
List<SignDayVo> voList = new ArrayList<>();
|
|
List<SignDayVo> voList = new ArrayList<>();
|
|
|
|
|
|
|
@@ -369,7 +360,6 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
vo.setDate(date);
|
|
vo.setDate(date);
|
|
|
|
|
|
|
|
boolean isToday = date.equals(today);
|
|
boolean isToday = date.equals(today);
|
|
|
- boolean isPast = date.isBefore(today);
|
|
|
|
|
|
|
|
|
|
// 查询该天是否已签 (建议优化为批量查询)
|
|
// 查询该天是否已签 (建议优化为批量查询)
|
|
|
boolean actuallySigned = false;
|
|
boolean actuallySigned = false;
|
|
@@ -415,129 +405,89 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void sign(SignDTO dto) {
|
|
public void sign(SignDTO dto) {
|
|
|
- // 1. 获取用户信息
|
|
|
|
|
- WxLoginUser wxLoginUser = SecurityUtils.getWxLoginUser();
|
|
|
|
|
- if (ObjectUtil.isNull(wxLoginUser)) {
|
|
|
|
|
- throw new RuntimeException("用户未登录");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 1. 用户登录校验
|
|
|
|
|
+ WxLoginUser wxLoginUser = getCurrentWxLoginUser();
|
|
|
String openId = wxLoginUser.getCOpenid();
|
|
String openId = wxLoginUser.getCOpenid();
|
|
|
|
|
|
|
|
- // 2. 获取当前城市有效的签到任务配置
|
|
|
|
|
- // 建议:这里应该加缓存,避免每次签到都查库
|
|
|
|
|
|
|
+ // 2. 获取有效签到任务
|
|
|
PointSignTask task = getEnabledTask(dto.getCityCode());
|
|
PointSignTask task = getEnabledTask(dto.getCityCode());
|
|
|
if (ObjectUtil.isNull(task)) {
|
|
if (ObjectUtil.isNull(task)) {
|
|
|
- throw new RuntimeException("当前城市暂无签到活动");
|
|
|
|
|
|
|
+ throw new ServiceException("当前城市暂无签到活动");
|
|
|
}
|
|
}
|
|
|
Long activityId = task.getActivityId();
|
|
Long activityId = task.getActivityId();
|
|
|
Long taskId = task.getId();
|
|
Long taskId = task.getId();
|
|
|
String activityName = task.getActivityName();
|
|
String activityName = task.getActivityName();
|
|
|
|
|
+ Integer taskType = PointActivityTypeEnum.SIGN_TASK.getCode();
|
|
|
|
|
|
|
|
- // 3. 防重复签到 (利用数据库唯一索引兜底,这里做快速失败)
|
|
|
|
|
- // 优化:直接查库比 count 快,且逻辑更清晰
|
|
|
|
|
- PointUserSignLog todayLog = pointUserSignLogService.getOne(new LambdaQueryWrapper<PointUserSignLog>()
|
|
|
|
|
- .eq(PointUserSignLog::getOpenId, openId)
|
|
|
|
|
- .eq(PointUserSignLog::getTaskId, taskId)
|
|
|
|
|
- .eq(PointUserSignLog::getSignDate, DateUtils.getNowDate()) // 假设日志表有 sign_date 字段,如果没有用 create_time 转 date
|
|
|
|
|
- .last("LIMIT 1"));
|
|
|
|
|
-
|
|
|
|
|
- if (ObjectUtil.isNotNull(todayLog)) {
|
|
|
|
|
- throw new RuntimeException("今日已签到");
|
|
|
|
|
|
|
+ // ======================== 核心:统一使用任务完成表防重 ========================
|
|
|
|
|
+ boolean todaySigned = pointUserActivityTaskCompletionService.isTodayCompleted(openId, activityId, taskId, taskType);
|
|
|
|
|
+ if (todaySigned) {
|
|
|
|
|
+ throw new ServiceException("今日已签到");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 4. 获取并锁定用户签到状态 (悲观锁)
|
|
|
|
|
- // 注意:selectByOpenIdAndActivityIdForUpdate 必须使用 FOR UPDATE 语法
|
|
|
|
|
|
|
+ // 3. 悲观锁获取用户签到状态(并发安全)
|
|
|
PointUserSignStatus status = pointUserSignStatusService.selectByOpenIdAndActivityIdForUpdate(openId, activityId);
|
|
PointUserSignStatus status = pointUserSignStatusService.selectByOpenIdAndActivityIdForUpdate(openId, activityId);
|
|
|
-
|
|
|
|
|
- // 检查今天是否已经签到
|
|
|
|
|
- // 逻辑:如果是老用户(status不为空) 且 最后签到日期是今天
|
|
|
|
|
- boolean isSignedToday = false;
|
|
|
|
|
-
|
|
|
|
|
- if (ObjectUtil.isNotNull(status)) {
|
|
|
|
|
- Date lastSignDate = status.getLastSignDate();
|
|
|
|
|
- // 比较日期是否相同 (忽略时分秒)
|
|
|
|
|
- if (DateUtil.isSameDay(lastSignDate, new Date())) {
|
|
|
|
|
- isSignedToday = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 如果今天已签,直接抛出异常
|
|
|
|
|
- if (isSignedToday) {
|
|
|
|
|
- // 这里可以定义一个自定义异常,或者使用通用的业务异常
|
|
|
|
|
- throw new ServiceException("今日已签到,请勿重复操作");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- int newContinuousDays = 1;
|
|
|
|
|
- DateTime today = DateUtil.date();
|
|
|
|
|
- DateTime yesterday = DateUtil.yesterday();
|
|
|
|
|
|
|
+ Date todayDate = DateUtil.date();
|
|
|
|
|
+ Date yesterdayDate = DateUtil.yesterday();
|
|
|
|
|
+ int newContinuousDays;
|
|
|
|
|
|
|
|
if (ObjectUtil.isNull(status)) {
|
|
if (ObjectUtil.isNull(status)) {
|
|
|
- // --- 首次签到 ---
|
|
|
|
|
|
|
+ // 首次签到
|
|
|
|
|
+ newContinuousDays = 1;
|
|
|
status = new PointUserSignStatus();
|
|
status = new PointUserSignStatus();
|
|
|
status.setOpenId(openId);
|
|
status.setOpenId(openId);
|
|
|
status.setActivityId(activityId);
|
|
status.setActivityId(activityId);
|
|
|
- status.setLastSignDate(today);
|
|
|
|
|
- status.setCurrentContinuousDays(1);
|
|
|
|
|
|
|
+ status.setLastSignDate(todayDate);
|
|
|
|
|
+ status.setCurrentContinuousDays(newContinuousDays);
|
|
|
status.setLastRewardCycleDays(0);
|
|
status.setLastRewardCycleDays(0);
|
|
|
pointUserSignStatusService.save(status);
|
|
pointUserSignStatusService.save(status);
|
|
|
} else {
|
|
} else {
|
|
|
- // --- 非首次签到:计算连续天数 ---
|
|
|
|
|
- Date lastSignDate = status.getLastSignDate();
|
|
|
|
|
-
|
|
|
|
|
- // 判断是否断签:昨天不是最后签到日期,即为断签
|
|
|
|
|
- boolean isBreak = !DateUtil.isSameDay(lastSignDate, yesterday);
|
|
|
|
|
-
|
|
|
|
|
- if (isBreak) {
|
|
|
|
|
- if (task.getBreakRule() == 0) {
|
|
|
|
|
- // 规则0:断签重置
|
|
|
|
|
- newContinuousDays = 1;
|
|
|
|
|
- } else {
|
|
|
|
|
- // 规则1:断签保留进度 (这里逻辑通常是 +1,除非你想做补签逻辑)
|
|
|
|
|
- newContinuousDays = status.getCurrentContinuousDays() + 1;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 正常连续
|
|
|
|
|
|
|
+ // 计算连续天数(修复断签逻辑)
|
|
|
|
|
+ boolean isContinue = DateUtil.isSameDay(status.getLastSignDate(), yesterdayDate);
|
|
|
|
|
+ if (isContinue) {
|
|
|
newContinuousDays = status.getCurrentContinuousDays() + 1;
|
|
newContinuousDays = status.getCurrentContinuousDays() + 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 断签规则:0重置 1保留
|
|
|
|
|
+ newContinuousDays = task.getBreakRule() == 0 ? 1 : status.getCurrentContinuousDays();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 更新状态
|
|
|
|
|
- status.setLastSignDate(today);
|
|
|
|
|
|
|
+ status.setLastSignDate(todayDate);
|
|
|
status.setCurrentContinuousDays(newContinuousDays);
|
|
status.setCurrentContinuousDays(newContinuousDays);
|
|
|
pointUserSignStatusService.updateById(status);
|
|
pointUserSignStatusService.updateById(status);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 5. 计算奖励积分
|
|
|
|
|
- // 优化:匹配 <= 当前天数的最大奖励配置 (例如配置了3天、7天,第5天应该拿3天的奖,或者拿基础奖)
|
|
|
|
|
- int rewardPoints = task.getBasePoints(); // 默认基础积分
|
|
|
|
|
|
|
+ // 4. 计算奖励积分
|
|
|
|
|
+ int rewardPoints = task.getBasePoints();
|
|
|
PointSignReward reward = pointSignRewardService.getOne(new LambdaQueryWrapper<PointSignReward>()
|
|
PointSignReward reward = pointSignRewardService.getOne(new LambdaQueryWrapper<PointSignReward>()
|
|
|
.eq(PointSignReward::getSignTaskId, taskId)
|
|
.eq(PointSignReward::getSignTaskId, taskId)
|
|
|
- .le(PointSignReward::getContinueDays, newContinuousDays) // 小于等于当前天数
|
|
|
|
|
|
|
+ .le(PointSignReward::getContinueDays, newContinuousDays)
|
|
|
.orderByDesc(PointSignReward::getContinueDays)
|
|
.orderByDesc(PointSignReward::getContinueDays)
|
|
|
.last("LIMIT 1"));
|
|
.last("LIMIT 1"));
|
|
|
-
|
|
|
|
|
- if (ObjectUtil.isNotNull(reward)) {
|
|
|
|
|
|
|
+ if (reward != null) {
|
|
|
rewardPoints = reward.getRewardPoints();
|
|
rewardPoints = reward.getRewardPoints();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 6. 写入签到流水日志
|
|
|
|
|
|
|
+ // 5. 写入签到流水
|
|
|
PointUserSignLog signLog = new PointUserSignLog();
|
|
PointUserSignLog signLog = new PointUserSignLog();
|
|
|
signLog.setOpenId(openId);
|
|
signLog.setOpenId(openId);
|
|
|
signLog.setActivityId(activityId);
|
|
signLog.setActivityId(activityId);
|
|
|
signLog.setTaskId(taskId);
|
|
signLog.setTaskId(taskId);
|
|
|
- signLog.setSignDate(today); // 需确保数据库字段支持 Date 类型
|
|
|
|
|
|
|
+ signLog.setSignDate(todayDate);
|
|
|
signLog.setContinuousDays(newContinuousDays);
|
|
signLog.setContinuousDays(newContinuousDays);
|
|
|
signLog.setPoints(rewardPoints);
|
|
signLog.setPoints(rewardPoints);
|
|
|
signLog.setIsMakeUp(0);
|
|
signLog.setIsMakeUp(0);
|
|
|
pointUserSignLogService.save(signLog);
|
|
pointUserSignLogService.save(signLog);
|
|
|
|
|
|
|
|
- // 7. 增加用户积分账户余额
|
|
|
|
|
- // 注意:这里假设 pointAccountService 内部会写入 point_user_log (积分总流水表)
|
|
|
|
|
|
|
+ // ======================== 统一记录任务完成(必须放在这里,事务内) ========================
|
|
|
|
|
+ pointUserActivityTaskCompletionService.completeTask(openId, activityId, taskId, taskType);
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 发放积分
|
|
|
try {
|
|
try {
|
|
|
- pointAccountService.addPoints(openId, rewardPoints, activityName, null, activityId, taskId, PointActivityTypeEnum.SIGN_TASK.getCode());
|
|
|
|
|
|
|
+ pointAccountService.addPoints(openId, rewardPoints, activityName, null, activityId, taskId, taskType);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("签到发放积分失败", e);
|
|
|
|
|
- throw new RuntimeException("签到成功,但积分发放失败,请联系客服");
|
|
|
|
|
|
|
+ log.error("签到发放积分异常 openid:{}", openId, e);
|
|
|
|
|
+ throw new ServiceException("签到成功,但积分发放失败,请联系客服");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -593,13 +543,13 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
|
|
|
|
|
private void validateActivityDTO(PointActivityDTO dto) {
|
|
private void validateActivityDTO(PointActivityDTO dto) {
|
|
|
if (ObjectUtil.isNull(dto)) {
|
|
if (ObjectUtil.isNull(dto)) {
|
|
|
- throw new BaseException("活动信息不能为空");
|
|
|
|
|
|
|
+ throw new ServiceException("活动信息不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PointActivityDTO.ActivityTimeConfig timeConfig = dto.getTimeConfig();
|
|
PointActivityDTO.ActivityTimeConfig timeConfig = dto.getTimeConfig();
|
|
|
if (ObjectUtil.isNull(timeConfig) || (!timeConfig.getIsPermanent() &&
|
|
if (ObjectUtil.isNull(timeConfig) || (!timeConfig.getIsPermanent() &&
|
|
|
(ObjectUtil.isNull(timeConfig.getStartTime()) || ObjectUtil.isNull(timeConfig.getEndTime())))) {
|
|
(ObjectUtil.isNull(timeConfig.getStartTime()) || ObjectUtil.isNull(timeConfig.getEndTime())))) {
|
|
|
- throw new BaseException("活动时间配置不能为空");
|
|
|
|
|
|
|
+ throw new ServiceException("活动时间配置不能为空");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -632,7 +582,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
entity.setCreateTime(new Date());
|
|
entity.setCreateTime(new Date());
|
|
|
int affectedRows = pointActivityMapper.insertPointActivity(entity);
|
|
int affectedRows = pointActivityMapper.insertPointActivity(entity);
|
|
|
if (affectedRows <= 0) {
|
|
if (affectedRows <= 0) {
|
|
|
- throw new BaseException("保存积分活动失败");
|
|
|
|
|
|
|
+ throw new ServiceException("保存积分活动失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -698,11 +648,11 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
boolean isSuccess = pointActivityExpirePolicyService.updateById(entity);
|
|
boolean isSuccess = pointActivityExpirePolicyService.updateById(entity);
|
|
|
if (!isSuccess) {
|
|
if (!isSuccess) {
|
|
|
log.error("保存或更新积分活动过期策略失败, activityType: {}", activityType);
|
|
log.error("保存或更新积分活动过期策略失败, activityType: {}", activityType);
|
|
|
- throw new BaseException(UPDATE_FAILED_MESSAGE);
|
|
|
|
|
|
|
+ throw new ServiceException(UPDATE_FAILED_MESSAGE);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("保存或更新积分活动过期策略时发生异常, activityType: {}", activityType, e);
|
|
log.error("保存或更新积分活动过期策略时发生异常, activityType: {}", activityType, e);
|
|
|
- throw new BaseException(UPDATE_FAILED_MESSAGE);
|
|
|
|
|
|
|
+ throw new ServiceException(UPDATE_FAILED_MESSAGE);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -748,14 +698,14 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
|
|
|
|
|
int affectedRows = pointActivityMapper.updatePointActivity(entity);
|
|
int affectedRows = pointActivityMapper.updatePointActivity(entity);
|
|
|
if (affectedRows <= 0) {
|
|
if (affectedRows <= 0) {
|
|
|
- throw new BaseException("更新积分活动失败");
|
|
|
|
|
|
|
+ throw new ServiceException("更新积分活动失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void saveSignTaskDetails(PointActivityDTO dto, Long activityId) {
|
|
private void saveSignTaskDetails(PointActivityDTO dto, Long activityId) {
|
|
|
PointSignTaskDTO signTaskDTO = dto.getSignTaskDTO();
|
|
PointSignTaskDTO signTaskDTO = dto.getSignTaskDTO();
|
|
|
if (ObjectUtil.isNull(signTaskDTO)) {
|
|
if (ObjectUtil.isNull(signTaskDTO)) {
|
|
|
- throw new BaseException("签到任务配置不能为空");
|
|
|
|
|
|
|
+ throw new ServiceException("签到任务配置不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PointSignTask pointSignTask = new PointSignTask();
|
|
PointSignTask pointSignTask = new PointSignTask();
|
|
@@ -764,7 +714,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
pointSignTask.setBreakRule(signTaskDTO.getBreakRule());
|
|
pointSignTask.setBreakRule(signTaskDTO.getBreakRule());
|
|
|
int affectedRows = pointSignTaskService.insertPointSignTask(pointSignTask);
|
|
int affectedRows = pointSignTaskService.insertPointSignTask(pointSignTask);
|
|
|
if (affectedRows <= 0) {
|
|
if (affectedRows <= 0) {
|
|
|
- throw new BaseException("保存积分签到任务规则失败");
|
|
|
|
|
|
|
+ throw new ServiceException("保存积分签到任务规则失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
saveSignRewards(signTaskDTO.getSignRewardList(), pointSignTask.getId());
|
|
saveSignRewards(signTaskDTO.getSignRewardList(), pointSignTask.getId());
|
|
@@ -859,7 +809,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
private void updateSignTaskDetails(PointActivityDTO dto, Long activityId) {
|
|
private void updateSignTaskDetails(PointActivityDTO dto, Long activityId) {
|
|
|
PointSignTaskDTO signTaskDTO = dto.getSignTaskDTO();
|
|
PointSignTaskDTO signTaskDTO = dto.getSignTaskDTO();
|
|
|
if (ObjectUtil.isNull(signTaskDTO)) {
|
|
if (ObjectUtil.isNull(signTaskDTO)) {
|
|
|
- throw new BaseException("签到任务配置不能为空");
|
|
|
|
|
|
|
+ throw new ServiceException("签到任务配置不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取现有的签到任务
|
|
// 获取现有的签到任务
|
|
@@ -874,7 +824,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
// 更新签到任务
|
|
// 更新签到任务
|
|
|
int affectedRows = pointSignTaskService.updatePointSignTask(pointSignTask);
|
|
int affectedRows = pointSignTaskService.updatePointSignTask(pointSignTask);
|
|
|
if (affectedRows <= 0) {
|
|
if (affectedRows <= 0) {
|
|
|
- throw new BaseException("更新积分签到任务规则失败");
|
|
|
|
|
|
|
+ throw new ServiceException("更新积分签到任务规则失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新签到奖励配置
|
|
// 更新签到奖励配置
|
|
@@ -975,7 +925,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
log.info("成功更新 {} 个活动的过期策略为 {}", activitiesToUpdate.size(), expirePolicyId);
|
|
log.info("成功更新 {} 个活动的过期策略为 {}", activitiesToUpdate.size(), expirePolicyId);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("批量更新活动过期策略失败, expirePolicyId: {}", expirePolicyId, e);
|
|
log.error("批量更新活动过期策略失败, expirePolicyId: {}", expirePolicyId, e);
|
|
|
- throw new BaseException("批量更新活动过期策略失败");
|
|
|
|
|
|
|
+ throw new ServiceException("批量更新活动过期策略失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -988,7 +938,7 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
.last("LIMIT 1")
|
|
.last("LIMIT 1")
|
|
|
);
|
|
);
|
|
|
if (ObjectUtil.isNull(activity)) {
|
|
if (ObjectUtil.isNull(activity)) {
|
|
|
- throw new RuntimeException("当前城市未配置签到活动");
|
|
|
|
|
|
|
+ throw new ServiceException("当前城市未配置签到活动");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 根据活动绑定的 taskId 查询签到任务
|
|
// 2. 根据活动绑定的 taskId 查询签到任务
|
|
@@ -1012,4 +962,12 @@ public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, P
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private WxLoginUser getCurrentWxLoginUser() {
|
|
|
|
|
+ WxLoginUser loginUser = SecurityUtils.getWxLoginUser();
|
|
|
|
|
+ if (ObjectUtil.isNull(loginUser)) {
|
|
|
|
|
+ throw new ServiceException("用户未登录或登录已过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ return loginUser;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|