yonge il y a 3 ans
Parent
commit
6b1027e481

+ 5 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationRecordMapper.xml

@@ -48,19 +48,19 @@
 		from activity_evaluation_record aer left join sys_user u on aer.user_id_ = u.id_
         left join student stu on stu.user_id_ = aer.user_id_
         left join subject s on s.id_ = stu.subject_id_
-		where aer.activity_id_ = #{activityPlanId} and aer.evaluation_id_ = #{activityEvaluationId} and aer.score_ > 0
-		order by aer.score_ desc,aer.times_ asc, aer.id_ asc 
+		where aer.activity_id_ = #{activityPlanId} and aer.evaluation_id_ = #{activityEvaluationId} and aer.score_ >= 0
+		order by aer.score_ desc,aer.times_ asc, aer.id_ asc limit 1000000
 		) a group by userId order by score desc,times asc,id_ asc
 		limit #{limit}
     </select>
 
     <select id="queryUserRanking" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo">
-		select aer.score_ socre,aer.user_id_ userId,u.avatar_ userAvatar,u.username_ username, aer.create_time_ joinDate,s.name_ userSubject,aer.times_ times
+		select aer.score_ score,aer.user_id_ userId,u.avatar_ userAvatar,u.username_ username, aer.create_time_ joinDate,s.name_ userSubject,aer.times_ times
 		from activity_evaluation_record aer left join sys_user u on aer.user_id_ = u.id_
         left join student stu on stu.user_id_ = aer.user_id_
         left join subject s on s.id_ = stu.subject_id_
 		where aer.id_ in (select * from (
-		select aer.id_ from activity_evaluation_record aer where aer.activity_id_ = #{activityPlanId} and aer.evaluation_id_ = #{activityEvaluationId} and aer.user_id_ = #{userId} and aer.score_ > 0
+		select aer.id_ from activity_evaluation_record aer where aer.activity_id_ = #{activityPlanId} and aer.evaluation_id_ = #{activityEvaluationId} and aer.user_id_ = #{userId} and aer.score_ >= 0
 		order by aer.score_ desc,aer.times_ asc, aer.id_ asc limit 1) a
 		) 
     </select>
@@ -68,6 +68,6 @@
     <select id="queryLastestRecord" resultMap="BaseResultMap">
 		select t.*
 		from activity_evaluation_record t 
-		where t.activity_id_ = #{activityPlanId} and t.user_id_ = #{userId} and t.score_ > 0 order by id_ desc limit 1
+		where t.activity_id_ = #{activityPlanId} and t.user_id_ = #{userId} and t.score_ >= 0 order by id_ desc limit 1
     </select>
 </mapper>

+ 9 - 21
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityPlanEvaluationMapper.xml

@@ -24,31 +24,19 @@
             select
                 a.activity_id_ as activityId,
                 a.evaluation_id_ as bizId,
-                b.user_id_ as userId,
+                a.user_id_ as userId,
                 c.reward_id_ as rewardId
             from (
-                select
-                    a.activity_id_,a.evaluation_id_,a.score_,min(b.id_) as id_
-                from(
-                    select
-                    activity_id_,evaluation_id_, max(score_) as score_
-                    from activity_evaluation_record where activity_id_ = #{activityPlanId} and score_ is not null
-                    group by activity_id_,evaluation_id_
-                ) a
-                left join activity_evaluation_record b on a.activity_id_ = b.activity_id_ and a.evaluation_id_ = b.evaluation_id_ and a.score_ = b.score_
-                GROUP BY a.activity_id_,a.evaluation_id_,a.score_
+                
+                select * from 
+		    	(
+				select aer.id_,aer.evaluation_id_,aer.score_ ,aer.user_id_ ,aer.activity_id_,aer.times_
+				from activity_evaluation_record aer 
+				where aer.activity_id_ = #{activityPlanId}  and aer.score_ > 0
+				order by aer.score_ desc,aer.times_ asc, aer.id_ asc limit 1000000
+				) a group by evaluation_id_ order by score_ desc,times_ asc,id_ asc
             ) a
-            left join activity_evaluation_record b on a.id_ = b.id_
             left join activity_plan_reward c on a.activity_id_ = c.activity_id_
             
-            <!-- select a.activity_id_ as activityId, a.evaluation_id_ as bizId, a.user_id_ as userId, c.reward_id_ as rewardId from 
-            (
-            select * from activity_evaluation_record aer 
-            where aer.activity_id_ = #{activityPlanId} and aer.score_ >= 0
-            order by aer.score_ desc,aer.times_ asc, aer.id_ asc 
-            ) a 
-            left join activity_plan_reward c on a.activity_id_ = c.activity_id_
-            group by a.evaluation_id_,a.user_id_ -->
-            
     </select>
 </mapper>