withdrawRecordMapper.xml
11.3 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
<?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.sibu.orderHelper.integral.web.dao.WithdrawRecordDao">
<resultMap type="com.sibu.orderHelper.integral.vo.WithdrawRecordVo" id="withdrawRecordResponse">
<id column="id" property="id" />
<result column="member_id" property="memberId" />
<result column="partner_trade_no" property="partnerTradeNo" />
<result column="open_id" property="openId" />
<result column="amount" property="amount" />
<result column="user_name" property="userName" />
<result column="pay_desc" property="payDesc" />
<result column="pay_dt" property="payDt" />
<result column="create_dt" property="createDt" />
<result column="status" property="status" />
<result column="fail_code" property="failCode" />
<result column="operator" property="operator" />
<result column="nick_name" property="nickName"></result>
<result column="phone" property="phone"></result>
<result column="payment_no" property="paymentNo"></result>
</resultMap>
<!--分页查询提现记录-->
<select id="selectHasWithdrawForPage" parameterType="java.util.Map" resultMap="withdrawRecordResponse">
SELECT r.*,m.nick_name,m.phone FROM `t_withdraw_record` r INNER JOIN `t_member_info` m
ON r.`member_id` =m.`member_id`
where 1=1
<if test="phone!=null and phone !=''">
and m.phone=#{phone}
</if>
<if test="partnerTradeNo!=null and partnerTradeNo!=''">
and r.partner_trade_no=#{partnerTradeNo}
</if>
<if test="paymentNo!=null and paymentNo!=''">
and r.payment_no=#{paymentNo}
</if>
<if test="startDt !=null">
and r.create_dt >=#{startDt}
</if>
<if test="endDt !=null">
and r.create_dt <= #{endDt}
</if>
<if test="payStartDt !=null">
and r.pay_dt >=#{payStartDt}
</if>
<if test="payEndDt !=null">
and r.pay_dt <= #{payEndDt}
</if>
<if test="status!=null">
and r.status=#{status}
</if>
limit #{pageNow},#{pageSize}
</select>
<!--查询总记录条数-->
<select id="selectCountWithdraw" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(1) FROM `t_withdraw_record` r INNER JOIN `t_member_info` m
ON r.`member_id` =m.`member_id`
where 1=1
<if test="phone!=null and phone!=''">
and m.phone=#{phone}
</if>
<if test="partnerTradeNo!=null and partnerTradeNo!=''">
and r.partner_trade_no=#{partnerTradeNo}
</if>
<if test="paymentNo!=null and paymentNo!=''">
and r.payment_no=#{paymentNo}
</if>
<if test="startDt !=null">
and r.create_dt >=#{startDt}
</if>
<if test="endDt !=null">
and r.create_dt <= #{endDt}
</if>
<if test="payStartDt !=null">
and r.pay_dt >=#{payStartDt}
</if>
<if test="payEndDt !=null">
and r.pay_dt <= #{payEndDt}
</if>
<if test="status!=null">
and r.status=#{status}
</if>
</select>
<!--更新提现记录-->
<update id="updateWithdrawRecord" parameterType="com.sibu.orderHelper.integral.vo.UpdateWithdrawRecordVo" >
update t_withdraw_record
<set>
<if test="payDesc!=null and payDesc!='' " >
pay_desc=#{payDesc},
</if>
<if test="paymentNo!=null and paymentNo!=''" >
payment_no=#{paymentNo},
</if>
<if test="status!=null" >
status=#{status},
</if>
<if test="payDt!=null" >
pay_dt=#{payDt},
</if>
<if test="failCode!=null and failCode!=''" >
fail_code=#{failCode},
</if>
<if test="operator!=null and operator!=''">
operator=#{operator},
</if>
</set>
where id=#{id} and status=#{previousStatus}
</update>
<!--新增提现记录详情-->
<insert id="updateWithdrawRecordDetail" parameterType="com.sibu.orderHelper.integral.vo.UpdateWithdrawRecordVo" >
insert into t_withdraw_record_status(withdraw_recode_id,status,create_dt)
VALUE(
#{id},
#{status},
NOW()
)
</insert>
<!--通过ID查询记录-->
<select id="selectWithdrawRecordById" resultMap="withdrawRecordResponse" parameterType="java.lang.Long">
SELECT r.*,m.nick_name,m.phone FROM `t_withdraw_record` r INNER JOIN `t_member_info` m
ON r.`member_id` =m.`member_id`
where r.id=#{id}
</select>
<!--查询收益总额-->
<select id="selectTotalProfitAmount" parameterType="java.util.Map" resultType="java.math.BigDecimal">
select sum(profit_money-refund_money) from `t_share_profit_record` WHERE share_user_id =#{memberId} and profit_status =1 AND create_dt < #{createDt}
</select>
<!--查询已提现记录-->
<select id="selectHasWithdrawSum" parameterType="java.util.Map" resultType="java.math.BigDecimal">
select sum(amount) from t_withdraw_record where status in(1,2) and member_id=#{memberId} and create_dt <#{createDt}
</select>
<resultMap type="com.sibu.orderHelper.integral.reponse.WebWithdrawRecord" id="withdrawRecordResultMap">
<id column="id" property="id" />
<result column="member_id" property="memberId" />
<result column="partner_trade_no" property="partnerTradeNo" />
<result column="open_id" property="openId" />
<result column="amount" property="amount" />
<result column="user_name" property="userName" />
<result column="pay_desc" property="payDesc" />
<result column="pay_dt" property="payDt" />
<result column="create_dt" property="createDt" />
<result column="status" property="status" />
<result column="fail_code" property="failCode" />
<result column="operator" property="operator" />
<result column="nick_name" property="nickName"/>
<result column="true_name" property="trueName"/>
<result column="phone" property="phone"/>
<result column="wechat" property="wechat"/>
<result column="id_card" property="idCard"/>
</resultMap>
<!--分页查询提现记录-->
<select id="listWithdrawRecord" parameterType="java.util.Map" resultMap="withdrawRecordResultMap">
SELECT r.*,m.nick_name,m.phone,m.wechat,m.id_card,m.true_name FROM `t_withdraw_record` r INNER JOIN `t_member_info` m
ON r.`member_id` =m.`member_id`
where 1=1
<if test="phone!=null and phone !=''">
and m.phone=#{phone}
</if>
<if test="nickName!=null and nickName!=''">
and m.nick_name=#{nickName}
</if>
<if test="idCard!=null and idCard!=''">
and m.id_card=#{idCard}
</if>
<if test="startDt !=null">
and r.create_dt >=#{startDt}
</if>
<if test="endDt !=null">
and r.create_dt <= #{endDt}
</if>
limit #{pageNow},#{pageSize}
</select>
<!--查询总记录条数-->
<select id="totalWithdrawRecord" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(1) FROM `t_withdraw_record` r INNER JOIN `t_member_info` m
ON r.`member_id` =m.`member_id`
where 1=1
<if test="phone!=null and phone !=''">
and m.phone=#{phone}
</if>
<if test="nickName!=null and nickName!=''">
and m.nick_name=#{nickName}
</if>
<if test="idCard!=null and idCard!=''">
and m.id_card=#{idCard}
</if>
<if test="startDt !=null">
and r.create_dt >=#{startDt}
</if>
<if test="endDt !=null">
and r.create_dt <= #{endDt}
</if>
</select>
<!--查询提现记录的佣金详情记录条数-->
<select id="totalWithdrawDetail" parameterType="java.util.Map" resultType="java.lang.Integer">
select count(1) FROM t_share_profit_record WHERE share_user_id=#{shareUserId}
</select>
<!--查询提现记录的佣金详情-->
<select id="selectHasWithdrawDetailForPage" parameterType="java.util.Map" resultMap="selectHasWithdrawDetailMap" >
select r.*,t.nick_name AS nickName,p.name AS productName from t_share_profit_record r
LEFT JOIN t_member_info t ON r.buyer_user_id=t.member_id
LEFT JOIN im_product p ON r.product_id=p.im_product_id
WHERE r.share_user_id=#{shareUserId}
ORDER BY r.id ASC
limit #{pageNow},#{pageSize}
</select>
<resultMap type="com.sibu.orderHelper.vo.WithdrawRecordDetailVo" id="selectHasWithdrawDetailMap">
<id column="id" property="id" />
<result column="share_user_id" property="shareUserId" />
<result column="buyer_user_id" property="buyerUserId" />
<result column="order_id" property="orderId" />
<result column="nick_name" property="nickName" />
<result column="name" property="productName" />
<result column="order_code" property="orderCode" />
<result column="profit_money" property="profitMoney" />
<result column="refund_money" property="refundMoney" />
<result column="profit_status" property="profitStatus" />
<result column="product_id" property="productId" />
<result column="product_price" property="productPrice" />
<result column="product_share_percentage" property="productSharePercentage" />
<result column="product_amount" property="productAmount" />
<result column="profit_dt" property="profitDt"/>
<result column="order_dt" property="orderDt"/>
<result column="refund_dt" property="refundDt"/>
<result column="create_dt" property="createDt"/>
<result column="update_dt" property="updateDt"/>
<result column="settlement_dt" property="settlementDt"/>
</resultMap>
<!--根据不同状态查询提现记录总金额-->
<select id="totalWithdraw" parameterType="java.util.Map" resultType="java.math.BigDecimal">
SELECT SUM(amount) AS sumMoney FROM t_withdraw_record WHERE member_id=#{memberId} AND status=#{status}
</select>
<!-- 总利润 -->
<select id="sumProfit" parameterType="java.util.Map" resultType="java.math.BigDecimal">
SELECT SUM(profit_money) AS sumProfitMoney FROM t_share_profit_record WHERE share_user_id=#{memberId}
</select>
<!-- 佣金不用状态的总金额-->
<select id="shareProfitRecordList" parameterType="java.util.Map" resultMap="getRecord">
select SUM(profit_money) AS money,profit_status AS status FROM t_share_profit_record
WHERE share_user_id=#{memberId}
GROUP BY profit_status
</select>
<resultMap type="java.util.Map" id="getRecord">
<id column="money" property="money" />
<result column="status" property="status" />
</resultMap>
<!-- 不同状态的提现记录总金额-->
<select id="withdrawRecordList" parameterType="java.util.Map">
SELECT SUM(amount) AS money,status FROM t_withdraw_record WHERE member_id=#{memberId} GROUP BY status
</select>
</mapper>