TradeBillsMapper.xml
8.66 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
<?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.yohoufo.dal.order.TradeBillsMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.TradeBills">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="user_type" jdbcType="TINYINT" property="userType" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome" />
<result column="amount" jdbcType="DECIMAL" property="amount" />
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount" />
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="deal_uid" jdbcType="INTEGER" property="dealUid" />
<result column="deal_status" jdbcType="TINYINT" property="dealStatus" />
<result column="deal_time" jdbcType="INTEGER" property="dealTime" />
<result column="deal_relate_id" jdbcType="INTEGER" property="dealRelateId" />
<result column="deal_user_name" jdbcType="VARCHAR" property="dealUserName" />
</resultMap>
<sql id="Base_Column_List">
id,uid, order_code, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time
,deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByDealRelateId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where deal_relate_id = #{dealRelateId,jdbcType=INTEGER}
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.TradeBills" useGeneratedKeys="true">
insert into trade_bills (id, uid, order_code, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time
,deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name)
values (#{id},#{uid},#{orderCode},#{userType},#{payType},#{tradeType},
#{incomeOutcome},#{amount},#{systemAmount},
#{tradeStatus},#{createTime},#{dealUid},#{dealStatus},#{dealTime},#{dealRelateId},#{dealUserName})
</insert>
<!-- 买家只显示补偿款收入 ,卖家只显示货款收入 -->
<sql id="Query_Condition_Sql" >
uid = #{uid,jdbcType=INTEGER} and income_outcome = 1 and ( (user_type =1 and trade_type = 3) or (user_type =2 and trade_type = 2) ) and (trade_status = 100 or (trade_status != 100 and deal_status !=1 ))
</sql>
<select id="selectCountGoodsIncomeOrCompensateIncomeByUid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
select
count(id)
from trade_bills
where <include refid="Query_Condition_Sql" />
</select>
<select id="selectGoodsIncomeOrCompensateIncomeTradeBillsWithPageByUid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where <include refid="Query_Condition_Sql" />
order by id desc
limit #{start,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
</select>
<select id="selectIncomeAmountByUid" resultType="java.util.HashMap">
select trade_type as tradeType,sum(amount) as allAmount from trade_bills
where <include refid="Query_Condition_Sql" />
group by trade_type
</select>
<!--
<select id="selectSpendAmountByUid" resultType="java.util.HashMap">
select trade_type as tradeType,sum(amount) as allAmount from trade_bills
where uid = #{uid} and income_outcome = 2 and ( trade_type = 2 or trade_type = 3 ) and (trade_status = 100 or (trade_status != 100 and deal_status !=1 )) group by trade_type
</select>
-->
<update id="updateToOkByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills
<set >
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=BIGINT},
</if>
<if test="userType != null" >
user_type = #{userType,jdbcType=INTEGER},
</if>
<if test="payType != null" >
pay_type = #{payType,jdbcType=INTEGER},
</if>
<if test="tradeType != null" >
trade_type = #{tradeType,jdbcType=INTEGER},
</if>
<if test="incomeOutcome != null" >
income_outcome = #{incomeOutcome,jdbcType=INTEGER},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="systemAmount != null" >
system_amount = #{systemAmount,jdbcType=DECIMAL},
</if>
<if test="tradeStatus != null" >
trade_status = #{tradeStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="dealUid != null" >
deal_uid = #{dealUid,jdbcType=INTEGER},
</if>
<if test="dealStatus != null" >
deal_status = #{dealStatus,jdbcType=INTEGER},
</if>
<if test="dealTime != null" >
deal_time = #{dealTime,jdbcType=INTEGER},
</if>
<if test="dealRelateId != null" >
deal_relate_id = #{dealRelateId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER} and deal_status != 1
</update>
<update id="updateToFailByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills set deal_status = #{dealStatus,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<!--
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from trade_bills
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.TradeBills" >
insert into trade_bills
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="userType != null" >
user_type,
</if>
<if test="payType != null" >
pay_type,
</if>
<if test="tradeType != null" >
trade_type,
</if>
<if test="incomeOutcome != null" >
income_outcome,
</if>
<if test="amount != null" >
amount,
</if>
<if test="systemAmount != null" >
system_amount,
</if>
<if test="tradeStatus != null" >
trade_status,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=BIGINT},
</if>
<if test="userType != null" >
#{userType,jdbcType=INTEGER},
</if>
<if test="payType != null" >
#{payType,jdbcType=INTEGER},
</if>
<if test="tradeType != null" >
#{tradeType,jdbcType=INTEGER},
</if>
<if test="incomeOutcome != null" >
#{incomeOutcome,jdbcType=INTEGER},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="systemAmount != null" >
#{systemAmount,jdbcType=DECIMAL},
</if>
<if test="tradeStatus != null" >
#{tradeStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills
set uid = #{uid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
user_type = #{userType,jdbcType=INTEGER},
pay_type = #{payType,jdbcType=INTEGER},
trade_type = #{tradeType,jdbcType=INTEGER},
income_outcome = #{incomeOutcome,jdbcType=INTEGER},
amount = #{amount,jdbcType=DECIMAL},
system_amount = #{systemAmount,jdbcType=DECIMAL},
trade_status = #{tradeStatus,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
-->
</mapper>