mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
121
122
123
<?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.ComActIntegralUserTradeMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActIntegralUserTradeDO">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="integral_id" property="integralId" />
        <result column="community_id" property="communityId" />
        <result column="service_id" property="serviceId" />
        <result column="service_type" property="serviceType" />
        <result column="amount" property="amount" />
        <result column="change_type" property="changeType" />
        <result column="remark" property="remark" />
        <result column="identity_type" property="identityType" />
        <result column="create_at" property="createAt" />
        <result column="create_by" property="createBy" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, integral_id, community_id, service_id, service_type, amount, change_type, remark, identity_type, create_at, create_by
    </sql>
 
    <select id="getIntegralCount" resultType="Integer" parameterType="com.panzhihua.common.model.dtos.community.integral.ComActIntegralCountDTO">
        select count(id) from com_act_integral_user_trade where community_id = ${integralCountDTO.communityId} and service_type = #{integralCountDTO.serviceType} and user_id = #{integralCountDTO.userId} and change_type = #{integralCountDTO.type} and create_at between #{integralCountDTO.startTime} and #{integralCountDTO.endTime}
    </select>
 
    <select id="getIntegralCommunityTradeApplets" parameterType="com.panzhihua.common.model.dtos.community.integral.ComActIntegralCommunityRankDTO"
            resultType="com.panzhihua.common.model.vos.community.integral.ComActIntegralCommunityTradeVO">
        SELECT
            caiut.id,
            caiut.amount,
            caiut.service_type,
            caiut.remark,
            caiut.create_at,
            caiut.change_type,
            caiut.identity_type,
            ca.`name` AS communityName
        FROM
            com_act_integral_user_trade AS caiut
            LEFT JOIN com_act AS ca ON ca.community_id = caiut.community_id
            <where>
                1=1
                <if test="communityTradeDTO.changeType != null">
                    AND caiut.change_type = #{communityTradeDTO.changeType}
                </if>
                <if test="communityTradeDTO.communityId != null">
                    and caiut.community_id = ${communityTradeDTO.communityId}
                </if>
 
                <if test="communityTradeDTO.userId != null">
                    and caiut.user_id = #{communityTradeDTO.userId}
                </if>
 
                <if test="communityTradeDTO.identityType != null">
                    and caiut.identity_type = #{communityTradeDTO.identityType}
                </if>
            </where>
            order by caiut.create_at desc
    </select>
 
    <select id="getIntegralTradeListAdmin" parameterType="com.panzhihua.common.model.dtos.community.integral.admin.PageComActIntegralTradeDTO"
            resultType="com.panzhihua.common.model.vos.community.integral.admin.ComActIntegralUserTradeAdminVO">
        SELECT
            caiut.id,
            su.nick_name,
            su.phone,
            su.`name`,
            su.is_volunteer,
            su.is_partymember,
            caiut.amount,
            caiut.identity_type,
            caiut.remark,
            caiut.create_at
        FROM
            com_act_integral_user_trade AS caiut
            LEFT JOIN sys_user AS su ON su.user_id = caiut.user_id
            <where>
                <if test="integralRuleDTO.communityId != null">
                    and caiut.community_id = ${integralRuleDTO.communityId}
                </if>
                <if test="integralRuleDTO.identityType != null">
                    and caiut.identity_type = #{integralRuleDTO.identityType}
                </if>
                <if test="integralRuleDTO.name != null and integralRuleDTO.name != &quot;&quot;">
                    and (su.nick_name like concat (#{integralRuleDTO.name},'%') or su.name like concat (#{integralRuleDTO.name},'%'))
                </if>
                <if test="integralRuleDTO.phone != null and integralRuleDTO.phone != &quot;&quot;">
                    and su.phone = #{integralRuleDTO.phone}
                </if>
                <if test="integralRuleDTO.userIdentity != null and integralRuleDTO.userIdentity == 2">
                    and su.is_partymember = 1
                </if>
                <if test="integralRuleDTO.userIdentity != null and integralRuleDTO.userIdentity == 3">
                    and su.is_volunteer = 1
                </if>
            </where>
            order by caiut.create_at desc
    </select>
 
    <select id="getUserInfo" resultType="com.panzhihua.common.model.vos.community.integral.admin.IntegralUserVO">
        select user_id,phone,nick_name,id_card,`name`,`status`,is_volunteer,is_partymember,create_at from sys_user where user_id = #{userId}
    </select>
    <select id="getUserIntegralDetail"
            resultType="com.panzhihua.common.model.vos.community.integral.IntegralTradeVO">
        SELECT
            caiut.id,
            caiut.amount,
            caiut.service_type,
            caiut.service_id,
            caiut.remark,
            caiut.create_at,
            caiut.change_type,
            caiut.identity_type,
            ca.`name` AS communityName
        FROM
        com_act_integral_user_trade AS caiut
        LEFT JOIN com_act AS ca ON ca.community_id = caiut.community_id
        WHERE caiut.id = #{id}
    </select>
</mapper>