101captain
2021-12-23 5a8a90c095280fbd2106869ecd2bad10e01a57a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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_community.dao.ComActIntegralUserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActIntegralUserDO">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="community_id" property="communityId" />
        <result column="integral_sum" property="integralSum" />
        <result column="integral_available_sum" property="integralAvailableSum" />
        <result column="integral_frozen_sum" property="integralFrozenSum" />
        <result column="integral_party" property="integralParty" />
        <result column="integral_available_party" property="integralAvailableParty" />
        <result column="integral_frozen_party" property="integralFrozenParty" />
        <result column="integral_volunteer" property="integralVolunteer" />
        <result column="integral_available_volunteer" property="integralAvailableVolunteer" />
        <result column="integral_frozen_volunteer" property="integralFrozenVolunteer" />
        <result column="integral_resident" property="integralResident" />
        <result column="integral_available_resident" property="integralAvailableResident" />
        <result column="integral_frozen_resident" property="integralFrozenResident" />
        <result column="create_at" property="createAt" />
        <result column="update_at" property="updateAt" />
        <result column="status" property="status" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, community_id, integral_sum, integral_available_sum, integral_frozen_sum, integral_party, integral_available_party, integral_frozen_party, integral_volunteer, integral_available_volunteer, integral_frozen_volunteer, integral_resident, integral_available_resident, integral_frozen_resident, create_at, update_at
    </sql>
 
    <select id="getIntegralUserListApplets" resultType="com.panzhihua.common.model.vos.community.integral.ComActIntegralUserListVO">
        SELECT
            caiu.integral_sum as amount,
            caiu.community_id,
            ca.`name` AS communityName
        FROM
            com_act_integral_user AS caiu
            LEFT JOIN com_act AS ca ON ca.community_id = caiu.community_id
        WHERE
            caiu.user_id = #{userId}
    </select>
 
    <select id="getIntegralUserRank" resultType="com.panzhihua.common.model.vos.community.integral.IntegralUserRankVO">
        SELECT
            *
        FROM
            (
            SELECT
                t1.user_id,
                @rank := @rank + 1 AS rank
            FROM
                (
                SELECT
                    caiu.user_id,
                    caiu.integral_sum
                FROM
                    com_act_integral_user as caiu
                    left join sys_user as su on su.user_id = caiu.user_id
                WHERE
                    caiu.community_id = #{communityId}
                ORDER BY
                    caiu.integral_sum DESC,su.create_at asc
                 ) AS t1,
                ( SELECT @rank := 0 ) AS t2
            ) AS m
        WHERE
            user_id = #{userId}
    </select>
 
    <select id="getIntegralCommunityRankApplets" parameterType="com.panzhihua.common.model.dtos.community.integral.ComActIntegralCommunityRankDTO"
            resultType="com.panzhihua.common.model.vos.community.integral.ComActIntegralCommunityRankVO">
        SELECT
            su.nick_name,
            su.image_url,
            <if test="communityRankDTO.type == 1">
                caiu.integral_sum as amount,
            </if>
            <if test="communityRankDTO.type == 2">
                caiu.integral_resident as amount,
            </if>
            <if test="communityRankDTO.type == 3">
                caiu.integral_volunteer as amount,
            </if>
            <if test="communityRankDTO.type == 4">
                caiu.integral_party as amount,
            </if>
            su.is_partymember,
            su.is_volunteer
        FROM
            com_act_integral_user AS caiu
            LEFT JOIN sys_user AS su ON su.user_id = caiu.user_id
        WHERE
            caiu.community_id = #{communityRankDTO.communityId}
            <if test="communityRankDTO.type == 3">
                and su.is_volunteer = 1
            </if>
            <if test="communityRankDTO.type == 4">
                and su.is_partymember = 1
            </if>
 
            <if test="communityRankDTO.type == 1">
                order by caiu.integral_sum desc,su.create_at asc
            </if>
            <if test="communityRankDTO.type == 2">
                order by caiu.integral_resident desc,su.create_at asc
            </if>
            <if test="communityRankDTO.type == 3">
                order by caiu.integral_volunteer desc,su.create_at asc
            </if>
            <if test="communityRankDTO.type == 4">
                order by caiu.integral_party desc,su.create_at asc
            </if>
    </select>
 
    <select id="getTaskActivityPeopleList" resultType="com.panzhihua.common.model.vos.community.integral.admin.ComActActivityPeopleVO">
        select caas.user_id,caas.activity_id,caa.community_id,caas.is_volunteer from com_act_act_sign as caas left join com_act_activity as caa on caa.id = caas.activity_id where caa.id = #{activityId}
    </select>
 
</mapper>