CustomerMapper.xml
9.54 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?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.fw.valhalla.dao.mapper.CustomerMapper">
<select
id="getAppPageList"
resultType="cn.fw.valhalla.domain.vo.customer.CustomerListVO"
parameterType="cn.fw.valhalla.domain.query.CustomerQueryVO"
>
SELECT
t1.id, name AS ownerName, t1.car_image, t1.plate_no, t1.cus_level, t1.frame_no,
CONCAT_WS(' ', NULLIF(t1.brand_name, ''), NULLIF(t1.series_name, ''), NULLIF(t1.spec_name, '')) AS carName,
t1.tags
FROM customer t1 left join customer_base_info t2 on t1.base_id = t2.id
<where>
t1.yn = 1
<if test="condition.keyword != null and condition.keyword !='' ">
and (t2.`name` like concat('%', #{condition.keyword}, '%')
or t1.`plate_no` like concat('%', #{condition.keyword}, '%')
or t1.`frame_no` like concat('%', #{condition.keyword}, '%'))
</if>
<if test="condition.regionCode !=null and condition.regionCode != ''">
and t2.city_code like concat(#{condition.regionCode}, '%')
</if>
<if test="condition.companyName != null and condition.companyName != ''">
and t2.`company_name` like concat('%', #{condition.keyword}, '%')
</if>
<if test="condition != null and condition.levels != null and condition.levels.size > 0">
and t1.cus_level IN
<foreach collection="condition.levels" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="condition != null and condition.tags != null and condition.tags.size() > 0">
and
<foreach collection="condition.tags" item="item" separator="or" open="(" close=")">
t1.tags LIKE concat('%', #{item}, '%')
</foreach>
</if>
<if test="condition.brandId !=null">
and t1.brand_id = #{condition.brandId}
</if>
<if test="condition.seriesId !=null">
and t1.series_id = #{condition.seriesId}
</if>
<if test="condition.specId !=null">
and t1.spec_id = #{condition.specId}
</if>
<if test="condition.gender !=null">
and t2.gender = #{condition.gender}
</if>
<if test="condition.cusType !=null">
and t2.cus_type = #{condition.cusType}
</if>
<if test="condition.month !=null">
and month(t2.birthday) = #{condition.month}
</if>
<if test="condition.endBirthday !=null">
and t2.birthday >= #{condition.endBirthday}
</if>
<if test="condition.startBirthday !=null">
and t2.birthday <= #{condition.startBirthday}
</if>
<if test="condition.leftCreatTime !=null">
and t1.create_time >= #{condition.leftCreatTime}
</if>
<if test="condition.rightCreatTime !=null">
and t1.create_time <= #{condition.rightCreatTime}
</if>
<if test="condition != null and condition.shopIds != null and condition.shopIds.size() > 0">
and t1.shop_id IN
<foreach collection="condition.shopIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
<if test="condition.consultantId !=null">
and t1.adviser_id = #{condition.consultantId}
</if>
<if test="condition != null and condition.customerIdList != null and condition.customerIdList.size > 0">
and t1.id IN
<foreach collection="condition.customerIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
order by t1.create_time desc
limit #{startIndex},#{pageSize};
</select>
<select
id="analyseList"
resultType="cn.fw.valhalla.domain.dto.StammkundeAnalyseDTO"
parameterType="cn.fw.valhalla.domain.query.StammkundeAnalyseQueryVO"
>
select distinct
t1.id customer_id,
t1.plate_no,
t2.contact customer_name,
t2.address,
t2.city_code region_code,
t2.city_name region_name,
t2.lat,
t2.lng
from customer t1 inner join customer_base_info t2 on t1.base_id = t2.id
where t1.yn = 1 and t1.group_id = #{condition.groupId} and t2.city_code is not null
<if test="condition.customerIds !=null">
and t1.id in
<foreach collection="condition.customerIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.shopIds !=null">
and t1.shop_id in
<foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.minLat !=null">
and t2.lat >= #{condition.minLat}
</if>
<if test="condition.maxLat !=null">
and t2.lat <= #{condition.maxLat}
</if>
<if test="condition.minLng !=null">
and t2.lng >= #{condition.minLng}
</if>
<if test="condition.maxLng !=null">
and t2.lng <= #{condition.maxLng}
</if>
</select>
<select
id="queryCustomList"
resultType="cn.fw.valhalla.domain.dto.CustomerDetailDto"
parameterType="cn.fw.valhalla.domain.query.CustomCustomerQuery"
>
select distinct
t1.*,
t2.contact name,
t2.member_id member_id,
t2.mobile
from customer t1 inner join customer_base_info t2 on t1.base_id = t2.id
left join follow_task t3 on t1.id=t3.customer_id and t3.state=1 and t3.type=2
left join follow_task t4 on t1.id=t4.customer_id and t4.state=1 and t4.type=4
where t1.yn = 1 and t1.group_id = #{condition.groupId}
<if test="condition.shopList !=null and condition.shopList.size() != 0">
and t1.shop_id in
<foreach collection="condition.shopList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.excludeCustomerIds !=null and condition.excludeCustomerIds.size() != 0">
and t1.id not in
<foreach collection="condition.excludeCustomerIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.followType !=null and condition.followType==2">
and t3.id is not null
</if>
<if test="condition.followType !=null and condition.followType==4">
and t4.id is not null
</if>
<if test="condition.frameNo !=null">
and t1.frame_no = #{condition.frameNo}
</if>
<if test="condition.andCondition==true">
and (
t1.adviser_id is not null
<if test="condition.minMileage !=null and condition.maxMileage !=null">
<if test="condition.minMileage !=null">
and t1.current_mileage >= #{condition.minMileage}
</if>
<if test="condition.maxMileage !=null">
and t1.current_mileage <= #{condition.maxMileage}
</if>
</if>
<if test="condition.minBuyDate !=null and condition.maxBuyDate !=null">
<if test="condition.minBuyDate !=null">
and t1.buy_date >= #{condition.minBuyDate}
</if>
<if test="condition.maxBuyDate !=null">
and t1.buy_date <= #{condition.maxBuyDate}
</if>
</if>
<if test="condition.level !=null">
and t1.cus_level = #{condition.level}
</if>
)
</if>
<if test="condition.andCondition==false">
and (
t1.adviser_id is not null
<if test="condition.minMileage !=null and condition.maxMileage !=null">
or (
t1.current_mileage is not null
<if test="condition.minMileage !=null">
and t1.current_mileage >= #{condition.minMileage}
</if>
<if test="condition.maxMileage !=null">
and t1.current_mileage <= #{condition.maxMileage}
</if>
)
</if>
<if test="condition.minBuyDate !=null and condition.maxBuyDate !=null">
or (
t1.buy_date is not null
<if test="condition.minBuyDate !=null">
and t1.buy_date >= #{condition.minBuyDate}
</if>
<if test="condition.maxBuyDate !=null">
and t1.buy_date <= #{condition.maxBuyDate}
</if>
)
</if>
<if test="condition.level !=null">
or t1.cus_level = #{condition.level}
</if>
)
</if>
</select>
</mapper>