gongzuming
2024-09-19 a768dc3daa04d35fedfbe75c0a59b9b2545b85c4
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
<?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.mzl.flower.mapper.member.MemberGrowthRecordMapper">
 
    <select id="queryPage" resultType="com.mzl.flower.dto.response.member.MemberGrowthRecordVO">
        select * from t_member_growth_record t where t.deleted= 0
        <if test="dto.type != null and dto.type != ''">
            and t.type = #{dto.type}
        </if>
        <if test="dto.source != null and dto.source != ''">
            and t.source = #{dto.source}
        </if>
        <if test="dto.startRecordDate!=null ">
            <![CDATA[
               AND t.create_time >= #{dto.startRecordDate}
            ]]>
        </if>
        <if test="dto.endRecordDate!=null ">
            <![CDATA[
               AND t.create_time <= #{dto.endRecordDate}
            ]]>
        </if>
        <if test="dto.userId != null and dto.userId != ''">
            and t.user_id = #{dto.userId}
        </if>
        order by t.update_time desc
    </select>
 
    <select id="queryUserPage" resultType="com.mzl.flower.dto.response.member.UserGrowthRecordVO">
        SELECT c.name as nickName, c.level_id as levelId, t.tel, t.id as userId, m.name AS levelName, IFNULL(SUM(mg.growth), 0) AS sumGrowthValue
        FROM t_customer_info c
                 LEFT JOIN t_user t ON c.user_id = t.id
                 LEFT JOIN t_member m ON c.level_id = m.id
                 LEFT JOIN (SELECT user_id, SUM(growth) AS growth
                            FROM t_member_growth_record
                            WHERE deleted = 0
                            GROUP BY user_id) mg ON c.user_id = mg.user_id
        WHERE c.deleted = 0
        <if test="dto.nickName!= null and dto.nickName != ''">
            AND c.name LIKE CONCAT('%',#{dto.nickName},'%')
        </if>
        <if test="dto.tel!= null and dto.tel != ''">
            and t.tel like CONCAT('%',#{dto.tel},'%')
        </if>
        GROUP BY c.id
        order by c.update_time desc
    </select>
</mapper>