Procházet zdrojové kódy

修复分享活动问题

Eric před 3 roky
rodič
revize
4441089775

+ 9 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/ActivityEvaluationDao.java

@@ -76,4 +76,13 @@ public interface ActivityEvaluationDao extends BaseMapper<ActivityEvaluation> {
 	 * @return List<ActivityTeacherWrapper>
 	 */
 	List<ActivityTeacherWrapper> selectActivityTeacherPageInfo(@Param("page") IPage<ActivityTeacherWrapper> page, @Param("record") ActivityTeacherQuery query);
+
+	/**
+	 * 查询活动老师信息
+	 * - 通过时间匹配
+	 * @param page IPage<ActivityTeacherWrapper>
+	 * @param query ActivityTeacherQuery
+	 * @return List<ActivityTeacherWrapper>
+	 */
+	List<ActivityTeacherWrapper> selectActivityTeacherByTimePageInfo(@Param("page") IPage<ActivityTeacherWrapper> page, @Param("record") ActivityTeacherQuery query);
 }

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

@@ -196,8 +196,7 @@ public class ActivityEvaluationServiceImpl extends ServiceImpl<ActivityEvaluatio
                         .resourceType(ActivityResourceEnum.TEACHER.getCode())
                         .activityState(EStatus.ENABLE.getValue())
                         .startTime(Optional.ofNullable(activityPlan.getActivityStart()).map(Date::getTime).orElse(null))
-                        .endTime(Optional.ofNullable(activityPlan.getActivityEnd()).map(Date::getTime).orElse(null))
-                        .activityId(null); // 重置活动匹配
+                        .endTime(Optional.ofNullable(activityPlan.getActivityEnd()).map(Date::getTime).orElse(null));
             }
         }
 

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

@@ -182,6 +182,19 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
             activityId = activityPlan.getId();
         } else {
             ActivityPlan old = getById(activityPlan.getId());
+
+            // 分享活动-活动时间修改需要先校验与老师其他分享活动是否存在冲突
+            if (ActivityTypeEnum.SHARE == old.getActivityType()) {
+
+                if (activityPlan.getActivityStart().getTime() != old.getActivityStart().getTime()
+                        || activityPlan.getActivityEnd().getTime() != old.getActivityEnd().getTime()) {
+
+                    // 排除当前活动,其他活动时间存在重复
+
+                }
+
+            }
+
             //启用状态,只能修改活动结束时间
             if (old.getActivityState().equals(1)) {
                 if (activityPlan.getActivityEnd().after(new Date())) {
@@ -224,7 +237,8 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
             item.setActivityId(activityId);
         }
 
-        List<Long> deleteRewardIds = activityPlanRewardService.getBaseMapper().selectBatchIds(Lists.newArrayList(activityId)).stream()
+        List<Long> deleteRewardIds = activityPlanRewardService.getBaseMapper()
+                .selectList(Wrappers.<ActivityPlanReward>lambdaQuery().eq(ActivityPlanReward::getActivityId, activityId)).stream()
                 .map(ActivityPlanReward::getRewardId).distinct().collect(Collectors.toList());
 
         // 删除原始活动奖品映射关系

+ 14 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityUserRewardServiceImpl.java

@@ -53,13 +53,18 @@ public class ActivityUserRewardServiceImpl extends ServiceImpl<ActivityUserRewar
         // 分享活动关联老师信息
         if (ActivityTypeEnum.SHARE == activityPlan.getActivityType()) {
 
+            // 关联老师信息
             Map<Long, String> teacherNameMap = Maps.newConcurrentMap();
+            // 关联老师ID
+            Map<Long, String> teacherIdMap = Maps.newConcurrentMap();
+
             List<Long> userIds = userRewards.stream().map(UserRewardVo::getUserId).distinct().collect(Collectors.toList());
 
             Lists.partition(userIds, 30).parallelStream().forEach(item -> {
 
+                List<UserRewardVo> retlist = getBaseMapper().selectActivityShareTeacher(activityPlan.getId(), item);
                 // 同一个活动,用户关联多个老师信息
-                Map<Long, String> collect = getBaseMapper().selectActivityShareTeacher(activityPlan.getId(), item).stream()
+                Map<Long, String> collect = retlist.stream()
                         .collect(Collectors.groupingBy(UserRewardVo::getUserId, Collectors.mapping(x -> {
 
                             if (StringUtils.isNotEmpty(x.getRealName())) {
@@ -69,12 +74,19 @@ public class ActivityUserRewardServiceImpl extends ServiceImpl<ActivityUserRewar
                         }, Collectors.joining("、"))));
 
                 teacherNameMap.putAll(collect);
+
+                // 老师ID
+                teacherIdMap.putAll(retlist.stream()
+                        .collect(Collectors.groupingBy(UserRewardVo::getUserId,
+                                Collectors.mapping(UserRewardVo::getTeacherId, Collectors.joining("、")))));
+
             });
 
             // 填充老师信息
             for (UserRewardVo item : userRewards) {
 
-                item.setTeacherName(teacherNameMap.getOrDefault(item.getUserId(), ""));
+                item.teacherName(teacherNameMap.getOrDefault(item.getUserId(), ""))
+                        .setTeacherIds(teacherIdMap.getOrDefault(item.getUserId(), ""));
             }
         }
 

+ 13 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/UserRewardVo.java

@@ -48,7 +48,9 @@ public class UserRewardVo implements Serializable {
 	@ApiModelProperty("关联老师 ")
 	private String teacherName;
 	@ApiModelProperty("关联老师ID ")
-	private Long teacherId;
+	private String teacherIds;
+	@ApiModelProperty(hidden = true)
+	private String teacherId;
 
 	public Long getAmount() {
 		return amount;
@@ -130,21 +132,25 @@ public class UserRewardVo implements Serializable {
 		this.teacherName = teacherName;
 	}
 
-	public Long getTeacherId() {
+	public String getTeacherId() {
 		return teacherId;
 	}
 
-	public void setTeacherId(Long teacherId) {
+	public void setTeacherId(String teacherId) {
 		this.teacherId = teacherId;
 	}
 
+	public String getTeacherIds() {
+		return teacherIds;
+	}
+
+	public void setTeacherIds(String teacherIds) {
+		this.teacherIds = teacherIds;
+	}
+
 	public UserRewardVo teacherName(String teacherName) {
 		this.teacherName = teacherName;
 		return this;
 	}
 
-	public UserRewardVo teacherId(Long teacherId) {
-		this.teacherId = teacherId;
-		return this;
-	}
 }

+ 48 - 8
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationMapper.xml

@@ -146,7 +146,7 @@
     </resultMap>
     <sql id="ActivityTeacherPageInfo_Column_List">
         t1.id_ AS teacher_id, t1.real_name_, t1.username_, t1.phone_, t2.subject_id_
-        <if test="record.activityId != null">, t3.id_</if>
+        <if test="record.activityId != null and record.addType == 0">, t3.id_</if>
     </sql>
     <sql id="ActivityTeacherPageInfo_Condition_List">
         <if test="record.id != null">
@@ -172,14 +172,21 @@
         <if test="record.activityType != null">
             AND t1.activity_type_ = #{record.activityType}
         </if>
-        <if test="record.activityState != null">
-            AND t1.activity_state_ = #{record.activityState}
-        </if>
         <if test="record.resourceType != null">
-            AND t2.resource_type_ = #{record.resourceType})
+            AND t2.resource_type_ = #{record.resourceType}
         </if>
+        <choose>
+            <when test="record.activityId != null">
+                AND (t2.activity_id_ = #{record.activityId} <if test="record.startTime != null and record.endTime != null"> OR (<include refid="ActivityTeacherNotIn_ActivityTime_Condition_List" />) </if>)
+            </when>
+            <otherwise>
+                AND <include refid="ActivityTeacherNotIn_ActivityTime_Condition_List" />
+            </otherwise>
+        </choose>
+    </sql>
+    <sql id="ActivityTeacherNotIn_ActivityTime_Condition_List">
         <if test="record.startTime != null and record.endTime != null">
-            AND (unix_timestamp(t1.activity_start_) &lt;= #{record.startTime} AND #{record.startTime} &lt;= unix_timestamp(t1.activity_end_) OR unix_timestamp(t1.activity_start_) &lt;= #{record.endTime} AND #{record.endTime} &lt;= unix_timestamp(t1.activity_end_))
+            t1.activity_state_ = #{record.activityState} AND ((unix_timestamp(t1.activity_start_) &lt;= #{record.startTime} AND #{record.startTime} &lt;= unix_timestamp(t1.activity_end_)) OR (unix_timestamp(t1.activity_start_) &lt;= #{record.endTime} AND #{record.endTime} &lt;= unix_timestamp(t1.activity_end_)))
         </if>
     </sql>
     <select id="selectActivityTeacherPageInfo" resultMap="ActivityTeacherPageInfoResultMap">
@@ -187,10 +194,10 @@
         FROM sys_user t1 JOIN teacher t2 ON (t1.id_ = t2.user_id_ <if test="record.lockFlag !=null"> AND t2.lock_flag_ = #{record.lockFlag} </if> )
         <choose>
             <when test="record.addType == 1">
-                LEFT JOIN (SELECT t2.music_sheet_id_ AS user_id FROM activity_plan t1 JOIN activity_evaluation t2 ON (t1.id_ = t2.activity_id_ <include refid="ActivityTeacherNotIn_Condition_List"/> ) t4 ON (t4.user_id = t1.id_)
+                LEFT JOIN (SELECT t2.music_sheet_id_ AS user_id FROM activity_plan t1 JOIN activity_evaluation t2 ON (t1.id_ = t2.activity_id_ <include refid="ActivityTeacherNotIn_Condition_List"/> ) )t4 ON (t4.user_id = t1.id_)
             </when>
             <otherwise>
-                <if test="record.activityId != null"> JOIN activity_evaluation t3 ON (t1.id_ = t3.music_sheet_id_ AND t3.activity_id_ = #{record.activityId}) </if>
+                <if test="record.activityId != null and record.addType == 0"> JOIN activity_evaluation t3 ON (t1.id_ = t3.music_sheet_id_ AND t3.activity_id_ = #{record.activityId}) </if>
             </otherwise>
         </choose>
         <where>
@@ -201,4 +208,37 @@
         </where>
     </select>
     <!--活动老师信息-->
+
+    <!--时间匹配活动老师信息-->
+    <resultMap id="ActivityTeacherByTimePageInfoResultMap" type="com.yonge.cooleshow.biz.dal.vo.activity.ActivityTeacherWrapper">
+        <result column="real_name_" jdbcType="BIGINT" property="realName" />
+        <result column="username_" jdbcType="VARCHAR" property="username" />
+        <result column="teacher_id" jdbcType="BIGINT" property="teacherId" />
+    </resultMap>
+    <sql id="ActivityTeacherByTimePageInfo_Column_List">
+        t4.id_ AS teacher_id, t4.real_name_, t4.username_
+    </sql>
+    <select id="selectActivityTeacherByTimePageInfo" resultMap="ActivityTeacherByTimePageInfoResultMap">
+        SELECT <include refid="ActivityTeacherByTimePageInfo_Column_List" />
+        FROM activity_plan t1 JOIN activity_evaluation t2 ON t1.id_ = t2.activity_id_ LEFT JOIN activity_evaluation t3 ON (t3.music_sheet_id_ = t2.music_sheet_id_ AND t3.activity_id_ = #{record.activityId}) JOIN sys_user t4 ON (t2.music_sheet_id_ = t4.id_)
+        <where>
+            t3.id_ IS NOT NULL
+            <if test="record.activityId != null">
+                AND t2.activity_id_ != #{record.activityId}
+            </if>
+            <if test="record.lockFlag != null">
+                AND t4.lock_flag_ = #{record.lockFlag}
+            </if>
+            <if test="record.deleteFlag != null">
+                AND t4.del_flag_ = #{record.deleteFlag}
+            </if>
+            <if test="record.activityState != null">
+                AND t1.activity_state_ = #{record.activityState}
+            </if>
+            <if test="record.startTime != null and record.endTime != null">
+                AND ((unix_timestamp(t1.activity_start_) &lt;= #{record.startTime} AND #{record.startTime} &lt;= unix_timestamp(t1.activity_end_)) OR (unix_timestamp(t1.activity_start_) &lt;= #{record.endTime} AND #{record.endTime} &lt;= unix_timestamp(t1.activity_end_)))
+            </if>
+        </where>
+    </select>
+    <!--时间匹配活动老师信息-->
 </mapper>