|
|
@ -677,4 +677,156 @@ WHERE 1 = 1 |
|
|
|
u.register_time desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectListUserPoints" resultType="com.elink.esua.epdc.dto.UserPointsDTO"> |
|
|
|
select * from( |
|
|
|
SELECT u.id, |
|
|
|
u.NICKNAME, |
|
|
|
u.REAL_NAME, |
|
|
|
u.MOBILE, |
|
|
|
u.REGISTER_TIME, |
|
|
|
ADDRESS, |
|
|
|
ug.ALL_DEPT_NAMES AS myGridName, |
|
|
|
u.DEL_FLAG, |
|
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.GRID_ID, u.DEPT_ID) as GRID_ID, |
|
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.PARENT_DEPT_IDS, u.PARENT_DEPT_IDS) as PARENT_DEPT_IDS, |
|
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), ug.ALL_DEPT_IDS, u.ALL_DEPT_IDS) as ALL_DEPT_IDS, |
|
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), substring_index(ug.ALL_DEPT_NAMES, '-', -1), substring_index(u.ALL_DEPT_NAMES, '-', -1) ) as gridName, |
|
|
|
IF((u.DEPT_ID is null or u.DEPT_ID = '0'), substring_index(substring_index(ug.ALL_DEPT_NAMES,'-',-2), '-', 1) , substring_index(substring_index(u.ALL_DEPT_NAMES,'-',-2), '-', 1) ) as communityName, |
|
|
|
u.POINTS, |
|
|
|
u.POINTS_TOTLE |
|
|
|
FROM epdc_user u |
|
|
|
LEFT JOIN ( select * from (select * from epdc_user_grid_relation order by CREATED_TIME)t group by t.USER_ID) ug ON u.ID = ug.USER_ID |
|
|
|
)ug |
|
|
|
where |
|
|
|
ug.del_flag = '0' |
|
|
|
<if test="realName != '' and realName != null">and ug.real_name like '%${realName}%' or ug.nickname like '%${realName}%'</if> |
|
|
|
<if test="mobile != '' and mobile != null">and ug.mobile like '%${mobile}%'</if> |
|
|
|
<if test="streetId != '' and streetId != null"> |
|
|
|
AND (find_in_set(#{streetId},ug.PARENT_DEPT_IDS) |
|
|
|
OR find_in_set(#{streetId},ug.ALL_DEPT_IDS)) |
|
|
|
</if> |
|
|
|
<if test="communityId != '' and communityId != null"> |
|
|
|
AND (find_in_set(#{communityId},ug.PARENT_DEPT_IDS) |
|
|
|
OR find_in_set(#{communityId},ug.ALL_DEPT_IDS)) |
|
|
|
</if> |
|
|
|
<if test="gridId != '' and gridId != null"> |
|
|
|
and (ug.grid_id = #{gridId} |
|
|
|
OR find_in_set(#{gridId},ug.ALL_DEPT_IDS)) |
|
|
|
</if> |
|
|
|
<if test="deptIdList!=null and deptIdList.size()>0"> |
|
|
|
AND ug.GRID_ID IN |
|
|
|
<foreach collection="deptIdList" item="deptId" index="index" open="(" close=")" separator=","> |
|
|
|
#{deptId} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
GROUP BY |
|
|
|
ug.ID |
|
|
|
ORDER BY |
|
|
|
ug.POINTS desc, |
|
|
|
ug.register_time desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectListUsersRanking" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAppRankingUserDTO"> |
|
|
|
SELECT |
|
|
|
u.ID userId, |
|
|
|
u.REAL_NAME realName, |
|
|
|
u.POINTS points |
|
|
|
FROM |
|
|
|
epdc_user u |
|
|
|
WHERE |
|
|
|
u.DEL_FLAG = 0 AND u.STATE != 0 |
|
|
|
<if test="allUserIdByDept!=null and allUserIdByDept.size()>0"> |
|
|
|
and u.ID in |
|
|
|
<foreach collection="allUserIdByDept" index="index" item="userId" open="(" separator="," close=")"> |
|
|
|
#{userId} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
ORDER BY u.POINTS DESC, u.CREATED_TIME DESC |
|
|
|
LIMIT #{pageIndex}, #{pageSize} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectListUsersGradeRanking" resultType="com.elink.esua.epdc.dto.epdc.result.UsersGradeRankingDTO"> |
|
|
|
SELECT |
|
|
|
userGrade.userId, |
|
|
|
userGrade.nickName, |
|
|
|
userGrade.grade |
|
|
|
FROM( |
|
|
|
SELECT |
|
|
|
u.ID userId, |
|
|
|
u.REAL_NAME nickName, |
|
|
|
CASE |
|
|
|
WHEN IFNULL(u.POINTS_TOTLE,0) <= 0 THEN 0 |
|
|
|
ELSE |
|
|
|
IFNULL(FLOOR(IFNULL(u.POINTS_TOTLE,0) / IFNULL(g.POINTS,0) * IFNULL(g.GRADE,0)),0) |
|
|
|
END grade, |
|
|
|
u.CREATED_TIME |
|
|
|
FROM |
|
|
|
epdc_user u |
|
|
|
left join epdc_points_grade g ON 1=1 AND g.DEL_FLAG = 0 |
|
|
|
WHERE |
|
|
|
u.DEL_FLAG = '0' AND u.STATE != '0' |
|
|
|
<if test="streetId != null and streetId != '' "> |
|
|
|
AND instr(u.PARENT_DEPT_IDS , #{streetId} ) > 0 |
|
|
|
</if> |
|
|
|
) userGrade |
|
|
|
ORDER BY userGrade.grade DESC, userGrade.CREATED_TIME DESC |
|
|
|
LIMIT #{pageIndex}, #{pageSize} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectCurrentUserRanking" resultType="com.elink.esua.epdc.dto.epdc.result.EpdcAppRankingUserDTO"> |
|
|
|
SELECT |
|
|
|
userRanking.rank, |
|
|
|
userRanking.points |
|
|
|
FROM( |
|
|
|
SELECT |
|
|
|
(@i:=@i+1) rank, |
|
|
|
u.ID userId, |
|
|
|
IFNULL(u.POINTS, 0) points, |
|
|
|
GROUP_CONCAT(u.ID SEPARATOR ',') tjid |
|
|
|
FROM |
|
|
|
epdc_user u ,(select @i:=0) t1 |
|
|
|
WHERE |
|
|
|
u.DEL_FLAG = 0 AND u.STATE != 0 |
|
|
|
<if test="allUserIdByDept!=null and allUserIdByDept.size()>0"> |
|
|
|
and u.ID in |
|
|
|
<foreach collection="allUserIdByDept" index="index" item="userId" open="(" separator="," close=")"> |
|
|
|
#{userId} |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
GROUP BY IFNULL(u.POINTS, 0) |
|
|
|
ORDER BY IFNULL(u.POINTS, 0) DESC |
|
|
|
) userRanking |
|
|
|
WHERE instr(userRanking.tjid , #{userId}) > 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectCurrentUserGradeRanking" resultType="com.elink.esua.epdc.dto.epdc.result.UsersGradeRankingDTO"> |
|
|
|
SELECT |
|
|
|
userRanking.rank, |
|
|
|
userRanking.grade |
|
|
|
FROM( |
|
|
|
SELECT |
|
|
|
(@i:=@i+1) rank, |
|
|
|
tab.USER_ID userId, |
|
|
|
GROUP_CONCAT(tab.USER_ID SEPARATOR ',') pdtj, -- 有展示上限,所以不用该字段 删选名次 |
|
|
|
tab.POINTS_TOTLE, |
|
|
|
tab.grade |
|
|
|
FROM( |
|
|
|
SELECT |
|
|
|
u.ID USER_ID, |
|
|
|
u.POINTS_TOTLE, |
|
|
|
CASE |
|
|
|
WHEN IFNULL(u.POINTS_TOTLE,0) <= 0 THEN 0 |
|
|
|
ELSE |
|
|
|
IFNULL(FLOOR(IFNULL(u.POINTS_TOTLE,0) / IFNULL(g.POINTS,0) * IFNULL(g.GRADE,0)),0) |
|
|
|
END grade |
|
|
|
FROM epdc_user u |
|
|
|
LEFT JOIN epdc_points_grade g ON 1=1 AND g.DEL_FLAG = '0' |
|
|
|
WHERE u.DEL_FLAG = '0' |
|
|
|
AND instr(u.PARENT_DEPT_IDS , #{streetId} ) > 0 |
|
|
|
) tab ,(select @i:=0) t1 |
|
|
|
GROUP BY tab.grade |
|
|
|
ORDER BY tab.grade DESC |
|
|
|
) userRanking |
|
|
|
WHERE userRanking.POINTS_TOTLE = #{pointsTotle} |
|
|
|
</select> |
|
|
|
</mapper> |
|
|
|