|
@@ -1,6 +1,7 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.ActivityPlanDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.ActivityPlanDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.ActivityPlanRewardDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.OrderPayReq;
|
|
@@ -10,6 +11,7 @@ import com.yonge.cooleshow.biz.dal.entity.ActivityPlanReward;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ActivityUserReward;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.activity.ActivityRankingMethodEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
|
|
@@ -52,6 +54,8 @@ public class ActivityPlanEvaluationServiceImpl extends ServiceImpl<ActivityPlanE
|
|
|
|
|
|
@Autowired
|
|
|
private ActivityEvaluationService activityEvaluationService;
|
|
|
+ @Autowired
|
|
|
+ private ActivityPlanDao activityPlanMapper;
|
|
|
|
|
|
@Override
|
|
|
public boolean createOrUpdate(ActivityPlanDto activityPlan) {
|
|
@@ -86,7 +90,7 @@ public class ActivityPlanEvaluationServiceImpl extends ServiceImpl<ActivityPlanE
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ //@Transactional(rollbackFor = Exception.class)
|
|
|
public void successActivity(Long activityId) {
|
|
|
//关闭未付款订单
|
|
|
closeActivity(activityId);
|
|
@@ -110,53 +114,114 @@ public class ActivityPlanEvaluationServiceImpl extends ServiceImpl<ActivityPlanE
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- for (ActivityEvaluation activityEvaluation : activityEvaluationList) {
|
|
|
+ // 总分排名发奖流程
|
|
|
+ if (ActivityRankingMethodEnum.TOTAL_SCORE == detail.getRankingMethod()) {
|
|
|
|
|
|
- List<ActivityRankingVo> activityRankingVos = activityEvaluationRecordService.queryRankingList(activityId,
|
|
|
- activityEvaluation.getId(),detail.getRanking());
|
|
|
- for (int i = 0; i < activityRankingVos.size(); i++) {
|
|
|
+ // 查询活动获奖用户信息
|
|
|
+ List<ActivityRankingVo> rankingInfos = activityPlanMapper.selectActivityHighestScoreRankingInfo(detail.getId(), null,
|
|
|
+ detail.getRankingScore(), 9999);
|
|
|
|
|
|
- ActivityRankingVo activityRankingVo = activityRankingVos.get(i);
|
|
|
+ if (CollectionUtils.isEmpty(detail.getActivityRewardList())) {
|
|
|
+ // 活动未关联奖品,忽略后续流程
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- List<ActivityPlanRewardDto> activityPlanRewardDtos = rewardMap.get(i + 1 + "");
|
|
|
- if (CollectionUtils.isEmpty(activityPlanRewardDtos)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ // 活动关联奖品ID
|
|
|
+ List<Long> activityRewardIds = detail.getActivityRewardList().stream()
|
|
|
+ .map(ActivityPlanReward::getId).collect(Collectors.toList());
|
|
|
|
|
|
- // 活动关联奖品ID
|
|
|
- List<Long> activityRewardIds = activityPlanRewardDtos.stream()
|
|
|
- .map(ActivityPlanReward::getId).collect(Collectors.toList());
|
|
|
+ int ranking = 0;
|
|
|
+ for (ActivityRankingVo rankingInfo : rankingInfos) {
|
|
|
|
|
|
- //给用户发放奖品 传入用户id和活动id
|
|
|
- List<Long> collect = activityRewardService.sendReward(activityRankingVo.getUserId(), activityId, activityRewardIds, date);
|
|
|
+ // 推送发奖消息给用户
|
|
|
+ List<Long> collect = activityRewardService.sendReward(rankingInfo.getUserId(), activityId, activityRewardIds, date);
|
|
|
|
|
|
- // 保存奖品发放记录
|
|
|
- for (ActivityPlanRewardDto item : activityPlanRewardDtos) {
|
|
|
+ // 活动奖品信息
|
|
|
+ for (ActivityPlanRewardDto reward : detail.getActivityRewardList()) {
|
|
|
|
|
|
ActivityUserReward activityUserReward = new ActivityUserReward();
|
|
|
activityUserReward.setActivityId(activityId);
|
|
|
- activityUserReward.setBizId(activityEvaluation.getId());
|
|
|
- activityUserReward.setUserId(activityRankingVo.getUserId());
|
|
|
+ activityUserReward.setBizId(rankingInfo.getResourceId());
|
|
|
+ activityUserReward.setUserId(rankingInfo.getUserId());
|
|
|
activityUserReward.setRankingRule(detail.getRankingRule());
|
|
|
- activityUserReward.setRanking(i+1);
|
|
|
- activityUserReward.setGrantFlag(0);
|
|
|
- activityUserReward.setWinningTime(activityRankingVo.getJoinDate());
|
|
|
+ activityUserReward.setRanking(ranking++);
|
|
|
+ // 奖品发送状态
|
|
|
+ activityUserReward.setGrantFlag(collect.contains(reward.getId()) ? 1 : 0);
|
|
|
+ // 获取最高分时间
|
|
|
+ activityUserReward.setWinningTime(rankingInfo.getJoinDate());
|
|
|
activityUserReward.setCreateTime(date);
|
|
|
activityUserReward.setUpdateTime(date);
|
|
|
- activityUserReward.setRewardId(item.getRewardId());
|
|
|
+ activityUserReward.setRewardId(reward.getRewardId());
|
|
|
|
|
|
- // 奖品发送状态
|
|
|
- if (collect.contains(item.getId())) {
|
|
|
- activityUserReward.setGrantFlag(1);
|
|
|
- }
|
|
|
+ // 添加发放记录
|
|
|
activityUserRewardList.add(activityUserReward);
|
|
|
}
|
|
|
|
|
|
+ // 若奖品数量超过1000,提交数据刷新缓存
|
|
|
+ if (activityUserRewardList.size() > 1000) {
|
|
|
+
|
|
|
+ // 提交奖品发放记录
|
|
|
+ activityUserRewardService.saveBatch(activityUserRewardList);
|
|
|
+
|
|
|
+ // 清除缓存数据
|
|
|
+ activityUserRewardList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // 曲目排名发奖流程
|
|
|
+ for (ActivityEvaluation activityEvaluation : activityEvaluationList) {
|
|
|
+
|
|
|
+ List<ActivityRankingVo> activityRankingVos = activityEvaluationRecordService.queryRankingList(activityId,
|
|
|
+ activityEvaluation.getId(),detail.getRanking());
|
|
|
+ for (int i = 0; i < activityRankingVos.size(); i++) {
|
|
|
+
|
|
|
+ ActivityRankingVo activityRankingVo = activityRankingVos.get(i);
|
|
|
+
|
|
|
+ List<ActivityPlanRewardDto> activityPlanRewardDtos = rewardMap.get(i + 1 + "");
|
|
|
+ if (CollectionUtils.isEmpty(activityPlanRewardDtos)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 活动关联奖品ID
|
|
|
+ List<Long> activityRewardIds = activityPlanRewardDtos.stream()
|
|
|
+ .map(ActivityPlanReward::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //给用户发放奖品 传入用户id和活动id
|
|
|
+ List<Long> collect = activityRewardService.sendReward(activityRankingVo.getUserId(), activityId, activityRewardIds, date);
|
|
|
+
|
|
|
+ // 保存奖品发放记录
|
|
|
+ for (ActivityPlanRewardDto item : activityPlanRewardDtos) {
|
|
|
+
|
|
|
+ ActivityUserReward activityUserReward = new ActivityUserReward();
|
|
|
+ activityUserReward.setActivityId(activityId);
|
|
|
+ activityUserReward.setBizId(activityEvaluation.getId());
|
|
|
+ activityUserReward.setUserId(activityRankingVo.getUserId());
|
|
|
+ activityUserReward.setRankingRule(detail.getRankingRule());
|
|
|
+ activityUserReward.setRanking(i+1);
|
|
|
+ activityUserReward.setGrantFlag(0);
|
|
|
+ activityUserReward.setWinningTime(activityRankingVo.getJoinDate());
|
|
|
+ activityUserReward.setCreateTime(date);
|
|
|
+ activityUserReward.setUpdateTime(date);
|
|
|
+ activityUserReward.setRewardId(item.getRewardId());
|
|
|
+
|
|
|
+ // 奖品发送状态
|
|
|
+ if (collect.contains(item.getId())) {
|
|
|
+ activityUserReward.setGrantFlag(1);
|
|
|
+ }
|
|
|
+ activityUserRewardList.add(activityUserReward);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(activityUserRewardList)) {
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(activityUserRewardList)) {
|
|
|
activityUserRewardService.saveBatch(activityUserRewardList);
|
|
|
}
|
|
|
+
|
|
|
//发完奖后将库存归还
|
|
|
// activityPlanRewardService.recoveryReward(activityId);
|
|
|
}
|