|
|
@ -81,24 +81,29 @@ |
|
|
|
<select id="selectListPointsRanking" resultType="com.elink.esua.epdc.dto.result.EpdcAppPointsRankingResultDTO"> |
|
|
|
SELECT |
|
|
|
tab.USER_ID userId, |
|
|
|
tab.NICKNAME nickName, |
|
|
|
( |
|
|
|
SELECT NICKNAME |
|
|
|
FROM epdc_points_logs |
|
|
|
WHERE tab.USER_ID = USER_ID |
|
|
|
ORDER BY CREATED_TIME DESC |
|
|
|
limit 0,1 |
|
|
|
) nickName, |
|
|
|
(tab.totalPointsAdd - tab.totalPointsDeducted) points |
|
|
|
FROM( |
|
|
|
SELECT |
|
|
|
USER_ID, |
|
|
|
NICKNAME, |
|
|
|
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted, |
|
|
|
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd |
|
|
|
FROM epdc_points_logs |
|
|
|
WHERE DEL_FLAG = 0 |
|
|
|
<if test="rankingType != null and rankingType == 0"> |
|
|
|
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now()) |
|
|
|
</if> |
|
|
|
<if test="rankingType != null and rankingType == 1"> |
|
|
|
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) |
|
|
|
</if> |
|
|
|
GROUP BY USER_ID |
|
|
|
SELECT |
|
|
|
USER_ID, |
|
|
|
SUM(case when OPERATION_TYPE = 0 then IFNULL(points,0) else 0 end) totalPointsDeducted, |
|
|
|
SUM(case when OPERATION_TYPE = 1 then IFNULL(points,0) else 0 end) totalPointsAdd |
|
|
|
FROM epdc_points_logs |
|
|
|
WHERE DEL_FLAG = 0 |
|
|
|
<if test="rankingType != null and rankingType == 0"> |
|
|
|
AND YEARWEEK(date_format(OPERATION_TIME,'%Y-%m-%d')) = YEARWEEK(now()) |
|
|
|
</if> |
|
|
|
<if test="rankingType != null and rankingType == 1"> |
|
|
|
AND DATE_FORMAT( OPERATION_TIME, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) |
|
|
|
</if> |
|
|
|
GROUP BY USER_ID |
|
|
|
) tab ORDER BY (tab.totalPointsAdd - tab.totalPointsDeducted) DESC |
|
|
|
LIMIT #{pageIndex}, #{pageSize} |
|
|
|
</select> |
|
|
|
</mapper> |
|
|
|
</mapper> |
|
|
|