PointsAccountMapper.xml
10.9 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
<?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.points.mapper.PointsAccountMapper">
<resultMap id="BaseResultMap" type="cn.runsa.crmapp.points.entity.PointsAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="PNT_ID" jdbcType="BIGINT" property="pntId" />
<result column="ACT_ID" jdbcType="BIGINT" property="actId" />
<result column="PNT_TYPE" jdbcType="VARCHAR" property="pntType" />
<result column="PNT_NAME" jdbcType="VARCHAR" property="pntName" />
<result column="CST_ID" jdbcType="BIGINT" property="cstId" />
<result column="PNT_VAL" jdbcType="DOUBLE" property="pntVal" />
<result column="TOTAL_ALL" jdbcType="DOUBLE" property="totalAll" />
<result column="TOTAL_THIS" jdbcType="DOUBLE" property="totalThis" />
<result column="S_TIME" jdbcType="TIMESTAMP" property="sTime" />
<result column="E_TIME" jdbcType="TIMESTAMP" property="eTime" />
<result column="PNT_UNIT" jdbcType="VARCHAR" property="pntUnit" />
<result column="PNT_U_V" jdbcType="DECIMAL" property="pntUV" />
<result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
`PNT_ID`, `ACT_ID`, `PNT_TYPE`, `CST_ID`, `PNT_VAL`, `TOTAL_ALL`, `TOTAL_THIS`, `S_TIME`,
`E_TIME`, `REC_TIME`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from crm_points_account
where `PNT_ID` = #{pntId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from crm_points_account
where `PNT_ID` = #{pntId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="cn.runsa.crmapp.points.entity.PointsAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="pntId" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into crm_points_account (`PNT_ID`, `ACT_ID`, `PNT_TYPE`,
`CST_ID`, `PNT_VAL`, `TOTAL_ALL`,
`TOTAL_THIS`, `S_TIME`, `E_TIME`,
`REC_TIME`)
values (#{pntId,jdbcType=BIGINT}, #{actId,jdbcType=BIGINT}, #{pntType,jdbcType=VARCHAR},
#{cstId,jdbcType=BIGINT}, #{pntVal,jdbcType=DOUBLE}, #{totalAll,jdbcType=DOUBLE},
#{totalThis,jdbcType=DOUBLE}, #{sTime,jdbcType=TIMESTAMP}, #{eTime,jdbcType=TIMESTAMP},
#{recTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="cn.runsa.crmapp.points.entity.PointsAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey keyProperty="pntId" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into crm_points_account
<trim prefix="(" suffix=")" suffixOverrides=",">
`PNT_ID`,
<if test="actId != null">
`ACT_ID`,
</if>
<if test="pntType != null">
`PNT_TYPE`,
</if>
<if test="cstId != null">
`CST_ID`,
</if>
<if test="pntVal != null">
`PNT_VAL`,
</if>
<if test="totalAll != null">
`TOTAL_ALL`,
</if>
<if test="totalThis != null">
`TOTAL_THIS`,
</if>
<if test="sTime != null">
`S_TIME`,
</if>
<if test="eTime != null">
`E_TIME`,
</if>
<if test="recTime != null">
`REC_TIME`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{pntId,jdbcType=BIGINT},
<if test="actId != null">
#{actId,jdbcType=BIGINT},
</if>
<if test="pntType != null">
#{pntType,jdbcType=VARCHAR},
</if>
<if test="cstId != null">
#{cstId,jdbcType=BIGINT},
</if>
<if test="pntVal != null">
#{pntVal,jdbcType=DOUBLE},
</if>
<if test="totalAll != null">
#{totalAll,jdbcType=DOUBLE},
</if>
<if test="totalThis != null">
#{totalThis,jdbcType=DOUBLE},
</if>
<if test="sTime != null">
#{sTime,jdbcType=TIMESTAMP},
</if>
<if test="eTime != null">
#{eTime,jdbcType=TIMESTAMP},
</if>
<if test="recTime != null">
#{recTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.points.entity.PointsAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_points_account
<set>
<if test="actId != null">
`ACT_ID` = #{actId,jdbcType=BIGINT},
</if>
<if test="pntType != null">
`PNT_TYPE` = #{pntType,jdbcType=VARCHAR},
</if>
<if test="cstId != null">
`CST_ID` = #{cstId,jdbcType=BIGINT},
</if>
<if test="pntVal != null">
`PNT_VAL` = #{pntVal,jdbcType=DOUBLE},
</if>
<if test="totalAll != null">
`TOTAL_ALL` = #{totalAll,jdbcType=DOUBLE},
</if>
<if test="totalThis != null">
`TOTAL_THIS` = #{totalThis,jdbcType=DOUBLE},
</if>
<if test="sTime != null">
`S_TIME` = #{sTime,jdbcType=TIMESTAMP},
</if>
<if test="eTime != null">
`E_TIME` = #{eTime,jdbcType=TIMESTAMP},
</if>
<if test="recTime != null">
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
</if>
</set>
where `PNT_ID` = #{pntId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.points.entity.PointsAccount">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update crm_points_account
set `ACT_ID` = #{actId,jdbcType=BIGINT},
`PNT_TYPE` = #{pntType,jdbcType=VARCHAR},
`CST_ID` = #{cstId,jdbcType=BIGINT},
`PNT_VAL` = #{pntVal,jdbcType=DOUBLE},
`TOTAL_ALL` = #{totalAll,jdbcType=DOUBLE},
`TOTAL_THIS` = #{totalThis,jdbcType=DOUBLE},
`S_TIME` = #{sTime,jdbcType=TIMESTAMP},
`E_TIME` = #{eTime,jdbcType=TIMESTAMP},
`REC_TIME` = #{recTime,jdbcType=TIMESTAMP}
where `PNT_ID` = #{pntId,jdbcType=BIGINT}
</update>
<update id="updatePointsValue" parameterType="map">
update crm_points_account
set `PNT_VAL` = `PNT_VAL` + #{account.pntVal,jdbcType=DOUBLE}
<if test="updateTotal == true">
,`TOTAL_ALL` = `TOTAL_ALL`+ #{account.pntVal,jdbcType=DOUBLE}
</if>
where `PNT_ID` = #{account.pntId,jdbcType=BIGINT}
</update>
<select id="selectPointsAccount" parameterType="map" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM crm_points_account
WHERE CST_ID = #{cstId}
AND ACT_ID = #{actId}
AND PNT_TYPE = #{pntType}
</select>
<select id="selectPoints" parameterType="map" resultMap="BaseResultMap">
SELECT a.`PNT_ID`,a.`ACT_ID`,a.`PNT_TYPE`,a.`PNT_VAL`,s.`PNT_SET_NAME` AS PNT_NAME,s.`PNT_UNIT`,s.`PNT_U_V`
FROM crm_points_account a
RIGHT JOIN crm_points_set s
ON a.`ACT_ID`=s.`ACT_ID`
AND a.`PNT_TYPE` = s.`PNT_TYPE`
WHERE a.`CST_ID`= #{cstId}
<if test="sets !=null">
AND a.`ACT_ID` IN
<foreach collection="sets" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
<if test="types !=null">
AND a.`PNT_TYPE` IN
<foreach collection="types" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
</select>
<select id="selectPointsAvaliable" parameterType="map" resultMap="BaseResultMap">
SELECT a.`PNT_ID`,a.`ACT_ID`,a.`PNT_TYPE`,SUM(i.`PNT_VAL`) AS PNT_VAL,s.`PNT_SET_NAME` AS PNT_NAME ,s.`PNT_UNIT`,s.`PNT_U_V`
FROM crm_points_account a
LEFT JOIN crm_points_set s
ON a.`ACT_ID` = s.`ACT_ID`
AND a.`PNT_TYPE` = s.`PNT_TYPE`
LEFT JOIN crm_points_item i
ON a.`PNT_ID`=i.`PNT_ID`
WHERE a.`CST_ID`= #{cstId}
<if test="sets !=null">
AND a.`ACT_ID` IN
<foreach collection="sets" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
<if test="types !=null">
AND a.`PNT_TYPE` IN
<foreach collection="types" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
AND i.`E_TIME` > NOW()
AND i.`S_TIME` < NOW()
GROUP BY a.`PNT_ID`
</select>
<select id="selectPointsExpiring" parameterType="map" resultMap="BaseResultMap">
SELECT a.`PNT_ID`,a.`ACT_ID`,a.`PNT_TYPE`,SUM(i.`PNT_VAL`) AS PNT_VAL,s.`PNT_SET_NAME` AS PNT_NAME ,s.`PNT_UNIT`,s.`PNT_U_V`
FROM crm_points_account a
LEFT JOIN crm_points_set s
ON a.`ACT_ID` = s.`ACT_ID`
AND a.`PNT_TYPE` = s.`PNT_TYPE`
LEFT JOIN crm_points_item i
ON a.`PNT_ID`=i.`PNT_ID`
WHERE a.`CST_ID`= #{cstId}
<if test="sets !=null">
AND a.`ACT_ID` IN
<foreach collection="sets" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
<if test="types !=null">
AND a.`PNT_TYPE` IN
<foreach collection="types" open="(" close=")" item="it" separator=",">
#{it}
</foreach>
</if>
AND i.`E_TIME` BETWEEN #{fDate} AND #{tDate}
GROUP BY a.`PNT_ID`
</select>
<select id="selectTotalPointsByDate" parameterType="map" resultType="map">
SELECT a.`CST_ID` AS cstId,SUM(c.`PNT_VAL`) AS val
FROM crm_points_change c
INNER JOIN crm_points_account a
ON c.`PNT_ID` = a.`PNT_ID`
WHERE a.`ACT_ID` = #{actId}
AND a.`CST_ID` IN
<foreach collection="csts" open="(" close=")" separator="," item="it">
#{it}
</foreach>
AND a.`PNT_TYPE` = #{type,jdbcType=VARCHAR}
AND c.`PNT_VAL` > 0
AND c.`REC_TIME` BETWEEN #{fDate,jdbcType=TIMESTAMP} AND #{tDate,jdbcType=TIMESTAMP}
GROUP BY a.`CST_ID`
</select>
<select id="selectSharedPoints" parameterType="java.lang.Long" resultMap="BaseResultMap">
SELECT a.`PNT_ID`, a.`ACT_ID`, a.`PNT_TYPE`, a.`CST_ID`, a.`PNT_VAL`,s.`PNT_SET_NAME` AS PNT_NAME,s.`PNT_UNIT`,s.`PNT_U_V`
FROM crm_points_account a
INNER JOIN crm_points_set s
ON (a.`ACT_ID` = s.`ACT_ID` AND a.`PNT_TYPE` = s.`PNT_TYPE`)
WHERE CST_ID = #{cstId} AND s.`EXCHANGE` = 1
</select>
<select id="selectSharedPointsAvaliable" parameterType="java.lang.Long" resultType="map">
SELECT i.`ITM_ID`,s.`PNT_U_V` FROM crm_points_account a
INNER JOIN crm_points_set s ON (a.`ACT_ID` = s.`ACT_ID` AND a.`PNT_TYPE` = s.`PNT_TYPE`)
INNER JOIN crm_points_item i ON a.`PNT_ID` = i.`PNT_ID`
WHERE a.`CST_ID` = #{cstId} AND s.`EXCHANGE` = 1
AND i.`E_TIME` > NOW()
AND i.`S_TIME` < NOW()
</select>
</mapper>