Commit 3f8d8472a1a852cf01d225288f051807705d3788
1 parent
d70f1fe9
完成订单列表
Showing
40 changed files
with
1143 additions
and
248 deletions
b2c-orders-client/pom.xml
... | ... | @@ -9,6 +9,11 @@ |
9 | 9 | <artifactId>b2c-orders-client</artifactId> |
10 | 10 | |
11 | 11 | <dependencies> |
12 | + <dependency> | |
13 | + <groupId>${project.groupId}</groupId> | |
14 | + <artifactId>b2c-orders-commons</artifactId> | |
15 | + <version>${project.parent.version}</version> | |
16 | + </dependency> | |
12 | 17 | <!--swagger --> |
13 | 18 | <dependency> |
14 | 19 | <groupId>io.springfox</groupId> |
... | ... | @@ -124,5 +129,18 @@ |
124 | 129 | <groupId>com.fasterxml.jackson.module</groupId> |
125 | 130 | <artifactId>jackson-module-jaxb-annotations</artifactId> |
126 | 131 | </dependency> |
132 | + <dependency> | |
133 | + <groupId>junit</groupId> | |
134 | + <artifactId>junit</artifactId> | |
135 | + <scope>test</scope> | |
136 | + </dependency> | |
127 | 137 | </dependencies> |
138 | + | |
139 | + <build> | |
140 | + <plugins> | |
141 | + <plugin> | |
142 | + <artifactId>maven-source-plugin</artifactId> | |
143 | + </plugin> | |
144 | + </plugins> | |
145 | + </build> | |
128 | 146 | </project> |
129 | 147 | \ No newline at end of file | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/OrderClient.java
1 | 1 | package com.b2c.orders.domain.client; |
2 | 2 | |
3 | +import com.b2c.orders.domain.client.service.OrderService; | |
4 | +import com.b2c.orders.domain.client.service.impl.OrderServiceBean; | |
5 | + | |
3 | 6 | public class OrderClient { |
4 | 7 | |
5 | - private String baseUrl; | |
6 | - private String token; | |
8 | + private OrderService orderService; | |
7 | 9 | |
8 | 10 | public OrderClient(String baseUrl, String token) { |
9 | - this.baseUrl = baseUrl; | |
10 | - this.token = token; | |
11 | + this.orderService = new OrderServiceBean(token, baseUrl); | |
12 | + } | |
13 | + | |
14 | + public OrderService getOrderService() { | |
15 | + return orderService; | |
11 | 16 | } |
12 | 17 | |
13 | 18 | } | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/BuyerCancelRequestDto.java
... | ... | @@ -14,9 +14,9 @@ public class BuyerCancelRequestDto extends BaseRequestDto { |
14 | 14 | @ApiParam(value = "订单id", required = true) |
15 | 15 | @NotNull(message = "订单id不能为空") |
16 | 16 | private Long orderId; |
17 | - @ApiParam(value = "买家id", required = true) | |
18 | - @NotNull(message = "买家id不能为空") | |
19 | - private Long buyerId; | |
17 | + @ApiParam(value = "买家店铺id", required = true) | |
18 | + @NotNull(message = "买家店铺id不能为空") | |
19 | + private Long shopBuyerId; | |
20 | 20 | |
21 | 21 | public Long getOrderId() { |
22 | 22 | return orderId; |
... | ... | @@ -26,12 +26,12 @@ public class BuyerCancelRequestDto extends BaseRequestDto { |
26 | 26 | this.orderId = orderId; |
27 | 27 | } |
28 | 28 | |
29 | - public Long getBuyerId() { | |
30 | - return buyerId; | |
29 | + public Long getShopBuyerId() { | |
30 | + return shopBuyerId; | |
31 | 31 | } |
32 | 32 | |
33 | - public void setBuyerId(Long buyerId) { | |
34 | - this.buyerId = buyerId; | |
33 | + public void setShopBuyerId(Long shopBuyerId) { | |
34 | + this.shopBuyerId = shopBuyerId; | |
35 | 35 | } |
36 | 36 | |
37 | 37 | } | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/BuyerConfirmRequestDto.java
... | ... | @@ -16,7 +16,7 @@ public class BuyerConfirmRequestDto extends BaseRequestDto { |
16 | 16 | private Long orderId; |
17 | 17 | @ApiParam(value = "买家id", required = true) |
18 | 18 | @NotNull(message = "买家id不能为空") |
19 | - private Long buyerId; | |
19 | + private Long shopBuyerId; | |
20 | 20 | |
21 | 21 | public Long getOrderId() { |
22 | 22 | return orderId; |
... | ... | @@ -26,12 +26,12 @@ public class BuyerConfirmRequestDto extends BaseRequestDto { |
26 | 26 | this.orderId = orderId; |
27 | 27 | } |
28 | 28 | |
29 | - public Long getBuyerId() { | |
30 | - return buyerId; | |
29 | + public Long getShopBuyerId() { | |
30 | + return shopBuyerId; | |
31 | 31 | } |
32 | 32 | |
33 | - public void setBuyerId(Long buyerId) { | |
34 | - this.buyerId = buyerId; | |
33 | + protected void setShopBuyerId(Long shopBuyerId) { | |
34 | + this.shopBuyerId = shopBuyerId; | |
35 | 35 | } |
36 | 36 | |
37 | 37 | } | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/OrderDetailRequestDto.java
0 → 100644
1 | +package com.b2c.orders.domain.client.dto.request; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +import io.swagger.annotations.ApiParam; | |
6 | + | |
7 | +public class OrderDetailRequestDto implements Serializable { | |
8 | + | |
9 | + /** | |
10 | + * | |
11 | + */ | |
12 | + private static final long serialVersionUID = 1588667432248557550L; | |
13 | + | |
14 | + @ApiParam("订单id") | |
15 | + private Long orderId; | |
16 | + | |
17 | + public Long getOrderId() { | |
18 | + return orderId; | |
19 | + } | |
20 | + | |
21 | + public void setOrderId(Long orderId) { | |
22 | + this.orderId = orderId; | |
23 | + } | |
24 | + | |
25 | +} | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/PayOrderRequestDto.java
... | ... | @@ -16,7 +16,7 @@ public class PayOrderRequestDto extends BaseRequestDto { |
16 | 16 | private Long orderId; |
17 | 17 | @ApiParam(value = "买家id", required = true) |
18 | 18 | @NotNull(message = "买家id不能为空") |
19 | - private Long buyerId; | |
19 | + private Long shopBuyerId; | |
20 | 20 | @ApiParam(value = "支付方式", required = true) |
21 | 21 | @NotNull(message = "支付方式不能为空") |
22 | 22 | private Integer payType; |
... | ... | @@ -29,12 +29,12 @@ public class PayOrderRequestDto extends BaseRequestDto { |
29 | 29 | this.orderId = orderId; |
30 | 30 | } |
31 | 31 | |
32 | - public Long getBuyerId() { | |
33 | - return buyerId; | |
32 | + public Long getShopBuyerId() { | |
33 | + return shopBuyerId; | |
34 | 34 | } |
35 | 35 | |
36 | - public void setBuyerId(Long buyerId) { | |
37 | - this.buyerId = buyerId; | |
36 | + protected void setShopBuyerId(Long shopBuyerId) { | |
37 | + this.shopBuyerId = shopBuyerId; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | public Integer getPayType() { | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/SubmitOrderRequestDto.java
... | ... | @@ -22,6 +22,10 @@ public class SubmitOrderRequestDto implements Serializable { |
22 | 22 | private String buyerMemo; |
23 | 23 | @ApiParam(value = "送货时间") |
24 | 24 | private String deliveryTime; |
25 | + @ApiParam("送货地址") | |
26 | + private String deliveryAddress; | |
27 | + @ApiParam("收货人电话") | |
28 | + private String receiverPhoneNumber; | |
25 | 29 | @ApiParam(value = "提货时间") |
26 | 30 | private String reservationTime; |
27 | 31 | @ApiParam(value = "订单项", required = true) |
... | ... | @@ -67,6 +71,22 @@ public class SubmitOrderRequestDto implements Serializable { |
67 | 71 | this.deliveryTime = deliveryTime; |
68 | 72 | } |
69 | 73 | |
74 | + public String getDeliveryAddress() { | |
75 | + return deliveryAddress; | |
76 | + } | |
77 | + | |
78 | + public void setDeliveryAddress(String deliveryAddress) { | |
79 | + this.deliveryAddress = deliveryAddress; | |
80 | + } | |
81 | + | |
82 | + public String getReceiverPhoneNumber() { | |
83 | + return receiverPhoneNumber; | |
84 | + } | |
85 | + | |
86 | + public void setReceiverPhoneNumber(String receiverPhoneNumber) { | |
87 | + this.receiverPhoneNumber = receiverPhoneNumber; | |
88 | + } | |
89 | + | |
70 | 90 | public String getReservationTime() { |
71 | 91 | return reservationTime; |
72 | 92 | } | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/OrderDetailResponseDto.java
0 → 100644
1 | +package com.b2c.orders.domain.client.dto.response; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class OrderDetailResponseDto implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = 2572442090886362100L; | |
11 | + | |
12 | + /** 配送类型 */ | |
13 | + private Integer deliveryType; | |
14 | + /** 订单状态 */ | |
15 | + private Integer orderStatus; | |
16 | + /** 支付状态 */ | |
17 | + private Integer payStatus; | |
18 | + /** 买家备注说明 */ | |
19 | + private String buyerMemo; | |
20 | + /** | |
21 | + * 送货时间 | |
22 | + */ | |
23 | + private String deliveryTime; | |
24 | + /** | |
25 | + * 送货地址 | |
26 | + */ | |
27 | + private String deliveryAddress; | |
28 | + /** 提货时间 */ | |
29 | + private String reservationTime; | |
30 | + /** 订单提交时间 */ | |
31 | + private String submitTime; | |
32 | + /** 支付类型 */ | |
33 | + private Integer payType; | |
34 | + /** 预计总金额 */ | |
35 | + private Long totalPrice; | |
36 | + /** | |
37 | + * 实际价格,有商家接单后修改 | |
38 | + */ | |
39 | + private Long realTotalPrice; | |
40 | + | |
41 | + public Integer getDeliveryType() { | |
42 | + return deliveryType; | |
43 | + } | |
44 | + | |
45 | + public void setDeliveryType(Integer deliveryType) { | |
46 | + this.deliveryType = deliveryType; | |
47 | + } | |
48 | + | |
49 | + public Integer getOrderStatus() { | |
50 | + return orderStatus; | |
51 | + } | |
52 | + | |
53 | + public void setOrderStatus(Integer orderStatus) { | |
54 | + this.orderStatus = orderStatus; | |
55 | + } | |
56 | + | |
57 | + public Integer getPayStatus() { | |
58 | + return payStatus; | |
59 | + } | |
60 | + | |
61 | + public void setPayStatus(Integer payStatus) { | |
62 | + this.payStatus = payStatus; | |
63 | + } | |
64 | + | |
65 | + public String getBuyerMemo() { | |
66 | + return buyerMemo; | |
67 | + } | |
68 | + | |
69 | + public void setBuyerMemo(String buyerMemo) { | |
70 | + this.buyerMemo = buyerMemo; | |
71 | + } | |
72 | + | |
73 | + public String getDeliveryTime() { | |
74 | + return deliveryTime; | |
75 | + } | |
76 | + | |
77 | + public void setDeliveryTime(String deliveryTime) { | |
78 | + this.deliveryTime = deliveryTime; | |
79 | + } | |
80 | + | |
81 | + public String getDeliveryAddress() { | |
82 | + return deliveryAddress; | |
83 | + } | |
84 | + | |
85 | + public void setDeliveryAddress(String deliveryAddress) { | |
86 | + this.deliveryAddress = deliveryAddress; | |
87 | + } | |
88 | + | |
89 | + public String getReservationTime() { | |
90 | + return reservationTime; | |
91 | + } | |
92 | + | |
93 | + public void setReservationTime(String reservationTime) { | |
94 | + this.reservationTime = reservationTime; | |
95 | + } | |
96 | + | |
97 | + public String getSubmitTime() { | |
98 | + return submitTime; | |
99 | + } | |
100 | + | |
101 | + public void setSubmitTime(String submitTime) { | |
102 | + this.submitTime = submitTime; | |
103 | + } | |
104 | + | |
105 | + public Integer getPayType() { | |
106 | + return payType; | |
107 | + } | |
108 | + | |
109 | + public void setPayType(Integer payType) { | |
110 | + this.payType = payType; | |
111 | + } | |
112 | + | |
113 | + public Long getTotalPrice() { | |
114 | + return totalPrice; | |
115 | + } | |
116 | + | |
117 | + public void setTotalPrice(Long totalPrice) { | |
118 | + this.totalPrice = totalPrice; | |
119 | + } | |
120 | + | |
121 | + public Long getRealTotalPrice() { | |
122 | + return realTotalPrice; | |
123 | + } | |
124 | + | |
125 | + public void setRealTotalPrice(Long realTotalPrice) { | |
126 | + this.realTotalPrice = realTotalPrice; | |
127 | + } | |
128 | + | |
129 | +} | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/OrderService.java renamed to b2c-orders-client/src/main/java/com/b2c/orders/domain/client/service/OrderService.java
1 | -package com.b2c.orders.domain.client; | |
1 | +package com.b2c.orders.domain.client.service; | |
2 | 2 | |
3 | 3 | import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; |
4 | 4 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; |
5 | +import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; | |
5 | 6 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; |
6 | 7 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; |
7 | 8 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; |
8 | 9 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; |
9 | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | 11 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; |
12 | +import com.b2c.orders.domain.client.dto.response.ApiDataResponse; | |
11 | 13 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
12 | 14 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
15 | +import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; | |
13 | 16 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
14 | 17 | |
15 | 18 | public interface OrderService { |
... | ... | @@ -71,6 +74,14 @@ public interface OrderService { |
71 | 74 | ApiResponse cancel(BuyerCancelRequestDto request); |
72 | 75 | |
73 | 76 | /** |
77 | + * 订单详情 | |
78 | + * | |
79 | + * @param request | |
80 | + * @return | |
81 | + */ | |
82 | + ApiDataResponse<OrderDetailResponseDto> detail(OrderDetailRequestDto request); | |
83 | + | |
84 | + /** | |
74 | 85 | * 订单列表 |
75 | 86 | * |
76 | 87 | * @param request | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/service/impl/OrderServiceBean.java
0 → 100644
1 | +package com.b2c.orders.domain.client.service.impl; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | + | |
6 | +import com.b2c.orders.commons.utils.HttpUtils; | |
7 | +import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; | |
8 | +import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; | |
9 | +import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; | |
10 | +import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; | |
11 | +import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; | |
12 | +import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; | |
13 | +import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; | |
14 | +import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
15 | +import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; | |
16 | +import com.b2c.orders.domain.client.dto.response.ApiDataResponse; | |
17 | +import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; | |
18 | +import com.b2c.orders.domain.client.dto.response.ApiResponse; | |
19 | +import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; | |
20 | +import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; | |
21 | +import com.b2c.orders.domain.client.service.OrderService; | |
22 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
23 | + | |
24 | +public class OrderServiceBean implements OrderService { | |
25 | + | |
26 | + private static final Logger LOG = LoggerFactory.getLogger(OrderServiceBean.class); | |
27 | + | |
28 | + private static final String CHARSET = "UTF-8"; | |
29 | + | |
30 | + private String token; | |
31 | + private String baseUrl; | |
32 | + | |
33 | + public OrderServiceBean(String token, String baseUrl) { | |
34 | + this.token = token; | |
35 | + this.baseUrl = baseUrl; | |
36 | + } | |
37 | + | |
38 | + @Override | |
39 | + public ApiResponse submit(SubmitOrderRequestDto request) { | |
40 | + ApiResponse response = new ApiResponse(); | |
41 | + try { | |
42 | + ObjectMapper mapper = new ObjectMapper(); | |
43 | + String json = mapper.writeValueAsString(request); | |
44 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/submit", json, CHARSET); | |
45 | + if (bytes == null) { | |
46 | + response.setMessage("接口调用失败"); | |
47 | + } | |
48 | + response = mapper.readValue(bytes, response.getClass()); | |
49 | + return response; | |
50 | + } catch (Exception e) { | |
51 | + LOG.error(e.getMessage(), e); | |
52 | + response.setMessage(e.getMessage()); | |
53 | + return response; | |
54 | + } | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + public ApiResponse take(TakeOrderRequestDto request) { | |
59 | + ApiResponse response = new ApiResponse(); | |
60 | + try { | |
61 | + ObjectMapper mapper = new ObjectMapper(); | |
62 | + String json = mapper.writeValueAsString(request); | |
63 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/take", json, CHARSET); | |
64 | + if (bytes == null) { | |
65 | + response.setMessage("接口调用失败"); | |
66 | + } | |
67 | + response = mapper.readValue(bytes, response.getClass()); | |
68 | + return response; | |
69 | + } catch (Exception e) { | |
70 | + LOG.error(e.getMessage(), e); | |
71 | + response.setMessage(e.getMessage()); | |
72 | + return response; | |
73 | + } | |
74 | + } | |
75 | + | |
76 | + @Override | |
77 | + public ApiResponse pay(PayOrderRequestDto request) { | |
78 | + ApiResponse response = new ApiResponse(); | |
79 | + try { | |
80 | + ObjectMapper mapper = new ObjectMapper(); | |
81 | + String json = mapper.writeValueAsString(request); | |
82 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/pay", json, CHARSET); | |
83 | + if (bytes == null) { | |
84 | + response.setMessage("接口调用失败"); | |
85 | + } | |
86 | + response = mapper.readValue(bytes, response.getClass()); | |
87 | + return response; | |
88 | + } catch (Exception e) { | |
89 | + LOG.error(e.getMessage(), e); | |
90 | + response.setMessage(e.getMessage()); | |
91 | + return response; | |
92 | + } | |
93 | + } | |
94 | + | |
95 | + @Override | |
96 | + public ApiResponse buyerConfirm(BuyerConfirmRequestDto request) { | |
97 | + ApiResponse response = new ApiResponse(); | |
98 | + try { | |
99 | + ObjectMapper mapper = new ObjectMapper(); | |
100 | + String json = mapper.writeValueAsString(request); | |
101 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/buyerConfirm", json, CHARSET); | |
102 | + if (bytes == null) { | |
103 | + response.setMessage("接口调用失败"); | |
104 | + } | |
105 | + response = mapper.readValue(bytes, response.getClass()); | |
106 | + return response; | |
107 | + } catch (Exception e) { | |
108 | + LOG.error(e.getMessage(), e); | |
109 | + response.setMessage(e.getMessage()); | |
110 | + return response; | |
111 | + } | |
112 | + } | |
113 | + | |
114 | + @Override | |
115 | + public ApiResponse sellerConfirm(SellerConfirmRequestDto request) { | |
116 | + ApiResponse response = new ApiResponse(); | |
117 | + try { | |
118 | + ObjectMapper mapper = new ObjectMapper(); | |
119 | + String json = mapper.writeValueAsString(request); | |
120 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/sellerConfirm", json, CHARSET); | |
121 | + if (bytes == null) { | |
122 | + response.setMessage("接口调用失败"); | |
123 | + } | |
124 | + response = mapper.readValue(bytes, response.getClass()); | |
125 | + return response; | |
126 | + } catch (Exception e) { | |
127 | + LOG.error(e.getMessage(), e); | |
128 | + response.setMessage(e.getMessage()); | |
129 | + return response; | |
130 | + } | |
131 | + } | |
132 | + | |
133 | + @Override | |
134 | + public ApiResponse refuse(SellerRefuseRequestDto request) { | |
135 | + ApiResponse response = new ApiResponse(); | |
136 | + try { | |
137 | + ObjectMapper mapper = new ObjectMapper(); | |
138 | + String json = mapper.writeValueAsString(request); | |
139 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/refuse", json, CHARSET); | |
140 | + if (bytes == null) { | |
141 | + response.setMessage("接口调用失败"); | |
142 | + } | |
143 | + response = mapper.readValue(bytes, response.getClass()); | |
144 | + return response; | |
145 | + } catch (Exception e) { | |
146 | + LOG.error(e.getMessage(), e); | |
147 | + response.setMessage(e.getMessage()); | |
148 | + return response; | |
149 | + } | |
150 | + } | |
151 | + | |
152 | + @Override | |
153 | + public ApiResponse cancel(BuyerCancelRequestDto request) { | |
154 | + ApiResponse response = new ApiResponse(); | |
155 | + try { | |
156 | + ObjectMapper mapper = new ObjectMapper(); | |
157 | + String json = mapper.writeValueAsString(request); | |
158 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/cancel", json, CHARSET); | |
159 | + if (bytes == null) { | |
160 | + response.setMessage("接口调用失败"); | |
161 | + } | |
162 | + response = mapper.readValue(bytes, response.getClass()); | |
163 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
164 | + response.setSuccess(true); | |
165 | + } catch (Exception e) { | |
166 | + LOG.error(e.getMessage(), e); | |
167 | + response.setMessage(e.getMessage()); | |
168 | + } | |
169 | + return response; | |
170 | + } | |
171 | + | |
172 | + @SuppressWarnings("unchecked") | |
173 | + @Override | |
174 | + public ApiDataResponse<OrderDetailResponseDto> detail(OrderDetailRequestDto request) { | |
175 | + ApiDataResponse<OrderDetailResponseDto> response = new ApiDataResponse<>(); | |
176 | + try { | |
177 | + ObjectMapper mapper = new ObjectMapper(); | |
178 | + String json = mapper.writeValueAsString(request); | |
179 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/detail", json, CHARSET); | |
180 | + if (bytes == null) { | |
181 | + response.setMessage("接口调用失败"); | |
182 | + } | |
183 | + response = mapper.readValue(bytes, response.getClass()); | |
184 | + return response; | |
185 | + } catch (Exception e) { | |
186 | + LOG.error(e.getMessage(), e); | |
187 | + response.setMessage(e.getMessage()); | |
188 | + return response; | |
189 | + } | |
190 | + } | |
191 | + | |
192 | + @SuppressWarnings("unchecked") | |
193 | + @Override | |
194 | + public ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request) { | |
195 | + ApiPageDataResponse<OrderListResponseDto> response = new ApiPageDataResponse<>(); | |
196 | + try { | |
197 | + ObjectMapper mapper = new ObjectMapper(); | |
198 | + String json = mapper.writeValueAsString(request); | |
199 | + byte[] bytes = HttpUtils.doHttpPost(this.baseUrl + "/api/list", json, CHARSET); | |
200 | + if (bytes == null) { | |
201 | + response.setMessage("接口调用失败"); | |
202 | + } | |
203 | + response = mapper.readValue(bytes, response.getClass()); | |
204 | + return response; | |
205 | + } catch (Exception e) { | |
206 | + LOG.error(e.getMessage(), e); | |
207 | + response.setMessage(e.getMessage()); | |
208 | + return response; | |
209 | + } | |
210 | + } | |
211 | + | |
212 | +} | ... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/enums/PayType.java
b2c-orders-client/src/test/java/com/b2c/orders/client/service/OrderServiceTestCase.java
0 → 100644
1 | +package com.b2c.orders.client.service; | |
2 | + | |
3 | +import static org.junit.Assert.*; | |
4 | + | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.List; | |
7 | + | |
8 | +import org.junit.After; | |
9 | +import org.junit.AfterClass; | |
10 | +import org.junit.Assert; | |
11 | +import org.junit.Before; | |
12 | +import org.junit.BeforeClass; | |
13 | +import org.junit.Test; | |
14 | + | |
15 | +import com.b2c.orders.domain.client.OrderClient; | |
16 | +import com.b2c.orders.domain.client.dto.request.OrderItemDto; | |
17 | +import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | |
18 | +import com.b2c.orders.domain.client.dto.response.ApiResponse; | |
19 | +import com.b2c.orders.domain.client.service.OrderService; | |
20 | +import com.b2c.orders.enums.DeliveryType; | |
21 | + | |
22 | +public class OrderServiceTestCase { | |
23 | + | |
24 | + private static OrderService orderService; | |
25 | + | |
26 | + @BeforeClass | |
27 | + public static void setUpBeforeClass() throws Exception { | |
28 | + OrderClient client = new OrderClient("http://orders.zandeapp.com", ""); | |
29 | + orderService = client.getOrderService(); | |
30 | + } | |
31 | + | |
32 | + @Test | |
33 | + public void testSubmit() { | |
34 | + SubmitOrderRequestDto request = new SubmitOrderRequestDto(); | |
35 | + request.setBuyerMemo("不要放鸡精味精"); | |
36 | + request.setDeliveryType(DeliveryType.Self.getIndex()); | |
37 | + request.setMarketId(1L); | |
38 | + List<OrderItemDto> orderItems = new ArrayList<>(); | |
39 | + OrderItemDto orderItem = new OrderItemDto(); | |
40 | + orderItem.setAmount(2); | |
41 | + orderItem.setSku("1bKvCngjj0w"); | |
42 | + orderItems.add(orderItem); | |
43 | + request.setOrderItems(orderItems); | |
44 | + request.setReservationTime("2016-12-22 18:00:00"); | |
45 | + request.setShopBuyerId(1L); | |
46 | + ApiResponse response = orderService.submit(request); | |
47 | + Assert.assertTrue(response.isSuccess()); | |
48 | + } | |
49 | + | |
50 | +} | ... | ... |
b2c-orders-commons/pom.xml
... | ... | @@ -14,4 +14,12 @@ |
14 | 14 | <artifactId>commons-lang</artifactId> |
15 | 15 | </dependency> |
16 | 16 | </dependencies> |
17 | + | |
18 | + <build> | |
19 | + <plugins> | |
20 | + <plugin> | |
21 | + <artifactId>maven-source-plugin</artifactId> | |
22 | + </plugin> | |
23 | + </plugins> | |
24 | + </build> | |
17 | 25 | </project> |
18 | 26 | \ No newline at end of file | ... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/utils/HttpUtils.java
0 → 100644
1 | +package com.b2c.orders.commons.utils; | |
2 | + | |
3 | +import java.io.ByteArrayOutputStream; | |
4 | +import java.io.IOException; | |
5 | +import java.io.InputStream; | |
6 | +import java.io.OutputStreamWriter; | |
7 | +import java.net.HttpURLConnection; | |
8 | +import java.net.URL; | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +import org.apache.commons.lang.StringUtils; | |
13 | + | |
14 | +public final class HttpUtils { | |
15 | + | |
16 | + private HttpUtils() { | |
17 | + } | |
18 | + | |
19 | + public static byte[] doHttpPut(String path, String json, String charset) throws IllegalStateException, IOException { | |
20 | + URL url = null; | |
21 | + HttpURLConnection conn = null; | |
22 | + try { | |
23 | + url = new URL(path); | |
24 | + conn = (HttpURLConnection) url.openConnection(); | |
25 | + conn.setDoInput(true); | |
26 | + conn.setDoOutput(true); | |
27 | + conn.setUseCaches(false); | |
28 | + conn.setConnectTimeout(50000);// 设置连接超时 | |
29 | + conn.setReadTimeout(50000);// 设置读取超时 | |
30 | + conn.setRequestMethod("PUT"); | |
31 | + conn.setRequestProperty("Content-Type", "application/json"); | |
32 | + conn.connect(); | |
33 | + if (!StringUtils.isEmpty(json)) { | |
34 | + OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), charset); | |
35 | + osw.write(json); | |
36 | + osw.flush(); | |
37 | + osw.close(); | |
38 | + } | |
39 | + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { | |
40 | + return parseToByteArray(conn.getInputStream()); | |
41 | + } | |
42 | + return null; | |
43 | + } catch (Exception e) { | |
44 | + e.printStackTrace(); | |
45 | + return null; | |
46 | + } finally { | |
47 | + if (conn != null) { | |
48 | + conn.disconnect(); | |
49 | + } | |
50 | + } | |
51 | + } | |
52 | + | |
53 | + public static byte[] doHttpPut(String url, String params) throws IllegalStateException, IOException { | |
54 | + return doHttpPut(url, params, "UTF-8"); | |
55 | + } | |
56 | + | |
57 | + public static byte[] doHttpGet(String path, Map<String, Object> params) { | |
58 | + HttpURLConnection conn = null; | |
59 | + InputStream in = null; | |
60 | + try { | |
61 | + StringBuilder sb = new StringBuilder(path); | |
62 | + if (params != null && params.size() > 0) { | |
63 | + sb.append("?"); | |
64 | + for (Map.Entry<String, Object> entry : params.entrySet()) { | |
65 | + sb.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); | |
66 | + } | |
67 | + sb.deleteCharAt(sb.length() - 1); | |
68 | + } | |
69 | + URL url = new URL(sb.toString()); | |
70 | + conn = (HttpURLConnection) url.openConnection(); | |
71 | + conn.setRequestMethod("GET"); | |
72 | + in = conn.getInputStream(); | |
73 | + return parseToByteArray(in); | |
74 | + } catch (Exception e) { | |
75 | + e.printStackTrace(); | |
76 | + return null; | |
77 | + } finally { | |
78 | + if (in != null) { | |
79 | + try { | |
80 | + in.close(); | |
81 | + } catch (IOException e) { | |
82 | + e.printStackTrace(); | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + } | |
87 | + } | |
88 | + | |
89 | + public static byte[] doHttpPost(String path, List<ValuePair> params, String charset) throws Exception { | |
90 | + URL url = null; | |
91 | + HttpURLConnection conn = null; | |
92 | + try { | |
93 | + url = new URL(path); | |
94 | + conn = (HttpURLConnection) url.openConnection(); | |
95 | + conn.setDoInput(true); | |
96 | + conn.setDoOutput(true); | |
97 | + conn.setUseCaches(false); | |
98 | + conn.setConnectTimeout(50000);// 设置连接超时 | |
99 | + conn.setReadTimeout(50000);// 设置读取超时 | |
100 | + conn.setRequestMethod("POST"); | |
101 | + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); | |
102 | + conn.connect(); | |
103 | + if (params != null && params.size() > 0) { | |
104 | + StringBuilder sb = new StringBuilder(); | |
105 | + for (ValuePair valuePair : params) { | |
106 | + sb.append('&').append(valuePair.getName()).append('=').append(valuePair.getValue()); | |
107 | + } | |
108 | + OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), charset); | |
109 | + osw.write(sb.toString()); | |
110 | + osw.flush(); | |
111 | + osw.close(); | |
112 | + } | |
113 | + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { | |
114 | + return parseToByteArray(conn.getInputStream()); | |
115 | + } | |
116 | + return null; | |
117 | + } catch (Exception e) { | |
118 | + throw e; | |
119 | + } finally { | |
120 | + if (conn != null) { | |
121 | + conn.disconnect(); | |
122 | + } | |
123 | + } | |
124 | + } | |
125 | + | |
126 | + public static byte[] doHttpPost(String path, String json, String charset) throws IllegalStateException, IOException { | |
127 | + URL url = null; | |
128 | + HttpURLConnection conn = null; | |
129 | + try { | |
130 | + url = new URL(path); | |
131 | + conn = (HttpURLConnection) url.openConnection(); | |
132 | + conn.setDoInput(true); | |
133 | + conn.setDoOutput(true); | |
134 | + conn.setUseCaches(false); | |
135 | + conn.setConnectTimeout(50000);// 设置连接超时 | |
136 | + conn.setReadTimeout(50000);// 设置读取超时 | |
137 | + conn.setRequestMethod("POST"); | |
138 | + conn.setRequestProperty("Content-Type", "application/json"); | |
139 | + conn.connect(); | |
140 | + if (!StringUtils.isEmpty(json)) { | |
141 | + OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), charset); | |
142 | + osw.write(json); | |
143 | + osw.flush(); | |
144 | + osw.close(); | |
145 | + } | |
146 | + if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { | |
147 | + return parseToByteArray(conn.getInputStream()); | |
148 | + } | |
149 | + return null; | |
150 | + } catch (Exception e) { | |
151 | + e.printStackTrace(); | |
152 | + return null; | |
153 | + } finally { | |
154 | + if (conn != null) { | |
155 | + conn.disconnect(); | |
156 | + } | |
157 | + } | |
158 | + } | |
159 | + | |
160 | + private static byte[] parseToByteArray(InputStream in) throws IOException { | |
161 | + ByteArrayOutputStream baos = null; | |
162 | + try { | |
163 | + baos = new ByteArrayOutputStream(); | |
164 | + byte[] buff = new byte[1024]; | |
165 | + int len = 0; | |
166 | + while ((len = in.read(buff)) > 0) { | |
167 | + baos.write(buff, 0, len); | |
168 | + } | |
169 | + return baos.toByteArray(); | |
170 | + } catch (IOException e) { | |
171 | + e.printStackTrace(); | |
172 | + throw e; | |
173 | + } finally { | |
174 | + if (baos != null) { | |
175 | + try { | |
176 | + baos.close(); | |
177 | + } catch (IOException e) { | |
178 | + e.printStackTrace(); | |
179 | + } | |
180 | + } | |
181 | + } | |
182 | + } | |
183 | +} | ... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/utils/ValuePair.java
0 → 100644
1 | +package com.b2c.orders.commons.utils; | |
2 | + | |
3 | +/** | |
4 | + * Created by cc on 2016/5/11. | |
5 | + */ | |
6 | +public class ValuePair { | |
7 | + | |
8 | + private String name; | |
9 | + private Object value; | |
10 | + | |
11 | + public ValuePair() { | |
12 | + } | |
13 | + | |
14 | + public ValuePair(String name, Object value) { | |
15 | + this.name = name; | |
16 | + this.value = value; | |
17 | + } | |
18 | + | |
19 | + public String getName() { | |
20 | + return name; | |
21 | + } | |
22 | + | |
23 | + public void setName(String name) { | |
24 | + this.name = name; | |
25 | + } | |
26 | + | |
27 | + public Object getValue() { | |
28 | + return value; | |
29 | + } | |
30 | + | |
31 | + public void setValue(Object value) { | |
32 | + this.value = value; | |
33 | + } | |
34 | +} | ... | ... |
b2c-orders-dao/pom.xml
... | ... | @@ -14,10 +14,10 @@ |
14 | 14 | <artifactId>b2c-orders-domain</artifactId> |
15 | 15 | <version>${project.version}</version> |
16 | 16 | </dependency> |
17 | - <dependency> | |
17 | + <!-- <dependency> | |
18 | 18 | <groupId>cglib</groupId> |
19 | 19 | <artifactId>cglib</artifactId> |
20 | - </dependency> | |
20 | + </dependency> --> | |
21 | 21 | <dependency> |
22 | 22 | <groupId>com.b2c.website</groupId> |
23 | 23 | <artifactId>diligrp-website-util</artifactId> | ... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/ShopDao.java
1 | 1 | package com.b2c.orders.dao; |
2 | 2 | |
3 | +import com.b2c.orders.commons.exceptions.SellerException; | |
3 | 4 | import com.b2c.orders.domain.Shop; |
4 | 5 | |
5 | 6 | public interface ShopDao { |
6 | 7 | |
7 | - Shop findByBuyerShopId(Long shopBuyerId); | |
8 | + Shop findByBuyerShopId(Long shopBuyerId) throws SellerException; | |
8 | 9 | } | ... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/ProductDaoBean.java
1 | 1 | package com.b2c.orders.dao.impl; |
2 | 2 | |
3 | -import java.util.Arrays; | |
3 | +import java.io.IOException; | |
4 | +import java.io.InputStream; | |
4 | 5 | import java.util.Map; |
5 | 6 | import java.util.Map.Entry; |
6 | 7 | |
... | ... | @@ -17,7 +18,11 @@ import com.b2c.orders.dao.ProductDao; |
17 | 18 | import com.b2c.orders.domain.rpc.Product; |
18 | 19 | import com.diligrp.titan.sdk.TitanClient; |
19 | 20 | import com.diligrp.titan.sdk.output.BaseOutput; |
20 | -import com.diligrp.titan.sdk.service.ProductService; | |
21 | +import com.fasterxml.jackson.annotation.JsonInclude.Include; | |
22 | +import com.fasterxml.jackson.databind.DeserializationFeature; | |
23 | +import com.fasterxml.jackson.databind.JsonNode; | |
24 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
25 | +import com.fasterxml.jackson.databind.type.MapType; | |
21 | 26 | |
22 | 27 | @Repository |
23 | 28 | public class ProductDaoBean implements ProductDao { |
... | ... | @@ -34,9 +39,28 @@ public class ProductDaoBean implements ProductDao { |
34 | 39 | |
35 | 40 | @Override |
36 | 41 | public Product findBySku(String sku) throws ProductException { |
37 | - ProductService productRPCService = this.titanClient.getProductService(); | |
38 | - BaseOutput<Map<String, com.diligrp.titan.sdk.domain.Product>> rpcResponse = productRPCService | |
39 | - .getSkuInfoMap(Arrays.asList(sku)); | |
42 | + // ProductService productRPCService = | |
43 | + // this.titanClient.getProductService(); | |
44 | + // BaseOutput<Map<String, com.diligrp.titan.sdk.domain.Product>> | |
45 | + // rpcResponse = productRPCService | |
46 | + // .getSkuInfoMap(Arrays.asList(sku)); | |
47 | + InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("product.json"); | |
48 | + ObjectMapper mapper = new ObjectMapper(); | |
49 | + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
50 | + mapper.setSerializationInclusion(Include.NON_NULL); | |
51 | + BaseOutput<Map<String, com.diligrp.titan.sdk.domain.Product>> rpcResponse = new BaseOutput<>(); | |
52 | + try { | |
53 | + JsonNode rootNode = mapper.readTree(in); | |
54 | + rpcResponse.setCode(rootNode.get("code").asInt()); | |
55 | + String json = rootNode.get("data").toString(); | |
56 | + MapType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, | |
57 | + com.diligrp.titan.sdk.domain.Product.class); | |
58 | + Map<String, com.diligrp.titan.sdk.domain.Product> map = mapper.readValue(json, type); | |
59 | + rpcResponse.setData(map); | |
60 | + rpcResponse.setResult(rootNode.get("result").toString()); | |
61 | + } catch (IOException e) { | |
62 | + throw new RuntimeException(e); | |
63 | + } | |
40 | 64 | if (rpcResponse.getCode() != 200) { |
41 | 65 | LOG.error(rpcResponse.getResult()); |
42 | 66 | throw new ProductException(ApplicationException.DATA_EXCEPTION, "根据sku查询商品信息失败"); |
... | ... | @@ -56,7 +80,7 @@ public class ProductDaoBean implements ProductDao { |
56 | 80 | } |
57 | 81 | com.diligrp.titan.sdk.domain.Sku targetSku = null; |
58 | 82 | for (com.diligrp.titan.sdk.domain.Sku skuInfo : rpcProduct.getSkus()) { |
59 | - if (skuInfo.getSku().equals(sku)) { | |
83 | + if (skuInfo.getDecodeSku().equals(sku)) { | |
60 | 84 | targetSku = skuInfo; |
61 | 85 | } |
62 | 86 | } | ... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/ShopDaoBean.java
0 → 100644
1 | +package com.b2c.orders.dao.impl; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.stereotype.Repository; | |
7 | + | |
8 | +import com.b2c.myapp.common.api.shop.output.ShopOutput; | |
9 | +import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
10 | +import com.b2c.myapp.common.utils.BaseOutput; | |
11 | +import com.b2c.myapp.sdk.MyAppClient; | |
12 | +import com.b2c.myapp.sdk.service.ShopBuyerService; | |
13 | +import com.b2c.myapp.sdk.service.ShopInfoService; | |
14 | +import com.b2c.orders.commons.exceptions.ApplicationException; | |
15 | +import com.b2c.orders.commons.exceptions.SellerException; | |
16 | +import com.b2c.orders.dao.ShopDao; | |
17 | +import com.b2c.orders.domain.Shop; | |
18 | + | |
19 | +@Repository | |
20 | +public class ShopDaoBean implements ShopDao { | |
21 | + | |
22 | + private static final Logger LOG = LoggerFactory.getLogger(ShopDaoBean.class); | |
23 | + | |
24 | + @Autowired | |
25 | + private MyAppClient myAppClient; | |
26 | + | |
27 | + @Override | |
28 | + public Shop findByBuyerShopId(Long shopBuyerId) throws SellerException { | |
29 | + ShopBuyerService sbs = this.myAppClient.getShopBuyerService(); | |
30 | + BaseOutput<ShopBuyerKeyOutput> response = sbs.getShopBuyerKeys(shopBuyerId); | |
31 | + if (response == null || !response.getCode().equals("200")) { | |
32 | + LOG.error(String.format("调用店铺接口失败,Api:ShopBuyerService,Method:getShopBuyerKeys,params:%s", shopBuyerId)); | |
33 | + throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
34 | + } | |
35 | + ShopBuyerKeyOutput sbkOutput = response.getData(); | |
36 | + ShopInfoService sis = this.myAppClient.getShopInfoService(); | |
37 | + BaseOutput<ShopOutput> shopResponse = sis.getShopByShopId(sbkOutput.getShopId()); | |
38 | + if (response == null || !response.getCode().equals("200")) { | |
39 | + LOG.error( | |
40 | + String.format("调用店铺接口失败,ShopInfoService,Method:getShopByShopId,params:%s", sbkOutput.getShopId())); | |
41 | + throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
42 | + } | |
43 | + ShopOutput rpcShop = shopResponse.getData(); | |
44 | + Shop shop = new Shop(); | |
45 | + shop.setId(rpcShop.getId()); | |
46 | + shop.setName(rpcShop.getShopName()); | |
47 | + return shop; | |
48 | + } | |
49 | + | |
50 | +} | ... | ... |
b2c-orders-dao/src/main/resources/product.json
0 → 100644
1 | +{ | |
2 | + "code" : 200, | |
3 | + "result" : "成功", | |
4 | + "data" : { | |
5 | + "1bKvCngjj0w" : { | |
6 | + "pid" : 8000000487, | |
7 | + "name" : "name", | |
8 | + "cid" : 272, | |
9 | + "userDefined" : 123, | |
10 | + "salesNum" : 0, | |
11 | + "productionAddr" : "日本", | |
12 | + "productionAddrId" : -20, | |
13 | + "localityAddr" : "山东潍坊市寿光市", | |
14 | + "localityId" : 1370810, | |
15 | + "countryAreaId" : -20, | |
16 | + "publishedLocationID" : 11, | |
17 | + "saleType" : "10", | |
18 | + "quotationType" : 2, | |
19 | + "sellerID" : 998, | |
20 | + "vendorId" : 998, | |
21 | + "prepareTime" : 4, | |
22 | + "foreignPid" : null, | |
23 | + "status" : 3, | |
24 | + "saleUnit" : "公斤", | |
25 | + "storeUnit" : 38, | |
26 | + "defaultPic" : "http://img8.dili7.com/images/i1/67.jpeg", | |
27 | + "minPrice" : 1000, | |
28 | + "maxPrice" : 1100, | |
29 | + "indate" : 15, | |
30 | + "onSaleTime" : 1429858403000, | |
31 | + "publishMode" : 2, | |
32 | + "dropsTime" : 1431154403000, | |
33 | + "publishSettime" : 1431154403000, | |
34 | + "minNum" : 12, | |
35 | + "stockNum" : 1111, | |
36 | + "skus" : [{ | |
37 | + "sku" : "2t3oocXHY7", | |
38 | + "decodeSku" : "1bKvCngjj0w", | |
39 | + "remark" : "", | |
40 | + "pid" : 8000000487, | |
41 | + "stockNum" : 1111, | |
42 | + "minNum" : 0, | |
43 | + "price" : 20, | |
44 | + "version" : 1, | |
45 | + "sales" : 0, | |
46 | + "status" : 3, | |
47 | + "attributesMap" : { | |
48 | + "品种" : "毛粉" | |
49 | + } | |
50 | + }], | |
51 | + "productQuotation" : [{ | |
52 | + "id" : 962, | |
53 | + "price" : 1100, | |
54 | + "minPurchaseScope" : 12, | |
55 | + "maxPurchaseScope" : 13 | |
56 | + }], | |
57 | + "pictures" : ["http://img8.dili7.com/images/i1/67.jpeg", | |
58 | + "http://img9.dili7.com/images/i1/eb.jpg"], | |
59 | + "ctime" : 1429858403000, | |
60 | + "utime" : 1429858403000 | |
61 | + } | |
62 | + } | |
63 | +} | |
0 | 64 | \ No newline at end of file | ... | ... |
b2c-orders-dao/src/main/resources/spring-redis.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<beans xmlns="http://www.springframework.org/schema/beans" | |
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" | |
4 | + xmlns:context="http://www.springframework.org/schema/context" | |
5 | + xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache" | |
6 | + xsi:schemaLocation="http://www.springframework.org/schema/beans | |
7 | + http://www.springframework.org/schema/beans/spring-beans-4.3.xsd | |
8 | + http://www.springframework.org/schema/context | |
9 | + http://www.springframework.org/schema/context/spring-context-4.3.xsd | |
10 | + http://www.springframework.org/schema/mvc | |
11 | + http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd | |
12 | + http://www.springframework.org/schema/cache | |
13 | + http://www.springframework.org/schema/cache/spring-cache-4.3.xsd"> | |
14 | + | |
15 | + <!-- 启用缓存注解功能,这个是必须的,否则注解不会生效,另外,该注解一定要声明在spring主配置文件中才会生效 --> | |
16 | + <cache:annotation-driven cache-manager="cacheManager" /> | |
17 | +</beans> | |
0 | 18 | \ No newline at end of file | ... | ... |
b2c-orders-dao/src/main/resources/sqlmap-config.xml
... | ... | @@ -3,18 +3,15 @@ |
3 | 3 | |
4 | 4 | <configuration> |
5 | 5 | <settings> |
6 | - <!-- 开启全局性设置懒加载 --> | |
7 | - <setting name="lazyLoadingEnabled" value="true" /> | |
8 | - <!-- 开启按需加载 --> | |
9 | - <setting name="aggressiveLazyLoading" value="false" /> | |
10 | - <!-- 全局映射器启用缓存 --> | |
11 | - <setting name="cacheEnabled" value="true" /> | |
12 | - <!-- 对于未知的SQL查询,允许返回不同的结果集以达到通用的效果 --> | |
6 | + <setting name="cacheEnabled" value="false" /> | |
13 | 7 | <setting name="multipleResultSetsEnabled" value="true" /> |
14 | - <!-- 允许使用列标签代替列名 --> | |
15 | 8 | <setting name="useColumnLabel" value="true" /> |
16 | - <!-- 数据库超过25000秒仍未响应则超时 --> | |
17 | - <setting name="defaultStatementTimeout" value="25000" /> | |
9 | + <setting name="useGeneratedKeys" value="false" /> | |
10 | + <setting name="defaultExecutorType" value="SIMPLE" /> | |
11 | + <!-- 开启按需加载 --> | |
12 | + <setting name="aggressiveLazyLoading" value="false" /> | |
13 | + <!-- 查询时,关闭关联对象即时加载以提高性能 --> | |
14 | + <setting name="lazyLoadingEnabled" value="true" /> | |
18 | 15 | <setting name="logImpl" value="STDOUT_LOGGING" /> |
19 | 16 | </settings> |
20 | 17 | ... | ... |
b2c-orders-dao/src/main/resources/sqlmap/OrderItemMapper.xml
... | ... | @@ -4,19 +4,19 @@ |
4 | 4 | <resultMap id="OrderItemRM" type="com.b2c.orders.domain.OrderItem"> |
5 | 5 | <id property="id" column="id" /> |
6 | 6 | <result property="orderId" column="order_id" /> |
7 | + <result property="shopId" column="shop_id" /> | |
8 | + <result property="amount" column="amount" /> | |
9 | + <result property="versionNum" column="version_num" /> | |
10 | + <result property="editTime" column="edit_time" /> | |
11 | + <result property="createTime" column="create_time" /> | |
7 | 12 | <result property="productId" column="product_id" /> |
8 | 13 | <result property="productName" column="product_name" /> |
9 | - <result property="shopId" column="shop_id" /> | |
10 | 14 | <result property="sku" column="sku" /> |
11 | 15 | <result property="skuTitle" column="sku_title" /> |
12 | 16 | <result property="skuAttributes" column="sku_attributes" /> |
13 | - <result property="amount" column="amount" /> | |
14 | 17 | <result property="skuPrice" column="sku_price" /> |
15 | 18 | <result property="priceUnit" column="price_unit" /> |
16 | 19 | <result property="skuPicture" column="sku_picture" /> |
17 | - <result property="versionNum" column="version_num" /> | |
18 | - <result property="editTime" column="edit_time" /> | |
19 | - <result property="createTime" column="create_time" /> | |
20 | 20 | </resultMap> |
21 | 21 | |
22 | 22 | <sql id="selectCondition"> |
... | ... | @@ -33,12 +33,6 @@ |
33 | 33 | <if test="param.productName != null and param.productName != ''"> |
34 | 34 | and product_name = #{param.productName} |
35 | 35 | </if> |
36 | - <if test="param.buyerId != null and param.buyerId != ''"> | |
37 | - and buyer_id = #{param.buyerId} | |
38 | - </if> | |
39 | - <if test="param.sellerId != null and param.sellerId != ''"> | |
40 | - and seller_id = #{param.sellerId} | |
41 | - </if> | |
42 | 36 | <if test="param.shopId != null and param.shopId != ''"> |
43 | 37 | and shop_id = #{param.shopId} |
44 | 38 | </if> |
... | ... | @@ -63,10 +57,10 @@ |
63 | 57 | </if> |
64 | 58 | </sql> |
65 | 59 | |
66 | - <select id="findByOrderId" resultMap="OrderItemRM"> | |
60 | + <select id="findByOrderId" parameterType="Long" resultMap="OrderItemRM"> | |
67 | 61 | <![CDATA[ |
68 | 62 | SELECT |
69 | - id | |
63 | + id, | |
70 | 64 | order_id, |
71 | 65 | product_id, |
72 | 66 | product_name, | ... | ... |
b2c-orders-dao/src/main/resources/sqlmap/OrderMapper.xml
... | ... | @@ -3,17 +3,16 @@ |
3 | 3 | <mapper namespace="com.b2c.orders.dao.impl.OrderDaoBean"> |
4 | 4 | <resultMap id="OrderRM" type="com.b2c.orders.domain.Order"> |
5 | 5 | <id property="id" column="id" /> |
6 | - <result property="buyerId" column="buyer_id" /> | |
7 | - <result property="buyerName" column="buyer_name" /> | |
8 | - <result property="sellerId" column="seller_id" /> | |
9 | - <result property="sellerName" column="seller_name" /> | |
6 | + <result property="shopBuyerId" column="shop_buyer_id" /> | |
7 | + <result property="marketId" column="market_id" /> | |
10 | 8 | <result property="deliveryType" column="delivery_type" /> |
11 | - <result property="orderStatus" column="order_status" | |
12 | - typeHandler="com.b2c.orders.dao.utils.OrderStatusTypeHandler" /> | |
9 | + <result property="orderStatus" column="order_status" /> | |
13 | 10 | <result property="payStatus" column="pay_status" /> |
14 | 11 | <result property="buyerMemo" column="buyer_memo" /> |
15 | 12 | <result property="payTime" column="pay_time" /> |
16 | 13 | <result property="deliveryTime" column="delivery_time" /> |
14 | + <result property="deliveryAddress" column="delivery_address" /> | |
15 | + <result property="receiverPhoneNumber" column="receiver_phone_number" /> | |
17 | 16 | <result property="buyerConfirmTime" column="buyer_confirm_time" /> |
18 | 17 | <result property="sellerConfirmTime" column="seller_confirm_time" /> |
19 | 18 | <result property="reservationTime" column="reservation_time" /> |
... | ... | @@ -24,6 +23,13 @@ |
24 | 23 | <result property="versionNum" column="version_num" /> |
25 | 24 | <result property="delete" column="delete_flag" /> |
26 | 25 | <result property="statusInReason" column="status_in_reason" /> |
26 | + <result property="buyerId" column="buyer_id" /> | |
27 | + <result property="buyerName" column="buyer_name" /> | |
28 | + <result property="buyerPhoneNumber" column="buyer_phone_number" /> | |
29 | + <result property="sellerId" column="seller_id" /> | |
30 | + <result property="seller_name" column="seller_name" /> | |
31 | + <result property="shopId" column="shop_id" /> | |
32 | + <result property="shopName" column="shop_name" /> | |
27 | 33 | <collection property="orderItems" column="id" |
28 | 34 | select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" /> |
29 | 35 | </resultMap> |
... | ... | @@ -34,12 +40,16 @@ |
34 | 40 | ,t1.buyer_name |
35 | 41 | ,t1.seller_id |
36 | 42 | ,t1.seller_name |
43 | + ,t1.shop_buyer_id | |
44 | + ,t1.market_id | |
37 | 45 | ,t1.delivery_type |
38 | 46 | ,t1.order_status |
39 | 47 | ,t1.pay_status |
40 | 48 | ,t1.buyer_memo |
41 | 49 | ,t1.pay_time |
42 | 50 | ,t1.delivery_time |
51 | + ,t1.delivery_address | |
52 | + ,t1.receiver_phone_number | |
43 | 53 | ,t1.reservation_time |
44 | 54 | ,t1.buyer_confirm_time |
45 | 55 | ,t1.seller_confirm_time |
... | ... | @@ -68,6 +78,9 @@ |
68 | 78 | <if test="param.sellerName != null and param.sellerName != ''"> |
69 | 79 | and t1.seller_name = #{param.sellerName} |
70 | 80 | </if> |
81 | + <if test="param.marketId != null and param.marketId != ''"> | |
82 | + and t1.market_id = #{param.marketId} | |
83 | + </if> | |
71 | 84 | <if test="param.deliveryType != null and param.deliveryType != ''"> |
72 | 85 | and t1.delivery_type = #{param.deliveryType} |
73 | 86 | </if> |
... | ... | @@ -80,6 +93,10 @@ |
80 | 93 | <if test="param.buyerMemo != null and param.buyerMemo != ''"> |
81 | 94 | and t1.buyer_memo = #{param.buyerMemo} |
82 | 95 | </if> |
96 | + <if | |
97 | + test="param.receiverPhoneNumber != null and param.receiverPhoneNumber != ''"> | |
98 | + and t1.receiver_phone_number = #{param.receiverPhoneNumber} | |
99 | + </if> | |
83 | 100 | <if test="param.payBeginTime != null and param.payBeginTime != ''"> |
84 | 101 | <![CDATA[and t1.pay_time >= #{param.payBeginTime}]]> |
85 | 102 | </if> |
... | ... | @@ -154,23 +171,41 @@ |
154 | 171 | INSERT INTO t_order( |
155 | 172 | id, |
156 | 173 | buyer_id, |
174 | + buyer_name, | |
175 | + buyer_phone_number, | |
157 | 176 | seller_id, |
177 | + seller_name, | |
178 | + shop_id, | |
179 | + shop_name, | |
180 | + shop_buyer_id, | |
181 | + market_id, | |
158 | 182 | delivery_type, |
159 | 183 | order_status, |
160 | 184 | pay_status, |
161 | 185 | buyer_memo, |
162 | 186 | delivery_time, |
187 | + delivery_address, | |
188 | + receiver_phone_number, | |
163 | 189 | pay_type, |
164 | 190 | total_price |
165 | 191 | ) VALUES( |
166 | 192 | #{id}, |
167 | - #{buyerId}, | |
193 | + #{buyerId}, | |
194 | + #{buyerName}, | |
195 | + #{buyerPhoneNumber}, | |
168 | 196 | #{sellerId}, |
197 | + #{sellerName}, | |
198 | + #{shopId}, | |
199 | + #{shopName}, | |
200 | + #{shopBuyerId}, | |
201 | + #{marketId}, | |
169 | 202 | #{deliveryType}, |
170 | 203 | #{orderStatus}, |
171 | 204 | #{payStatus}, |
172 | 205 | #{buyerMemo}, |
173 | 206 | #{deliveryTime}, |
207 | + #{deliveryAddress}, | |
208 | + #{receiverPhoneNumber}, | |
174 | 209 | #{payType}, |
175 | 210 | #{totalPrice} |
176 | 211 | ) |
... | ... | @@ -182,13 +217,14 @@ |
182 | 217 | UPDATE t_order set |
183 | 218 | order_status=#{orderStatus}, |
184 | 219 | pay_status=#{payStatus}, |
220 | + pay_type=#{payType}, | |
185 | 221 | buyer_memo=#{buyerMemo}, |
186 | 222 | pay_time=#{payTime}, |
187 | 223 | delivery_time=#{deliveryTime}, |
188 | 224 | buyer_confirm_time=#{buyerConfirmTime}, |
189 | 225 | seller_confirm_time=#{sellerConfirmTime}, |
190 | 226 | real_total_price=#{realTotalPrice}, |
191 | - status_in_reason=#{statusInReason} | |
227 | + status_in_reason=#{statusInReason}, | |
192 | 228 | version_num=version_num + 1 |
193 | 229 | where 1=1 |
194 | 230 | and version_num=#{versionNum} and id = #{id} | ... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... | ... | @@ -18,15 +18,9 @@ import lombok.Data; |
18 | 18 | import lombok.EqualsAndHashCode; |
19 | 19 | import lombok.NoArgsConstructor; |
20 | 20 | |
21 | -/** | |
22 | - * orders | |
23 | - * | |
24 | - * @author dev-center | |
25 | - * @since 2014-05-19 | |
26 | - */ | |
27 | 21 | @Data |
28 | -@EqualsAndHashCode(callSuper = true) | |
29 | 22 | @NoArgsConstructor |
23 | +@EqualsAndHashCode(callSuper = true) | |
30 | 24 | public class Order extends BaseDomain { |
31 | 25 | |
32 | 26 | /** |
... | ... | @@ -37,7 +31,9 @@ public class Order extends BaseDomain { |
37 | 31 | /** |
38 | 32 | * 买家 |
39 | 33 | */ |
40 | - private Buyer buyer; | |
34 | + private Long buyerId; | |
35 | + private String buyerName; | |
36 | + private String buyerPhoneNumber; | |
41 | 37 | /** |
42 | 38 | * 资金账户id |
43 | 39 | */ |
... | ... | @@ -45,7 +41,8 @@ public class Order extends BaseDomain { |
45 | 41 | /** |
46 | 42 | * 卖家 |
47 | 43 | */ |
48 | - private Seller seller; | |
44 | + private Long sellerId; | |
45 | + private String sellerName; | |
49 | 46 | /** |
50 | 47 | * 市场id |
51 | 48 | */ |
... | ... | @@ -72,6 +69,14 @@ public class Order extends BaseDomain { |
72 | 69 | * 送货时间 |
73 | 70 | */ |
74 | 71 | private Date deliveryTime; |
72 | + /** | |
73 | + * 送货地址 | |
74 | + */ | |
75 | + private String deliveryAddress; | |
76 | + /** | |
77 | + * 收货人电话 | |
78 | + */ | |
79 | + private String receiverPhoneNumber; | |
75 | 80 | /** 提货时间 */ |
76 | 81 | private Date reservationTime; |
77 | 82 | /** 买家确认收货时间 */ |
... | ... | @@ -97,7 +102,8 @@ public class Order extends BaseDomain { |
97 | 102 | /** |
98 | 103 | * 店铺 |
99 | 104 | */ |
100 | - private Shop shop; | |
105 | + private Long shopId; | |
106 | + private String shopName; | |
101 | 107 | /** 进入当前状态说明或原因,如取消原因,退款审批通过原因等 */ |
102 | 108 | private String statusInReason; |
103 | 109 | /** |
... | ... | @@ -106,58 +112,6 @@ public class Order extends BaseDomain { |
106 | 112 | private List<OrderItem> orderItems; |
107 | 113 | |
108 | 114 | /** |
109 | - * 提交订单 | |
110 | - * | |
111 | - * @param vo | |
112 | - * 订单属性 | |
113 | - * @throws ParseException | |
114 | - */ | |
115 | - // public void submit(SubmitOrderRequestDto vo, OrderIdGenerator | |
116 | - // idGenerator) throws ParseException { | |
117 | - // Long orderId = idGenerator.getOrdersNewSeqNo(); | |
118 | - // this.setId(orderId); | |
119 | - // this.buyerId = vo.getBuyerId(); | |
120 | - // this.sellerId = vo.getSellerId(); | |
121 | - // this.shopBuyerId = vo.getShopBuyerId(); | |
122 | - // this.marketId = vo.getMarketId(); | |
123 | - // this.buyerMemo = vo.getBuyerMemo(); | |
124 | - // DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
125 | - // if (!TextUtils.isEmpty(vo.getDeliveryTime())) { | |
126 | - // this.deliveryTime = df.parse(vo.getDeliveryTime()); | |
127 | - // } | |
128 | - // this.deliveryType = DeliveryType.getDeliveryType(vo.getDeliveryType()); | |
129 | - // this.orderStatus = OrderStatus.PendingTake; | |
130 | - // if (!TextUtils.isEmpty(vo.getReservationTime())) { | |
131 | - // this.reservationTime = df.parse(vo.getReservationTime()); | |
132 | - // } | |
133 | - // this.sellerId = vo.getSellerId(); | |
134 | - // long totalPrice = 0; | |
135 | - // List<OrderItem> orderItems = new ArrayList<>(vo.getOrderItems().size()); | |
136 | - // int itemIdx = 1; | |
137 | - // for (OrderItemDto orderItemDto : vo.getOrderItems()) { | |
138 | - // Long orderItemId = idGenerator.getOrdersItemNewSeqNo(orderId, itemIdx++); | |
139 | - // OrderItem orderItem = new OrderItem(); | |
140 | - // orderItem.setBuyerId(vo.getBuyerId()); | |
141 | - // orderItem.setId(orderItemId); | |
142 | - // orderItem.setOrderId(orderId); | |
143 | - // orderItem.setPriceUnit(orderItemDto.getPriceUnit()); | |
144 | - // orderItem.setProductId(orderItemDto.getProductId()); | |
145 | - // orderItem.setSellerId(orderItemDto.getSellerId()); | |
146 | - // orderItem.setShopId(vo.getShopId()); | |
147 | - // orderItem.setSku(orderItemDto.getSku()); | |
148 | - // orderItem.setSkuAttributes(orderItem.getSkuAttributes()); | |
149 | - // orderItem.setAmount(orderItemDto.getAmount()); | |
150 | - // orderItem.setSkuPicture(orderItemDto.getSkuPicture()); | |
151 | - // orderItem.setSkuPrice(orderItemDto.getSkuPrice()); | |
152 | - // orderItem.setSkuTitle(orderItemDto.getSkuTitle()); | |
153 | - // orderItems.add(orderItem); | |
154 | - // totalPrice += orderItemDto.getSkuPrice() * orderItemDto.getAmount(); | |
155 | - // } | |
156 | - // this.orderItems = orderItems; | |
157 | - // this.totalPrice = totalPrice; | |
158 | - // }撒 | |
159 | - | |
160 | - /** | |
161 | 115 | * 商家接单 |
162 | 116 | * |
163 | 117 | * @param totalPrice |
... | ... | @@ -211,6 +165,12 @@ public class Order extends BaseDomain { |
211 | 165 | this.orderStatus = OrderStatus.Completed; |
212 | 166 | } |
213 | 167 | |
168 | + /** | |
169 | + * 拒绝接单 | |
170 | + * | |
171 | + * @param refuseReason | |
172 | + * @throws OrderException | |
173 | + */ | |
214 | 174 | public void refuse(String refuseReason) throws OrderException { |
215 | 175 | if (!this.orderStatus.equals(OrderStatus.PendingTake)) { |
216 | 176 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); |
... | ... | @@ -219,6 +179,11 @@ public class Order extends BaseDomain { |
219 | 179 | this.statusInReason = refuseReason; |
220 | 180 | } |
221 | 181 | |
182 | + /** | |
183 | + * 取消订单 | |
184 | + * | |
185 | + * @throws OrderException | |
186 | + */ | |
222 | 187 | public void cancel() throws OrderException { |
223 | 188 | if (!this.isCanCancel()) { |
224 | 189 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能被取消"); |
... | ... | @@ -226,6 +191,11 @@ public class Order extends BaseDomain { |
226 | 191 | this.orderStatus = OrderStatus.Canceled; |
227 | 192 | } |
228 | 193 | |
194 | + /** | |
195 | + * 接单超时 | |
196 | + * | |
197 | + * @throws OrderException | |
198 | + */ | |
229 | 199 | public void takenTimeout() throws OrderException { |
230 | 200 | if (this.orderStatus.equals(OrderStatus.PendingTake)) { |
231 | 201 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置支付超时"); |
... | ... | @@ -233,6 +203,11 @@ public class Order extends BaseDomain { |
233 | 203 | this.orderStatus = OrderStatus.TakenTimeout; |
234 | 204 | } |
235 | 205 | |
206 | + /** | |
207 | + * 支付超时 | |
208 | + * | |
209 | + * @throws OrderException | |
210 | + */ | |
236 | 211 | public void paymentTimeout() throws OrderException { |
237 | 212 | if (this.orderStatus.equals(OrderStatus.PendingPayment)) { |
238 | 213 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | ... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/OrderItem.java
... | ... | @@ -6,8 +6,6 @@ package com.b2c.orders.domain; |
6 | 6 | |
7 | 7 | import java.sql.Timestamp; |
8 | 8 | |
9 | -import com.b2c.orders.domain.rpc.Product; | |
10 | - | |
11 | 9 | import lombok.Data; |
12 | 10 | import lombok.EqualsAndHashCode; |
13 | 11 | import lombok.NoArgsConstructor; |
... | ... | @@ -30,9 +28,14 @@ public class OrderItem extends BaseDomain { |
30 | 28 | |
31 | 29 | private Long orderId; |
32 | 30 | private Order order; |
33 | - private Product product; | |
34 | - private Long buyerId; | |
35 | - private Long sellerId; | |
31 | + private Long productId; | |
32 | + private String productName; | |
33 | + private String sku; | |
34 | + private String skuTitle; | |
35 | + private String skuAttributes; | |
36 | + private String skuPicture; | |
37 | + private String priceUnit; | |
38 | + private Long skuPrice; | |
36 | 39 | private Integer amount; |
37 | 40 | private Timestamp createTime; |
38 | 41 | private Timestamp editTime; | ... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
... | ... | @@ -6,6 +6,7 @@ import com.b2c.orders.commons.exceptions.OrderException; |
6 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
7 | 7 | import com.b2c.orders.commons.exceptions.ProductException; |
8 | 8 | import com.b2c.orders.commons.exceptions.SellerException; |
9 | +import com.b2c.orders.domain.Order; | |
9 | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | 11 | import com.b2c.orders.enums.PayType; |
11 | 12 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
... | ... | @@ -21,10 +22,11 @@ public interface OrderManager { |
21 | 22 | * @throws DtmsRPCException |
22 | 23 | * @throws OrderException |
23 | 24 | * @throws ProductException |
24 | - * @throws SellerException | |
25 | - * @throws BuyerException | |
25 | + * @throws SellerException | |
26 | + * @throws BuyerException | |
26 | 27 | */ |
27 | - void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
28 | + void submit(SubmitOrderRequestDto orderVo) | |
29 | + throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
28 | 30 | |
29 | 31 | /** |
30 | 32 | * 接单 |
... | ... | @@ -87,13 +89,14 @@ public interface OrderManager { |
87 | 89 | * |
88 | 90 | * @param orderId |
89 | 91 | * 订单id |
90 | - * @param shopBuyerId | |
92 | + * @param sellerId | |
91 | 93 | * 商家id |
92 | - * @param refuseReason TODO | |
94 | + * @param refuseReason | |
95 | + * TODO | |
93 | 96 | * @throws OrderRepositoryException |
94 | 97 | * @throws OrderException |
95 | 98 | */ |
96 | - void refuse(Long orderId, Long shopBuyerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
99 | + void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
97 | 100 | |
98 | 101 | /** |
99 | 102 | * 取消订单 |
... | ... | @@ -137,5 +140,14 @@ public interface OrderManager { |
137 | 140 | */ |
138 | 141 | void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException; |
139 | 142 | |
143 | + /** | |
144 | + * 订单详情 | |
145 | + * | |
146 | + * @param orderId | |
147 | + * 订单id | |
148 | + * @return 订单详情 | |
149 | + */ | |
150 | + Order detail(Long orderId); | |
151 | + | |
140 | 152 | PageTemplate list(BaseQuery query); |
141 | 153 | } | ... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/BuyerManagerBean.java
... | ... | @@ -22,7 +22,7 @@ public class BuyerManagerBean implements BuyerManager { |
22 | 22 | @Override |
23 | 23 | public void lockBalance(LockBalanceParam param) { |
24 | 24 | FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); |
25 | - BeanCopier copier = BeanCopier.create(LockBalanceParam.class, FoundTradeInput.class, false); | |
25 | + BeanCopier copier = BeanCopier.create(LockBalanceParam.class, FoundTradeSaveInput.class, false); | |
26 | 26 | copier.copy(param, rpcParam, null); |
27 | 27 | rpcParam.setTradeType(TradeType.Freeze); |
28 | 28 | this.myAppClient.getFoundTradeService().foundTrade(rpcParam); |
... | ... | @@ -31,7 +31,7 @@ public class BuyerManagerBean implements BuyerManager { |
31 | 31 | @Override |
32 | 32 | public void debit(DebitParam param) { |
33 | 33 | FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); |
34 | - BeanCopier copier = BeanCopier.create(DebitParam.class, FoundTradeInput.class, false); | |
34 | + BeanCopier copier = BeanCopier.create(DebitParam.class, FoundTradeSaveInput.class, false); | |
35 | 35 | copier.copy(param, rpcParam, null); |
36 | 36 | rpcParam.setTradeType(TradeType.Consume); |
37 | 37 | this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | ... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
... | ... | @@ -44,7 +44,6 @@ import com.b2c.orders.enums.PayType; |
44 | 44 | import com.b2c.orders.enums.UserType; |
45 | 45 | import com.b2c.orders.manager.BuyerManager; |
46 | 46 | import com.b2c.orders.manager.OrderManager; |
47 | -import com.b2c.orders.rpc.BuyerAccountService; | |
48 | 47 | import com.b2c.orders.rpc.DtmsRPCService; |
49 | 48 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
50 | 49 | import com.b2c.orders.rpc.param.DebitParam; |
... | ... | @@ -66,8 +65,6 @@ public class OrderManagerBean implements OrderManager { |
66 | 65 | @Autowired |
67 | 66 | private DtmsRPCService dtmsService; |
68 | 67 | @Autowired |
69 | - private BuyerAccountService userAccountService; | |
70 | - @Autowired | |
71 | 68 | private OrderLogDao orderLogDao; |
72 | 69 | @Autowired |
73 | 70 | private ProductDao productDao; |
... | ... | @@ -89,21 +86,27 @@ public class OrderManagerBean implements OrderManager { |
89 | 86 | po.setId(orderId); |
90 | 87 | po.setShopBuyerId(orderVo.getShopBuyerId()); |
91 | 88 | Buyer buyer = this.buyerDao.findByBuyerShopId(orderVo.getShopBuyerId()); |
92 | - po.setBuyer(buyer); | |
89 | + po.setBuyerId(buyer.getId()); | |
90 | + po.setBuyerName(buyer.getName()); | |
91 | + po.setBuyerPhoneNumber(buyer.getPhoneNumber()); | |
93 | 92 | Seller seller = this.sellerDao.findByBuyerShopId(orderVo.getShopBuyerId()); |
94 | - po.setSeller(seller); | |
93 | + po.setSellerId(seller.getId()); | |
94 | + po.setSellerName(seller.getName()); | |
95 | 95 | Shop shop = this.shopDao.findByBuyerShopId(orderVo.getShopBuyerId()); |
96 | - po.setShop(shop); | |
96 | + po.setShopId(shop.getId()); | |
97 | + po.setShopName(shop.getName()); | |
97 | 98 | po.setMarketId(orderVo.getMarketId()); |
98 | 99 | po.setBuyerMemo(orderVo.getBuyerMemo()); |
99 | 100 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
100 | 101 | po.setDeliveryType(DeliveryType.getDeliveryType(orderVo.getDeliveryType())); |
102 | + po.setDeliveryAddress(orderVo.getDeliveryAddress()); | |
103 | + po.setReceiverPhoneNumber(orderVo.getReceiverPhoneNumber()); | |
101 | 104 | if (orderVo.getDeliveryType().equals(DeliveryType.Delivery.getIndex())) { |
102 | 105 | if (TextUtils.isEmpty(orderVo.getDeliveryTime())) { |
103 | 106 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "送货时间不能为空"); |
104 | 107 | } |
105 | 108 | po.setDeliveryTime(df.parse(orderVo.getDeliveryTime())); |
106 | - } else if (orderVo.getDeliveryType().equals(DeliveryType.Self)) { | |
109 | + } else if (orderVo.getDeliveryType().equals(DeliveryType.Self.getIndex())) { | |
107 | 110 | if (TextUtils.isEmpty(orderVo.getReservationTime())) { |
108 | 111 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "提货时间不能为空"); |
109 | 112 | } |
... | ... | @@ -118,14 +121,19 @@ public class OrderManagerBean implements OrderManager { |
118 | 121 | for (OrderItemDto orderItemDto : orderVo.getOrderItems()) { |
119 | 122 | Long orderItemId = idGenerator.getOrdersItemNewSeqNo(orderId, itemIdx++); |
120 | 123 | OrderItem orderItem = new OrderItem(); |
121 | - orderItem.setBuyerId(buyer.getId()); | |
122 | 124 | orderItem.setId(orderItemId); |
123 | 125 | orderItem.setOrderId(orderId); |
124 | - orderItem.setSellerId(seller.getId()); | |
125 | 126 | orderItem.setShopId(shop.getId()); |
126 | 127 | orderItem.setAmount(orderItemDto.getAmount()); |
127 | 128 | Product product = this.productDao.findBySku(orderItemDto.getSku()); |
128 | - orderItem.setProduct(product); | |
129 | + orderItem.setProductId(product.getId()); | |
130 | + orderItem.setProductName(product.getName()); | |
131 | + orderItem.setSku(orderItemDto.getSku()); | |
132 | + orderItem.setSkuAttributes(product.getSkuAttributes()); | |
133 | + orderItem.setSkuPicture(product.getSkuPicture()); | |
134 | + orderItem.setSkuPrice(product.getSkuPrice()); | |
135 | + orderItem.setSkuTitle(product.getSkuTitle()); | |
136 | + orderItem.setPriceUnit(product.getPriceUnit()); | |
129 | 137 | orderItems.add(orderItem); |
130 | 138 | totalPrice += product.getSkuPrice() * orderItemDto.getAmount(); |
131 | 139 | } |
... | ... | @@ -140,7 +148,7 @@ public class OrderManagerBean implements OrderManager { |
140 | 148 | OrderLog log = new OrderLog(); |
141 | 149 | log.setAction(Action.BUYER_PLACE_ORDER); |
142 | 150 | log.setOrderId(po.getId()); |
143 | - log.setUserId(po.getBuyer().getId()); | |
151 | + log.setUserId(po.getBuyerId()); | |
144 | 152 | log.setUserType(UserType.BUYER); |
145 | 153 | this.orderLogDao.save(log); |
146 | 154 | // 发送dtms消息 |
... | ... | @@ -155,10 +163,10 @@ public class OrderManagerBean implements OrderManager { |
155 | 163 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
156 | 164 | String.format("未找到id为%s的订单", orderId)); |
157 | 165 | } |
158 | - if (po.getSeller().getId() == null) { | |
166 | + if (po.getSellerId() == null) { | |
159 | 167 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
160 | 168 | } |
161 | - if (!po.getSeller().getId().equals(sellerId)) { | |
169 | + if (!po.getSellerId().equals(sellerId)) { | |
162 | 170 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); |
163 | 171 | } |
164 | 172 | po.take(totalPrice); |
... | ... | @@ -238,16 +246,16 @@ public class OrderManagerBean implements OrderManager { |
238 | 246 | } |
239 | 247 | |
240 | 248 | @Override |
241 | - public void sellerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
249 | + public void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException { | |
242 | 250 | Order po = this.orderDao.getById(orderId); |
243 | 251 | if (po == null) { |
244 | 252 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
245 | 253 | String.format("未找到id为%s的订单", orderId)); |
246 | 254 | } |
247 | - if (po.getShopBuyerId() == null) { | |
255 | + if (po.getSellerId() == null) { | |
248 | 256 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
249 | 257 | } |
250 | - if (!po.getShopBuyerId().equals(shopBuyerId)) { | |
258 | + if (!po.getSellerId().equals(sellerId)) { | |
251 | 259 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能收款"); |
252 | 260 | } |
253 | 261 | po.confirm(); |
... | ... | @@ -255,28 +263,29 @@ public class OrderManagerBean implements OrderManager { |
255 | 263 | OrderLog log = new OrderLog(); |
256 | 264 | log.setAction(Action.SELLER_CONFIRM); |
257 | 265 | log.setOrderId(orderId); |
258 | - log.setUserId(po.getSeller().getId()); | |
266 | + log.setUserId(po.getSellerId()); | |
259 | 267 | log.setUserType(UserType.SELLER); |
260 | 268 | this.orderLogDao.save(log); |
261 | 269 | DebitParam param = new DebitParam(); |
262 | 270 | param.setOrderId(po.getId()); |
263 | - param.setShopBuyerId(shopBuyerId); | |
271 | + param.setShopBuyerId(po.getShopBuyerId()); | |
264 | 272 | param.setTradeName(po.getTradeName()); |
265 | 273 | param.setTradePrice(po.getRealTotalPrice()); |
266 | 274 | this.buyerManager.debit(param); |
267 | 275 | } |
268 | 276 | |
269 | 277 | @Override |
270 | - public void refuse(Long orderId, Long shopBuyerId, String refuseReason) throws OrderRepositoryException, OrderException { | |
278 | + public void refuse(Long orderId, Long sellerId, String refuseReason) | |
279 | + throws OrderRepositoryException, OrderException { | |
271 | 280 | Order po = this.orderDao.getById(orderId); |
272 | 281 | if (po == null) { |
273 | 282 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
274 | 283 | String.format("未找到id为%s的订单", orderId)); |
275 | 284 | } |
276 | - if (po.getSeller().getId() == null) { | |
285 | + if (po.getSellerId() == null) { | |
277 | 286 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
278 | 287 | } |
279 | - if (!po.getSeller().getId().equals(shopBuyerId)) { | |
288 | + if (!po.getSellerId().equals(sellerId)) { | |
280 | 289 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); |
281 | 290 | } |
282 | 291 | po.refuse(refuseReason); |
... | ... | @@ -284,7 +293,7 @@ public class OrderManagerBean implements OrderManager { |
284 | 293 | OrderLog log = new OrderLog(); |
285 | 294 | log.setAction(Action.SELLER_REFUSE); |
286 | 295 | log.setOrderId(orderId); |
287 | - log.setUserId(shopBuyerId); | |
296 | + log.setUserId(sellerId); | |
288 | 297 | log.setUserType(UserType.SELLER); |
289 | 298 | this.orderLogDao.save(log); |
290 | 299 | } |
... | ... | @@ -311,8 +320,8 @@ public class OrderManagerBean implements OrderManager { |
311 | 320 | log.setUserType(UserType.BUYER); |
312 | 321 | log.setDescription("买家取消订单"); |
313 | 322 | this.orderLogDao.save(log); |
314 | - if (po.getPayStatus().equals(PayStatus.Paid)) { | |
315 | - UnlockBalanceParam param=new UnlockBalanceParam(); | |
323 | + if (po.getPayStatus() != null && po.getPayStatus().equals(PayStatus.Paid)) { | |
324 | + UnlockBalanceParam param = new UnlockBalanceParam(); | |
316 | 325 | this.buyerManager.unlockBalance(param); |
317 | 326 | } |
318 | 327 | } |
... | ... | @@ -379,12 +388,18 @@ public class OrderManagerBean implements OrderManager { |
379 | 388 | log.setUserType(UserType.SYSTEM); |
380 | 389 | this.orderLogDao.save(log); |
381 | 390 | if (po.getPayType().equals(PayType.Online)) { |
382 | - this.userAccountService.debit(null); | |
391 | + this.buyerManager.debit(null); | |
383 | 392 | } |
384 | 393 | } |
385 | 394 | |
386 | 395 | @Transactional(propagation = Propagation.SUPPORTS) |
387 | 396 | @Override |
397 | + public Order detail(Long orderId) { | |
398 | + return this.orderDao.getById(orderId); | |
399 | + } | |
400 | + | |
401 | + @Transactional(propagation = Propagation.SUPPORTS) | |
402 | + @Override | |
388 | 403 | public PageTemplate list(BaseQuery query) { |
389 | 404 | List<Order> list = this.orderDao.listByCondition(query); |
390 | 405 | Integer count = this.orderDao.countByCondition(query); | ... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/BuyerAccountService.java deleted
100644 → 0
1 | -package com.b2c.orders.rpc; | |
2 | - | |
3 | -import com.b2c.orders.rpc.param.DebitParam; | |
4 | -import com.b2c.orders.rpc.param.LockBalanceParam; | |
5 | -import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
6 | - | |
7 | -public interface BuyerAccountService { | |
8 | - | |
9 | - /** | |
10 | - * 锁定买家账户余额 | |
11 | - * | |
12 | - * @param | |
13 | - */ | |
14 | - void lockBalance(LockBalanceParam param); | |
15 | - | |
16 | - /** | |
17 | - * 买家账户扣款 | |
18 | - * @param param TODO | |
19 | - */ | |
20 | - void debit(DebitParam param); | |
21 | - | |
22 | - /** | |
23 | - * 解除买家账户锁定 | |
24 | - * @param param TODO | |
25 | - */ | |
26 | - void unlockBalance(UnlockBalanceParam param); | |
27 | -} |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/ProductService.java deleted
100644 → 0
b2c-orders-rpc/src/main/resources/spring-rpc.xml
... | ... | @@ -19,15 +19,16 @@ |
19 | 19 | <constructor-arg name="token" value="${dtms.token}" /> |
20 | 20 | </bean> |
21 | 21 | |
22 | - <bean id="titanClient" class="com.b2c.orders.rpc.ProductService"> | |
23 | - <constructor-arg value="" /> | |
24 | - <constructor-arg value="" /> | |
25 | - <constructor-arg value="titan.zandeapp.com" /> | |
22 | + <bean id="titanClient" class="com.diligrp.titan.sdk.TitanClient"> | |
23 | + <constructor-arg index="0" value="" type="java.lang.String" /> | |
24 | + <constructor-arg index="1" value="" type="java.lang.String" /> | |
25 | + <constructor-arg index="2" value="titan.zandeapp.com" | |
26 | + type="java.lang.String" /> | |
26 | 27 | </bean> |
27 | 28 | |
28 | - <bean id="buyerAccountService" class="com.b2c.orders.rpc.impl.BuyerAccountServiceBean"> | |
29 | + <bean id="myAppClient" class="com.b2c.myapp.sdk.MyAppClient"> | |
29 | 30 | <constructor-arg name="token" value="" /> |
30 | - <constructor-arg name="baseUrl" value="www.zandeapp.com" /> | |
31 | + <constructor-arg name="baseUrl" value="http://www.zandeapp.com" /> | |
31 | 32 | </bean> |
32 | 33 | |
33 | 34 | </beans> |
34 | 35 | \ No newline at end of file | ... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
... | ... | @@ -6,6 +6,7 @@ import com.b2c.orders.commons.exceptions.OrderException; |
6 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
7 | 7 | import com.b2c.orders.commons.exceptions.ProductException; |
8 | 8 | import com.b2c.orders.commons.exceptions.SellerException; |
9 | +import com.b2c.orders.domain.Order; | |
9 | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | 11 | import com.b2c.orders.enums.PayType; |
11 | 12 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
... | ... | @@ -21,11 +22,12 @@ public interface OrderService { |
21 | 22 | * 订单id |
22 | 23 | * @throws DtmsRPCException |
23 | 24 | * @throws OrderException |
24 | - * @throws ProductException | |
25 | - * @throws BuyerException | |
26 | - * @throws SellerException | |
25 | + * @throws ProductException | |
26 | + * @throws BuyerException | |
27 | + * @throws SellerException | |
27 | 28 | */ |
28 | - void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
29 | + void submit(SubmitOrderRequestDto order) | |
30 | + throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
29 | 31 | |
30 | 32 | /** |
31 | 33 | * 商家接单 |
... | ... | @@ -48,7 +50,7 @@ public interface OrderService { |
48 | 50 | * |
49 | 51 | * @param orderId |
50 | 52 | * 订单id |
51 | - * @param buyerId | |
53 | + * @param shopBuyerId | |
52 | 54 | * 买家id |
53 | 55 | * @param payType |
54 | 56 | * TODO |
... | ... | @@ -56,7 +58,7 @@ public interface OrderService { |
56 | 58 | * @throws OrderRepositoryException |
57 | 59 | * @throws DtmsRPCException |
58 | 60 | */ |
59 | - void pay(Long orderId, Long buyerId, PayType payType) | |
61 | + void pay(Long orderId, Long shopBuyerId, PayType payType) | |
60 | 62 | throws OrderRepositoryException, OrderException, DtmsRPCException; |
61 | 63 | |
62 | 64 | /** |
... | ... | @@ -64,12 +66,12 @@ public interface OrderService { |
64 | 66 | * |
65 | 67 | * @param orderId |
66 | 68 | * 订单id |
67 | - * @param buyerId | |
69 | + * @param shopBuyerId | |
68 | 70 | * 买家id |
69 | 71 | * @throws OrderException |
70 | 72 | * @throws OrderRepositoryException |
71 | 73 | */ |
72 | - void buyerConfirm(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; | |
74 | + void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
73 | 75 | |
74 | 76 | /** |
75 | 77 | * 商家确认收款 |
... | ... | @@ -90,7 +92,8 @@ public interface OrderService { |
90 | 92 | * 订单id |
91 | 93 | * @param sellerId |
92 | 94 | * 商家id |
93 | - * @param refuseReason TODO | |
95 | + * @param refuseReason | |
96 | + * TODO | |
94 | 97 | * @throws OrderException |
95 | 98 | * @throws OrderRepositoryException |
96 | 99 | */ |
... | ... | @@ -101,12 +104,12 @@ public interface OrderService { |
101 | 104 | * |
102 | 105 | * @param orderId |
103 | 106 | * 订单id |
104 | - * @param buyerId | |
107 | + * @param shopBuyerId | |
105 | 108 | * 买家id |
106 | 109 | * @throws OrderException |
107 | 110 | * @throws OrderRepositoryException |
108 | 111 | */ |
109 | - void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; | |
112 | + void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
110 | 113 | |
111 | 114 | /** |
112 | 115 | * 商家{@link Constant.ORDER_TAKEN_TIMEOUT_SECONDS}秒未接单,订单超时 |
... | ... | @@ -137,6 +140,15 @@ public interface OrderService { |
137 | 140 | void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; |
138 | 141 | |
139 | 142 | /** |
143 | + * 订单详情 | |
144 | + * | |
145 | + * @param orderId | |
146 | + * 订单id | |
147 | + * @return 订单详情 | |
148 | + */ | |
149 | + Order detail(Long orderId); | |
150 | + | |
151 | + /** | |
140 | 152 | * 条件查询订单 |
141 | 153 | * |
142 | 154 | * @param query | ... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
... | ... | @@ -13,6 +13,7 @@ import com.b2c.orders.commons.exceptions.OrderException; |
13 | 13 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
14 | 14 | import com.b2c.orders.commons.exceptions.ProductException; |
15 | 15 | import com.b2c.orders.commons.exceptions.SellerException; |
16 | +import com.b2c.orders.domain.Order; | |
16 | 17 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
17 | 18 | import com.b2c.orders.enums.PayType; |
18 | 19 | import com.b2c.orders.manager.OrderManager; |
... | ... | @@ -31,7 +32,8 @@ public class OrderServiceBean implements OrderService { |
31 | 32 | private OrderManager orderManager; |
32 | 33 | |
33 | 34 | @Override |
34 | - public void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException { | |
35 | + public void submit(SubmitOrderRequestDto order) | |
36 | + throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException { | |
35 | 37 | this.orderManager.submit(order); |
36 | 38 | } |
37 | 39 | |
... | ... | @@ -42,14 +44,14 @@ public class OrderServiceBean implements OrderService { |
42 | 44 | } |
43 | 45 | |
44 | 46 | @Override |
45 | - public void pay(Long orderId, Long buyerId, PayType payType) | |
47 | + public void pay(Long orderId, Long shopBuyerId, PayType payType) | |
46 | 48 | throws OrderRepositoryException, OrderException, DtmsRPCException { |
47 | - this.orderManager.pay(orderId, buyerId, payType); | |
49 | + this.orderManager.pay(orderId, shopBuyerId, payType); | |
48 | 50 | } |
49 | 51 | |
50 | 52 | @Override |
51 | - public void buyerConfirm(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException { | |
52 | - this.orderManager.buyerConfirm(orderId, buyerId); | |
53 | + public void buyerConfirm(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
54 | + this.orderManager.buyerConfirm(orderId, shopBuyerId); | |
53 | 55 | } |
54 | 56 | |
55 | 57 | @Override |
... | ... | @@ -58,13 +60,14 @@ public class OrderServiceBean implements OrderService { |
58 | 60 | } |
59 | 61 | |
60 | 62 | @Override |
61 | - public void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException { | |
63 | + public void refuse(Long orderId, Long sellerId, String refuseReason) | |
64 | + throws OrderRepositoryException, OrderException { | |
62 | 65 | this.orderManager.refuse(orderId, sellerId, refuseReason); |
63 | 66 | } |
64 | 67 | |
65 | 68 | @Override |
66 | - public void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException { | |
67 | - this.orderManager.cancel(orderId, buyerId); | |
69 | + public void cancel(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
70 | + this.orderManager.cancel(orderId, shopBuyerId); | |
68 | 71 | } |
69 | 72 | |
70 | 73 | @Override |
... | ... | @@ -92,6 +95,12 @@ public class OrderServiceBean implements OrderService { |
92 | 95 | |
93 | 96 | @Transactional(propagation = Propagation.SUPPORTS) |
94 | 97 | @Override |
98 | + public Order detail(Long orderId) { | |
99 | + return this.orderManager.detail(orderId); | |
100 | + } | |
101 | + | |
102 | + @Transactional(propagation = Propagation.SUPPORTS) | |
103 | + @Override | |
95 | 104 | public PageTemplate list(BaseQuery query) { |
96 | 105 | return this.orderManager.list(query); |
97 | 106 | } | ... | ... |
b2c-orders-web/pom.xml
... | ... | @@ -108,10 +108,6 @@ |
108 | 108 | <groupId>ch.qos.logback</groupId> |
109 | 109 | <artifactId>logback-core</artifactId> |
110 | 110 | </dependency> |
111 | - <dependency> | |
112 | - <groupId>org.slf4j</groupId> | |
113 | - <artifactId>slf4j-api</artifactId> | |
114 | - </dependency> | |
115 | 111 | <!-- if you enable @AspectJ style AOP in spring. --> |
116 | 112 | <dependency> |
117 | 113 | <groupId>org.aspectj</groupId> | ... | ... |
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.text.DateFormat; | |
4 | +import java.text.SimpleDateFormat; | |
3 | 5 | import java.util.ArrayList; |
4 | 6 | import java.util.List; |
5 | 7 | |
6 | 8 | import javax.validation.Valid; |
7 | 9 | |
8 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | +import org.springframework.cglib.beans.BeanCopier; | |
9 | 12 | import org.springframework.http.MediaType; |
10 | 13 | import org.springframework.util.CollectionUtils; |
11 | 14 | import org.springframework.validation.BindingResult; |
... | ... | @@ -24,14 +27,17 @@ import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; |
24 | 27 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; |
25 | 28 | import com.b2c.orders.domain.client.dto.request.DtmsConfirmRequestDto; |
26 | 29 | import com.b2c.orders.domain.client.dto.request.DtmsTimeoutRequestDto; |
30 | +import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; | |
27 | 31 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; |
28 | 32 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; |
29 | 33 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; |
30 | 34 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; |
31 | 35 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
32 | 36 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; |
37 | +import com.b2c.orders.domain.client.dto.response.ApiDataResponse; | |
33 | 38 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
34 | 39 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
40 | +import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; | |
35 | 41 | import com.b2c.orders.domain.client.dto.response.OrderItemResponseDto; |
36 | 42 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
37 | 43 | import com.b2c.orders.enums.PayType; |
... | ... | @@ -41,7 +47,6 @@ import com.diligrp.website.util.web.PageTemplate; |
41 | 47 | |
42 | 48 | import io.swagger.annotations.Api; |
43 | 49 | import io.swagger.annotations.ApiOperation; |
44 | -import net.sf.cglib.beans.BeanCopier; | |
45 | 50 | |
46 | 51 | @Api("订单api") |
47 | 52 | @RestController |
... | ... | @@ -86,7 +91,8 @@ public class OrderRestController { |
86 | 91 | public ApiResponse pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { |
87 | 92 | ApiResponse dto = new ApiResponse(); |
88 | 93 | try { |
89 | - this.orderService.pay(request.getOrderId(), request.getBuyerId(), PayType.getPayType(request.getPayType())); | |
94 | + this.orderService.pay(request.getOrderId(), request.getShopBuyerId(), | |
95 | + PayType.getPayType(request.getPayType())); | |
90 | 96 | dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
91 | 97 | dto.setSuccess(true); |
92 | 98 | } catch (ApplicationException e) { |
... | ... | @@ -100,7 +106,7 @@ public class OrderRestController { |
100 | 106 | public ApiResponse buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) { |
101 | 107 | ApiResponse response = new ApiResponse(); |
102 | 108 | try { |
103 | - this.orderService.buyerConfirm(request.getOrderId(), request.getBuyerId()); | |
109 | + this.orderService.buyerConfirm(request.getOrderId(), request.getShopBuyerId()); | |
104 | 110 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
105 | 111 | response.setSuccess(true); |
106 | 112 | } catch (ApplicationException e) { |
... | ... | @@ -155,7 +161,7 @@ public class OrderRestController { |
155 | 161 | public ApiResponse buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) { |
156 | 162 | ApiResponse response = new ApiResponse(); |
157 | 163 | try { |
158 | - this.orderService.cancel(request.getOrderId(), request.getBuyerId()); | |
164 | + this.orderService.cancel(request.getOrderId(), request.getShopBuyerId()); | |
159 | 165 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
160 | 166 | response.setSuccess(true); |
161 | 167 | } catch (ApplicationException e) { |
... | ... | @@ -190,6 +196,30 @@ public class OrderRestController { |
190 | 196 | return response; |
191 | 197 | } |
192 | 198 | |
199 | + @ApiOperation("订单详情") | |
200 | + @RequestMapping(value = "/detail", method = RequestMethod.GET) | |
201 | + public ApiDataResponse<OrderDetailResponseDto> detail(OrderDetailRequestDto request) { | |
202 | + ApiDataResponse<OrderDetailResponseDto> response = new ApiDataResponse<>(); | |
203 | + Order po = this.orderService.detail(request.getOrderId()); | |
204 | + OrderDetailResponseDto dto = new OrderDetailResponseDto(); | |
205 | + dto.setBuyerMemo(po.getBuyerMemo()); | |
206 | + dto.setDeliveryAddress(po.getDeliveryAddress()); | |
207 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
208 | + dto.setDeliveryTime(df.format(po.getDeliveryTime())); | |
209 | + dto.setDeliveryType(po.getDeliveryType().getIndex()); | |
210 | + dto.setOrderStatus(po.getOrderStatus().getIndex()); | |
211 | + dto.setPayStatus(po.getPayStatus().getIndex()); | |
212 | + dto.setPayType(po.getPayType().getIndex()); | |
213 | + dto.setRealTotalPrice(po.getRealTotalPrice()); | |
214 | + dto.setReservationTime(df.format(po.getReservationTime())); | |
215 | + dto.setSubmitTime(df.format(po.getSubmitTime())); | |
216 | + dto.setTotalPrice(po.getTotalPrice()); | |
217 | + response.setData(dto); | |
218 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
219 | + response.setSuccess(true); | |
220 | + return response; | |
221 | + } | |
222 | + | |
193 | 223 | @ApiOperation("查询订单") |
194 | 224 | @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
195 | 225 | public ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request) { | ... | ... |
b2c-orders-web/src/main/resources/spring-mvc.xml
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <context:annotation-config /> |
38 | 38 | |
39 | 39 | <!-- static resources --> |
40 | - <mvc:resources location="/assets/" mapping="/static/**" | |
40 | + <mvc:resources location="/assets/" mapping="/assets/**" | |
41 | 41 | cache-period="864000" /><!-- 24 * 3600 * 10 --> |
42 | 42 | |
43 | 43 | <!-- template view --> | ... | ... |
b2c-orders-web/src/main/resources/spring.xml
b2c-orders-web/src/main/webapp/WEB-INF/vm/list.vm
... | ... | @@ -148,9 +148,10 @@ |
148 | 148 | <th #sorting($!{orders} "sellerName")>卖家帐号</th> |
149 | 149 | <th>订单预估金额</th> |
150 | 150 | <th>订单实际金额</th> |
151 | - <th>配送类型</th> | |
152 | 151 | <th>付款方式</th> |
152 | + <th>配送方式</th> | |
153 | 153 | <th>订单状态</th> |
154 | + <th>下单时间</th> | |
154 | 155 | <th>操作</th> |
155 | 156 | </tr> |
156 | 157 | </thead> |
... | ... | @@ -168,19 +169,20 @@ |
168 | 169 | <td class="textC">$!{item.sellerName}</td> |
169 | 170 | <td class="textC">$!{item.totalPrice}</td> |
170 | 171 | <td class="textC">$!{item.realTotalPrice}</td> |
171 | - <td class="textC"> | |
172 | - $!{item.deliveryType.name} | |
173 | - </td> | |
174 | 172 | <td class="textC"> |
175 | 173 | $!{item.payType.name} |
176 | 174 | </td> |
175 | + <td class="textC"> | |
176 | + $!{item.deliveryType.name} | |
177 | + </td> | |
177 | 178 | <td class="textC"> |
178 | 179 | $!{item.orderStatus.name} |
179 | 180 | </td> |
181 | + <td class="textC"> | |
182 | + $dateTool.format('yyyy-MM-dd HH:mm:ss',$!{item.submitTime}) | |
183 | + </td> | |
180 | 184 | <td class="textC"> |
181 | - #if($!{detailRight}) | |
182 | - <a name="toViewDetail" data="$!{item.id}" href="#">查看</a> | |
183 | - #end | |
185 | + <a data="$!{item.id}" href="$!{domain}/order/detail?id=$!{item.id}">查看</a> | |
184 | 186 | </td> |
185 | 187 | </tr> |
186 | 188 | <tr id="collapseOrderItem$!{item.id}" class="accordion-body collapse"> | ... | ... |
pom.xml
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | <user.client.devlop.version>0.0.1-SNAPSHOT</user.client.devlop.version> |
48 | 48 | <user.client.product.version>0.0.3-SNAPSHOT</user.client.product.version> |
49 | 49 | <fastjson.version>1.2.7</fastjson.version> |
50 | - <mybatis.version>3.2.5</mybatis.version> | |
50 | + <mybatis.version>3.3.1</mybatis.version> | |
51 | 51 | <guava.version>20.0</guava.version> |
52 | 52 | <pnr-shop-develop.version>0.0.1-SNAPSHOT</pnr-shop-develop.version> |
53 | 53 | <pnr-shop-product.version>0.0.1-SNAPSHOT</pnr-shop-product.version> |
... | ... | @@ -360,15 +360,13 @@ |
360 | 360 | <dependency> |
361 | 361 | <groupId>org.mybatis</groupId> |
362 | 362 | <artifactId>mybatis-spring</artifactId> |
363 | - <version>1.2.0</version> | |
363 | + <version>1.2.5</version> | |
364 | 364 | </dependency> |
365 | 365 | <dependency> |
366 | 366 | <groupId>com.alibaba</groupId> |
367 | 367 | <artifactId>druid</artifactId> |
368 | 368 | <version>1.0.27</version> |
369 | 369 | </dependency> |
370 | - <!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> | |
371 | - <version>5.1.25</version> </dependency> --> | |
372 | 370 | <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client --> |
373 | 371 | <dependency> |
374 | 372 | <groupId>org.mariadb.jdbc</groupId> |
... | ... | @@ -422,9 +420,6 @@ |
422 | 420 | <artifactId>hibernate-validator</artifactId> |
423 | 421 | <version>5.1.3.Final</version> |
424 | 422 | </dependency> |
425 | - <!-- if you enable json support in spring mvc. --> | |
426 | - <!-- <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> | |
427 | - <version>${jackson.version}</version> </dependency> --> | |
428 | 423 | <!-- if you use fileupload in spring mvc --> |
429 | 424 | <dependency> |
430 | 425 | <groupId>commons-fileupload</groupId> |
... | ... | @@ -506,6 +501,7 @@ |
506 | 501 | <properties> |
507 | 502 | <!-- 数据库 --> |
508 | 503 | <orders.jdbc.driver>org.mariadb.jdbc.Driver</orders.jdbc.driver> |
504 | + <!-- <orders.jdbc.url>jdbc:mariadb://10.28.11.162:3306/orders?characterEncoding=UTF-8</orders.jdbc.url> --> | |
509 | 505 | <orders.jdbc.url>jdbc:mariadb://10.28.11.162:3306/orders?characterEncoding=UTF-8</orders.jdbc.url> |
510 | 506 | <orders.jdbc.username>root</orders.jdbc.username> |
511 | 507 | <orders.jdbc.password>123456</orders.jdbc.password> |
... | ... | @@ -565,8 +561,9 @@ |
565 | 561 | <path>/</path> |
566 | 562 | <port>80</port> |
567 | 563 | <uriEncoding>UTF-8</uriEncoding> |
568 | - <server>order_dev_server</server> | |
569 | - <url>http://10.28.10.182/manager</url> | |
564 | + <username>admin</username> | |
565 | + <password>123456</password> | |
566 | + <url>http://10.28.11.197/manager/text</url> | |
570 | 567 | </configuration> |
571 | 568 | </plugin> |
572 | 569 | <plugin> |
... | ... | @@ -600,7 +597,6 @@ |
600 | 597 | </plugin> |
601 | 598 | </plugins> |
602 | 599 | </pluginManagement> |
603 | - <defaultGoal>compile</defaultGoal> | |
604 | 600 | <resources> |
605 | 601 | <resource> |
606 | 602 | <directory>${project.basedir}/src/main/resources</directory> | ... | ... |