<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.panzhihua.service_dangjian.dao.NewStriveForDAO">
|
|
|
<!-- 通过用户id 查询人员的排名 -->
|
<select id="getUserRank" resultType="com.panzhihua.common.model.dtos.partybuilding.UserRankDTO">
|
SELECT
|
tab2.community_id,
|
tab2.check_unit_id,
|
tab2.image_url,
|
tab2.user_id,
|
tab2.user_name,
|
tab2.unit_name,
|
tab2.community_name,
|
tab2.amount,
|
tab2.rank
|
FROM(SELECT
|
tab.community_id,
|
tab.check_unit_id,
|
tab.image_url,
|
tab.user_id,
|
tab.user_name,
|
tab.unit_name,
|
tab.community_name,
|
tab.amount,
|
(@row_number:=@row_number+1) AS rank
|
FROM (SELECT
|
cpm.community_id as community_id,
|
cpm.check_unit_id as check_unit_id,
|
su.image_url as image_url,
|
cpm.user_id as user_id,
|
cpm.`name` as user_name,
|
cpcu.`name` as unit_name,
|
ca.`name` as community_name,
|
IFNULL(SUM(caiu.integral_sum),0) as amount
|
FROM com_pb_member as cpm
|
LEFT JOIN com_pb_check_unit as cpcu on cpcu.id=cpm.check_unit_id
|
LEFT JOIN sys_user as su on su.user_id=cpm.user_id
|
LEFT JOIN com_act as ca on ca.community_id = cpm.community_id
|
LEFT JOIN com_act_integral_user as caiu on cpm.user_id=caiu.user_id and cpm.community_id=caiu.community_id
|
WHERE cpm.check_unit_id=(SELECT check_unit_id FROM com_pb_member WHERE user_id=#{userId} limit 1)
|
GROUP BY cpm.user_id
|
order by amount desc,user_id desc) as tab
|
,(SELECT @row_number:=0) AS t) tab2
|
WHERE tab2.user_id =#{userId}
|
</select>
|
|
<!-- 查询人员的排名 -->
|
<select id="getUserRankList" resultType="com.panzhihua.common.model.dtos.partybuilding.UserRankDTO">
|
SELECT
|
tab.community_id,
|
tab.check_unit_id,
|
tab.image_url,
|
tab.user_id,
|
tab.user_name,
|
tab.unit_name,
|
tab.community_name,
|
tab.amount,
|
(@row_number:=@row_number+1) AS rank
|
FROM (SELECT
|
cpm.community_id as community_id,
|
cpm.check_unit_id as check_unit_id,
|
su.image_url as image_url,
|
cpm.user_id as user_id,
|
cpm.`name` as user_name,
|
cpcu.`name` as unit_name,
|
ca.`name` as community_name,
|
IFNULL(SUM(caiu.integral_sum),0) as amount
|
FROM com_pb_member as cpm
|
LEFT JOIN com_pb_check_unit as cpcu on cpcu.id=cpm.check_unit_id
|
LEFT JOIN sys_user as su on su.user_id=cpm.user_id
|
LEFT JOIN com_act as ca on ca.community_id = cpm.community_id
|
LEFT JOIN com_act_integral_user as caiu on cpm.user_id=caiu.user_id and cpm.community_id=caiu.community_id
|
WHERE cpm.check_unit_id=(SELECT check_unit_id FROM com_pb_member WHERE user_id=#{userId} limit 1)
|
GROUP BY cpm.user_id
|
order by amount desc,user_id desc) as tab
|
,(SELECT @row_number:=0) AS t
|
</select>
|
|
<select id="getAllintegral" resultType="String">
|
SELECT
|
SUM(integral_sum) as amount
|
FROM
|
com_act_integral_user
|
<where>
|
1=1
|
<if test="userIds !=null ">
|
and user_id in
|
<foreach collection="userIds" item="ids" index="index"
|
open="(" close=")" separator=",">
|
#{ids}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
|
<select id="getPartyMember" resultType="String">
|
SELECT
|
cpm.user_id
|
FROM com_pb_member as cpm
|
WHERE cpm.check_unit_id=(SELECT check_unit_id FROM com_pb_member WHERE user_id=#{userId})
|
</select>
|
|
|
|
</mapper>
|