guohongjin
2024-05-15 5b7639f0bd9e056738ec15100ed0532e965c6cd5
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
<?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.stylefeng.roses.kernel.customer.modular.mapper.CustomerMapper">
 
    <sql id="getWorkerByLineStatusAndPostType">
        toc_customer o
        LEFT JOIN im_user_status ius ON o.customer_id = ius.userid
        <where>
            AND o.status_flag = 1
            <if test="lineStatus != null and lineStatus != ''">
                AND ius.`status` = #{lineStatus}
            </if>
            <if test="postType != null">
                AND FIND_IN_SET( #{postType}, post_types )
            </if>
            <if test="postId != null">
                AND FIND_IN_SET( #{postId}, post_ids )
            </if>
            <if test="workStatus != null">
                AND o.work_status = #{workStatus}
            </if>
        </where>
        GROUP BY o.customer_id
    </sql>
 
    <select id="getWorkerIdByLineStatusAndPostType" resultType="java.lang.Long">
        SELECT customer_id FROM <include refid="getWorkerByLineStatusAndPostType"/>
    </select>
 
    <select id="randomWorkerByLineStatusAndPostNeWorkerId" resultType="java.lang.Long">
        SELECT customer_id FROM toc_customer o
        LEFT JOIN im_user_status ius ON o.customer_id = ius.userid
        <where>
            AND o.status_flag = 1
            <if test="lineStatus != null and lineStatus != ''">
                AND ius.`status` = #{lineStatus}
            </if>
            <if test="postType != null">
                AND FIND_IN_SET( #{postType}, post_types )
            </if>
            <if test="postId != null">
                AND FIND_IN_SET( #{postId}, post_ids )
            </if>
            <if test="workStatus != null">
                AND o.work_status = #{workStatus}
            </if>
            <if test="mentalAnalysisStatus != null">
                AND o.mental_analysis_status = #{mentalAnalysisStatus}
            </if>
            <if test="eqWorkerIdList != null and eqWorkerIdList.size != 0">
                AND o.customer_id IN
                <foreach collection="eqWorkerIdList" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="neWorkerIdList != null and neWorkerIdList.size != 0">
                AND o.customer_id NOT IN
                <foreach collection="neWorkerIdList" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        GROUP BY o.customer_id
    </select>
 
    <select id="getWorkerListByLineStatusAndPostType" resultType="cn.stylefeng.roses.kernel.customer.modular.entity.Customer">
        SELECT * FROM <include refid="getWorkerByLineStatusAndPostType"/>
    </select>
 
    <select id="getCustomerPage" resultType="cn.stylefeng.roses.kernel.customer.api.pojo.UserManagePageResponseDTO">
        SELECT
            o.*,
            o1.nick_name AS classWorkerName,
            o2.nick_name AS consultWorkerName
        FROM toc_customer o
        LEFT JOIN toc_customer o1 ON o1.customer_id = o.class_worker_id
        LEFT JOIN toc_customer o2 ON o2.customer_id = o.consult_worker_id
        <where>
            o.status_flag <![CDATA[ <> ]]> 3
            <if test="userType != null">
                AND o.user_type = #{userType}
            </if>
            <if test="id != null">
                AND o.customer_id = #{id}
            </if>
            <if test="name != null and name != ''">
                AND o.nick_name LIKE CONCAT('%', #{name}, '%')
            </if>
            <if test="telephone != null and telephone != ''">
                AND o.telephone LIKE CONCAT('%', #{telephone}, '%')
            </if>
            <if test="statusFlag != null">
                AND o.status_flag = #{statusFlag}
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
</mapper>