zxl
4 天以前 2701dca44e1972afe9956ced2f949d2998c1bb4b
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
<?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="cn.lili.modules.lmk.mapper.CustomerMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.lili.modules.member.entity.vo.MemberVO">
        <id property="id" column="id"/>
 
        <!-- 基础字段映射 -->
        <result property="username" column="username"/>
        <result property="nickName" column="nick_name"/>
        <result property="sex" column="sex"/>
        <result property="birthday" column="birthday"/>
        <result property="regionId" column="region_id"/>
        <result property="region" column="region"/>
        <result property="mobile" column="mobile"/>
        <result property="point" column="point"/>
        <result property="totalPoint" column="total_point"/>
        <result property="face" column="face"/>
        <result property="disabled" column="disabled"/>
        <result property="haveStore" column="have_store"/>
        <result property="storeId" column="store_id"/>
        <result property="openId" column="open_id"/>
        <result property="clientEnum" column="client_enum"/>
        <result property="lastLoginDate" column="last_login_date"/>
        <result property="gradeId" column="grade_id"/>
        <result property="experience" column="experience"/>
        <result property="createTime" column="create_time"/>
        <result property="blackId" column="blackId"/>
        <collection property="customerTagList"  ofType="cn.lili.modules.lmk.domain.vo.CustomerTagVO"
                    select="selectTagByMemberId"
                    column="id"
        />
    </resultMap>
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            LM.*
        FROM
            li_member LM
        LEFT JOIN lmk_customer_black LMK ON LM.id = LMK.user_id and LMK.delete_flag = 0
        <where>
        <!-- 用户名模糊查询 -->
        <if test="query.username != null and query.username != ''">
            AND LM.username LIKE CONCAT('%', #{query.username}, '%')
        </if>
 
        <!-- 昵称模糊查询 -->
        <if test="query.nickName != null and query.nickName != ''">
            AND LM.nick_name LIKE CONCAT('%', #{query.nickName}, '%')
        </if>
 
        <!-- 手机号码精确查询 -->
        <if test="query.mobile != null and query.mobile != ''">
            AND LM.mobile = #{query.mobile}
        </if>
 
        <!-- 会员状态转 -->
        <if test="query.disabled != null and query.disabled != ''">
            AND LM.disabled = #{query.disabled}
        </if>
 
        <!-- 商铺id -->
        <if test="query.storeId != null and query.storeId != ''">
            AND LM.store_id = #{query.storeId}
        </if>
            AND LM.delete_flag = 0
        </where>
        ORDER BY lm.create_time DESC
    </select>
 
    <select id="selectTagByMemberId" resultType="cn.lili.modules.lmk.domain.vo.CustomerTagVO">
        SELECT
            LCT.id,
            LCT.tag_name,
            LCT.create_type
        FROM lmk_customer_tag_ref LCTR
            LEFT JOIN lmk_customer_tag  LCT
                ON LCTR.customer_tag_id = LCT.id
        WHERE LCTR.customer_id =#{id}
    </select>
 
 
</mapper>