liujunchi 3 tahun lalu
induk
melakukan
b6195b6512

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/ActivityPlanRewardDao.java

@@ -25,7 +25,7 @@ public interface ActivityPlanRewardDao extends BaseMapper<ActivityPlanReward>{
 	 * @date 2022-08-17 11:13:13
 	 * @return: com.yonge.cooleshow.biz.dal.vo.ActivityPlanRewardVo
 	 */
-	ActivityPlanReward detailByActivityIdAndRewardId(@Param("activityId") Long activityId,@Param("rewardId") Long rewardId);
+	ActivityPlanReward detailByActivityIdAndRewardId(@Param("activityId") Long activityId,@Param("rewardId") Long rewardId, @Param("group") String group);
 	/**
 	 * 分页查询
      * @author liweifan

+ 0 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/ActivityReward.java

@@ -46,10 +46,6 @@ public class ActivityReward implements Serializable {
     @NotNull(message = "奖品类型不能为空")
     private RewardTypeEnum rewardType;
 
-    // @ApiModelProperty("关联优惠券ID ")
-    // @TableField(value = "coupon_id_")
-    // private Long couponId;
-
     @ApiModelProperty("奖品描述 ")
     @TableField(value = "reward_describe_")
     private String rewardDescribe;

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ActivityPlanRewardService.java

@@ -25,7 +25,7 @@ public interface ActivityPlanRewardService extends IService<ActivityPlanReward>
      */
     ActivityPlanRewardVo detail(Long id);
 
-    ActivityPlanReward detailByActivityIdAndRewardId(Long activityId, Long rewardId);
+    ActivityPlanReward detailByActivityIdAndRewardId(Long activityId, Long rewardId, String group);
     /**
      * 分页查询
      *

+ 108 - 100
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityEvaluationRecordServiceImpl.java

@@ -1,83 +1,86 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
-
-import com.google.common.collect.Lists;
-import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
-import com.yonge.cooleshow.biz.dal.enums.activity.ActivityRankingRuleEnum;
-import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
-import org.apache.commons.collections.CollectionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.yonge.cooleshow.biz.dal.dao.ActivityEvaluationRecordDao;
 import com.yonge.cooleshow.biz.dal.dto.search.ActivityEvaluationRecordSearch;
 import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluation;
 import com.yonge.cooleshow.biz.dal.entity.ActivityEvaluationRecord;
+import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
 import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationRecordService;
 import com.yonge.cooleshow.biz.dal.service.ActivityEvaluationService;
+import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
 import com.yonge.cooleshow.biz.dal.vo.ActivityEvaluationRecordVo;
 import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
 import com.yonge.cooleshow.common.enums.ActivityResourceEnum;
 import com.yonge.toolset.base.exception.BizException;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
 
 @Service
-public class ActivityEvaluationRecordServiceImpl extends ServiceImpl<ActivityEvaluationRecordDao, ActivityEvaluationRecord> implements ActivityEvaluationRecordService {
-    private final static Logger log = LoggerFactory.getLogger(ActivityEvaluationRecordServiceImpl.class);
-
-    @Autowired
-    private ActivityEvaluationService activityEvaluationService;
-
-    @Autowired
-    private ActivityPlanService activityPlanService;
-
-	@Override
-    public ActivityEvaluationRecordVo detail(Long id) {
-        return baseMapper.detail(id);
+public class ActivityEvaluationRecordServiceImpl
+    extends ServiceImpl<ActivityEvaluationRecordDao, ActivityEvaluationRecord>
+    implements ActivityEvaluationRecordService {
+  private final static Logger log =
+      LoggerFactory.getLogger(ActivityEvaluationRecordServiceImpl.class);
+
+  @Autowired private ActivityEvaluationService activityEvaluationService;
+
+  @Autowired private ActivityPlanService activityPlanService;
+
+  @Override
+  public ActivityEvaluationRecordVo detail(Long id) {
+    return baseMapper.detail(id);
+  }
+
+  @Override
+  public IPage<ActivityEvaluationRecordVo>
+  selectPage(IPage<ActivityEvaluationRecordVo> page,
+             ActivityEvaluationRecordSearch query) {
+    return page.setRecords(baseMapper.selectPage(page, query));
+  }
+
+  @Override
+  public List<Long> getJoinEvaluationIdList(Long activityId, Long userId) {
+    return baseMapper.getJoinEvaluationIdList(activityId, userId);
+  }
+
+  @Override
+  public void saveRecord(Long evaluationId, Long userId, BigDecimal score) {
+    if (evaluationId == null) {
+      throw new BizException("评测项目id不能为空");
     }
-    
-    @Override
-    public IPage<ActivityEvaluationRecordVo> selectPage(IPage<ActivityEvaluationRecordVo> page, ActivityEvaluationRecordSearch query){
-        return page.setRecords(baseMapper.selectPage(page, query));
-    }
-
-    @Override
-    public List<Long> getJoinEvaluationIdList(Long activityId, Long userId) {
-        return baseMapper.getJoinEvaluationIdList(activityId,userId);
+    ActivityEvaluation activityEvaluation =
+        activityEvaluationService.getById(evaluationId);
+    if (activityEvaluation == null) {
+      throw new BizException("未找到评测项目");
     }
-
-    @Override
-    public void saveRecord(Long evaluationId, Long userId, BigDecimal score) {
-        if (evaluationId == null) {
-            throw new BizException("评测项目id不能为空");
-        }
-        ActivityEvaluation activityEvaluation = activityEvaluationService.getById(evaluationId);
-        if (activityEvaluation == null) {
-            throw new BizException("未找到评测项目");
-        }
-        ActivityEvaluationRecord activityEvaluationRecord = new ActivityEvaluationRecord();
-        activityEvaluationRecord.setActivityId(activityEvaluation.getActivityId());
-        activityEvaluationRecord.setUserId(userId);
-        activityEvaluationRecord.setEvaluationId(evaluationId);
-        activityEvaluationRecord.setCreateTime(new Date());
-        activityEvaluationRecord.setScore(score == null ? 0:score.doubleValue());
-        
-        ActivityEvaluationRecord lastestRecord = baseMapper.queryLastestRecord(activityEvaluation.getActivityId(), userId);
-        if(lastestRecord == null){
-        	activityEvaluationRecord.setTimes(1);
-        }else{
-        	activityEvaluationRecord.setTimes(lastestRecord.getTimes() + 1);
-        }
-        save(activityEvaluationRecord);
+    ActivityEvaluationRecord activityEvaluationRecord =
+        new ActivityEvaluationRecord();
+    activityEvaluationRecord.setActivityId(activityEvaluation.getActivityId());
+    activityEvaluationRecord.setUserId(userId);
+    activityEvaluationRecord.setEvaluationId(evaluationId);
+    activityEvaluationRecord.setCreateTime(new Date());
+    activityEvaluationRecord.setScore(score == null ? 0 : score.doubleValue());
+
+    ActivityEvaluationRecord lastestRecord = baseMapper.queryLastestRecord(
+        activityEvaluation.getActivityId(), userId);
+    if (lastestRecord == null) {
+      activityEvaluationRecord.setTimes(1);
+    } else {
+      activityEvaluationRecord.setTimes(lastestRecord.getTimes() + 1);
     }
+    save(activityEvaluationRecord);
+  }
 
 
     @Override
@@ -99,46 +102,51 @@ public class ActivityEvaluationRecordServiceImpl extends ServiceImpl<ActivityEva
         this.save(activityEvaluationRecord);
     }
 
-
-    @Override
-	public List<ActivityRankingVo> queryRankingList(Long activityPlanId, Long activityEvaluationId, int limit) {
-        ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
-        if (activityPlan == null) {
-            throw new BizException("活动已结束");
-        }
-		return baseMapper.queryRankingList(activityPlanId, activityEvaluationId, limit,activityPlan.getRankingRule());
-	}
-
-	@Override
-	public ActivityRankingVo queryUserRanking(Long activityPlanId, Long activityEvaluationId, Long userId) {
-        ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
-        if (activityPlan == null) {
-            throw new BizException("活动已结束");
-        }
-        return baseMapper.queryUserRanking(activityPlanId, activityEvaluationId, userId,activityPlan.getRankingRule());
-	}
-
-    /**
-     * 用户活动最高排名信息
-     *
-     * @param activityId 活动ID
-     * @param userIds 用户ID
-     * @return List<ActivityEvaluationRecord>
-     */
-    @Override
-    public List<ActivityEvaluationRecord> queryActivityUserHighestRankingInfo(Long activityId, List<Long> userIds) {
-
-        if (CollectionUtils.isEmpty(userIds)) {
-            return Lists.newArrayList();
-        }
-        ActivityPlan activityPlan = activityPlanService.getById(activityId);
-        if (activityPlan == null) {
-            throw new BizException("活动已结束");
-        }
-        // 用户最高排名信息
-        List<ActivityEvaluationRecord> records = getBaseMapper().selectUserHighestRankingInfo(activityId, userIds,activityPlan.getRankingRule());
-
-        return Optional.ofNullable(records).orElse(Lists.newArrayList());
+  @Override
+  public List<ActivityRankingVo> queryRankingList(Long activityPlanId, Long activityEvaluationId, int limit) {
+    ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
+    if (activityPlan == null) {
+      throw new BizException("活动已结束");
+    }
+    return baseMapper.queryRankingList(activityPlanId, activityEvaluationId,
+                                       limit, activityPlan.getRankingRule());
+  }
+
+  @Override
+  public ActivityRankingVo queryUserRanking(Long activityPlanId,
+                                            Long activityEvaluationId,
+                                            Long userId) {
+    ActivityPlan activityPlan = activityPlanService.getById(activityPlanId);
+    if (activityPlan == null) {
+      throw new BizException("活动已结束");
+    }
+    return baseMapper.queryUserRanking(activityPlanId, activityEvaluationId,
+                                       userId, activityPlan.getRankingRule());
+  }
+
+  /**
+   * 用户活动最高排名信息
+   *
+   * @param activityId 活动ID
+   * @param userIds 用户ID
+   * @return List<ActivityEvaluationRecord>
+   */
+  @Override
+  public List<ActivityEvaluationRecord>
+  queryActivityUserHighestRankingInfo(Long activityId, List<Long> userIds) {
+
+    if (CollectionUtils.isEmpty(userIds)) {
+      return Lists.newArrayList();
+    }
+    ActivityPlan activityPlan = activityPlanService.getById(activityId);
+    if (activityPlan == null) {
+      throw new BizException("活动已结束");
     }
+    // 用户最高排名信息
+    List<ActivityEvaluationRecord> records =
+        getBaseMapper().selectUserHighestRankingInfo(
+            activityId, userIds, activityPlan.getRankingRule());
 
+    return Optional.ofNullable(records).orElse(Lists.newArrayList());
+  }
 }

+ 4 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityPlanRewardServiceImpl.java

@@ -52,8 +52,8 @@ public class ActivityPlanRewardServiceImpl extends ServiceImpl<ActivityPlanRewar
     }
 
     @Override
-    public ActivityPlanReward detailByActivityIdAndRewardId(Long activityId, Long rewardId) {
-        return baseMapper.detailByActivityIdAndRewardId(activityId, rewardId);
+    public ActivityPlanReward detailByActivityIdAndRewardId(Long activityId, Long rewardId, String group) {
+        return baseMapper.detailByActivityIdAndRewardId(activityId, rewardId, group);
     }
 
     @Override
@@ -81,7 +81,7 @@ public class ActivityPlanRewardServiceImpl extends ServiceImpl<ActivityPlanRewar
                                             , (param) -> {
                                                 ActivityRewardVo detail = activityRewardService.detail(param.getRewardId());
 
-                                                ActivityPlanReward old = detailByActivityIdAndRewardId(param.getActivityId(), param.getRewardId());
+                                                ActivityPlanReward old = detailByActivityIdAndRewardId(param.getActivityId(), param.getRewardId(), param.getGroup());
                                                 if (null == old) {
                                                     Integer stock = detail.getStock() - param.getRewardNum();
                                                     if (stock < 0) {
@@ -161,7 +161,7 @@ public class ActivityPlanRewardServiceImpl extends ServiceImpl<ActivityPlanRewar
                                             , (param) -> {
                                                 ActivityRewardVo detail = activityRewardService.detail(param.getRewardId());
 
-                                                ActivityPlanReward old = detailByActivityIdAndRewardId(param.getActivityId(), param.getRewardId());
+                                                ActivityPlanReward old = detailByActivityIdAndRewardId(param.getActivityId(), param.getRewardId(), reward.getGroup());
 
                                                 if (old.getRewardNum() > 0) {
                                                     //入库存变更记录

+ 6 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityPlanServiceImpl.java

@@ -644,11 +644,16 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
         for (ActivityPlanRewardDto item : updateRewardDtoList) {
             // activityPlanRewardService.saveOrUpdateReward(item);
 
+            // 设置默认值
+            if (StringUtils.isEmpty(item.getGroup())) {
+                item.setGroup("1");
+            }
+
             // 评测活动
             if (ActivityTypeEnum.EVALUATION == activityPlan.getActivityType()) {
                 item.setRewardNum(ret);
             }
-            planReward = activityPlanRewardService.detailByActivityIdAndRewardId(item.getActivityId(), item.getRewardId());
+            planReward = activityPlanRewardService.detailByActivityIdAndRewardId(item.getActivityId(), item.getRewardId(), item.getGroup());
 
             if (Objects.isNull(planReward)) {
 

+ 2 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityPlanRewardMapper.xml

@@ -15,6 +15,7 @@
         , t.activity_id_ as activityId
         , t.reward_id_ as rewardId
         , t.reward_num_ as rewardNum
+        , t.group_ AS `group`
         , t.create_time_ as createTime
         </sql>
     
@@ -30,7 +31,7 @@
         SELECT
             <include refid="baseColumns"/>
         FROM activity_plan_reward t
-        where t.activity_id_ = #{activityId} and t.reward_id_ = #{rewardId}
+        where t.activity_id_ = #{activityId} and t.reward_id_ = #{rewardId} AND t.group_ = #{group}
     </select>
 
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanRewardVo">