admin
2019-07-11 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<?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.yeshi.fanli.dao.mybatis.ExtractAuditRecordMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.bus.user.ExtractAuditRecord">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="beforeMoney" property="beforeMoney" jdbcType="DECIMAL" />
        <result column="afterMoney" property="afterMoney" jdbcType="DECIMAL" />
        <result column="countMoney" property="countMoney" jdbcType="DECIMAL" />
        <result column="countNum" property="countNum" jdbcType="BIGINT" />
        <result column="orderNum" property="orderNum" jdbcType="BIGINT" />
        <result column="auditRole" property="auditRole" jdbcType="VARCHAR" />
        <result column="cancelOrderNum" property="cancelOrderNum"
            jdbcType="BIGINT" />
        <result column="auditTime" property="auditTime" jdbcType="BIGINT" />
        <result column="extraInfo" property="extraInfoStr" jdbcType="VARCHAR" />
        <association property="adminUser" column="aid"
            select="com.yeshi.fanli.dao.mybatis.AdminUserMapper.selectByPrimaryKey">
        </association>
        <association property="extract" column="extractId"
            select="com.yeshi.fanli.dao.mybatis.ExtractMapper.selectByPrimaryKey">
        </association>
 
    </resultMap>
    <sql id="Base_Column_List">id,aid,extractId,beforeMoney,afterMoney,countMoney,countNum,orderNum,cancelOrderNum,auditTime,auditRole,extraInfo
    </sql>
 
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_extract_audit_record where id = #{id,jdbcType=BIGINT}
    </select>
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from
        yeshi_ec_extract_audit_record where id = #{id,jdbcType=BIGINT}
    </delete>
 
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ExtractAuditRecord"
        useGeneratedKeys="true" keyProperty="id">
        insert into
        yeshi_ec_extract_audit_record
        (id,aid,extractId,beforeMoney,afterMoney,countMoney,countNum,auditTime,extraInfo)
        values
        (#{id,jdbcType=BIGINT},#{adminUser.id,jdbcType=BIGINT},#{extract.id,jdbcType=BIGINT},
        #{beforeMoney,jdbcType=DECIMAL},#{afterMoney,jdbcType=DECIMAL},#{countMoney,jdbcType=DECIMAL},#{auditRole,jdbcType=VARCHAR})
        #{countNum,jdbcType=BIGINT},#{orderNum,jdbcType=BIGINT},#{cancelOrderNum,jdbcType=BIGINT},#{auditTime,jdbcType=BIGINT},#{extraInfoStr,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ExtractAuditRecord"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_extract_audit_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="adminUser != null">aid,</if>
            <if test="extract != null">extractId,</if>
            <if test="beforeMoney != null">beforeMoney,</if>
            <if test="afterMoney != null">afterMoney,</if>
            <if test="countMoney != null">countMoney,</if>
            <if test="countNum != null">countNum,</if>
            <if test="orderNum != null">orderNum,</if>
            <if test="cancelOrderNum != null">cancelOrderNum,</if>
            <if test="auditTime != null">auditTime,</if>
            <if test="auditRole != null">auditRole,</if>
            <if test="extraInfoStr != null">extraInfo,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="adminUser != null">#{adminUser.id,jdbcType=BIGINT},</if>
            <if test="extract != null">#{extract.id,jdbcType=BIGINT},</if>
            <if test="beforeMoney != null">#{beforeMoney,jdbcType=DECIMAL},</if>
            <if test="afterMoney != null">#{afterMoney,jdbcType=DECIMAL},</if>
            <if test="countMoney != null">#{countMoney,jdbcType=DECIMAL},</if>
            <if test="countNum != null">#{countNum,jdbcType=BIGINT},</if>
            <if test="orderNum != null">#{orderNum,jdbcType=BIGINT},</if>
            <if test="cancelOrderNum != null">#{cancelOrderNum,jdbcType=BIGINT},</if>
            <if test="auditTime != null">#{auditTime,jdbcType=BIGINT},</if>
            <if test="auditRole != null">#{auditRole,jdbcType=VARCHAR},</if>
            <if test="extraInfoStr != null">#{extraInfoStr,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ExtractAuditRecord">
        update
        yeshi_ec_extract_audit_record set aid =
        #{adminUser.id,jdbcType=BIGINT},
        extractId =
        #{extract.id,jdbcType=BIGINT},beforeMoney =
        #{beforeMoney,jdbcType=DECIMAL},
        afterMoney =
        #{afterMoney,jdbcType=DECIMAL},countMoney =
        #{countMoney,jdbcType=DECIMAL},
        countNum =
        #{countNum,jdbcType=BIGINT},auditRole =
        #{auditRole,jdbcType=VARCHAR},
        orderNum = #{orderNum,jdbcType=BIGINT},cancelOrderNum =
        #{cancelOrderNum,jdbcType=BIGINT},
        auditTime =
        #{auditTime,jdbcType=BIGINT},
        extraInfo =
        #{extraInfoStr,jdbcType=VARCHAR} 
        where id = #{id,jdbcType=BIGINT}
    </update>
 
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.ExtractAuditRecord">
        update yeshi_ec_extract_audit_record
        <set>
            <if test="adminUser != null">aid=#{adminUser.id,jdbcType=BIGINT},</if>
            <if test="extract != null">extractId=#{extract.id,jdbcType=BIGINT},</if>
            <if test="beforeMoney != null">beforeMoney=#{beforeMoney,jdbcType=DECIMAL},</if>
            <if test="afterMoney != null">afterMoney=#{afterMoney,jdbcType=DECIMAL},</if>
            <if test="countMoney != null">countMoney=#{countMoney,jdbcType=DECIMAL},</if>
            <if test="countNum != null">countNum=#{countNum,jdbcType=BIGINT},</if>
            <if test="orderNum != null">orderNum=#{orderNum,jdbcType=BIGINT},</if>
            <if test="cancelOrderNum != null">cancelOrderNum=#{cancelOrderNum,jdbcType=BIGINT},</if>
            <if test="auditTime != null">auditTime=#{auditTime,jdbcType=BIGINT},</if>
            <if test="auditRole != null">auditRole=#{auditRole,jdbcType=VARCHAR},</if>
            <if test="extraInfoStr != null">extraInfo=#{extraInfoStr,jdbcType=VARCHAR},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
 
    <select id="getListbyExtractId" resultMap="BaseResultMap">
        <!-- 查询最近一次提现记录 -->
        SELECT * FROM yeshi_ec_extract_audit_record ear
        WHERE ear.`extractId` =
        #{extractId,jdbcType=BIGINT}
        and auditTime is not null and auditTime >
        0 ORDER BY ear.`auditTime`
    </select>
 
    <select id="getbyExtractId" resultMap="BaseResultMap">
        <!-- 查询提现时已记录信息 -->
        SELECT * FROM yeshi_ec_extract_audit_record ear
        WHERE ear.`extractId` =
        #{extractId,jdbcType=BIGINT}
        and (auditTime is null or auditTime = 0)
        ORDER BY ear.`auditTime` desc
    </select>
 
    <select id="getList" resultMap="BaseResultMap">
 
        SELECT * FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE 
      <![CDATA[
        auditTime is not null and auditTime > 0  AND
        FROM_UNIXTIME(ex.extractTime/1000)  >= #{startTime}
           AND  FROM_UNIXTIME(ex.extractTime/1000) <= #{endTime} 
       ]]>
        <if test='key != null and key != ""'>
            AND (ex.uid like '%${key}%' OR ar.aid like '%${key}%')
        </if>
        ORDER BY ex.extractTime DESC LIMIT ${start},${count}
    </select>
 
    <select id="getCount" resultType="java.lang.Integer">
        SELECT count(ar.id) FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE
      <![CDATA[
         auditTime is not null and auditTime > 0  AND
         FROM_UNIXTIME(ex.`extractTime`/1000)  >= #{startTime}
           AND  FROM_UNIXTIME(ex.`extractTime`/1000) <= #{endTime} 
       ]]>
        <if test='key != null and key != ""'>
            AND (ex.uid like '%${key}%' OR ar.aid like '%${key}%')
        </if>
    </select>
 
 
    <select id="getMyAuditedAllList" resultMap="BaseResultMap">
 
        SELECT * FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE ar.aid = ${adminId}
        <if test='key != null and key != ""'>
            AND ex.uid like '%${key}%'
        </if>
        <if test='state != null'>
            AND ex.state = #{state}
        </if>
        ORDER BY ex.extractTime DESC LIMIT ${start},${count}
    </select>
 
    <select id="getMyAuditedAllCount" resultType="java.lang.Integer">
 
        SELECT count(ar.id) FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE ar.aid = ${adminId}
        <if test='key != null and key != ""'>
            AND ex.uid like '%${key}%'
        </if>
        <if test='state != null'>
            AND ex.state = #{state}
        </if>
    </select>
 
    <select id="getMyAuditedTimeSlotList" resultMap="BaseResultMap">
        SELECT ar.*,(CASE WHEN ex.state = 2 THEN 1 WHEN ex.state =1 THEN 1
        ELSE 0 END) AS stateOrde FROM yeshi_ec_extract_audit_record ar
        LEFT
        JOIN yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE  <![CDATA[1>0]]>
        <if test="adminId != null">
            AND ar.aid = ${adminId}
        </if>
 
        <if test='key != null and key != ""'>
            AND ex.uid like '%${key}%'
        </if>
 
        <if test="days != null">
            <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL ${days}  DAY) <= FROM_UNIXTIME(ex.extractTime/1000) ]]>
        </if>
 
        <if test='state != null'>
            AND ex.state = #{state}
        </if>
        ORDER BY stateOrde,ex.`extractTime` DESC LIMIT ${start},${count}
 
    </select>
 
    <select id="getMyAuditedTimeSlotCount" resultType="java.lang.Integer">
        SELECT count(ar.id) FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE  <![CDATA[1>0]]>
        <if test="adminId != null">
            AND ar.aid = ${adminId}
        </if>
 
        <if test='key != null and key != ""'>
            AND ex.uid like '%${key}%'
        </if>
 
        <if test="days != null">
            <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL ${days}  DAY) <= FROM_UNIXTIME(ex.extractTime/1000) ]]>
        </if>
 
        <if test='state != null'>
            AND ex.state = #{state}
        </if>
    </select>
 
    <select id="getMyAuditedCountWeek" resultType="java.lang.Integer">
        SELECT COUNT(id) FROM yeshi_ec_extract_audit_record WHERE aid =
        ${adminId} 
       <![CDATA[
           AND YEARWEEK(DATE_FORMAT(FROM_UNIXTIME(auditTime/1000),'%Y-%m-%d')) = YEARWEEK(NOW());
       ]]>
    </select>
 
    <select id="getMyAuditedCountMonth" resultType="java.lang.Integer">
        SELECT COUNT(id) FROM yeshi_ec_extract_audit_record WHERE aid =
        ${adminId} 
       <![CDATA[
           AND DATE_FORMAT(FROM_UNIXTIME(auditTime/1000),'%Y-%m')=DATE_FORMAT(NOW(),'%Y-%m')
       ]]>
    </select>
 
    <select id="getMyAuditedCountToday" resultType="java.lang.Integer">
        SELECT COUNT(id) FROM yeshi_ec_extract_audit_record WHERE aid =
        ${adminId} 
       <![CDATA[
           AND TO_DAYS(FROM_UNIXTIME(auditTime/1000)) = TO_DAYS(NOW())
       ]]>
    </select>
 
    <!-- 查询历史提现申请记录 -->
    <select id="getByUidList" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE ex.uid = ${uid}  
            <![CDATA[and ar.auditTime > 0 and ar.auditTime is not null ]]>
        ORDER BY ex.extractTime DESC LIMIT ${start},${count}
    </select>
 
    <select id="getByUidCount" resultType="java.lang.Integer">
        SELECT COUNT(ar.id) FROM yeshi_ec_extract_audit_record ar
        LEFT JOIN
        yeshi_ec_extract ex ON ar.extractId=ex.id
        WHERE ex.uid = ${uid} <![CDATA[and ar.auditTime > 0 and ar.auditTime is not null ]]>
    </select>
 
 
 
    <select id="countAuditTotal" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(tr.id),0) AS 'showValue',
        <if test="type == 1">
            FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
            FROM_UNIXTIME(tr.`auditTime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
            FROM_UNIXTIME(tr.`auditTime`/1000,'%Y') AS 'showDate'
        </if>
        FROM `yeshi_ec_extract_audit_record` tr
        <if test="state != null and state != 0">
            LEFT JOIN `yeshi_ec_extract` t ON t.`id` = tr.`extractId`
        </if>
        WHERE tr.`auditTime` IS NOT NULL
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(tr.`auditTime`/1000,'%Y') = '${years}'
        </if>
        <if test="state != null and state != 3">
            AND t.`state` = ${state}
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(tr.`auditTime`/1000,'%Y')
        </if>
        ORDER BY tr.`auditTime`
    </select>
 
    <select id="countExtractMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(t.`money`)AS DECIMAL(19,2)) AS showValue,
        <if test="type == 1">
            FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
            FROM_UNIXTIME(t.`extractTime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
            FROM_UNIXTIME(t.`extractTime`/1000,'%Y') AS 'showDate'
        </if>
        FROM `yeshi_ec_extract` t
        WHERE t.`extractTime` IS NOT NULL
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y') = '${years}'
        </if>
        <if test="state != null">
            AND t.`state` = ${state}
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y')
        </if>
        ORDER BY t.`extractTime`
    </select>
 
    <select id="countExtractApplyNumber" resultType="java.util.HashMap">
        SELECT COUNT(t.id) AS showValue,
        <if test="type == 1">
            FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') AS
            'showDate'
        </if>
        <if test="type == 2">
            FROM_UNIXTIME(t.`extractTime`/1000,'%m') AS 'showDate'
        </if>
        <if test="type == 3">
            FROM_UNIXTIME(t.`extractTime`/1000,'%Y') AS 'showDate'
        </if>
        FROM `yeshi_ec_extract` t
        WHERE t.`extractTime` IS NOT NULL
        <if test="startTime != null and startTime != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
            '${endTime}'
        </if>
        <if test="years != null and years != '' ">
            AND FROM_UNIXTIME(t.`extractTime`/1000,'%Y') = '${years}'
        </if>
        <if test="state != null">
            AND t.`state` = ${state}
        </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
            GROUP BY FROM_UNIXTIME(t.`extractTime`/1000,'%Y')
        </if>
        ORDER BY t.`extractTime`
    </select>
 
</mapper>