Commit 41841db023ae10dbfe8066d636c0c00ab444e877

Authored by Jiang
1 parent 161e8bdc

增加资金账户依赖

Showing 23 changed files with 353 additions and 107 deletions
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/OrderListRequestDto.java
1 1 package com.b2c.orders.client.domain.dto.request;
2 2  
3   -import com.b2c.orders.enums.OrderStatus;
4   -
5 3 import io.swagger.annotations.ApiParam;
6 4  
7 5 public class OrderListRequestDto {
... ... @@ -18,7 +16,7 @@ public class OrderListRequestDto {
18 16 private Long sellerId;
19 17 /** 订单状态 */
20 18 @ApiParam("订单状态")
21   - private OrderStatus orderStatus;
  19 + private Integer orderStatus;
22 20 @ApiParam("每页显示记录数")
23 21 private Integer pageSize = 10;
24 22 @ApiParam("第几页")
... ... @@ -40,11 +38,11 @@ public class OrderListRequestDto {
40 38 this.sellerId = sellerId;
41 39 }
42 40  
43   - public OrderStatus getOrderStatus() {
  41 + public Integer getOrderStatus() {
44 42 return orderStatus;
45 43 }
46 44  
47   - public void setOrderStatus(OrderStatus orderStatus) {
  45 + public void setOrderStatus(Integer orderStatus) {
48 46 this.orderStatus = orderStatus;
49 47 }
50 48  
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/response/OrderItemResponseDto.java
1 1 package com.b2c.orders.client.domain.dto.response;
2 2  
  3 +import com.fasterxml.jackson.annotation.JsonInclude;
  4 +import com.fasterxml.jackson.annotation.JsonInclude.Include;
  5 +
  6 +@JsonInclude(Include.NON_EMPTY)
3 7 public class OrderItemResponseDto {
4 8  
5 9 private Long orderId;
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/response/OrderListResponseDto.java
... ... @@ -7,7 +7,11 @@ import com.b2c.orders.enums.DeliveryType;
7 7 import com.b2c.orders.enums.OrderStatus;
8 8 import com.b2c.orders.enums.PayStatus;
9 9 import com.b2c.orders.enums.PayType;
  10 +import com.fasterxml.jackson.annotation.JsonFormat;
  11 +import com.fasterxml.jackson.annotation.JsonInclude;
  12 +import com.fasterxml.jackson.annotation.JsonInclude.Include;
10 13  
  14 +@JsonInclude(Include.NON_EMPTY)
11 15 public class OrderListResponseDto {
12 16  
13 17 /**
... ... @@ -31,23 +35,29 @@ public class OrderListResponseDto {
31 35 /** 买家备注说明 */
32 36 private String buyerMemo;
33 37 /** 支付时间 */
  38 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
34 39 private Date payTime;
35 40 /**
36 41 * 送货时间
37 42 */
38 43 private Date deliveryTime;
39 44 /** 提货时间 */
  45 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
40 46 private Date reservationTime;
41 47 /** 买家确认收货时间 */
  48 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
42 49 private Date buyerConfirmTime;
43 50 /** 订单提交时间 */
  51 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
44 52 private Date submitTime;
45 53 /** 支付类型 */
46 54 private PayType payType;
47 55 /** 总金额 */
48 56 private Long totalPrice;
49   - /** 进入当前状态说明或原因,如取消原因,退款审批通过原因等 */
50   - private String statusInReason;
  57 + /**
  58 + * 接单后修改的价格
  59 + */
  60 + private Long realTotalPrice;
51 61 /**
52 62 * 订单项
53 63 */
... ... @@ -165,12 +175,12 @@ public class OrderListResponseDto {
165 175 this.totalPrice = totalPrice;
166 176 }
167 177  
168   - public String getStatusInReason() {
169   - return statusInReason;
  178 + public Long getRealTotalPrice() {
  179 + return realTotalPrice;
170 180 }
171 181  
172   - public void setStatusInReason(String statusInReason) {
173   - this.statusInReason = statusInReason;
  182 + public void setRealTotalPrice(Long realTotalPrice) {
  183 + this.realTotalPrice = realTotalPrice;
174 184 }
175 185  
176 186 public List<OrderItemResponseDto> getOrderItems() {
... ... @@ -180,4 +190,5 @@ public class OrderListResponseDto {
180 190 public void setOrderItems(List<OrderItemResponseDto> orderItems) {
181 191 this.orderItems = orderItems;
182 192 }
  193 +
183 194 }
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/response/PageResponseDto.java 0 → 100644
  1 +package com.b2c.orders.client.domain.dto.response;
  2 +
  3 +import java.util.List;
  4 +
  5 +public class PageResponseDto<T> {
  6 +
  7 + /**
  8 + * 总页数
  9 + */
  10 + private int totalPage;
  11 +
  12 + /**
  13 + * 总数量
  14 + */
  15 + private int totalSize;
  16 +
  17 + /**
  18 + * 当前页
  19 + */
  20 + private int currentPage;
  21 +
  22 + /**
  23 + * 每页数量
  24 + */
  25 + private int pageSize;
  26 +
  27 + /**
  28 + * 数据集合
  29 + */
  30 + private List<T> list;
  31 +
  32 + public int getTotalPage() {
  33 + return totalPage;
  34 + }
  35 +
  36 + public void setTotalPage(int totalPage) {
  37 + this.totalPage = totalPage;
  38 + }
  39 +
  40 + public int getTotalSize() {
  41 + return totalSize;
  42 + }
  43 +
  44 + public void setTotalSize(int totalSize) {
  45 + this.totalSize = totalSize;
  46 + }
  47 +
  48 + public int getCurrentPage() {
  49 + return currentPage;
  50 + }
  51 +
  52 + public void setCurrentPage(int currentPage) {
  53 + this.currentPage = currentPage;
  54 + }
  55 +
  56 + public int getPageSize() {
  57 + return pageSize;
  58 + }
  59 +
  60 + public void setPageSize(int pageSize) {
  61 + this.pageSize = pageSize;
  62 + }
  63 +
  64 + public List<T> getList() {
  65 + return list;
  66 + }
  67 +
  68 + public void setList(List<T> list) {
  69 + this.list = list;
  70 + }
  71 +
  72 +}
... ...
b2c-orders-commons/src/main/java/com/b2c/orders/commons/constant/Constant.java
... ... @@ -5,15 +5,15 @@ public class Constant {
5 5 /**
6 6 * 商家未接单,订单超时api接口地址
7 7 */
8   - public static final String ORDER_TAKE_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/timeout";
  8 + public static final String ORDER_TAKEN_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/takenTimeout";
9 9 /**
10 10 * 买家未付款,订单超时api接口
11 11 */
12   - public static final String ORDER_PAY_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/timeout";
  12 + public static final String ORDER_PAYMENT_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/paymentTimeout";
13 13 /**
14 14 * 商家未接单,订单超时时间
15 15 */
16   - public static final int ORDER_TAKEN_TIMEOUT_SECONDS = 24 * 60 * 60;
  16 + public static final int ORDER_TAKEN_TIMEOUT_SECONDS = 2 * 60 * 60;
17 17 /**
18 18 * 买家未支付,订单超时时间
19 19 */
... ... @@ -21,7 +21,7 @@ public class Constant {
21 21 /**
22 22 * 买家超过{@link ORDER_CONFIRM_TIMEOUT_SECONDS}秒没有确认收货或者卖家超过{@link ORDER_CONFIRM_TIMEOUT_SECONDS}没有确认收款,dtms调用接口地址自动确认收货、收款
23 23 */
24   - public static final String ORDER_CONFIRM_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/confirm";
  24 + public static final String ORDER_CONFIRM_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtmsConfirm";
25 25 /**
26 26 * 买家超过这个时间(单位:秒)没有确认收货或者卖家超过这个时间(单位:秒)没有确认收款,dtms调用{@link ORDER_CONFIRM_TIMEOUT_CALL_URL}订单接口确认收货、收款
27 27 */
... ...
b2c-orders-dao/src/main/java/com/b2c/orders/dao/utils/Query.java 0 → 100644
  1 +package com.b2c.orders.dao.utils;
  2 +
  3 +import com.diligrp.website.util.dao.BaseQuery;
  4 +
  5 +public class Query extends BaseQuery {
  6 +
  7 + @Override
  8 + public Integer getCurrPage() {
  9 + if (super.getCurrPage() == null || super.getCurrPage() < 0) {
  10 + this.setCurrPage(1);
  11 + }
  12 + return super.getCurrPage();
  13 + }
  14 +
  15 + @Override
  16 + public int getStartRow() {
  17 + return (this.getCurrPage() - 1) * this.getPageSize();
  18 + }
  19 +
  20 +}
... ...
b2c-orders-dao/src/main/resources/sqlmap-config.xml
... ... @@ -22,8 +22,7 @@
22 22 <typeAliases>
23 23 <typeAlias type="com.b2c.orders.domain.OrderMaxid" alias="orderMaxid" />
24 24 <typeAlias type="com.b2c.orders.domain.OrderLog" alias="OrderLog" />
25   - <typeAlias type="com.diligrp.website.util.dao.BaseQuery"
26   - alias="Query" />
  25 + <typeAlias type="com.b2c.orders.dao.utils.Query" alias="Query" />
27 26 </typeAliases>
28 27  
29 28 <typeHandlers>
... ...
b2c-orders-dao/src/main/resources/sqlmap/OrderItemMapper.xml
... ... @@ -5,8 +5,7 @@
5 5 <id property="id" column="id" />
6 6 <result property="orderId" column="order_id" />
7 7 <result property="productId" column="product_id" />
8   - <result property="buyerId" column="buyer_id" />
9   - <result property="sellerId" column="seller_id" />
  8 + <result property="productName" column="product_name" />
10 9 <result property="shopId" column="shop_id" />
11 10 <result property="sku" column="sku" />
12 11 <result property="skuTitle" column="sku_title" />
... ... @@ -31,6 +30,9 @@
31 30 <if test="param.productId != null and param.productId != ''">
32 31 and product_id = #{param.productId}
33 32 </if>
  33 + <if test="param.productName != null and param.productName != ''">
  34 + and product_name = #{param.productName}
  35 + </if>
34 36 <if test="param.buyerId != null and param.buyerId != ''">
35 37 and buyer_id = #{param.buyerId}
36 38 </if>
... ... @@ -67,7 +69,7 @@
67 69 id
68 70 order_id,
69 71 product_id,
70   - seller_id,
  72 + product_name,
71 73 shop_id,
72 74 sku,
73 75 sku_title,
... ... @@ -90,8 +92,7 @@
90 92 id,
91 93 order_id,
92 94 product_id,
93   - buyer_id,
94   - seller_id,
  95 + product_name,
95 96 shop_id,
96 97 sku,
97 98 sku_title,
... ... @@ -104,8 +105,7 @@
104 105 #{id},
105 106 #{orderId},
106 107 #{productId},
107   - #{buyerId},
108   - #{sellerId},
  108 + #{productName},
109 109 #{shopId},
110 110 #{sku},
111 111 #{skuTitle},
... ...
b2c-orders-dao/src/main/resources/sqlmap/OrderLogMapper.xml
1 1 <?xml version="1.0" encoding="UTF-8" ?>
2 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3 <mapper namespace="com.b2c.orders.dao.impl.OrderLogDaoBean">
4   - <resultMap id="OrderRM" type="OrderLog">
  4 + <resultMap id="OrderLogRM" type="OrderLog">
5 5 <id property="id" column="id" />
6 6 <result property="action" column="action" />
7 7 <result property="actionTime" column="action_time" />
... ... @@ -62,7 +62,7 @@
62 62 <include refid="selectCondition" />
63 63 </select>
64 64  
65   - <select id="listByCondition" parameterType="Query" resultMap="OrderRM">
  65 + <select id="listByCondition" parameterType="Query" resultMap="OrderLogRM">
66 66 <![CDATA[
67 67 SELECT
68 68 id
... ...
b2c-orders-dao/src/main/resources/sqlmap/OrderMapper.xml
1 1 <?xml version="1.0" encoding="UTF-8" ?>
2 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3 <mapper namespace="com.b2c.orders.dao.impl.OrderDaoBean">
4   - <resultMap id="OrderLogRM" type="com.b2c.orders.domain.Order">
  4 + <resultMap id="OrderRM" type="com.b2c.orders.domain.Order">
5 5 <id property="id" column="id" />
6 6 <result property="buyerId" column="buyer_id" />
7 7 <result property="sellerId" column="seller_id" />
... ... @@ -20,86 +20,124 @@
20 20 <result property="realTotalPrice" column="real_total_price" />
21 21 <result property="versionNum" column="version_num" />
22 22 <result property="delete" column="delete_flag" />
  23 + <result property="statusInReason" column="status_in_reason" />
23 24 <collection property="orderItems" column="id"
24 25 select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" />
25 26 </resultMap>
26 27  
  28 + <sql id="selectColumn">
  29 + t1.id
  30 + ,t1.buyer_id
  31 + ,t1.seller_id
  32 + ,t1.delivery_type
  33 + ,t1.order_status
  34 + ,t1.pay_status
  35 + ,t1.buyer_memo
  36 + ,t1.pay_time
  37 + ,t1.delivery_time
  38 + ,t1.reservation_time
  39 + ,t1.buyer_confirm_time
  40 + ,t1.seller_confirm_time
  41 + ,t1.submit_time
  42 + ,t1.pay_type
  43 + ,t1.total_price
  44 + ,t1.real_total_price
  45 + ,t1.version_num
  46 + ,t1.status_in_reason
  47 + </sql>
  48 +
27 49 <sql id="selectCondition">
28 50 <if test="param != null">
29 51 <if test="param.id != null and param.id != ''">
30   - and id = #{param.id}
  52 + and t1.id = #{param.id}
31 53 </if>
32 54 <if test="param.buyerId != null and param.buyerId != ''">
33   - and buyer_id = #{param.buyerId}
  55 + and t1.buyer_id = #{param.buyerId}
34 56 </if>
35 57 <if test="param.sellerId != null and param.sellerId != ''">
36   - and seller_id = #{param.sellerId}
  58 + and t1.seller_id = #{param.sellerId}
37 59 </if>
38 60 <if test="param.deliveryType != null and param.deliveryType != ''">
39   - and delivery_type = #{param.deliveryType}
  61 + and t1.delivery_type = #{param.deliveryType}
40 62 </if>
41 63 <if test="param.orderStatus != null and param.orderStatus != ''">
42   - and order_status = #{param.orderStatus}
  64 + and t1.order_status = #{param.orderStatus}
43 65 </if>
44 66 <if test="param.payStatus != null and param.payStatus != ''">
45   - and pay_status = #{param.payStatus}
  67 + and t1.pay_status = #{param.payStatus}
46 68 </if>
47 69 <if test="param.buyerMemo != null and param.buyerMemo != ''">
48   - and buyer_memo = #{param.buyerMemo}
  70 + and t1.buyer_memo = #{param.buyerMemo}
49 71 </if>
50 72 <if test="param.payBeginTime != null and param.payBeginTime != ''">
51   - <![CDATA[and pay_time >= #{param.payBeginTime}]]>
  73 + <![CDATA[and t1.pay_time >= #{param.payBeginTime}]]>
52 74 </if>
53 75 <if test="param.payEndTime != null and param.payEndTime != ''">
54   - <![CDATA[and pay_time <= #{param.payEndTime}]]>
  76 + <![CDATA[and t1.pay_time <= #{param.payEndTime}]]>
55 77 </if>
56 78 <if
57 79 test="param.deliveryBeginTime != null and param.deliveryBeginTime != ''">
58   - <![CDATA[and delivery_time >= #{param.deliveryBeginTime}]]>
  80 + <![CDATA[and t1.delivery_time >= #{param.deliveryBeginTime}]]>
59 81 </if>
60 82 <if test="param.deliveryEndTime != null and param.deliveryEndTime != ''">
61   - <![CDATA[and delivery_time <= #{param.deliveryEndTime}]]>
  83 + <![CDATA[and t1.delivery_time <= #{param.deliveryEndTime}]]>
62 84 </if>
63 85 <if
64 86 test="param.buyerConfirmEndTime != null and param.buyerConfirmBeginTime != ''">
65   - <![CDATA[and buyer_confirm_time >= #{param.buyerConfirmBeginTime}]]>
  87 + <![CDATA[and t1.buyer_confirm_time >= #{param.buyerConfirmBeginTime}]]>
66 88 </if>
67 89 <if
68 90 test="param.buyerConfirmEndTime != null and param.buyerConfirmEndTime != ''">
69   - <![CDATA[and buyer_confirm_time <= #{param.buyerConfirmEndTime}]]>
  91 + <![CDATA[and t1.buyer_confirm_time <= #{param.buyerConfirmEndTime}]]>
70 92 </if>
71 93 <if
72 94 test="param.sellerConfirmBeginTime != null and param.sellerConfirmBeginTime != ''">
73   - <![CDATA[and seller_confirm_time >= #{param.sellerConfirmBeginTime}]]>
  95 + <![CDATA[and t1.seller_confirm_time >= #{param.sellerConfirmBeginTime}]]>
74 96 </if>
75 97 <if
76 98 test="param.sellerConfirmEndTime != null and param.sellerConfirmEndTime != ''">
77   - <![CDATA[and seller_confirm_time <= #{param.sellerConfirmEndTime}]]>
  99 + <![CDATA[and t1.seller_confirm_time <= #{param.sellerConfirmEndTime}]]>
78 100 </if>
79 101 <if
80 102 test="param.reservationBeginTime != null and param.reservationBeginTime != ''">
81   - <![CDATA[and reservation_time >= #{param.reservationBeginTime}]]>
  103 + <![CDATA[and t1.reservation_time >= #{param.reservationBeginTime}]]>
82 104 </if>
83 105 <if
84 106 test="param.reservationEndTime != null and param.reservationEndTime != ''">
85   - <![CDATA[and reservation_time <= #{param.reservationEndTime}]]>
  107 + <![CDATA[and t1.reservation_time <= #{param.reservationEndTime}]]>
86 108 </if>
87 109 <if test="param.submitBeginTime != null and param.submitBeginTime != ''">
88   - <![CDATA[and submit_time >= #{param.submitBeginTime}]]>
  110 + <![CDATA[and t1.submit_time >= #{param.submitBeginTime}]]>
89 111 </if>
90 112 <if test="param.submitEndTime != null and param.submitEndTime != ''">
91   - <![CDATA[and submit_time <= #{param.submitEndTime}]]>
  113 + <![CDATA[and t1.submit_time <= #{param.submitEndTime}]]>
92 114 </if>
93 115 <if test="param.buyerMemo != null and param.buyerMemo != ''">
94   - and pay_type = #{param.payType}
  116 + and t1.pay_type = #{param.payType}
95 117 </if>
96 118 <if test="param.buyerMemo != null and param.buyerMemo != ''">
97   - and total_price = #{param.totalPrice}
  119 + and t1.total_price = #{param.totalPrice}
  120 + </if>
  121 + <if test="param.productName != null and param.productName != ''">
  122 + <![CDATA[and t2.product_name like CONCAT('%',#{param.productName},'%')]]>
98 123 </if>
99 124 </if>
100 125 and delete_flag = 0
101 126 </sql>
102 127  
  128 + <sql id="joinOrderItem">
  129 + <if test="params.productName != null and params.productName != ''">
  130 + RIGHT JOIN t_order_item t2 ON t2.order_id = t1.id
  131 + </if>
  132 + </sql>
  133 +
  134 + <select id="getById" parameterType="Long" resultMap="OrderRM">
  135 + SELECT
  136 + <include refid="selectColumn" />
  137 + FROM t_order t1
  138 + WHERE delete_flag = 0 AND id = #{id}
  139 + </select>
  140 +
103 141 <insert id="save" parameterType="com.b2c.orders.domain.Order">
104 142 <![CDATA[
105 143 INSERT INTO t_order(
... ... @@ -136,10 +174,10 @@
136 174 buyer_memo=#{buyerMemo},
137 175 pay_time=#{payTime},
138 176 delivery_time=#{deliveryTime},
139   - buyer_confirm_time=#{buyerConfirm_time},
  177 + buyer_confirm_time=#{buyerConfirmTime},
140 178 seller_confirm_time=#{sellerConfirmTime},
141 179 real_total_price=#{realTotalPrice},
142   - submit_time=#{submitTime},
  180 + status_in_reason=#{statusInReason}
143 181 version_num=version_num + 1
144 182 where 1=1
145 183 and version_num=#{versionNum} and id = #{id}
... ... @@ -147,34 +185,18 @@
147 185 </update>
148 186  
149 187 <select id="countByCondition" parameterType="Query" resultType="Integer">
150   - <![CDATA[
151   - SELECT count(1) FROM t_order where 1=1
152   - ]]>
  188 + SELECT count(1) FROM t_order
  189 + <include refid="joinOrderItem" />
  190 + where 1=1
153 191 <include refid="selectCondition" />
154 192 </select>
155 193  
156   - <select id="listByCondition" parameterType="Query" resultMap="OrderLogRM">
157   - <![CDATA[
  194 + <select id="listByCondition" parameterType="Query" resultMap="OrderRM">
158 195 SELECT
159   - id
160   - ,buyer_id
161   - ,seller_id
162   - ,delivery_type
163   - ,order_status
164   - ,pay_status
165   - ,buyer_memo
166   - ,pay_time
167   - ,delivery_time
168   - ,reservation_time
169   - ,buyer_confirm_time
170   - ,seller_confirm_time
171   - ,submit_time
172   - ,pay_type
173   - ,total_price
174   - ,real_total_price
175   - ,version_num
176   - FROM t_order where 1=1
177   - ]]>
  196 + <include refid="selectColumn" />
  197 + FROM t_order t1
  198 + <include refid="joinOrderItem" />
  199 + where 1=1
178 200 <include refid="selectCondition" />
179 201 order by id desc
180 202 <![CDATA[
... ...
b2c-orders-dao/src/main/resources/sqlmap/OrderMaxid.xml
... ... @@ -35,7 +35,7 @@
35 35 </sql>
36 36  
37 37 <!-- 插入order_maxid记录 -->
38   - <insert id="insertEntry" parameterType="Maxid">
  38 + <insert id="insertEntry" parameterType="orderMaxid">
39 39 <![CDATA[
40 40 INSERT INTO order_maxid (id,id_type,id_value,memo,version_num)
41 41 VALUES (#{id},#{idType},#{idValue},#{memo},#{versionNum})
... ... @@ -55,13 +55,13 @@
55 55 </delete>
56 56  
57 57 <!-- 删除,通过条件 -->
58   - <update id="deleteByCondtion" parameterType="Maxid">
  58 + <update id="deleteByCondtion" parameterType="orderMaxid">
59 59 <![CDATA[DELETE FROM order_maxid]]>
60 60 <include refid="QUERY_WHERE_CLAUSE" />
61 61 </update>
62 62  
63 63 <!-- 修改记录通过主键 -->
64   - <update id="updateByKey" parameterType="Maxid">
  64 + <update id="updateByKey" parameterType="orderMaxid">
65 65 <![CDATA[UPDATE order_maxid]]>
66 66 <include refid="UPDATE_COLUMN_SET" />
67 67 <![CDATA[WHERE id = #{id} AND version_num = #{versionNum}]]>
... ... @@ -69,7 +69,7 @@
69 69  
70 70 <!-- 查询,通过主键IN(array) -->
71 71 <select id="selectEntryArray" parameterType="java.lang.reflect.Array"
72   - resultType="Maxid">
  72 + resultType="orderMaxid">
73 73 <![CDATA[SELECT]]>
74 74 <include refid="QUERY_COLUMN_LIST" />
75 75 <include refid="QUERY_FROM_TABLE" />
... ... @@ -81,8 +81,8 @@
81 81 </select>
82 82  
83 83 <!-- 查询,通过条件 -->
84   - <select id="selectEntryList" parameterType="Maxid"
85   - resultType="Maxid">
  84 + <select id="selectEntryList" parameterType="orderMaxid"
  85 + resultType="orderMaxid">
86 86 <![CDATA[SELECT]]>
87 87 <include refid="QUERY_COLUMN_LIST" />
88 88 <include refid="QUERY_FROM_TABLE" />
... ... @@ -90,7 +90,7 @@
90 90 </select>
91 91  
92 92 <!-- 总数查询,通过条件 -->
93   - <select id="selectEntryListCount" parameterType="Maxid"
  93 + <select id="selectEntryListCount" parameterType="orderMaxid"
94 94 resultType="int">
95 95 <![CDATA[SELECT COUNT(id) AS dataCount]]>
96 96 <include refid="QUERY_FROM_TABLE" />
... ...
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... ... @@ -120,7 +120,6 @@ public class Order extends BaseDomain {
120 120 this.deliveryTime = df.parse(vo.getDeliveryTime());
121 121 }
122 122 this.deliveryType = DeliveryType.getDeliveryType(vo.getDeliveryType());
123   - this.payStatus = PayStatus.PayWait;
124 123 this.orderStatus = OrderStatus.PendingTake;
125 124 if (!TextUtils.isEmpty(vo.getReservationTime())) {
126 125 this.reservationTime = df.parse(vo.getReservationTime());
... ... @@ -146,7 +145,7 @@ public class Order extends BaseDomain {
146 145 orderItem.setSkuPrice(orderItemDto.getSkuPrice());
147 146 orderItem.setSkuTitle(orderItemDto.getSkuTitle());
148 147 orderItems.add(orderItem);
149   - totalPrice += orderItemDto.getSkuPrice();
  148 + totalPrice += orderItemDto.getSkuPrice() * orderItemDto.getAmount();
150 149 }
151 150 this.orderItems = orderItems;
152 151 this.totalPrice = totalPrice;
... ... @@ -164,19 +163,8 @@ public class Order extends BaseDomain {
164 163 if (!this.orderStatus.equals(OrderStatus.PendingTake)) {
165 164 throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "订单状态流转顺序异常");
166 165 }
167   - if (this.payType.equals(PayType.Online)) {
168   - this.orderStatus = OrderStatus.PendingPayment;
169   - } else if (this.payType.equals(PayType.Offline)) {
170   - if (this.deliveryType.equals(DeliveryType.Delivery)) {
171   - this.orderStatus = OrderStatus.PendingDelivery;
172   - } else if (this.deliveryType.equals(DeliveryType.Self)) {
173   - this.orderStatus = OrderStatus.PendingStoreMention;
174   - } else {
175   - throw new OrderException(ApplicationException.DATA_EXCEPTION, "未知的配送类型");
176   - }
177   - } else {
178   - throw new OrderException(ApplicationException.DATA_EXCEPTION, "未知的支付类型");
179   - }
  166 + this.orderStatus = OrderStatus.PendingPayment;
  167 + this.payStatus = PayStatus.PayWait;
180 168 this.realTotalPrice = totalPrice;
181 169 }
182 170  
... ...
b2c-orders-domain/src/main/java/com/b2c/orders/domain/OrderItem.java
... ... @@ -29,6 +29,7 @@ public class OrderItem extends BaseDomain {
29 29 private Long orderId;
30 30 private Order order;
31 31 private Long productId;
  32 + private String produceName;
32 33 private Long buyerId;
33 34 private Long sellerId;
34 35 private String sku;
... ...
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
... ... @@ -6,6 +6,8 @@ import com.b2c.orders.commons.exceptions.OrderException;
6 6 import com.b2c.orders.commons.exceptions.OrderRepositoryException;
7 7 import com.b2c.orders.enums.PayType;
8 8 import com.b2c.orders.rpc.exception.DtmsRPCException;
  9 +import com.diligrp.website.util.dao.BaseQuery;
  10 +import com.diligrp.website.util.web.PageTemplate;
9 11  
10 12 public interface OrderManager {
11 13 /**
... ... @@ -127,4 +129,6 @@ public interface OrderManager {
127 129 * @throws OrderException
128 130 */
129 131 void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException;
  132 +
  133 + PageTemplate list(BaseQuery query);
130 134 }
... ...
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
1 1 package com.b2c.orders.manager.impl;
2 2  
3 3 import java.text.ParseException;
  4 +import java.util.List;
4 5  
5 6 import org.slf4j.Logger;
6 7 import org.slf4j.LoggerFactory;
... ... @@ -9,10 +10,7 @@ import org.springframework.stereotype.Component;
9 10 import org.springframework.transaction.annotation.Propagation;
10 11 import org.springframework.transaction.annotation.Transactional;
11 12  
12   -import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto;
13   -import com.b2c.dtms.common.enums.dtms.DtmsMessageType;
14 13 import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto;
15   -import com.b2c.orders.commons.constant.Constant;
16 14 import com.b2c.orders.commons.exceptions.ApplicationException;
17 15 import com.b2c.orders.commons.exceptions.OrderException;
18 16 import com.b2c.orders.commons.exceptions.OrderRepositoryException;
... ... @@ -29,6 +27,8 @@ import com.b2c.orders.manager.OrderManager;
29 27 import com.b2c.orders.rpc.BuyerAccountService;
30 28 import com.b2c.orders.rpc.DtmsRPCService;
31 29 import com.b2c.orders.rpc.exception.DtmsRPCException;
  30 +import com.diligrp.website.util.dao.BaseQuery;
  31 +import com.diligrp.website.util.web.PageTemplate;
32 32  
33 33 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = ApplicationException.class)
34 34 @Component
... ... @@ -288,4 +288,12 @@ public class OrderManagerBean implements OrderManager {
288 288 }
289 289 }
290 290  
  291 + @Transactional(propagation = Propagation.SUPPORTS)
  292 + @Override
  293 + public PageTemplate list(BaseQuery query) {
  294 + List<Order> list = this.orderDao.listByCondition(query);
  295 + Integer count = this.orderDao.countByCondition(query);
  296 + return PageTemplate.create(query, count, list);
  297 + }
  298 +
291 299 }
... ...
b2c-orders-rpc/pom.xml
... ... @@ -23,5 +23,13 @@
23 23 <groupId>org.springframework</groupId>
24 24 <artifactId>spring-beans</artifactId>
25 25 </dependency>
  26 + <!-- <dependency>
  27 + <groupId>com.b2c.myapp</groupId>
  28 + <artifactId>myapp-common</artifactId>
  29 + </dependency> -->
  30 + <dependency>
  31 + <groupId>com.b2c.myapp</groupId>
  32 + <artifactId>myapp-sdk</artifactId>
  33 + </dependency>
26 34 </dependencies>
27 35 </project>
28 36 \ No newline at end of file
... ...
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/BuyerAccountServiceBean.java
... ... @@ -2,16 +2,23 @@ package com.b2c.orders.rpc.impl;
2 2  
3 3 import org.slf4j.Logger;
4 4 import org.slf4j.LoggerFactory;
  5 +import org.springframework.beans.factory.annotation.Autowired;
5 6  
  7 +import com.b2c.myapp.common.api.foundTrade.input.FoundTradeInput;
  8 +import com.b2c.myapp.sdk.MyAppClient;
6 9 import com.b2c.orders.rpc.BuyerAccountService;
7 10  
8 11 public class BuyerAccountServiceBean implements BuyerAccountService {
9 12  
10 13 private static final Logger LOG = LoggerFactory.getLogger(BuyerAccountServiceBean.class);
11 14  
  15 + @Autowired
  16 + private MyAppClient myAppClient;
  17 +
12 18 @Override
13 19 public void lockBalance(Long userId, Long shopId, Long amount) {
14   - LOG.error("lockBalance方法还没实现");
  20 + FoundTradeInput input = new FoundTradeInput();
  21 + this.myAppClient.getFoundTradeService().foundTrade(input);
15 22 }
16 23  
17 24 @Override
... ...
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/DtmsRPCServiceBean.java
... ... @@ -29,7 +29,7 @@ public class DtmsRPCServiceBean implements DtmsRPCService {
29 29 public void sendOrderPayTimeoutDtms(Long orderId) throws DtmsRPCException {
30 30 DtmsProduceRequestDto request = new DtmsProduceRequestDto();
31 31 request.setBizId(orderId.toString());
32   - request.setCallUrl(Constant.ORDER_PAY_TIMEOUT_CALL_URL);
  32 + request.setCallUrl(Constant.ORDER_PAYMENT_TIMEOUT_CALL_URL);
33 33 request.setDelaySeconds(Constant.ORDER_PAYMENT_TIMEOUT_SECONDS);
34 34 request.setType(DtmsMessageType.Timer.code());
35 35 this.produceDtmsMessage(request);
... ... @@ -49,7 +49,7 @@ public class DtmsRPCServiceBean implements DtmsRPCService {
49 49 public void sendOrderTakenTimeoutDtms(Long orderId) throws DtmsRPCException {
50 50 DtmsProduceRequestDto request = new DtmsProduceRequestDto();
51 51 request.setBizId(orderId.toString());
52   - request.setCallUrl(Constant.ORDER_TAKE_TIMEOUT_CALL_URL);
  52 + request.setCallUrl(Constant.ORDER_TAKEN_TIMEOUT_CALL_URL);
53 53 request.setDelaySeconds(Constant.ORDER_TAKEN_TIMEOUT_SECONDS);
54 54 request.setType(DtmsMessageType.Timer.code());
55 55 this.produceDtmsMessage(request);
... ...
b2c-orders-rpc/src/main/resources/spring-rpc.xml
... ... @@ -19,6 +19,11 @@
19 19 <constructor-arg name="token" value="${dtms.token}" />
20 20 </bean>
21 21  
  22 + <bean id="myAppClient" class="com.b2c.myapp.sdk.MyAppClient">
  23 + <constructor-arg name="token" value="" />
  24 + <constructor-arg name="baseUrl" value="www.zandeapp.com" />
  25 + </bean>
  26 +
22 27 <bean id="buyerAccountService" class="com.b2c.orders.rpc.impl.BuyerAccountServiceBean" />
23 28  
24 29 </beans>
25 30 \ No newline at end of file
... ...
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
... ... @@ -6,6 +6,8 @@ import com.b2c.orders.commons.exceptions.OrderException;
6 6 import com.b2c.orders.commons.exceptions.OrderRepositoryException;
7 7 import com.b2c.orders.enums.PayType;
8 8 import com.b2c.orders.rpc.exception.DtmsRPCException;
  9 +import com.diligrp.website.util.dao.BaseQuery;
  10 +import com.diligrp.website.util.web.PageTemplate;
9 11  
10 12 public interface OrderService {
11 13  
... ... @@ -127,4 +129,13 @@ public interface OrderService {
127 129 */
128 130 void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException;
129 131  
  132 + /**
  133 + * 条件查询订单
  134 + *
  135 + * @param query
  136 + * 查询条件
  137 + * @return 含分页信息的结果集
  138 + */
  139 + PageTemplate list(BaseQuery query);
  140 +
130 141 }
... ...
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
... ... @@ -15,6 +15,8 @@ import com.b2c.orders.enums.PayType;
15 15 import com.b2c.orders.manager.OrderManager;
16 16 import com.b2c.orders.rpc.exception.DtmsRPCException;
17 17 import com.b2c.orders.service.OrderService;
  18 +import com.diligrp.website.util.dao.BaseQuery;
  19 +import com.diligrp.website.util.web.PageTemplate;
18 20  
19 21 @Service
20 22 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = ApplicationException.class)
... ... @@ -85,4 +87,10 @@ public class OrderServiceBean implements OrderService {
85 87 this.orderManager.dtmsConfirm(orderId);
86 88 }
87 89  
  90 + @Transactional(propagation = Propagation.SUPPORTS)
  91 + @Override
  92 + public PageTemplate list(BaseQuery query) {
  93 + return this.orderManager.list(query);
  94 + }
  95 +
88 96 }
... ...
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
1 1 package com.b2c.orders.web.restful;
2 2  
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
3 6 import javax.validation.Valid;
4 7  
5 8 import org.springframework.beans.factory.annotation.Autowired;
6 9 import org.springframework.http.MediaType;
  10 +import org.springframework.util.CollectionUtils;
7 11 import org.springframework.validation.BindingResult;
8 12 import org.springframework.web.bind.annotation.RequestBody;
9 13 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -23,26 +27,36 @@ import com.b2c.orders.client.domain.dto.request.SellerRefuseRequestDto;
23 27 import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto;
24 28 import com.b2c.orders.client.domain.dto.request.TakeOrderRequestDto;
25 29 import com.b2c.orders.client.domain.dto.response.BaseResponseDto;
  30 +import com.b2c.orders.client.domain.dto.response.OrderItemResponseDto;
26 31 import com.b2c.orders.client.domain.dto.response.OrderListResponseDto;
  32 +import com.b2c.orders.client.domain.dto.response.PageResponseDto;
27 33 import com.b2c.orders.client.domain.dto.response.SubmitOrderResponseDto;
28 34 import com.b2c.orders.commons.exceptions.ApplicationException;
  35 +import com.b2c.orders.dao.utils.Query;
  36 +import com.b2c.orders.domain.Order;
  37 +import com.b2c.orders.domain.OrderItem;
29 38 import com.b2c.orders.enums.PayType;
30 39 import com.b2c.orders.service.OrderService;
  40 +import com.diligrp.website.util.dao.BaseQuery;
  41 +import com.diligrp.website.util.web.PageTemplate;
31 42  
32 43 import io.swagger.annotations.Api;
33 44 import io.swagger.annotations.ApiOperation;
  45 +import net.sf.cglib.beans.BeanCopier;
34 46  
35 47 @Api("订单api")
36 48 @RestController
37 49 @RequestMapping("/api")
38 50 public class OrderRestController {
39 51  
  52 + private BeanCopier orderCopier = BeanCopier.create(Order.class, OrderListResponseDto.class, false);
  53 + private BeanCopier orderItemCopier = BeanCopier.create(OrderItem.class, OrderItemResponseDto.class, false);
40 54 @Autowired
41 55 private OrderService orderService;
42 56  
43 57 @ApiOperation("提交订单")
44 58 @RequestMapping(value = "/submit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
45   - public SubmitOrderResponseDto submit(@RequestBody SubmitOrderRequestDto order) {
  59 + public SubmitOrderResponseDto submit(@RequestBody @Valid SubmitOrderRequestDto order, BindingResult br) {
46 60 SubmitOrderResponseDto dto = new SubmitOrderResponseDto();
47 61 try {
48 62 this.orderService.submit(order);
... ... @@ -151,8 +165,8 @@ public class OrderRestController {
151 165 return response;
152 166 }
153 167  
154   - @RequestMapping(value = "/timeout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
155   - public DtmsCallBackReturn dtmsTimeout(@RequestBody @Valid DtmsTimeoutRequestDto request, BindingResult br) {
  168 + @RequestMapping(value = "/takenTimeout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  169 + public DtmsCallBackReturn takenTimeout(@RequestBody @Valid DtmsTimeoutRequestDto request, BindingResult br) {
156 170 DtmsCallBackReturn response = new DtmsCallBackReturn();
157 171 try {
158 172 this.orderService.takenTimeout(request.getOrderId());
... ... @@ -164,10 +178,66 @@ public class OrderRestController {
164 178 return response;
165 179 }
166 180  
  181 + @RequestMapping(value = "/paymentTimeout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  182 + public DtmsCallBackReturn paymentTimeout(@RequestBody @Valid DtmsTimeoutRequestDto request, BindingResult br) {
  183 + DtmsCallBackReturn response = new DtmsCallBackReturn();
  184 + try {
  185 + this.orderService.paymentTimeout(request.getOrderId());
  186 + response.setCode(HandleCode.SUCCESS.code());
  187 + } catch (ApplicationException e) {
  188 + response.setCode(HandleCode.FAILED.code());
  189 + response.setMessage(e.getMessage());
  190 + }
  191 + return response;
  192 + }
  193 +
167 194 @ApiOperation("查询订单")
168 195 @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
169   - public OrderListResponseDto list(@RequestBody OrderListRequestDto request) {
170   - throw new RuntimeException("该方法还没实现");
  196 + public PageResponseDto<OrderListResponseDto> list(OrderListRequestDto request) {
  197 + BaseQuery query = this.buildQuery(request);
  198 + PageTemplate page = this.orderService.list(query);
  199 + PageResponseDto<OrderListResponseDto> pageResponse = new PageResponseDto<>();
  200 + pageResponse.setCurrentPage(page.getCurrPage());
  201 + pageResponse.setPageSize(page.getPageSize());
  202 + pageResponse.setTotalPage(page.getTotalPage());
  203 + pageResponse.setTotalSize(page.getTotalSize());
  204 + @SuppressWarnings("unchecked")
  205 + List<Order> orderList = (List<Order>) page.getList();
  206 + if (!CollectionUtils.isEmpty(orderList)) {
  207 + List<OrderListResponseDto> orderDtoList = new ArrayList<>(orderList.size());
  208 + for (Order order : orderList) {
  209 + OrderListResponseDto orderDto = new OrderListResponseDto();
  210 + this.orderCopier.copy(order, orderDto, null);
  211 + if (!CollectionUtils.isEmpty(order.getOrderItems())) {
  212 + List<OrderItemResponseDto> orderItemDtoList = new ArrayList<>(order.getOrderItems().size());
  213 + for (OrderItem orderItem : order.getOrderItems()) {
  214 + OrderItemResponseDto orderItemDto = new OrderItemResponseDto();
  215 + this.orderItemCopier.copy(orderItem, orderItemDto, null);
  216 + orderItemDtoList.add(orderItemDto);
  217 + }
  218 + orderDto.setOrderItems(orderItemDtoList);
  219 + }
  220 + orderDtoList.add(orderDto);
  221 + }
  222 + pageResponse.setList(orderDtoList);
  223 + }
  224 + return pageResponse;
  225 + }
  226 +
  227 + private BaseQuery buildQuery(OrderListRequestDto request) {
  228 + Query query = new Query();
  229 + query.setCurrPage(request.getPage());
  230 + query.setPageSize(request.getPageSize());
  231 + if (request.getBuyerId() != null) {
  232 + query.addParam("buyerId", request.getBuyerId().toString());
  233 + }
  234 + if (request.getSellerId() != null) {
  235 + query.addParam("sellerId", request.getSellerId().toString());
  236 + }
  237 + if (request.getOrderStatus() != null) {
  238 + query.addParam("orderStatus", request.getOrderStatus().toString());
  239 + }
  240 + return query;
171 241 }
172 242  
173 243 }
... ...
... ... @@ -201,6 +201,16 @@
201 201 <artifactId>diligrp-crm-api</artifactId>
202 202 <version>0.0.1-SNAPSHOT</version>
203 203 </dependency>
  204 + <dependency>
  205 + <groupId>com.b2c.myapp</groupId>
  206 + <artifactId>myapp-common</artifactId>
  207 + <version>1.0-SNAPSHOT</version>
  208 + </dependency>
  209 + <dependency>
  210 + <groupId>com.b2c.myapp</groupId>
  211 + <artifactId>myapp-sdk</artifactId>
  212 + <version>1.0-SNAPSHOT</version>
  213 + </dependency>
204 214 <!-- 客户信息 -->
205 215 <!-- <dependency> <groupId>com.yqyw.website.user</groupId> <artifactId>diligrp-user-client</artifactId>
206 216 <version>${user.client.devlop.version}</version> </dependency> -->
... ...