xuhy
2 天以前 62b287b8fc5d0b4d3ac3cfd5b748f256b8693505
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?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.ruoyi.system.mapper.TCrmChangePointsMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TCrmChangePoints">
        <id column="id" property="id" />
        <result column="branch_salesperson_id" property="branchSalespersonId" />
        <result column="procurement_id" property="procurementId" />
        <result column="exchange_id" property="exchangeId" />
        <result column="user_type" property="userType" />
        <result column="change_type" property="changeType" />
        <result column="change_reason" property="changeReason" />
        <result column="change_value" property="changeValue" />
        <result column="remarks" property="remarks" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, branch_salesperson_id,procurement_id,exchange_id, user_type, change_type,change_reason, change_value, remarks, create_time, update_time, create_by, update_by, disabled
    </sql>
    <select id="pageListBranch" resultType="com.ruoyi.system.vo.TCrmChangePointsVO">
        select
            tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
            tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
            tccp.update_by, tccp.disabled,tcb.branch_name as branchName
        from t_crm_change_points tccp
        left join t_crm_branch tcb on tcb.id = tccp.branch_salesperson_id
        <where>
            <if test="query.branchName != null and query.branchName != ''">
                and tcb.branch_name like concat('%',#{query.branchName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 1
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
    <select id="pageListSalesperson" resultType="com.ruoyi.system.vo.TCrmChangePointsVO">
        select
            tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
            tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
            tccp.update_by, tccp.disabled,tcs.salesperson_name as salespersonName
        from t_crm_change_points tccp
        left join t_crm_salesperson tcs on tcs.id = tccp.branch_salesperson_id
        <where>
            <if test="query.salespersonName != null and query.salespersonName != ''">
                and tcs.salesperson_name like concat('%',#{query.salespersonName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 2
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
    <select id="pageListClinic" resultType="com.ruoyi.system.vo.TCrmChangePointsVO">
        select
            tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
            tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
            tccp.update_by, tccp.disabled,tcc.clinic_name as clinicName
        from t_crm_change_points tccp
        left join t_crm_clinic tcc on tcc.id = tccp.branch_salesperson_id
        <where>
            <if test="query.clinicName != null and query.clinicName != ''">
                and tcc.clinic_name like concat('%',#{query.clinicName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 3
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
    <select id="pageListBranchExport" resultType="com.ruoyi.system.export.TCrmChangePointsBranchExport">
        select
        tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
        tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
        tccp.update_by, tccp.disabled,tcb.branch_name as branchName
        from t_crm_change_points tccp
        left join t_crm_branch tcb on tcb.id = tccp.branch_salesperson_id
        <where>
            <if test="query.branchName != null and query.branchName != ''">
                and tcb.branch_name like concat('%',#{query.branchName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 1
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
    <select id="pageListSalespersonExport"
            resultType="com.ruoyi.system.export.TCrmChangePointsSalespersonExport">
        select
        tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
        tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
        tccp.update_by, tccp.disabled,tcs.salesperson_name as salespersonName
        from t_crm_change_points tccp
        left join t_crm_salesperson tcs on tcs.id = tccp.branch_salesperson_id
        <where>
            <if test="query.salespersonName != null and query.salespersonName != ''">
                and tcs.salesperson_name like concat('%',#{query.salespersonName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 2
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
    <select id="pageListClinicExport" resultType="com.ruoyi.system.export.TCrmChangePointsClinicExport">
        select
        tccp.id, tccp.branch_salesperson_id,tccp.procurement_id,tccp.exchange_id, tccp.user_type, tccp.change_type,
        tccp.change_reason, tccp.change_value, tccp.remarks, tccp.create_time, tccp.update_time, tccp.create_by,
        tccp.update_by, tccp.disabled,tcc.clinic_name as clinicName
        from t_crm_change_points tccp
        left join t_crm_clinic tcc on tcc.id = tccp.branch_salesperson_id
        <where>
            <if test="query.clinicName != null and query.clinicName != ''">
                and tcc.clinic_name like concat('%',#{query.clinicName},'%')
            </if>
            <if test="query.changeType != null">
                and tccp.change_type = #{query.changeType}
            </if>
            <if test="query.changeReason != null">
                and tccp.change_reason = #{query.changeReason}
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND tccp.create_time &gt;= #{query.startTime}
                AND tccp.create_time &lt;= #{query.endTime}
            </if>
            AND tccp.user_type = 3
            AND tccp.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tccp.create_time DESC
    </select>
 
</mapper>