InviteSettlementItemMapper.xml
4.94 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
<?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.InviteSettlementItemMapper" >
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.InviteSettlementItem" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="buyer_uid" property="buyerUid" jdbcType="INTEGER" />
<result column="buyer_order_code" property="buyerOrderCode" jdbcType="BIGINT" />
<result column="seller_uid" property="sellerUid" jdbcType="INTEGER" />
<result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
<result column="order_create_time" property="orderCreateTime" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="settle_amount" property="settleAmount" jdbcType="DECIMAL" />
<result column="invite_settlement_id" property="inviteSettlementId" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="status_desc" property="statusDesc" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="order_num" property="orderNum" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, buyer_uid, buyer_order_code, seller_uid, order_amount,order_create_time,type,settle_amount, invite_settlement_id,
status, status_desc, create_time
</sql>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.InviteSettlementItem" >
insert into invite_settlement_item (id,
uid,
buyer_uid,
buyer_order_code,
seller_uid,
order_amount,
order_create_time,
type,
settle_amount,
invite_settlement_id,
status,
status_desc,
create_time)
values (#{id,jdbcType=INTEGER},
#{uid,jdbcType=INTEGER},
#{buyerUid,jdbcType=INTEGER},
#{buyerOrderCode,jdbcType=BIGINT},
#{sellerUid,jdbcType=INTEGER},
#{orderAmount,jdbcType=DECIMAL},
#{orderCreateTime,jdbcType=INTEGER},
#{type,jdbcType=INTEGER},
#{settleAmount,jdbcType=DECIMAL},
#{inviteSettlementId,jdbcType=INTEGER},
#{status,jdbcType=INTEGER},
#{statusDesc,jdbcType=VARCHAR},
#{createTime,jdbcType=INTEGER})
</insert>
<update id="updateToSettled">
update invite_settlement_item
set status = #{tagStatus,jdbcType=INTEGER},
invite_settlement_id = #{inviteSettlementId,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} and type = #{type,jdbcType=INTEGER} and status = #{srcStatus,jdbcType=INTEGER}
</update>
<select id="selectByUidAndBuyerOrderCode" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER} and buyer_order_code = #{buyerOrderCode,jdbcType=BIGINT}
</select>
<select id="selectOneByUidAndStatus" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER} and status = #{status,jdbcType=INTEGER}
limit 1
</select>
<select id="selectOrderNumByInviterUid" resultMap="BaseResultMap" >
select
seller_uid, count(buyer_order_code) order_num
from invite_settlement_item
where uid = #{inviterUid,jdbcType=INTEGER} and status in (1,3)
GROUP by seller_uid
</select>
<select id="selectCountByUidTypeAndInviteSettlementId" resultType="java.lang.Integer" >
select
count(1)
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER} and type = #{type,jdbcType=INTEGER} and invite_settlement_id = #{inviteSettlementId,jdbcType=INTEGER}
</select>
<select id="selectTotalOrderAmountByUidTypeAndInviteSettlementId" resultType="java.math.BigDecimal" >
select
sum(order_amount)
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER} and type = #{type,jdbcType=INTEGER} and invite_settlement_id = #{inviteSettlementId,jdbcType=INTEGER}
</select>
<select id="selectStats" resultType="com.yohoufo.dal.order.model.InviteSettlementItemStats" >
select
count(1) as 'totalElements',
sum(order_amount) as 'totalOrderAmount'
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER}
and type = #{type,jdbcType=INTEGER}
and status in (1,3)
and order_create_time between #{startTime,jdbcType=INTEGER} and #{endTime,jdbcType=INTEGER}
</select>
<select id="select" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from invite_settlement_item
where uid = #{uid,jdbcType=INTEGER}
and type = #{type,jdbcType=INTEGER}
and status in (1,3)
and order_create_time between #{startTime,jdbcType=INTEGER} and #{endTime,jdbcType=INTEGER}
order by order_create_time desc
limit #{start,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
</select>
</mapper>