|
|
@@ -163,38 +163,25 @@ public class PointUserActivityTaskCompletionServiceImpl extends ServiceImpl<Poin
|
|
|
}
|
|
|
|
|
|
Long activityId = activity.getId();
|
|
|
- PointActivityTypeEnum activityTypeEnum = PointActivityTypeEnum.valueOf(activity.getActivityType());
|
|
|
+ Integer activityType = activity.getActivityType();
|
|
|
PointActivityTaskTypeEnum taskTypeEnum = PointActivityTaskTypeEnum.getByInfo(task.getTaskName());
|
|
|
int targetCount = Integer.parseInt(task.getTriggerValue());
|
|
|
- boolean isVerified;
|
|
|
- String taskName;
|
|
|
|
|
|
// 4. 任务校验逻辑
|
|
|
- if (activityTypeEnum == PointActivityTypeEnum.SIGN_TASK) {
|
|
|
- // 签到任务:今日未完成才可领取
|
|
|
- taskName = TaskNameEnum.USER_SIGN_IN.getInfo();
|
|
|
- if (isTodayCompleted(openId, activityId, taskId, taskTypeEnum.getCode())) {
|
|
|
- throw new ServiceException("今日已签到,请勿重复操作");
|
|
|
- }
|
|
|
- isVerified = true;
|
|
|
- } else if (activityTypeEnum == PointActivityTypeEnum.DAILY_ACTIVITY) {
|
|
|
- // 每日任务:今日未完成
|
|
|
- taskName = getTaskNameByType(taskTypeEnum);
|
|
|
- if (isTodayCompleted(openId, activityId, taskId, taskTypeEnum.getCode())) {
|
|
|
- throw new ServiceException("今日任务已完成,请勿重复领取");
|
|
|
- }
|
|
|
- isVerified = true;
|
|
|
- } else if (activityTypeEnum == PointActivityTypeEnum.NEW_USER_ACTIVITY || activityTypeEnum == PointActivityTypeEnum.MONTHLY_ACTIVITY) {
|
|
|
- // 新手/月度任务:校验业务数据
|
|
|
- taskName = getTaskNameByType(taskTypeEnum);
|
|
|
- Date queryTime = getQueryStartTime(activity.getIsPermanent(), activity.getStartTime(), activity.getActivityType());
|
|
|
- isVerified = checkBusinessData(openId, taskTypeEnum, queryTime, targetCount);
|
|
|
- } else {
|
|
|
+ if (ObjectUtil.notEqual(PointActivityTypeEnum.DAILY_ACTIVITY.getCode(), activityType) ||
|
|
|
+ ObjectUtil.notEqual(PointActivityTypeEnum.NEW_USER_ACTIVITY.getCode(), activityType) ||
|
|
|
+ ObjectUtil.notEqual(PointActivityTypeEnum.MONTHLY_ACTIVITY.getCode(), activityType)) {
|
|
|
throw new ServiceException("不支持的活动类型");
|
|
|
}
|
|
|
|
|
|
+ // 每日/新手/月度任务:校验业务数据
|
|
|
+ String taskName = getTaskNameByType(taskTypeEnum);
|
|
|
+ // 分享服务号、浏览动态和浏览商户
|
|
|
+ boolean isVerified = checkBusinessData(taskTypeEnum);
|
|
|
+
|
|
|
// 5. 校验通过 → 发放奖励
|
|
|
if (isVerified) {
|
|
|
+ Date queryTime = getQueryStartTime(activity.getIsPermanent(), activity.getActivityType());
|
|
|
// 防重复发奖:已达标则直接返回
|
|
|
PointUserActivityTaskCompletion record = this.getTaskRecord(openId, activityId, taskId, taskTypeEnum.getCode());
|
|
|
if (record != null && record.getCompletedCount() >= targetCount) {
|
|
|
@@ -231,38 +218,37 @@ public class PointUserActivityTaskCompletionServiceImpl extends ServiceImpl<Poin
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 校验业务数据(订单/充值) JDK8 兼容
|
|
|
+ * 校验业务数据(只针对:分享服务号、浏览动态和浏览商户)
|
|
|
*/
|
|
|
- private boolean checkBusinessData(String openId, PointActivityTaskTypeEnum taskType, Date queryTime, int targetCount) {
|
|
|
- if (taskType == PointActivityTaskTypeEnum.COMPLETE_ORDER) {
|
|
|
- return orderService.countCompletedOrders(openId, queryTime) >= targetCount;
|
|
|
- } else if (taskType == PointActivityTaskTypeEnum.RECHARGE_TASK) {
|
|
|
- return rechargeService.countSuccessRecharges(openId, queryTime) >= targetCount;
|
|
|
- } else if (taskType == PointActivityTaskTypeEnum.SHARE_SERVICE
|
|
|
+ private boolean checkBusinessData(PointActivityTaskTypeEnum taskType) {
|
|
|
+ boolean bool = false;
|
|
|
+ if (taskType == PointActivityTaskTypeEnum.SHARE_SERVICE
|
|
|
|| taskType == PointActivityTaskTypeEnum.BROWLE_NEWS
|
|
|
|| taskType == PointActivityTaskTypeEnum.BROWLE_MERCHANT) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
+ bool = true;
|
|
|
}
|
|
|
+ return bool;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取查询开始时间 JDK8 兼容
|
|
|
+ * 获取查询开始时间,
|
|
|
+ * 永久任务、新手活动:null
|
|
|
+ * 每日活动: 当天0点0分0秒
|
|
|
+ * 每月活动:当前月的第一天的0点0分0秒
|
|
|
*/
|
|
|
- private Date getQueryStartTime(String isPermanent, Date startTime, Integer activityType) {
|
|
|
+ private Date getQueryStartTime(String isPermanent, Integer activityType) {
|
|
|
+ Date StartTime = null;
|
|
|
// 永久任务:查询全部历史
|
|
|
if (StrUtil.equals(isPermanent, "1")) {
|
|
|
- return null;
|
|
|
+ return StartTime;
|
|
|
}
|
|
|
PointActivityTypeEnum typeEnum = PointActivityTypeEnum.valueOf(activityType);
|
|
|
if (typeEnum == PointActivityTypeEnum.DAILY_ACTIVITY) {
|
|
|
- return DateUtil.beginOfDay(new Date());
|
|
|
+ StartTime = DateUtil.beginOfDay(new Date());
|
|
|
} else if (typeEnum == PointActivityTypeEnum.MONTHLY_ACTIVITY) {
|
|
|
- return DateUtil.beginOfMonth(new Date());
|
|
|
- } else {
|
|
|
- return startTime;
|
|
|
+ StartTime = DateUtil.beginOfMonth(new Date());
|
|
|
}
|
|
|
+ return StartTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -330,7 +316,7 @@ public class PointUserActivityTaskCompletionServiceImpl extends ServiceImpl<Poin
|
|
|
try {
|
|
|
PointActivity activity = activityMap.get(task.getActivityId());
|
|
|
int targetCount = Integer.parseInt(task.getTriggerValue());
|
|
|
- Date queryTime = getQueryStartTime(activity.getIsPermanent(), activity.getStartTime(), typeCode);
|
|
|
+ Date queryTime = getQueryStartTime(activity.getIsPermanent(), typeCode);
|
|
|
int completed = countFunction.apply(queryTime);
|
|
|
|
|
|
if (completed < targetCount) {
|