admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
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
<?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>
    
    <resultMap id="ChartMap" type="com.yeshi.fanli.dto.ChartTDO">
        <result column="showDate" property="showDate" jdbcType="VARCHAR" />
        <result column="showValue" property="showValue" jdbcType="VARCHAR" />
    </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="Long">
        SELECT COUNT(tr.id) FROM `yeshi_ec_extract_audit_record` tr
        LEFT JOIN `yeshi_ec_extract` t ON t.`id` = tr.`extractId`
        WHERE t.`state` = #{state} AND FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d') = #{preDay} 
    </select>
 
    <select id="countApplyExtractMoney" resultType="BigDecimal">
        SELECT SUM(t.`money`) FROM `yeshi_ec_extract` t
        WHERE FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') = #{preDay} 
    </select>
 
    <select id="countApplyNumberByDay" resultType="Long">
        SELECT COUNT(t.id) FROM `yeshi_ec_extract` t
        WHERE FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') = #{preDay} 
    </select>
 
</mapper>