user-charge-report-mapper.xml
4.69 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
<?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">
<!-- 用户汇款告知 @author tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.fund.UserChargeReportDao">
<sql id="user_charge_report_field">
id, user_id, user_name, mobile, bank_no, bank_name, charge_name, report_amount, charge_amount, charge_status,
pay_at, charge_at, sys_charge_at,sys_charge_by, review_at, review_by, refuse_at, refuse_by, remark
</sql>
<sql id="searchCondition">
where 1 = 1
<if test="userId != null and userId != ''"> and user_id like CONCAT('%', #{userId}, '%') </if>
<if test="userName != null and userName != ''">
and user_name like CONCAT('%', #{userName}, '%')
</if>
<if test="bankNo != null and bankNo != ''"> and bank_no like CONCAT('%', #{bankNo}, '%') </if>
<if test="chargeName != null and chargeName != ''"> and charge_name like CONCAT('%', #{chargeName}, '%') </if>
<if test="reportAmount != null and reportAmount != ''"> and report_amount = #{reportAmount}</if>
<if test="chargeStatus != null and chargeStatus != ''"> and charge_status = #{chargeStatus} </if>
<if test="payStartDate != null and payStartDate != ''">
<![CDATA[ and pay_at >= concat(#{payStartDate}, ' 00:00:00')]]>
</if>
<if test="payEndDate != null and payEndDate != ''">
<![CDATA[ and pay_at <= concat(#{payEndDate}, ' 23:59:59')]]>
</if>
<if test="chargeStartDate != null and chargeStartDate != ''">
<![CDATA[ and charge_at >= concat(#{chargeStartDate}, ' 00:00:00')]]>
</if>
<if test="chargeEndDate != null and chargeEndDate != ''">
<![CDATA[ and charge_at <= concat(#{chargeEndDate}, ' 23:59:59')]]>
</if>
</sql>
<select id="search" parameterType="map" resultType="UserChargeReportInfo">
select <include refid="user_charge_report_field" />
from user_charge_report
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1)
from user_charge_report
<include refid="searchCondition" />
</select>
<update id="update" parameterType="map">
update user_charge_report set charge_status = #{chargeStatus}
<if test="chargeStatus == 2">
, sys_charge_at = #{updateAt}, sys_charge_by = #{updateBy}
</if>
<if test="chargeStatus == 3 or chargeStatus == 5">
, review_at = #{updateAt}, review_by = #{updateBy}
</if>
<if test="chargeStatus == 0">
, refuse_at = #{updateAt}, refuse_by = #{updateBy}
</if>
where id = #{id}
<if test="chargeStatus == 2">
and charge_status = '1'
</if>
<if test="chargeStatus == 3">
and charge_status = '2'
</if>
<if test="chargeStatus == 0">
and charge_status in ('1','2')
</if>
</update>
<!-- 导入流水批量复核 -->
<update id="updateUploadReview" parameterType="map">
update user_charge_report set charge_status = #{chargeStatus}, charge_amount = #{chargeAmount},
review_at = now(), review_by = #{updateBy}, remark = #{remark}
where id = #{id} and charge_status = '1'
</update>
<update id="ensure" parameterType="map">
update user_charge_report set charge_status = #{chargeStatus}, charge_amount = #{chargeAmount},
sys_charge_at = #{sysChargeAt}, sys_charge_by = #{sysChargeBy}, remark = #{remark}
where id = #{id} and charge_status in ('1', '2')
</update>
<select id="queryById" parameterType="string" resultType="UserChargeReportInfo">
select <include refid="user_charge_report_field" />
from user_charge_report
where id = #{id}
</select>
<insert id="save" parameterType="UserChargeReportInfo">
insert into user_charge_report(user_id, user_name, mobile, bank_no, bank_name,
charge_name, report_amount, charge_amount, charge_status, pay_at, charge_at)
values (#{userId}, #{userName}, #{mobile}, #{bankNo}, #{bankName},
#{chargeName}, #{reportAmount}, #{chargeAmount}, '1', #{payAt}, now())
</insert>
<update id="veto" parameterType="map">
update user_charge_report set charge_status = 0, remark = #{remark}, refuse_at = #{refuseAt}, refuse_by = #{refuseBy}
where id = #{id} and charge_status in ('1', '2')
</update>
<update id="vetoLot" parameterType="map">
update user_charge_report set charge_status = 0, remark = #{remark}, refuse_at = #{refuseAt}, refuse_by = #{refuseBy}
where charge_status in ('1')
<![CDATA[ and charge_at >= concat(#{chargeStartDate}, ' 00:00:00')]]>
<![CDATA[ and charge_at <= concat(#{chargeEndDate}, ' 23:59:59')]]>
</update>
<select id="searchFooter" parameterType="map" resultType="map">
select sum(report_amount) reportAmount, sum(charge_amount) chargeAmount
from user_charge_report
<include refid="searchCondition" />
</select>
</mapper>