AccountSetMapper.xml
14.2 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<?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.runsa.crmapp.common.mapper.AccountSetMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="ACT_ID" property="actId" jdbcType="BIGINT" />
<result column="ACT_CODE" property="actCode" jdbcType="VARCHAR" />
<result column="ACT_NAME" property="actName" jdbcType="VARCHAR" />
<result column="PTF_ID" property="ptfId" jdbcType="BIGINT" />
<result column="ENABLE" property="enable" jdbcType="BIT" />
<result column="ACT_DESC" property="actDesc" jdbcType="VARCHAR" />
<result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
<result column="REC_USER" property="recUser" jdbcType="BIGINT" />
<result column="ACT_TYPE" property="actType" jdbcType="VARCHAR" />
<result column="brId" property="brId" jdbcType="VARCHAR" />
<result column="brName" property="brName" jdbcType="VARCHAR" />
<result column="ptfName" property="ptfName" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="BaseResultMap2" type="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="ACT_ID" property="actId" jdbcType="BIGINT" />
<result column="ACT_CODE" property="actCode" jdbcType="VARCHAR" />
<result column="ACT_NAME" property="actName" jdbcType="VARCHAR" />
<result column="PTF_ID" property="ptfId" jdbcType="BIGINT" />
<result column="CHL_ID" property="msgChannel" jdbcType="BIGINT" />
<result column="ENABLE" property="enable" jdbcType="BIT" />
<result column="ACT_DESC" property="actDesc" jdbcType="VARCHAR" />
<result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
<result column="REC_USER" property="recUser" jdbcType="BIGINT" />
<result column="ACT_TYPE" property="actType" jdbcType="VARCHAR" />
<result column="brId" property="brId" jdbcType="VARCHAR" />
<result column="brName" property="brName" jdbcType="VARCHAR" />
<result column="ptfName" property="ptfName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
`ACT_ID`, `ACT_CODE`, `ACT_NAME`,`PTF_ID`, `ENABLE`, `ACT_DESC`, `REC_TIME`, `REC_USER` , `ACT_TYPE`
</sql>
<select id="countSetBrand" parameterType="java.lang.Long" resultType="java.lang.Integer">
SELECT COUNT(*) FROM crm_customer_account c WHERE c.ACT_ID IN (
SELECT a.ACT_ID FROM crm_account_set a where a.ACT_ID = #{actId,jdbcType=BIGINT});
</select>
<select id="findByActName" parameterType="java.lang.String" resultType="java.lang.Integer">
select
COUNT(*)
from
crm_account_set
where ACT_NAME = #{actName,jdbcType=VARCHAR}
</select>
<select id="findAccountSetAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from
crm_account_set
where 1=1 and ACT_TYPE=1
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from crm_account_set
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</select>
<select id="selectAccSet" resultMap="BaseResultMap2" parameterType="java.lang.Long" >
SELECT
accset.`ACT_ID`,
accset.`ACT_CODE`,
accset.`ACT_NAME`,
accset.`PTF_ID`,
accset.`ENABLE`,
accset.`ACT_DESC`,
accset.`REC_TIME`,
accset.`REC_USER`,
accset.`ACT_TYPE`,
pf.plName ptfName,
GROUP_CONCAT(br.brId) brId,
GROUP_CONCAT(br.brName) brName,
channel.CHL_ID CHL_ID
FROM
`crm_account_set` accset
LEFT JOIN smplatform pf ON accset.PTF_ID = pf.plId
LEFT JOIN crm_account_set_brand asb ON asb.ACT_ID = accset.ACT_ID
LEFT JOIN mtbrand br ON br.brId = asb.BND_ID
LEFT JOIN crm_account_set_channel channel ON accset.ACT_ID = channel.ACT_ID and channel.SCENE=1
WHERE accset.`ACT_ID` = #{actId,jdbcType=BIGINT}
GROUP BY accset.ACT_ID
</select>
<select id="selectByActCode" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from crm_account_set
ORDER BY ACT_CODE DESC
LIMIT 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from crm_account_set
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</delete>
<insert id="insert" useGeneratedKeys="true" keyProperty="actId" parameterType="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into crm_account_set (`ACT_ID`, `ACT_CODE`, `ACT_NAME`, `PTF_ID`,
`ENABLE`, `ACT_DESC`, `REC_TIME`,
`REC_USER`, `ACT_TYPE`)
values (#{actId,jdbcType=BIGINT}, #{actCode,jdbcType=VARCHAR}, #{actName,jdbcType=VARCHAR}, #{ptfId,jdbcType=BIGINT},
#{enable,jdbcType=BIT}, #{actDesc,jdbcType=VARCHAR}, #{recTime,jdbcType=TIMESTAMP}, #{recUser,jdbcType=BIGINT}, #{actType,jdbcType=VARCHAR})
</insert>
<insert id="insertBrand" parameterType="java.util.Map">
insert into crm_account_set_brand (`ACT_ID`, `BND_ID`) values (#{actId,jdbcType=BIGINT}, #{brId,jdbcType=BIGINT})
</insert>
<insert id="insertChannel" parameterType="java.util.Map">
insert into crm_account_set_channel (`ACT_ID`, `SCENE`, `CHL_ID`) values (#{actId,jdbcType=BIGINT}, #{scene,jdbcType=VARCHAR}, #{msgChannel,jdbcType=BIGINT})
</insert>
<insert id="insertRights" parameterType="java.util.Map">
insert into crm_account_set_rights (`ACT_ID`, `RIGHTS`) values (#{actId,jdbcType=BIGINT}, #{rights,jdbcType=VARCHAR})
</insert>
<!-- 绑定默认顾客等级 -->
<insert id="createCustRank" parameterType="java.util.Map">
insert into crm_customer_rank
(`ACT_ID`, `RAK_ID`, `RAK_NAME`, `RAK_DESC`, `RAK_INDEX`, `IS_FANS`, `IS_MEMBER`,`REC_TIME`, `REC_USER`)
values
(#{actId,jdbcType=BIGINT},1,'初级会员','不可删除,可修改,全局统一',1,0,1,SYSDATE(),#{recUser,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="actId" parameterType="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into crm_account_set
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="actId != null" >
`ACT_ID`,
</if>
<if test="actCode != null" >
`ACT_CODE`,
</if>
<if test="actName != null" >
`ACT_NAME`,
</if>
<if test="ptfId != null" >
`PTF_ID`,
</if>
<if test="enable != null" >
`ENABLE`,
</if>
<if test="actDesc != null" >
`ACT_DESC`,
</if>
<if test="recTime != null" >
`REC_TIME`,
</if>
<if test="recUser != null" >
`REC_USER`,
</if>
<if test="actType != null" >
`ACT_TYPE`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="actId != null" >
#{actId,jdbcType=BIGINT},
</if>
<if test="actCode != null" >
#{actCode,jdbcType=VARCHAR},
</if>
<if test="actName != null" >
#{actName,jdbcType=VARCHAR},
</if>
<if test="ptfId != null" >
#{ptfId,jdbcType=BIGINT},
</if>
<if test="enable != null" >
#{enable,jdbcType=BIT},
</if>
<if test="actDesc != null" >
#{actDesc,jdbcType=VARCHAR},
</if>
<if test="recTime != null" >
#{recTime,jdbcType=TIMESTAMP},
</if>
<if test="recUser != null" >
#{recUser,jdbcType=BIGINT},
</if>
<if test="actType != null" >
#{actType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" useGeneratedKeys="true" keyProperty="actId" parameterType="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_account_set
<set >
<if test="actCode != null" >
`ACT_CODE` = #{actCode,jdbcType=VARCHAR},
</if>
<if test="actName != null" >
`ACT_NAME` = #{actName,jdbcType=VARCHAR},
</if>
<if test="ptfId != 9999" >
`PTF_ID` = #{ptfId,jdbcType=BIGINT},
</if>
<if test="enable != null" >
`ENABLE` = #{enable,jdbcType=BIT},
</if>
<if test="actDesc != null" >
`ACT_DESC` = #{actDesc,jdbcType=VARCHAR},
</if>
<if test="recTime != null" >
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
</if>
<if test="recUser != null" >
`REC_USER` = #{recUser,jdbcType=BIGINT},
</if>
<if test="actType != null" >
`ACT_TYPE` = #{actType,jdbcType=VARCHAR},
</if>
</set>
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" useGeneratedKeys="true" keyProperty="actId" parameterType="cn.runsa.crmapp.common.entity.AccountSet" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_account_set
set `ACT_CODE` = #{actCode,jdbcType=VARCHAR},
`ACT_NAME` = #{actName,jdbcType=VARCHAR},
`PTF_ID` = #{ptfId,jdbcType=BIGINT},
`ENABLE` = #{enable,jdbcType=BIT},
`ACT_DESC` = #{actDesc,jdbcType=VARCHAR},
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
`REC_USER` = #{recUser,jdbcType=BIGINT},
`ACT_TYPE` = #{actType,jdbcType=VARCHAR},
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</update>
<delete id="deleteBrand" parameterType="java.lang.Long" >
delete from crm_account_set_brand
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</delete>
<update id="updateAccChannel" parameterType="java.util.Map">
update crm_account_set_channel
<set >
<if test="msgChannel != null" >
`CHL_ID` = #{msgChannel,jdbcType=BIGINT}
</if>
</set>
where `ACT_ID` = #{actId,jdbcType=BIGINT}
and `SCENE` = #{scene,jdbcType=VARCHAR}
</update>
<delete id="daleteAccSite" parameterType="java.lang.Long" >
delete from crm_account_set_site
where `ACT_ID` = #{actId,jdbcType=BIGINT}
</delete>
<select id="findBySiteId" resultType="java.lang.String" parameterType="java.lang.Integer">
SELECT
GROUP_CONCAT(t1.brId) brId
FROM
mtSiteBrand t1
WHERE
t1.sirId = #{sirId,jdbcType=INTEGER}
GROUP BY
t1.sirId
</select>
<insert id="insertAccSetSite" useGeneratedKeys="true" keyProperty="actId" parameterType="java.util.Map" >
insert into crm_account_set_site
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="actId != null" >
`ACT_ID`,
</if>
<if test="grpId != null" >
`GRP_ID`,
</if>
<if test="sitId != null" >
`SIT_ID`,
</if>
<if test="bndId != null" >
`BND_ID`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="actId != null" >
#{actId,jdbcType=BIGINT},
</if>
<if test="grpId != null" >
#{grpId,jdbcType=BIGINT},
</if>
<if test="sitId != null" >
#{sitId,jdbcType=BIGINT},
</if>
<if test="bndId != null" >
#{bndId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<insert id="insertAccountSiteBrands" useGeneratedKeys="true" keyProperty="actId" parameterType="java.util.Map" >
insert ignore into crm_account_set_site (ACT_ID, GRP_ID, SIT_ID, BND_ID)
select #{actId} actId,#{grpId} GRP_ID,siId,brId
from mtsiterange a
left join mtsitebrand b on a.sirId=b.sirId
left join crm_account_set_site t10 ON a.SIID =t10.SIT_ID AND b.BRID=t10.BND_ID
where (t10.SIT_ID IS NULL AND t10.BND_ID IS NULL)
and a.siId in (${sitesId})
<if test="bndsId != null and bndsId != ''" >
and b.brId IN (${bndsId})
</if>
</insert>
<delete id="deleteAccountSiteBrands" >
delete from crm_account_set_site where ACT_ID=#{actId}
<if test="grpId != null ">
and GRP_ID=#{grpId}
</if>
<if test="sitesId != null and sitesId != ''">
and SIT_ID in (${sitesId})
</if>
<if test="brId != null and brId != ''">
and BND_ID in (${brId})
</if>
</delete>
<delete id="deleteAccountSiteBrandsByBrands" >
delete from crm_account_set_site where ACT_ID=#{actId}
<if test="brId != null and brId != ''">
and BND_ID not in (${brId})
</if>
</delete>
<delete id="insertAccountSiteBrandsOnGroup" parameterType="java.util.Map" >
insert ignore into crm_account_set_site (ACT_ID, GRP_ID, SIT_ID, BND_ID)
select #{actId} actId,#{grpId} GRP_ID,siId,brId
from mtsiterange a
left join mtsitebrand b on a.sirId=b.sirId
left join crm_account_set_site t10 ON a.SIID =t10.SIT_ID AND b.BRID=t10.BND_ID
where (t10.SIT_ID IS NULL AND t10.BND_ID IS NULL)
and a.siId in (${sitesId})
<if test="bndsId != null and bndsId != ''" >
and b.brId IN (${bndsId})
</if>
</delete>
<select id="findAccountSetByFilterCondition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from crm_account_set t1 LEFT JOIN smPlatform t2 ON t2.plId=t1.PTF_ID
WHERE (CASE WHEN ${ptfId}= 1 THEN 1 = 1 WHEN ${ptfId}!= 1 THEN t1.PTF_ID=${ptfId} END)
AND t1.act_type=1
</select>
<insert id="changeAccountSiteBrands">
insert ignore into crm_account_set_site (ACT_ID, GRP_ID, SIT_ID, BND_ID)
select act_id, grp_id, sit_id, bb.brid from
(select distinct act_id, grp_id, sit_id from crm_account_set_site where act_id = #{actId}) aa left join
(select a.SIID,b.brid from mtsiterange a
left join mtsitebrand b on a.sirId=b.sirId ) bb on aa.sit_id = bb.siid
where bb.brid in (${brId})
</insert>
</mapper>