TdCAcctPayoutSMapper.xml
7.13 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
<?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.zteits.pay.mapper.smapper.TdCAcctPayoutSMapper" >
<resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCAcctPayout">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="payout_bill_id" jdbcType="VARCHAR" property="payoutBillId" />
<result column="acct_id" jdbcType="VARCHAR" property="acctId" />
<result column="cust_id" jdbcType="VARCHAR" property="custId" />
<result column="acct_type" jdbcType="INTEGER" property="acctType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
<result column="trade_detial_type" jdbcType="INTEGER" property="tradeDetialType" />
<result column="trade_fee" jdbcType="DECIMAL" property="tradeFee" />
<result column="trade_balance" jdbcType="DECIMAL" property="tradeBalance" />
<result column="trader_id" jdbcType="VARCHAR" property="traderId" />
<result column="trader_name" jdbcType="VARCHAR" property="traderName" />
<result column="trade_time" jdbcType="TIMESTAMP" property="tradeTime" />
<result column="rlt_payorder_id" jdbcType="VARCHAR" property="rltPayorderId" />
<result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId" />
<result column="rlt_order_type" jdbcType="VARCHAR" property="rltOrderType" />
<result column="acct_upt_state" jdbcType="INTEGER" property="acctUptState" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
</resultMap>
<sql id="Base_Column_List">
id, payout_bill_id, acct_id, cust_id, acct_type, trade_type, trade_detial_type, trade_fee,
trade_balance, trader_id, trader_name, trade_time, rlt_payorder_id, rlt_order_id,
rlt_order_type, acct_upt_state, data_state, create_empid, create_date, modfiy_empid,
modfiy_date, org_id, org_name
</sql>
<select id="getAcctPayout" resultMap="BaseResultMap"
parameterType="com.zteits.clouds.api.dto.pay.param.AcctPayoutForPageRequest">
select
<include refid="Base_Column_List" />
from td_c_acct_payout
where data_state = 1
<if test="userPhone != null and userPhone != ''">
and cust_id in (
select cust_id from td_c_cust_person
where user_phone = #{userPhone}
)
</if>
<if test="acctId != null">
and acct_id = #{acctId,jdbcType=VARCHAR}
</if>
<if test="custId != null">
and cust_id = #{custId,jdbcType=VARCHAR}
</if>
<if test="acctTypeList != null and acctTypeList.size >0">
and acct_type in
<foreach collection="acctTypeList" item="acctType" open="(" close=")" separator=",">
#{acctType}
</foreach>
</if>
<if test="tradeTypeList != null and tradeTypeList.size >0">
and trade_type in
<foreach collection="tradeTypeList" item="tradeType" open="(" close=")" separator=",">
#{tradeType}
</foreach>
</if>
<if test="custIds != null and custIds.size >0">
and cust_id in
<foreach collection="custIds" item="cust_id" open="(" close=")" separator=",">
#{cust_id}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and trade_time >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and trade_time <= #{endTime} ]]>
</if>
<if test="rltPayorderId != null">
and rlt_payorder_id = #{rltPayorderId,jdbcType=VARCHAR}
</if>
<if test="rltOrderId != null">
and rlt_order_id = #{rltOrderId,jdbcType=VARCHAR}
</if>
<if test="rltOrderType != null">
and rlt_order_type = #{rltOrderType,jdbcType=VARCHAR}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
order by trade_time desc
</select>
<select id="statisticAcctPayOut" resultType="com.zteits.clouds.api.dto.pay.AcctRechargeStatisticDTO">
select
ifnull(sum(CASE WHEN trade_fee > 0
THEN trade_fee
ELSE 0 END), 0) positiveFee,
ifnull(sum(CASE WHEN trade_fee > 0
THEN 1
ELSE 0 END), 0) positiveNum,
ifnull(sum(CASE WHEN trade_fee <= 0
THEN trade_fee
ELSE 0 END), 0) negativeFee,
ifnull(sum(CASE WHEN trade_fee <= 0
THEN 1
ELSE 0 END), 0) negativeNum
from td_c_acct_payout
where data_state = 1
<if test="userPhone != null and userPhone != ''">
and cust_id in (
select cust_id from td_c_cust_person
where user_phone = #{userPhone}
)
</if>
<if test="acctId != null">
and acct_id = #{acctId,jdbcType=VARCHAR}
</if>
<if test="custId != null">
and cust_id = #{custId,jdbcType=VARCHAR}
</if>
<if test="acctTypeList != null and acctTypeList.size >0">
and acct_type in
<foreach collection="acctTypeList" item="acctType" open="(" close=")" separator=",">
#{acctType}
</foreach>
</if>
<if test="tradeTypeList != null and tradeTypeList.size >0">
and trade_type in
<foreach collection="tradeTypeList" item="tradeType" open="(" close=")" separator=",">
#{tradeType}
</foreach>
</if>
<if test="custIds != null and custIds.size >0">
and cust_id in
<foreach collection="custIds" item="cust_id" open="(" close=")" separator=",">
#{cust_id}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and trade_time >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and trade_time <= #{endTime} ]]>
</if>
<if test="rltPayorderId != null">
and rlt_payorder_id = #{rltPayorderId,jdbcType=VARCHAR}
</if>
<if test="rltOrderId != null">
and rlt_order_id = #{rltOrderId,jdbcType=VARCHAR}
</if>
<if test="rltOrderType != null">
and rlt_order_type = #{rltOrderType,jdbcType=VARCHAR}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
</select>
<!-- 查询车主每月消费金额 -->
<select id="queryOwnerPayOutByMonth" resultType="com.zteits.clouds.api.dto.owner.dto.OwnerPayOutDTO"
parameterType="com.zteits.clouds.api.dto.owner.param.OwnerRequest">
select
IFNULL(SUM(trade_fee),0) AS fee,
DATE_FORMAT(create_date,'%Y-%m') dateStr
from td_c_acct_payout
where 1=1
and cust_id =#{custId}
and data_state = 1
and create_date BETWEEN #{beginTime} AND #{endTime}
group by dateStr
</select>
<!--根据充值时间查找最新的一条订单 ID-->
<select id="queryAcctPayoutRltOrderId" resultMap="BaseResultMap">
SELECT
id, payout_bill_id, acct_id, cust_id, acct_type, trade_type, trade_detial_type, trade_fee,
trade_balance, trader_id, trader_name, trade_time, rlt_payorder_id, rlt_order_id,
rlt_order_type, acct_upt_state, data_state, create_empid, create_date, modfiy_empid,
modfiy_date, org_id, org_name
FROM
td_c_acct_payout
WHERE 1=1
and acct_id = #{acctId}
<![CDATA[and trade_time <=#{rechargeTime}]]>
order by id desc
limit 1
</select>
</mapper>