Commit 15d31749b66e42c1a6d9c174aa92cdb369faf7da
1 parent
d2343ef0
订单dao层 基础方法编写
Showing
3 changed files
with
154 additions
and
46 deletions
src/main/java/com/diligrp/xtrade/order/dao/OrderDao.java
1 | package com.diligrp.xtrade.order.dao; | 1 | package com.diligrp.xtrade.order.dao; |
2 | 2 | ||
3 | +import java.util.List; | ||
4 | + | ||
3 | import org.apache.ibatis.annotations.Param; | 5 | import org.apache.ibatis.annotations.Param; |
4 | import org.springframework.stereotype.Repository; | 6 | import org.springframework.stereotype.Repository; |
5 | 7 | ||
6 | import com.diligrp.xtrade.order.domain.entity.OrderDo; | 8 | import com.diligrp.xtrade.order.domain.entity.OrderDo; |
7 | 9 | ||
8 | /** | 10 | /** |
9 | - * 订单相关数据层基本操作 | 11 | + * @ClassName: OrderDao |
12 | + * @Description 订单操作实体相关 | ||
10 | * @author zhangxing | 13 | * @author zhangxing |
14 | + * @date 2020年4月21日 | ||
11 | */ | 15 | */ |
12 | @Repository("orderDao") | 16 | @Repository("orderDao") |
13 | public interface OrderDao { | 17 | public interface OrderDao { |
14 | 18 | ||
15 | /** | 19 | /** |
16 | - * 插入订单数据 | 20 | + * |
21 | + * @Title insertEntity | ||
22 | + * @Description 保存订单信息 | ||
23 | + * @param order 订单数据实体 | ||
24 | + * @return | ||
25 | + * @throws | ||
17 | */ | 26 | */ |
18 | int insertEntity(OrderDo order); | 27 | int insertEntity(OrderDo order); |
19 | - | 28 | + |
20 | /** | 29 | /** |
21 | - * 根据订单id查询订单 | 30 | + * @Title selectEntityByOrderId |
31 | + * @Description 根据订单id查询订单 | ||
32 | + * @param orderId 订单id | ||
33 | + * @return 订单实体 | ||
34 | + * @throws | ||
22 | */ | 35 | */ |
23 | OrderDo selectEntityByOrderId(@Param("orderId") Long orderId); | 36 | OrderDo selectEntityByOrderId(@Param("orderId") Long orderId); |
24 | 37 | ||
38 | + /** | ||
39 | + * @Title selectEntryListCount | ||
40 | + * @Description 订单数量统计 | ||
41 | + * @param orderDo 查询条件 | ||
42 | + * @return 满足条件订单数量 | ||
43 | + * @throws | ||
44 | + */ | ||
45 | + int selectEntryListCount(OrderDo orderDo); | ||
46 | + | ||
47 | + /** | ||
48 | + * | ||
49 | + * @Title selectEntryList | ||
50 | + * @Description 查询订单列表 | ||
51 | + * @param orderDo 查询条件 | ||
52 | + * @return 满足条件订单实体列表 | ||
53 | + * @throws | ||
54 | + */ | ||
55 | + List<OrderDo> selectEntryList(OrderDo orderDo); | ||
56 | + | ||
57 | + /** | ||
58 | + * | ||
59 | + * @Title updateBuyerInfo | ||
60 | + * @Description 更新买家信息 | ||
61 | + * @param baccount 买家账号 | ||
62 | + * @param bcardNo 买家卡号 | ||
63 | + * @param bcardType 买家卡类型 | ||
64 | + * @param bname 买家姓名 | ||
65 | + * @param bmobile 买家手机号 | ||
66 | + * @return | ||
67 | + * @throws | ||
68 | + */ | ||
69 | + int updateBuyerInfo(@Param("baccount") Long baccount, @Param("bcardNo") Long bcardNo, | ||
70 | + @Param("bcardType") Long bcardType, @Param("bname") Long bname, @Param("bmobile") Long bmobile); | ||
71 | + | ||
72 | + /** | ||
73 | + * | ||
74 | + * @Title finishPayment | ||
75 | + * @Description 完成订单支付 | ||
76 | + * @param payType 支付方式 | ||
77 | + * @param paySrc 支付来源 | ||
78 | + * @return | ||
79 | + * @throws | ||
80 | + */ | ||
81 | + int finishPayment(@Param("payType") Integer payType, @Param("paySrc") Integer paySrc); | ||
82 | + | ||
83 | + /** | ||
84 | + * | ||
85 | + * @Title updateCommission | ||
86 | + * @Description 更新佣金信息 | ||
87 | + * @param scommission 卖家佣金 | ||
88 | + * @param bcommission 买家佣金 | ||
89 | + * @return | ||
90 | + * @throws | ||
91 | + */ | ||
92 | + int updateCommission(@Param("scommission") Long scommission, @Param("bcommission") Long bcommission); | ||
93 | + | ||
94 | + /** | ||
95 | + * @Title updateOrderStatus | ||
96 | + * @Description 更新订单状态 | ||
97 | + * @param orderStatus 订单状态值 根据相关枚举取值 | ||
98 | + * @return | ||
99 | + * @throws | ||
100 | + */ | ||
101 | + int updateOrderStatus(@Param("orderStatus") Integer orderStatus); | ||
102 | + | ||
25 | } | 103 | } |
src/main/java/com/diligrp/xtrade/order/dao/OrderItemDao.java
@@ -8,29 +8,55 @@ import org.springframework.stereotype.Repository; | @@ -8,29 +8,55 @@ import org.springframework.stereotype.Repository; | ||
8 | import com.diligrp.xtrade.order.domain.entity.OrderItemDo; | 8 | import com.diligrp.xtrade.order.domain.entity.OrderItemDo; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | - * 订单详情相关数据层操作 | 11 | + * @ClassName: OrderItemDao |
12 | + * @Description 订单详情操作相关 | ||
12 | * @author zhangxing | 13 | * @author zhangxing |
14 | + * @date 2020年4月21日 | ||
13 | */ | 15 | */ |
14 | @Repository("orderItemDao") | 16 | @Repository("orderItemDao") |
15 | public interface OrderItemDao { | 17 | public interface OrderItemDao { |
16 | 18 | ||
17 | /** | 19 | /** |
18 | - * 插入数据 | 20 | + * |
21 | + * @Title insertEntity | ||
22 | + * @Description 保存订单详情信息 | ||
23 | + * @param orderItemDo 订单详情数据实体 | ||
24 | + * @return | ||
25 | + * @throws | ||
19 | */ | 26 | */ |
20 | int insertEntity(OrderItemDo orderItemDo); | 27 | int insertEntity(OrderItemDo orderItemDo); |
21 | 28 | ||
22 | /** | 29 | /** |
23 | - * 根据详情id查询订单详情 | 30 | + * |
31 | + * @Title selectOrderItemByItemId | ||
32 | + * @Description 根据详情id查询订单详情 | ||
33 | + * @param itemId 订单详情id | ||
34 | + * @return | ||
35 | + * @throws | ||
24 | */ | 36 | */ |
25 | OrderItemDo selectOrderItemByItemId(@Param("itemId") Long itemId); | 37 | OrderItemDo selectOrderItemByItemId(@Param("itemId") Long itemId); |
26 | 38 | ||
27 | /** | 39 | /** |
28 | - * 根据订单id查询订单详情 | 40 | + * |
41 | + * @Title selectOrderItemByOrderId | ||
42 | + * @Description 根据订单id查询订单详情 | ||
43 | + * @param orderId 订单id | ||
44 | + * @return | ||
45 | + * @throws | ||
29 | */ | 46 | */ |
30 | List<OrderItemDo> selectOrderItemByOrderId(@Param("orderId") Long orderId); | 47 | List<OrderItemDo> selectOrderItemByOrderId(@Param("orderId") Long orderId); |
31 | 48 | ||
32 | /** | 49 | /** |
33 | - * 更新佣金及佣金规则 | 50 | + * |
51 | + * @Title updateCommission | ||
52 | + * @Description 更新佣金及佣金规则 | ||
53 | + * @param scommission 卖家佣金 | ||
54 | + * @param bcommission 买家佣金 | ||
55 | + * @param ruleId 佣金规则 | ||
56 | + * @param ruleRate 佣金描述 | ||
57 | + * @param itemId 订单详情id | ||
58 | + * @return | ||
59 | + * @throws | ||
34 | */ | 60 | */ |
35 | int updateCommission(@Param("scommission") Long scommission, @Param("bcommission") Long bcommission, | 61 | int updateCommission(@Param("scommission") Long scommission, @Param("bcommission") Long bcommission, |
36 | @Param("ruleId") Long ruleId, @Param("ruleRate") String ruleRate, @Param("itemId") Long itemId); | 62 | @Param("ruleId") Long ruleId, @Param("ruleRate") String ruleRate, @Param("itemId") Long itemId); |
src/main/resources/mapping/com/diligrp/xtrade/order/OrderDao.xml
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | `bname`, `bmobile`,`market_code` AS marketCode, `order_status` AS orderStatus, `trade_no` AS tradeNo, `total_money` AS totalMoney,`scommission`, `bcommission`, `weight`, | 7 | `bname`, `bmobile`,`market_code` AS marketCode, `order_status` AS orderStatus, `trade_no` AS tradeNo, `total_money` AS totalMoney,`scommission`, `bcommission`, `weight`, |
8 | `pay_type` AS payType, `pay_src` AS paySrc, `created_src` AS createdSrc, `order_type` AS orderType, `pay_time` AS payTime, `created_time` AS createdTime, `modified_time`AS modifiedTime, `is_del` AS isDel]]> | 8 | `pay_type` AS payType, `pay_src` AS paySrc, `created_src` AS createdSrc, `order_type` AS orderType, `pay_time` AS payTime, `created_time` AS createdTime, `modified_time`AS modifiedTime, `is_del` AS isDel]]> |
9 | </sql> | 9 | </sql> |
10 | - | 10 | + |
11 | <sql id="QUERY_WHERE_CLAUSE"> | 11 | <sql id="QUERY_WHERE_CLAUSE"> |
12 | <where> | 12 | <where> |
13 | <if test="orderId != null and orderId != ''"><![CDATA[AND xt_order.order_id = #{orderId}]]></if> | 13 | <if test="orderId != null and orderId != ''"><![CDATA[AND xt_order.order_id = #{orderId}]]></if> |
@@ -22,49 +22,25 @@ | @@ -22,49 +22,25 @@ | ||
22 | <if test="orderType != null and orderType != '' "><![CDATA[AND xt_order.order_type = #{orderType} ]]></if> | 22 | <if test="orderType != null and orderType != '' "><![CDATA[AND xt_order.order_type = #{orderType} ]]></if> |
23 | </where> | 23 | </where> |
24 | </sql> | 24 | </sql> |
25 | - | ||
26 | - <sql id="UPDATE_COLUMN_SET"> | ||
27 | - <set> | ||
28 | - <if test="buyerAccount != null"><![CDATA[buyer_account = #{buyerAccount},]]></if> | ||
29 | - <if test="buyerCardNo != null"><![CDATA[buyer_card_no = #{buyerCardNo},]]></if> | ||
30 | - <if test="buyerCardType != null"><![CDATA[buyer_card_type = #{buyerCardType},]]></if> | ||
31 | - <if test="buyerName != null"><![CDATA[buyer_name = #{buyerName},]]></if> | ||
32 | - <if test="buyerMobile != null"><![CDATA[buyer_mobile = #{buyerMobile},]]></if> | ||
33 | - <if test="payDate != null"><![CDATA[pay_date = #{payDate},]]></if> | ||
34 | - <if test="orderStatus != null"><![CDATA[order_status = #{orderStatus},]]></if> | ||
35 | - <if test="tradeNo != null"><![CDATA[trade_no = #{tradeNo},]]></if> | ||
36 | - <if test="scommission != null"><![CDATA[scommission = #{scommission},]]></if> | ||
37 | - <if test="bcommission != null"><![CDATA[bcommission = #{bcommission},]]></if> | ||
38 | - <if test="payType != null and payType != ''"><![CDATA[pay_type = #{payType},]]></if> | ||
39 | - <if test="paySrc != null and paySrc != ''"><![CDATA[pay_src = #{paySrc},]]></if> | ||
40 | - <if test="orderType != null and orderType !=''"><![CDATA[order_type = #{orderType},]]></if> | ||
41 | - <![CDATA[modify_date = now()]]> | ||
42 | - </set> | ||
43 | - </sql> | ||
44 | - | 25 | + |
45 | <sql id="QUERY_ORDER_LIMIT_CONDTION"> | 26 | <sql id="QUERY_ORDER_LIMIT_CONDTION"> |
46 | <if | 27 | <if |
47 | test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY etrade_order.${orderField} ${orderFieldType}]]></if> | 28 | test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY etrade_order.${orderField} ${orderFieldType}]]></if> |
48 | <if | 29 | <if |
49 | test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if> | 30 | test="startIndex != null and startIndex >= 0 and pageSize != null and pageSize > 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if> |
50 | </sql> | 31 | </sql> |
51 | - | ||
52 | - <insert id="insertEntity" parameterType="orderDo"> | 32 | + |
33 | + <insert id="insertEntity" parameterType="orderDo"> | ||
53 | <![CDATA[ | 34 | <![CDATA[ |
54 | INSERT INTO `xt_order`(`order_id`, `saccount`, `scard_no`, `scard_type`, `sname`, `smobile`, `baccount`, `bcard_no`, `bcard_type`, `bname`, `bmobile`, `market_code`, | 35 | INSERT INTO `xt_order`(`order_id`, `saccount`, `scard_no`, `scard_type`, `sname`, `smobile`, `baccount`, `bcard_no`, `bcard_type`, `bname`, `bmobile`, `market_code`, |
55 | `order_status`, `trade_no`, `total_money`, `scommission`, `bcommission`, `weight`, `pay_type`, `pay_src`, `created_src`, `pay_time`, `created_time`, `modified_time`, `is_del`) | 36 | `order_status`, `trade_no`, `total_money`, `scommission`, `bcommission`, `weight`, `pay_type`, `pay_src`, `created_src`, `pay_time`, `created_time`, `modified_time`, `is_del`) |
56 | VALUES(#{orderId}, #{saccount}, #{scardNo}, #{scardType}, #{sname}, #{smobile}, #{baccount}, #{bcardNo}, #{bcardType}, #{bname}, #{bmobile}, | 37 | VALUES(#{orderId}, #{saccount}, #{scardNo}, #{scardType}, #{sname}, #{smobile}, #{baccount}, #{bcardNo}, #{bcardType}, #{bname}, #{bmobile}, |
57 | - #{marketCode}, #{orderStatus}, #{tradeNo}, #{totalMoney}, #{scommission}, #{bcommission},#{weight}, #{payType}, #{paySrc}, #{createdSrc}, NOW(), NOW(), NOW(),1); | 38 | + #{marketCode}, #{orderStatus}, #{tradeNo}, #{totalMoney}, #{scommission}, #{bcommission},#{weight}, #{payType}, #{paySrc}, #{createdSrc}, #{payTime}, #{createdTime}, NOW(),1); |
58 | ]]> | 39 | ]]> |
59 | </insert> | 40 | </insert> |
60 | - | ||
61 | - <update id="updateByOrderId" parameterType="orderDo"> | ||
62 | - <![CDATA[UPDATE `xt_order`]]> | ||
63 | - <include refid="UPDATE_COLUMN_SET" /> | ||
64 | - <![CDATA[ WHERE order_id = #{orderId}]]> | ||
65 | - </update> | ||
66 | 41 | ||
67 | - <select id="selectEntryList" parameterType="orderDo" resultType="orderDo"> | 42 | + <select id="selectEntryList" parameterType="orderDo" |
43 | + resultType="orderDo"> | ||
68 | <![CDATA[SELECT]]> | 44 | <![CDATA[SELECT]]> |
69 | <include refid="QUERY_COLUMN_LIST" /> | 45 | <include refid="QUERY_COLUMN_LIST" /> |
70 | <![CDATA[FROM `xt_order`]]> | 46 | <![CDATA[FROM `xt_order`]]> |
@@ -72,16 +48,44 @@ | @@ -72,16 +48,44 @@ | ||
72 | <include refid="QUERY_ORDER_LIMIT_CONDTION" /> | 48 | <include refid="QUERY_ORDER_LIMIT_CONDTION" /> |
73 | </select> | 49 | </select> |
74 | 50 | ||
75 | - <select id="selectEntryListCount" parameterType="orderDo" resultType="int"> | 51 | + <select id="selectEntryListCount" parameterType="orderDo" |
52 | + resultType="int"> | ||
76 | <![CDATA[SELECT COUNT(xt_order.id) AS dataCount FROM `xt_order`]]> | 53 | <![CDATA[SELECT COUNT(xt_order.id) AS dataCount FROM `xt_order`]]> |
77 | <include refid="QUERY_WHERE_CLAUSE" /> | 54 | <include refid="QUERY_WHERE_CLAUSE" /> |
78 | </select> | 55 | </select> |
79 | - | ||
80 | - <select id="selectEntityByOrderId" parameterType="long" resultType="orderDo"> | ||
81 | - SELECT | ||
82 | - <include refid="QUERY_COLUMN_LIST"/> | ||
83 | - FROM `xt_order` | 56 | + |
57 | + <select id="selectEntityByOrderId" parameterType="long" | ||
58 | + resultType="orderDo"> | ||
59 | + SELECT | ||
60 | + <include refid="QUERY_COLUMN_LIST" /> | ||
61 | + FROM `xt_order` | ||
84 | WHERE order_id =#{orderId} | 62 | WHERE order_id =#{orderId} |
85 | </select> | 63 | </select> |
64 | + | ||
65 | + <update id="updateBuyerInfo"> | ||
66 | + UPDATE xt_order | ||
67 | + SET baccount = #{baccount},bcard_no = #{bcardNo}, | ||
68 | + bcard_type =#{bcardType},bname = #{bname}, | ||
69 | + bmobile = #{bmobile},modified_time =now() | ||
70 | + WHERE order_id=#{orderId} | ||
71 | + </update> | ||
72 | + | ||
73 | + <update id="finishPayment"> | ||
74 | + UPDATE xt_order | ||
75 | + SET order_status = 3, pay_type = #{payType}, | ||
76 | + pay_src = #{paySrc}, pay_time = now(), modified_time = now() | ||
77 | + WHERE order_id=#{orderId} | ||
78 | + </update> | ||
79 | + | ||
80 | + <update id="updateCommission"> | ||
81 | + UPDATE xt_order SET scommission = #{scommission}, bcommission = #{bcommission}, modified_time = now() | ||
82 | + WHERE order_id=#{orderId} | ||
83 | + </update> | ||
86 | 84 | ||
85 | + <update id="updateOrderStatus"> | ||
86 | + UPDATE xt_order | ||
87 | + SET order_status = #{orderStatus}, modified_time = now() | ||
88 | + WHERE order_id=#{orderId} | ||
89 | + </update> | ||
90 | + | ||
87 | </mapper> | 91 | </mapper> |
88 | \ No newline at end of file | 92 | \ No newline at end of file |