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,6 +9,11 @@ | ||
9 | <artifactId>b2c-orders-client</artifactId> | 9 | <artifactId>b2c-orders-client</artifactId> |
10 | 10 | ||
11 | <dependencies> | 11 | <dependencies> |
12 | + <dependency> | ||
13 | + <groupId>${project.groupId}</groupId> | ||
14 | + <artifactId>b2c-orders-commons</artifactId> | ||
15 | + <version>${project.parent.version}</version> | ||
16 | + </dependency> | ||
12 | <!--swagger --> | 17 | <!--swagger --> |
13 | <dependency> | 18 | <dependency> |
14 | <groupId>io.springfox</groupId> | 19 | <groupId>io.springfox</groupId> |
@@ -124,5 +129,18 @@ | @@ -124,5 +129,18 @@ | ||
124 | <groupId>com.fasterxml.jackson.module</groupId> | 129 | <groupId>com.fasterxml.jackson.module</groupId> |
125 | <artifactId>jackson-module-jaxb-annotations</artifactId> | 130 | <artifactId>jackson-module-jaxb-annotations</artifactId> |
126 | </dependency> | 131 | </dependency> |
132 | + <dependency> | ||
133 | + <groupId>junit</groupId> | ||
134 | + <artifactId>junit</artifactId> | ||
135 | + <scope>test</scope> | ||
136 | + </dependency> | ||
127 | </dependencies> | 137 | </dependencies> |
138 | + | ||
139 | + <build> | ||
140 | + <plugins> | ||
141 | + <plugin> | ||
142 | + <artifactId>maven-source-plugin</artifactId> | ||
143 | + </plugin> | ||
144 | + </plugins> | ||
145 | + </build> | ||
128 | </project> | 146 | </project> |
129 | \ No newline at end of file | 147 | \ No newline at end of file |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/OrderClient.java
1 | package com.b2c.orders.domain.client; | 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 | public class OrderClient { | 6 | public class OrderClient { |
4 | 7 | ||
5 | - private String baseUrl; | ||
6 | - private String token; | 8 | + private OrderService orderService; |
7 | 9 | ||
8 | public OrderClient(String baseUrl, String token) { | 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,9 +14,9 @@ public class BuyerCancelRequestDto extends BaseRequestDto { | ||
14 | @ApiParam(value = "订单id", required = true) | 14 | @ApiParam(value = "订单id", required = true) |
15 | @NotNull(message = "订单id不能为空") | 15 | @NotNull(message = "订单id不能为空") |
16 | private Long orderId; | 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 | public Long getOrderId() { | 21 | public Long getOrderId() { |
22 | return orderId; | 22 | return orderId; |
@@ -26,12 +26,12 @@ public class BuyerCancelRequestDto extends BaseRequestDto { | @@ -26,12 +26,12 @@ public class BuyerCancelRequestDto extends BaseRequestDto { | ||
26 | this.orderId = orderId; | 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,7 +16,7 @@ public class BuyerConfirmRequestDto extends BaseRequestDto { | ||
16 | private Long orderId; | 16 | private Long orderId; |
17 | @ApiParam(value = "买家id", required = true) | 17 | @ApiParam(value = "买家id", required = true) |
18 | @NotNull(message = "买家id不能为空") | 18 | @NotNull(message = "买家id不能为空") |
19 | - private Long buyerId; | 19 | + private Long shopBuyerId; |
20 | 20 | ||
21 | public Long getOrderId() { | 21 | public Long getOrderId() { |
22 | return orderId; | 22 | return orderId; |
@@ -26,12 +26,12 @@ public class BuyerConfirmRequestDto extends BaseRequestDto { | @@ -26,12 +26,12 @@ public class BuyerConfirmRequestDto extends BaseRequestDto { | ||
26 | this.orderId = orderId; | 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,7 +16,7 @@ public class PayOrderRequestDto extends BaseRequestDto { | ||
16 | private Long orderId; | 16 | private Long orderId; |
17 | @ApiParam(value = "买家id", required = true) | 17 | @ApiParam(value = "买家id", required = true) |
18 | @NotNull(message = "买家id不能为空") | 18 | @NotNull(message = "买家id不能为空") |
19 | - private Long buyerId; | 19 | + private Long shopBuyerId; |
20 | @ApiParam(value = "支付方式", required = true) | 20 | @ApiParam(value = "支付方式", required = true) |
21 | @NotNull(message = "支付方式不能为空") | 21 | @NotNull(message = "支付方式不能为空") |
22 | private Integer payType; | 22 | private Integer payType; |
@@ -29,12 +29,12 @@ public class PayOrderRequestDto extends BaseRequestDto { | @@ -29,12 +29,12 @@ public class PayOrderRequestDto extends BaseRequestDto { | ||
29 | this.orderId = orderId; | 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 | public Integer getPayType() { | 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,6 +22,10 @@ public class SubmitOrderRequestDto implements Serializable { | ||
22 | private String buyerMemo; | 22 | private String buyerMemo; |
23 | @ApiParam(value = "送货时间") | 23 | @ApiParam(value = "送货时间") |
24 | private String deliveryTime; | 24 | private String deliveryTime; |
25 | + @ApiParam("送货地址") | ||
26 | + private String deliveryAddress; | ||
27 | + @ApiParam("收货人电话") | ||
28 | + private String receiverPhoneNumber; | ||
25 | @ApiParam(value = "提货时间") | 29 | @ApiParam(value = "提货时间") |
26 | private String reservationTime; | 30 | private String reservationTime; |
27 | @ApiParam(value = "订单项", required = true) | 31 | @ApiParam(value = "订单项", required = true) |
@@ -67,6 +71,22 @@ public class SubmitOrderRequestDto implements Serializable { | @@ -67,6 +71,22 @@ public class SubmitOrderRequestDto implements Serializable { | ||
67 | this.deliveryTime = deliveryTime; | 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 | public String getReservationTime() { | 90 | public String getReservationTime() { |
71 | return reservationTime; | 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 | import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; | 3 | import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; |
4 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; | 4 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; |
5 | +import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; | ||
5 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; | 6 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; |
6 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; | 7 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; |
7 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; | 8 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; |
8 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; | 9 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; |
9 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; | 11 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; |
12 | +import com.b2c.orders.domain.client.dto.response.ApiDataResponse; | ||
11 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; | 13 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
12 | import com.b2c.orders.domain.client.dto.response.ApiResponse; | 14 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
15 | +import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; | ||
13 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; | 16 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
14 | 17 | ||
15 | public interface OrderService { | 18 | public interface OrderService { |
@@ -71,6 +74,14 @@ public interface OrderService { | @@ -71,6 +74,14 @@ public interface OrderService { | ||
71 | ApiResponse cancel(BuyerCancelRequestDto request); | 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 | * @param request | 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,4 +14,12 @@ | ||
14 | <artifactId>commons-lang</artifactId> | 14 | <artifactId>commons-lang</artifactId> |
15 | </dependency> | 15 | </dependency> |
16 | </dependencies> | 16 | </dependencies> |
17 | + | ||
18 | + <build> | ||
19 | + <plugins> | ||
20 | + <plugin> | ||
21 | + <artifactId>maven-source-plugin</artifactId> | ||
22 | + </plugin> | ||
23 | + </plugins> | ||
24 | + </build> | ||
17 | </project> | 25 | </project> |
18 | \ No newline at end of file | 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,10 +14,10 @@ | ||
14 | <artifactId>b2c-orders-domain</artifactId> | 14 | <artifactId>b2c-orders-domain</artifactId> |
15 | <version>${project.version}</version> | 15 | <version>${project.version}</version> |
16 | </dependency> | 16 | </dependency> |
17 | - <dependency> | 17 | + <!-- <dependency> |
18 | <groupId>cglib</groupId> | 18 | <groupId>cglib</groupId> |
19 | <artifactId>cglib</artifactId> | 19 | <artifactId>cglib</artifactId> |
20 | - </dependency> | 20 | + </dependency> --> |
21 | <dependency> | 21 | <dependency> |
22 | <groupId>com.b2c.website</groupId> | 22 | <groupId>com.b2c.website</groupId> |
23 | <artifactId>diligrp-website-util</artifactId> | 23 | <artifactId>diligrp-website-util</artifactId> |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/ShopDao.java
1 | package com.b2c.orders.dao; | 1 | package com.b2c.orders.dao; |
2 | 2 | ||
3 | +import com.b2c.orders.commons.exceptions.SellerException; | ||
3 | import com.b2c.orders.domain.Shop; | 4 | import com.b2c.orders.domain.Shop; |
4 | 5 | ||
5 | public interface ShopDao { | 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 | package com.b2c.orders.dao.impl; | 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 | import java.util.Map; | 5 | import java.util.Map; |
5 | import java.util.Map.Entry; | 6 | import java.util.Map.Entry; |
6 | 7 | ||
@@ -17,7 +18,11 @@ import com.b2c.orders.dao.ProductDao; | @@ -17,7 +18,11 @@ import com.b2c.orders.dao.ProductDao; | ||
17 | import com.b2c.orders.domain.rpc.Product; | 18 | import com.b2c.orders.domain.rpc.Product; |
18 | import com.diligrp.titan.sdk.TitanClient; | 19 | import com.diligrp.titan.sdk.TitanClient; |
19 | import com.diligrp.titan.sdk.output.BaseOutput; | 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 | @Repository | 27 | @Repository |
23 | public class ProductDaoBean implements ProductDao { | 28 | public class ProductDaoBean implements ProductDao { |
@@ -34,9 +39,28 @@ public class ProductDaoBean implements ProductDao { | @@ -34,9 +39,28 @@ public class ProductDaoBean implements ProductDao { | ||
34 | 39 | ||
35 | @Override | 40 | @Override |
36 | public Product findBySku(String sku) throws ProductException { | 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 | if (rpcResponse.getCode() != 200) { | 64 | if (rpcResponse.getCode() != 200) { |
41 | LOG.error(rpcResponse.getResult()); | 65 | LOG.error(rpcResponse.getResult()); |
42 | throw new ProductException(ApplicationException.DATA_EXCEPTION, "根据sku查询商品信息失败"); | 66 | throw new ProductException(ApplicationException.DATA_EXCEPTION, "根据sku查询商品信息失败"); |
@@ -56,7 +80,7 @@ public class ProductDaoBean implements ProductDao { | @@ -56,7 +80,7 @@ public class ProductDaoBean implements ProductDao { | ||
56 | } | 80 | } |
57 | com.diligrp.titan.sdk.domain.Sku targetSku = null; | 81 | com.diligrp.titan.sdk.domain.Sku targetSku = null; |
58 | for (com.diligrp.titan.sdk.domain.Sku skuInfo : rpcProduct.getSkus()) { | 82 | for (com.diligrp.titan.sdk.domain.Sku skuInfo : rpcProduct.getSkus()) { |
59 | - if (skuInfo.getSku().equals(sku)) { | 83 | + if (skuInfo.getDecodeSku().equals(sku)) { |
60 | targetSku = skuInfo; | 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 | \ No newline at end of file | 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 | \ No newline at end of file | 18 | \ No newline at end of file |
b2c-orders-dao/src/main/resources/sqlmap-config.xml
@@ -3,18 +3,15 @@ | @@ -3,18 +3,15 @@ | ||
3 | 3 | ||
4 | <configuration> | 4 | <configuration> |
5 | <settings> | 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 | <setting name="multipleResultSetsEnabled" value="true" /> | 7 | <setting name="multipleResultSetsEnabled" value="true" /> |
14 | - <!-- 允许使用列标签代替列名 --> | ||
15 | <setting name="useColumnLabel" value="true" /> | 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 | <setting name="logImpl" value="STDOUT_LOGGING" /> | 15 | <setting name="logImpl" value="STDOUT_LOGGING" /> |
19 | </settings> | 16 | </settings> |
20 | 17 |
b2c-orders-dao/src/main/resources/sqlmap/OrderItemMapper.xml
@@ -4,19 +4,19 @@ | @@ -4,19 +4,19 @@ | ||
4 | <resultMap id="OrderItemRM" type="com.b2c.orders.domain.OrderItem"> | 4 | <resultMap id="OrderItemRM" type="com.b2c.orders.domain.OrderItem"> |
5 | <id property="id" column="id" /> | 5 | <id property="id" column="id" /> |
6 | <result property="orderId" column="order_id" /> | 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 | <result property="productId" column="product_id" /> | 12 | <result property="productId" column="product_id" /> |
8 | <result property="productName" column="product_name" /> | 13 | <result property="productName" column="product_name" /> |
9 | - <result property="shopId" column="shop_id" /> | ||
10 | <result property="sku" column="sku" /> | 14 | <result property="sku" column="sku" /> |
11 | <result property="skuTitle" column="sku_title" /> | 15 | <result property="skuTitle" column="sku_title" /> |
12 | <result property="skuAttributes" column="sku_attributes" /> | 16 | <result property="skuAttributes" column="sku_attributes" /> |
13 | - <result property="amount" column="amount" /> | ||
14 | <result property="skuPrice" column="sku_price" /> | 17 | <result property="skuPrice" column="sku_price" /> |
15 | <result property="priceUnit" column="price_unit" /> | 18 | <result property="priceUnit" column="price_unit" /> |
16 | <result property="skuPicture" column="sku_picture" /> | 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 | </resultMap> | 20 | </resultMap> |
21 | 21 | ||
22 | <sql id="selectCondition"> | 22 | <sql id="selectCondition"> |
@@ -33,12 +33,6 @@ | @@ -33,12 +33,6 @@ | ||
33 | <if test="param.productName != null and param.productName != ''"> | 33 | <if test="param.productName != null and param.productName != ''"> |
34 | and product_name = #{param.productName} | 34 | and product_name = #{param.productName} |
35 | </if> | 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 | <if test="param.shopId != null and param.shopId != ''"> | 36 | <if test="param.shopId != null and param.shopId != ''"> |
43 | and shop_id = #{param.shopId} | 37 | and shop_id = #{param.shopId} |
44 | </if> | 38 | </if> |
@@ -63,10 +57,10 @@ | @@ -63,10 +57,10 @@ | ||
63 | </if> | 57 | </if> |
64 | </sql> | 58 | </sql> |
65 | 59 | ||
66 | - <select id="findByOrderId" resultMap="OrderItemRM"> | 60 | + <select id="findByOrderId" parameterType="Long" resultMap="OrderItemRM"> |
67 | <![CDATA[ | 61 | <![CDATA[ |
68 | SELECT | 62 | SELECT |
69 | - id | 63 | + id, |
70 | order_id, | 64 | order_id, |
71 | product_id, | 65 | product_id, |
72 | product_name, | 66 | product_name, |
b2c-orders-dao/src/main/resources/sqlmap/OrderMapper.xml
@@ -3,17 +3,16 @@ | @@ -3,17 +3,16 @@ | ||
3 | <mapper namespace="com.b2c.orders.dao.impl.OrderDaoBean"> | 3 | <mapper namespace="com.b2c.orders.dao.impl.OrderDaoBean"> |
4 | <resultMap id="OrderRM" type="com.b2c.orders.domain.Order"> | 4 | <resultMap id="OrderRM" type="com.b2c.orders.domain.Order"> |
5 | <id property="id" column="id" /> | 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 | <result property="deliveryType" column="delivery_type" /> | 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 | <result property="payStatus" column="pay_status" /> | 10 | <result property="payStatus" column="pay_status" /> |
14 | <result property="buyerMemo" column="buyer_memo" /> | 11 | <result property="buyerMemo" column="buyer_memo" /> |
15 | <result property="payTime" column="pay_time" /> | 12 | <result property="payTime" column="pay_time" /> |
16 | <result property="deliveryTime" column="delivery_time" /> | 13 | <result property="deliveryTime" column="delivery_time" /> |
14 | + <result property="deliveryAddress" column="delivery_address" /> | ||
15 | + <result property="receiverPhoneNumber" column="receiver_phone_number" /> | ||
17 | <result property="buyerConfirmTime" column="buyer_confirm_time" /> | 16 | <result property="buyerConfirmTime" column="buyer_confirm_time" /> |
18 | <result property="sellerConfirmTime" column="seller_confirm_time" /> | 17 | <result property="sellerConfirmTime" column="seller_confirm_time" /> |
19 | <result property="reservationTime" column="reservation_time" /> | 18 | <result property="reservationTime" column="reservation_time" /> |
@@ -24,6 +23,13 @@ | @@ -24,6 +23,13 @@ | ||
24 | <result property="versionNum" column="version_num" /> | 23 | <result property="versionNum" column="version_num" /> |
25 | <result property="delete" column="delete_flag" /> | 24 | <result property="delete" column="delete_flag" /> |
26 | <result property="statusInReason" column="status_in_reason" /> | 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 | <collection property="orderItems" column="id" | 33 | <collection property="orderItems" column="id" |
28 | select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" /> | 34 | select="com.b2c.orders.dao.impl.OrderItemDaoBean.findByOrderId" /> |
29 | </resultMap> | 35 | </resultMap> |
@@ -34,12 +40,16 @@ | @@ -34,12 +40,16 @@ | ||
34 | ,t1.buyer_name | 40 | ,t1.buyer_name |
35 | ,t1.seller_id | 41 | ,t1.seller_id |
36 | ,t1.seller_name | 42 | ,t1.seller_name |
43 | + ,t1.shop_buyer_id | ||
44 | + ,t1.market_id | ||
37 | ,t1.delivery_type | 45 | ,t1.delivery_type |
38 | ,t1.order_status | 46 | ,t1.order_status |
39 | ,t1.pay_status | 47 | ,t1.pay_status |
40 | ,t1.buyer_memo | 48 | ,t1.buyer_memo |
41 | ,t1.pay_time | 49 | ,t1.pay_time |
42 | ,t1.delivery_time | 50 | ,t1.delivery_time |
51 | + ,t1.delivery_address | ||
52 | + ,t1.receiver_phone_number | ||
43 | ,t1.reservation_time | 53 | ,t1.reservation_time |
44 | ,t1.buyer_confirm_time | 54 | ,t1.buyer_confirm_time |
45 | ,t1.seller_confirm_time | 55 | ,t1.seller_confirm_time |
@@ -68,6 +78,9 @@ | @@ -68,6 +78,9 @@ | ||
68 | <if test="param.sellerName != null and param.sellerName != ''"> | 78 | <if test="param.sellerName != null and param.sellerName != ''"> |
69 | and t1.seller_name = #{param.sellerName} | 79 | and t1.seller_name = #{param.sellerName} |
70 | </if> | 80 | </if> |
81 | + <if test="param.marketId != null and param.marketId != ''"> | ||
82 | + and t1.market_id = #{param.marketId} | ||
83 | + </if> | ||
71 | <if test="param.deliveryType != null and param.deliveryType != ''"> | 84 | <if test="param.deliveryType != null and param.deliveryType != ''"> |
72 | and t1.delivery_type = #{param.deliveryType} | 85 | and t1.delivery_type = #{param.deliveryType} |
73 | </if> | 86 | </if> |
@@ -80,6 +93,10 @@ | @@ -80,6 +93,10 @@ | ||
80 | <if test="param.buyerMemo != null and param.buyerMemo != ''"> | 93 | <if test="param.buyerMemo != null and param.buyerMemo != ''"> |
81 | and t1.buyer_memo = #{param.buyerMemo} | 94 | and t1.buyer_memo = #{param.buyerMemo} |
82 | </if> | 95 | </if> |
96 | + <if | ||
97 | + test="param.receiverPhoneNumber != null and param.receiverPhoneNumber != ''"> | ||
98 | + and t1.receiver_phone_number = #{param.receiverPhoneNumber} | ||
99 | + </if> | ||
83 | <if test="param.payBeginTime != null and param.payBeginTime != ''"> | 100 | <if test="param.payBeginTime != null and param.payBeginTime != ''"> |
84 | <![CDATA[and t1.pay_time >= #{param.payBeginTime}]]> | 101 | <![CDATA[and t1.pay_time >= #{param.payBeginTime}]]> |
85 | </if> | 102 | </if> |
@@ -154,23 +171,41 @@ | @@ -154,23 +171,41 @@ | ||
154 | INSERT INTO t_order( | 171 | INSERT INTO t_order( |
155 | id, | 172 | id, |
156 | buyer_id, | 173 | buyer_id, |
174 | + buyer_name, | ||
175 | + buyer_phone_number, | ||
157 | seller_id, | 176 | seller_id, |
177 | + seller_name, | ||
178 | + shop_id, | ||
179 | + shop_name, | ||
180 | + shop_buyer_id, | ||
181 | + market_id, | ||
158 | delivery_type, | 182 | delivery_type, |
159 | order_status, | 183 | order_status, |
160 | pay_status, | 184 | pay_status, |
161 | buyer_memo, | 185 | buyer_memo, |
162 | delivery_time, | 186 | delivery_time, |
187 | + delivery_address, | ||
188 | + receiver_phone_number, | ||
163 | pay_type, | 189 | pay_type, |
164 | total_price | 190 | total_price |
165 | ) VALUES( | 191 | ) VALUES( |
166 | #{id}, | 192 | #{id}, |
167 | - #{buyerId}, | 193 | + #{buyerId}, |
194 | + #{buyerName}, | ||
195 | + #{buyerPhoneNumber}, | ||
168 | #{sellerId}, | 196 | #{sellerId}, |
197 | + #{sellerName}, | ||
198 | + #{shopId}, | ||
199 | + #{shopName}, | ||
200 | + #{shopBuyerId}, | ||
201 | + #{marketId}, | ||
169 | #{deliveryType}, | 202 | #{deliveryType}, |
170 | #{orderStatus}, | 203 | #{orderStatus}, |
171 | #{payStatus}, | 204 | #{payStatus}, |
172 | #{buyerMemo}, | 205 | #{buyerMemo}, |
173 | #{deliveryTime}, | 206 | #{deliveryTime}, |
207 | + #{deliveryAddress}, | ||
208 | + #{receiverPhoneNumber}, | ||
174 | #{payType}, | 209 | #{payType}, |
175 | #{totalPrice} | 210 | #{totalPrice} |
176 | ) | 211 | ) |
@@ -182,13 +217,14 @@ | @@ -182,13 +217,14 @@ | ||
182 | UPDATE t_order set | 217 | UPDATE t_order set |
183 | order_status=#{orderStatus}, | 218 | order_status=#{orderStatus}, |
184 | pay_status=#{payStatus}, | 219 | pay_status=#{payStatus}, |
220 | + pay_type=#{payType}, | ||
185 | buyer_memo=#{buyerMemo}, | 221 | buyer_memo=#{buyerMemo}, |
186 | pay_time=#{payTime}, | 222 | pay_time=#{payTime}, |
187 | delivery_time=#{deliveryTime}, | 223 | delivery_time=#{deliveryTime}, |
188 | buyer_confirm_time=#{buyerConfirmTime}, | 224 | buyer_confirm_time=#{buyerConfirmTime}, |
189 | seller_confirm_time=#{sellerConfirmTime}, | 225 | seller_confirm_time=#{sellerConfirmTime}, |
190 | real_total_price=#{realTotalPrice}, | 226 | real_total_price=#{realTotalPrice}, |
191 | - status_in_reason=#{statusInReason} | 227 | + status_in_reason=#{statusInReason}, |
192 | version_num=version_num + 1 | 228 | version_num=version_num + 1 |
193 | where 1=1 | 229 | where 1=1 |
194 | and version_num=#{versionNum} and id = #{id} | 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,15 +18,9 @@ import lombok.Data; | ||
18 | import lombok.EqualsAndHashCode; | 18 | import lombok.EqualsAndHashCode; |
19 | import lombok.NoArgsConstructor; | 19 | import lombok.NoArgsConstructor; |
20 | 20 | ||
21 | -/** | ||
22 | - * orders | ||
23 | - * | ||
24 | - * @author dev-center | ||
25 | - * @since 2014-05-19 | ||
26 | - */ | ||
27 | @Data | 21 | @Data |
28 | -@EqualsAndHashCode(callSuper = true) | ||
29 | @NoArgsConstructor | 22 | @NoArgsConstructor |
23 | +@EqualsAndHashCode(callSuper = true) | ||
30 | public class Order extends BaseDomain { | 24 | public class Order extends BaseDomain { |
31 | 25 | ||
32 | /** | 26 | /** |
@@ -37,7 +31,9 @@ public class Order extends BaseDomain { | @@ -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 | * 资金账户id | 38 | * 资金账户id |
43 | */ | 39 | */ |
@@ -45,7 +41,8 @@ public class Order extends BaseDomain { | @@ -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 | * 市场id | 47 | * 市场id |
51 | */ | 48 | */ |
@@ -72,6 +69,14 @@ public class Order extends BaseDomain { | @@ -72,6 +69,14 @@ public class Order extends BaseDomain { | ||
72 | * 送货时间 | 69 | * 送货时间 |
73 | */ | 70 | */ |
74 | private Date deliveryTime; | 71 | private Date deliveryTime; |
72 | + /** | ||
73 | + * 送货地址 | ||
74 | + */ | ||
75 | + private String deliveryAddress; | ||
76 | + /** | ||
77 | + * 收货人电话 | ||
78 | + */ | ||
79 | + private String receiverPhoneNumber; | ||
75 | /** 提货时间 */ | 80 | /** 提货时间 */ |
76 | private Date reservationTime; | 81 | private Date reservationTime; |
77 | /** 买家确认收货时间 */ | 82 | /** 买家确认收货时间 */ |
@@ -97,7 +102,8 @@ public class Order extends BaseDomain { | @@ -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 | private String statusInReason; | 108 | private String statusInReason; |
103 | /** | 109 | /** |
@@ -106,58 +112,6 @@ public class Order extends BaseDomain { | @@ -106,58 +112,6 @@ public class Order extends BaseDomain { | ||
106 | private List<OrderItem> orderItems; | 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 | * @param totalPrice | 117 | * @param totalPrice |
@@ -211,6 +165,12 @@ public class Order extends BaseDomain { | @@ -211,6 +165,12 @@ public class Order extends BaseDomain { | ||
211 | this.orderStatus = OrderStatus.Completed; | 165 | this.orderStatus = OrderStatus.Completed; |
212 | } | 166 | } |
213 | 167 | ||
168 | + /** | ||
169 | + * 拒绝接单 | ||
170 | + * | ||
171 | + * @param refuseReason | ||
172 | + * @throws OrderException | ||
173 | + */ | ||
214 | public void refuse(String refuseReason) throws OrderException { | 174 | public void refuse(String refuseReason) throws OrderException { |
215 | if (!this.orderStatus.equals(OrderStatus.PendingTake)) { | 175 | if (!this.orderStatus.equals(OrderStatus.PendingTake)) { |
216 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); | 176 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); |
@@ -219,6 +179,11 @@ public class Order extends BaseDomain { | @@ -219,6 +179,11 @@ public class Order extends BaseDomain { | ||
219 | this.statusInReason = refuseReason; | 179 | this.statusInReason = refuseReason; |
220 | } | 180 | } |
221 | 181 | ||
182 | + /** | ||
183 | + * 取消订单 | ||
184 | + * | ||
185 | + * @throws OrderException | ||
186 | + */ | ||
222 | public void cancel() throws OrderException { | 187 | public void cancel() throws OrderException { |
223 | if (!this.isCanCancel()) { | 188 | if (!this.isCanCancel()) { |
224 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能被取消"); | 189 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前状态不能被取消"); |
@@ -226,6 +191,11 @@ public class Order extends BaseDomain { | @@ -226,6 +191,11 @@ public class Order extends BaseDomain { | ||
226 | this.orderStatus = OrderStatus.Canceled; | 191 | this.orderStatus = OrderStatus.Canceled; |
227 | } | 192 | } |
228 | 193 | ||
194 | + /** | ||
195 | + * 接单超时 | ||
196 | + * | ||
197 | + * @throws OrderException | ||
198 | + */ | ||
229 | public void takenTimeout() throws OrderException { | 199 | public void takenTimeout() throws OrderException { |
230 | if (this.orderStatus.equals(OrderStatus.PendingTake)) { | 200 | if (this.orderStatus.equals(OrderStatus.PendingTake)) { |
231 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置支付超时"); | 201 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置支付超时"); |
@@ -233,6 +203,11 @@ public class Order extends BaseDomain { | @@ -233,6 +203,11 @@ public class Order extends BaseDomain { | ||
233 | this.orderStatus = OrderStatus.TakenTimeout; | 203 | this.orderStatus = OrderStatus.TakenTimeout; |
234 | } | 204 | } |
235 | 205 | ||
206 | + /** | ||
207 | + * 支付超时 | ||
208 | + * | ||
209 | + * @throws OrderException | ||
210 | + */ | ||
236 | public void paymentTimeout() throws OrderException { | 211 | public void paymentTimeout() throws OrderException { |
237 | if (this.orderStatus.equals(OrderStatus.PendingPayment)) { | 212 | if (this.orderStatus.equals(OrderStatus.PendingPayment)) { |
238 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "当前状态不能设置接单超时"); | 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,8 +6,6 @@ package com.b2c.orders.domain; | ||
6 | 6 | ||
7 | import java.sql.Timestamp; | 7 | import java.sql.Timestamp; |
8 | 8 | ||
9 | -import com.b2c.orders.domain.rpc.Product; | ||
10 | - | ||
11 | import lombok.Data; | 9 | import lombok.Data; |
12 | import lombok.EqualsAndHashCode; | 10 | import lombok.EqualsAndHashCode; |
13 | import lombok.NoArgsConstructor; | 11 | import lombok.NoArgsConstructor; |
@@ -30,9 +28,14 @@ public class OrderItem extends BaseDomain { | @@ -30,9 +28,14 @@ public class OrderItem extends BaseDomain { | ||
30 | 28 | ||
31 | private Long orderId; | 29 | private Long orderId; |
32 | private Order order; | 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 | private Integer amount; | 39 | private Integer amount; |
37 | private Timestamp createTime; | 40 | private Timestamp createTime; |
38 | private Timestamp editTime; | 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 +6,7 @@ import com.b2c.orders.commons.exceptions.OrderException; | ||
6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
7 | import com.b2c.orders.commons.exceptions.ProductException; | 7 | import com.b2c.orders.commons.exceptions.ProductException; |
8 | import com.b2c.orders.commons.exceptions.SellerException; | 8 | import com.b2c.orders.commons.exceptions.SellerException; |
9 | +import com.b2c.orders.domain.Order; | ||
9 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | import com.b2c.orders.enums.PayType; | 11 | import com.b2c.orders.enums.PayType; |
11 | import com.b2c.orders.rpc.exception.DtmsRPCException; | 12 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
@@ -21,10 +22,11 @@ public interface OrderManager { | @@ -21,10 +22,11 @@ public interface OrderManager { | ||
21 | * @throws DtmsRPCException | 22 | * @throws DtmsRPCException |
22 | * @throws OrderException | 23 | * @throws OrderException |
23 | * @throws ProductException | 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,13 +89,14 @@ public interface OrderManager { | ||
87 | * | 89 | * |
88 | * @param orderId | 90 | * @param orderId |
89 | * 订单id | 91 | * 订单id |
90 | - * @param shopBuyerId | 92 | + * @param sellerId |
91 | * 商家id | 93 | * 商家id |
92 | - * @param refuseReason TODO | 94 | + * @param refuseReason |
95 | + * TODO | ||
93 | * @throws OrderRepositoryException | 96 | * @throws OrderRepositoryException |
94 | * @throws OrderException | 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,5 +140,14 @@ public interface OrderManager { | ||
137 | */ | 140 | */ |
138 | void paymentTimeout(Long orderId) throws OrderRepositoryException, OrderException; | 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 | PageTemplate list(BaseQuery query); | 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,7 +22,7 @@ public class BuyerManagerBean implements BuyerManager { | ||
22 | @Override | 22 | @Override |
23 | public void lockBalance(LockBalanceParam param) { | 23 | public void lockBalance(LockBalanceParam param) { |
24 | FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | 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 | copier.copy(param, rpcParam, null); | 26 | copier.copy(param, rpcParam, null); |
27 | rpcParam.setTradeType(TradeType.Freeze); | 27 | rpcParam.setTradeType(TradeType.Freeze); |
28 | this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | 28 | this.myAppClient.getFoundTradeService().foundTrade(rpcParam); |
@@ -31,7 +31,7 @@ public class BuyerManagerBean implements BuyerManager { | @@ -31,7 +31,7 @@ public class BuyerManagerBean implements BuyerManager { | ||
31 | @Override | 31 | @Override |
32 | public void debit(DebitParam param) { | 32 | public void debit(DebitParam param) { |
33 | FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | 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 | copier.copy(param, rpcParam, null); | 35 | copier.copy(param, rpcParam, null); |
36 | rpcParam.setTradeType(TradeType.Consume); | 36 | rpcParam.setTradeType(TradeType.Consume); |
37 | this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | 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,7 +44,6 @@ import com.b2c.orders.enums.PayType; | ||
44 | import com.b2c.orders.enums.UserType; | 44 | import com.b2c.orders.enums.UserType; |
45 | import com.b2c.orders.manager.BuyerManager; | 45 | import com.b2c.orders.manager.BuyerManager; |
46 | import com.b2c.orders.manager.OrderManager; | 46 | import com.b2c.orders.manager.OrderManager; |
47 | -import com.b2c.orders.rpc.BuyerAccountService; | ||
48 | import com.b2c.orders.rpc.DtmsRPCService; | 47 | import com.b2c.orders.rpc.DtmsRPCService; |
49 | import com.b2c.orders.rpc.exception.DtmsRPCException; | 48 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
50 | import com.b2c.orders.rpc.param.DebitParam; | 49 | import com.b2c.orders.rpc.param.DebitParam; |
@@ -66,8 +65,6 @@ public class OrderManagerBean implements OrderManager { | @@ -66,8 +65,6 @@ public class OrderManagerBean implements OrderManager { | ||
66 | @Autowired | 65 | @Autowired |
67 | private DtmsRPCService dtmsService; | 66 | private DtmsRPCService dtmsService; |
68 | @Autowired | 67 | @Autowired |
69 | - private BuyerAccountService userAccountService; | ||
70 | - @Autowired | ||
71 | private OrderLogDao orderLogDao; | 68 | private OrderLogDao orderLogDao; |
72 | @Autowired | 69 | @Autowired |
73 | private ProductDao productDao; | 70 | private ProductDao productDao; |
@@ -89,21 +86,27 @@ public class OrderManagerBean implements OrderManager { | @@ -89,21 +86,27 @@ public class OrderManagerBean implements OrderManager { | ||
89 | po.setId(orderId); | 86 | po.setId(orderId); |
90 | po.setShopBuyerId(orderVo.getShopBuyerId()); | 87 | po.setShopBuyerId(orderVo.getShopBuyerId()); |
91 | Buyer buyer = this.buyerDao.findByBuyerShopId(orderVo.getShopBuyerId()); | 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 | Seller seller = this.sellerDao.findByBuyerShopId(orderVo.getShopBuyerId()); | 92 | Seller seller = this.sellerDao.findByBuyerShopId(orderVo.getShopBuyerId()); |
94 | - po.setSeller(seller); | 93 | + po.setSellerId(seller.getId()); |
94 | + po.setSellerName(seller.getName()); | ||
95 | Shop shop = this.shopDao.findByBuyerShopId(orderVo.getShopBuyerId()); | 95 | Shop shop = this.shopDao.findByBuyerShopId(orderVo.getShopBuyerId()); |
96 | - po.setShop(shop); | 96 | + po.setShopId(shop.getId()); |
97 | + po.setShopName(shop.getName()); | ||
97 | po.setMarketId(orderVo.getMarketId()); | 98 | po.setMarketId(orderVo.getMarketId()); |
98 | po.setBuyerMemo(orderVo.getBuyerMemo()); | 99 | po.setBuyerMemo(orderVo.getBuyerMemo()); |
99 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 100 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
100 | po.setDeliveryType(DeliveryType.getDeliveryType(orderVo.getDeliveryType())); | 101 | po.setDeliveryType(DeliveryType.getDeliveryType(orderVo.getDeliveryType())); |
102 | + po.setDeliveryAddress(orderVo.getDeliveryAddress()); | ||
103 | + po.setReceiverPhoneNumber(orderVo.getReceiverPhoneNumber()); | ||
101 | if (orderVo.getDeliveryType().equals(DeliveryType.Delivery.getIndex())) { | 104 | if (orderVo.getDeliveryType().equals(DeliveryType.Delivery.getIndex())) { |
102 | if (TextUtils.isEmpty(orderVo.getDeliveryTime())) { | 105 | if (TextUtils.isEmpty(orderVo.getDeliveryTime())) { |
103 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "送货时间不能为空"); | 106 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "送货时间不能为空"); |
104 | } | 107 | } |
105 | po.setDeliveryTime(df.parse(orderVo.getDeliveryTime())); | 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 | if (TextUtils.isEmpty(orderVo.getReservationTime())) { | 110 | if (TextUtils.isEmpty(orderVo.getReservationTime())) { |
108 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "提货时间不能为空"); | 111 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "提货时间不能为空"); |
109 | } | 112 | } |
@@ -118,14 +121,19 @@ public class OrderManagerBean implements OrderManager { | @@ -118,14 +121,19 @@ public class OrderManagerBean implements OrderManager { | ||
118 | for (OrderItemDto orderItemDto : orderVo.getOrderItems()) { | 121 | for (OrderItemDto orderItemDto : orderVo.getOrderItems()) { |
119 | Long orderItemId = idGenerator.getOrdersItemNewSeqNo(orderId, itemIdx++); | 122 | Long orderItemId = idGenerator.getOrdersItemNewSeqNo(orderId, itemIdx++); |
120 | OrderItem orderItem = new OrderItem(); | 123 | OrderItem orderItem = new OrderItem(); |
121 | - orderItem.setBuyerId(buyer.getId()); | ||
122 | orderItem.setId(orderItemId); | 124 | orderItem.setId(orderItemId); |
123 | orderItem.setOrderId(orderId); | 125 | orderItem.setOrderId(orderId); |
124 | - orderItem.setSellerId(seller.getId()); | ||
125 | orderItem.setShopId(shop.getId()); | 126 | orderItem.setShopId(shop.getId()); |
126 | orderItem.setAmount(orderItemDto.getAmount()); | 127 | orderItem.setAmount(orderItemDto.getAmount()); |
127 | Product product = this.productDao.findBySku(orderItemDto.getSku()); | 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 | orderItems.add(orderItem); | 137 | orderItems.add(orderItem); |
130 | totalPrice += product.getSkuPrice() * orderItemDto.getAmount(); | 138 | totalPrice += product.getSkuPrice() * orderItemDto.getAmount(); |
131 | } | 139 | } |
@@ -140,7 +148,7 @@ public class OrderManagerBean implements OrderManager { | @@ -140,7 +148,7 @@ public class OrderManagerBean implements OrderManager { | ||
140 | OrderLog log = new OrderLog(); | 148 | OrderLog log = new OrderLog(); |
141 | log.setAction(Action.BUYER_PLACE_ORDER); | 149 | log.setAction(Action.BUYER_PLACE_ORDER); |
142 | log.setOrderId(po.getId()); | 150 | log.setOrderId(po.getId()); |
143 | - log.setUserId(po.getBuyer().getId()); | 151 | + log.setUserId(po.getBuyerId()); |
144 | log.setUserType(UserType.BUYER); | 152 | log.setUserType(UserType.BUYER); |
145 | this.orderLogDao.save(log); | 153 | this.orderLogDao.save(log); |
146 | // 发送dtms消息 | 154 | // 发送dtms消息 |
@@ -155,10 +163,10 @@ public class OrderManagerBean implements OrderManager { | @@ -155,10 +163,10 @@ public class OrderManagerBean implements OrderManager { | ||
155 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | 163 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
156 | String.format("未找到id为%s的订单", orderId)); | 164 | String.format("未找到id为%s的订单", orderId)); |
157 | } | 165 | } |
158 | - if (po.getSeller().getId() == null) { | 166 | + if (po.getSellerId() == null) { |
159 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); | 167 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
160 | } | 168 | } |
161 | - if (!po.getSeller().getId().equals(sellerId)) { | 169 | + if (!po.getSellerId().equals(sellerId)) { |
162 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); | 170 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); |
163 | } | 171 | } |
164 | po.take(totalPrice); | 172 | po.take(totalPrice); |
@@ -238,16 +246,16 @@ public class OrderManagerBean implements OrderManager { | @@ -238,16 +246,16 @@ public class OrderManagerBean implements OrderManager { | ||
238 | } | 246 | } |
239 | 247 | ||
240 | @Override | 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 | Order po = this.orderDao.getById(orderId); | 250 | Order po = this.orderDao.getById(orderId); |
243 | if (po == null) { | 251 | if (po == null) { |
244 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | 252 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
245 | String.format("未找到id为%s的订单", orderId)); | 253 | String.format("未找到id为%s的订单", orderId)); |
246 | } | 254 | } |
247 | - if (po.getShopBuyerId() == null) { | 255 | + if (po.getSellerId() == null) { |
248 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); | 256 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
249 | } | 257 | } |
250 | - if (!po.getShopBuyerId().equals(shopBuyerId)) { | 258 | + if (!po.getSellerId().equals(sellerId)) { |
251 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能收款"); | 259 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能收款"); |
252 | } | 260 | } |
253 | po.confirm(); | 261 | po.confirm(); |
@@ -255,28 +263,29 @@ public class OrderManagerBean implements OrderManager { | @@ -255,28 +263,29 @@ public class OrderManagerBean implements OrderManager { | ||
255 | OrderLog log = new OrderLog(); | 263 | OrderLog log = new OrderLog(); |
256 | log.setAction(Action.SELLER_CONFIRM); | 264 | log.setAction(Action.SELLER_CONFIRM); |
257 | log.setOrderId(orderId); | 265 | log.setOrderId(orderId); |
258 | - log.setUserId(po.getSeller().getId()); | 266 | + log.setUserId(po.getSellerId()); |
259 | log.setUserType(UserType.SELLER); | 267 | log.setUserType(UserType.SELLER); |
260 | this.orderLogDao.save(log); | 268 | this.orderLogDao.save(log); |
261 | DebitParam param = new DebitParam(); | 269 | DebitParam param = new DebitParam(); |
262 | param.setOrderId(po.getId()); | 270 | param.setOrderId(po.getId()); |
263 | - param.setShopBuyerId(shopBuyerId); | 271 | + param.setShopBuyerId(po.getShopBuyerId()); |
264 | param.setTradeName(po.getTradeName()); | 272 | param.setTradeName(po.getTradeName()); |
265 | param.setTradePrice(po.getRealTotalPrice()); | 273 | param.setTradePrice(po.getRealTotalPrice()); |
266 | this.buyerManager.debit(param); | 274 | this.buyerManager.debit(param); |
267 | } | 275 | } |
268 | 276 | ||
269 | @Override | 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 | Order po = this.orderDao.getById(orderId); | 280 | Order po = this.orderDao.getById(orderId); |
272 | if (po == null) { | 281 | if (po == null) { |
273 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | 282 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
274 | String.format("未找到id为%s的订单", orderId)); | 283 | String.format("未找到id为%s的订单", orderId)); |
275 | } | 284 | } |
276 | - if (po.getSeller().getId() == null) { | 285 | + if (po.getSellerId() == null) { |
277 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); | 286 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
278 | } | 287 | } |
279 | - if (!po.getSeller().getId().equals(shopBuyerId)) { | 288 | + if (!po.getSellerId().equals(sellerId)) { |
280 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); | 289 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); |
281 | } | 290 | } |
282 | po.refuse(refuseReason); | 291 | po.refuse(refuseReason); |
@@ -284,7 +293,7 @@ public class OrderManagerBean implements OrderManager { | @@ -284,7 +293,7 @@ public class OrderManagerBean implements OrderManager { | ||
284 | OrderLog log = new OrderLog(); | 293 | OrderLog log = new OrderLog(); |
285 | log.setAction(Action.SELLER_REFUSE); | 294 | log.setAction(Action.SELLER_REFUSE); |
286 | log.setOrderId(orderId); | 295 | log.setOrderId(orderId); |
287 | - log.setUserId(shopBuyerId); | 296 | + log.setUserId(sellerId); |
288 | log.setUserType(UserType.SELLER); | 297 | log.setUserType(UserType.SELLER); |
289 | this.orderLogDao.save(log); | 298 | this.orderLogDao.save(log); |
290 | } | 299 | } |
@@ -311,8 +320,8 @@ public class OrderManagerBean implements OrderManager { | @@ -311,8 +320,8 @@ public class OrderManagerBean implements OrderManager { | ||
311 | log.setUserType(UserType.BUYER); | 320 | log.setUserType(UserType.BUYER); |
312 | log.setDescription("买家取消订单"); | 321 | log.setDescription("买家取消订单"); |
313 | this.orderLogDao.save(log); | 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 | this.buyerManager.unlockBalance(param); | 325 | this.buyerManager.unlockBalance(param); |
317 | } | 326 | } |
318 | } | 327 | } |
@@ -379,12 +388,18 @@ public class OrderManagerBean implements OrderManager { | @@ -379,12 +388,18 @@ public class OrderManagerBean implements OrderManager { | ||
379 | log.setUserType(UserType.SYSTEM); | 388 | log.setUserType(UserType.SYSTEM); |
380 | this.orderLogDao.save(log); | 389 | this.orderLogDao.save(log); |
381 | if (po.getPayType().equals(PayType.Online)) { | 390 | if (po.getPayType().equals(PayType.Online)) { |
382 | - this.userAccountService.debit(null); | 391 | + this.buyerManager.debit(null); |
383 | } | 392 | } |
384 | } | 393 | } |
385 | 394 | ||
386 | @Transactional(propagation = Propagation.SUPPORTS) | 395 | @Transactional(propagation = Propagation.SUPPORTS) |
387 | @Override | 396 | @Override |
397 | + public Order detail(Long orderId) { | ||
398 | + return this.orderDao.getById(orderId); | ||
399 | + } | ||
400 | + | ||
401 | + @Transactional(propagation = Propagation.SUPPORTS) | ||
402 | + @Override | ||
388 | public PageTemplate list(BaseQuery query) { | 403 | public PageTemplate list(BaseQuery query) { |
389 | List<Order> list = this.orderDao.listByCondition(query); | 404 | List<Order> list = this.orderDao.listByCondition(query); |
390 | Integer count = this.orderDao.countByCondition(query); | 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,15 +19,16 @@ | ||
19 | <constructor-arg name="token" value="${dtms.token}" /> | 19 | <constructor-arg name="token" value="${dtms.token}" /> |
20 | </bean> | 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 | </bean> | 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 | <constructor-arg name="token" value="" /> | 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 | </bean> | 32 | </bean> |
32 | 33 | ||
33 | </beans> | 34 | </beans> |
34 | \ No newline at end of file | 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 +6,7 @@ import com.b2c.orders.commons.exceptions.OrderException; | ||
6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
7 | import com.b2c.orders.commons.exceptions.ProductException; | 7 | import com.b2c.orders.commons.exceptions.ProductException; |
8 | import com.b2c.orders.commons.exceptions.SellerException; | 8 | import com.b2c.orders.commons.exceptions.SellerException; |
9 | +import com.b2c.orders.domain.Order; | ||
9 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | 10 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
10 | import com.b2c.orders.enums.PayType; | 11 | import com.b2c.orders.enums.PayType; |
11 | import com.b2c.orders.rpc.exception.DtmsRPCException; | 12 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
@@ -21,11 +22,12 @@ public interface OrderService { | @@ -21,11 +22,12 @@ public interface OrderService { | ||
21 | * 订单id | 22 | * 订单id |
22 | * @throws DtmsRPCException | 23 | * @throws DtmsRPCException |
23 | * @throws OrderException | 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,7 +50,7 @@ public interface OrderService { | ||
48 | * | 50 | * |
49 | * @param orderId | 51 | * @param orderId |
50 | * 订单id | 52 | * 订单id |
51 | - * @param buyerId | 53 | + * @param shopBuyerId |
52 | * 买家id | 54 | * 买家id |
53 | * @param payType | 55 | * @param payType |
54 | * TODO | 56 | * TODO |
@@ -56,7 +58,7 @@ public interface OrderService { | @@ -56,7 +58,7 @@ public interface OrderService { | ||
56 | * @throws OrderRepositoryException | 58 | * @throws OrderRepositoryException |
57 | * @throws DtmsRPCException | 59 | * @throws DtmsRPCException |
58 | */ | 60 | */ |
59 | - void pay(Long orderId, Long buyerId, PayType payType) | 61 | + void pay(Long orderId, Long shopBuyerId, PayType payType) |
60 | throws OrderRepositoryException, OrderException, DtmsRPCException; | 62 | throws OrderRepositoryException, OrderException, DtmsRPCException; |
61 | 63 | ||
62 | /** | 64 | /** |
@@ -64,12 +66,12 @@ public interface OrderService { | @@ -64,12 +66,12 @@ public interface OrderService { | ||
64 | * | 66 | * |
65 | * @param orderId | 67 | * @param orderId |
66 | * 订单id | 68 | * 订单id |
67 | - * @param buyerId | 69 | + * @param shopBuyerId |
68 | * 买家id | 70 | * 买家id |
69 | * @throws OrderException | 71 | * @throws OrderException |
70 | * @throws OrderRepositoryException | 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,7 +92,8 @@ public interface OrderService { | ||
90 | * 订单id | 92 | * 订单id |
91 | * @param sellerId | 93 | * @param sellerId |
92 | * 商家id | 94 | * 商家id |
93 | - * @param refuseReason TODO | 95 | + * @param refuseReason |
96 | + * TODO | ||
94 | * @throws OrderException | 97 | * @throws OrderException |
95 | * @throws OrderRepositoryException | 98 | * @throws OrderRepositoryException |
96 | */ | 99 | */ |
@@ -101,12 +104,12 @@ public interface OrderService { | @@ -101,12 +104,12 @@ public interface OrderService { | ||
101 | * | 104 | * |
102 | * @param orderId | 105 | * @param orderId |
103 | * 订单id | 106 | * 订单id |
104 | - * @param buyerId | 107 | + * @param shopBuyerId |
105 | * 买家id | 108 | * 买家id |
106 | * @throws OrderException | 109 | * @throws OrderException |
107 | * @throws OrderRepositoryException | 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 | * 商家{@link Constant.ORDER_TAKEN_TIMEOUT_SECONDS}秒未接单,订单超时 | 115 | * 商家{@link Constant.ORDER_TAKEN_TIMEOUT_SECONDS}秒未接单,订单超时 |
@@ -137,6 +140,15 @@ public interface OrderService { | @@ -137,6 +140,15 @@ public interface OrderService { | ||
137 | void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; | 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 | * @param query | 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,6 +13,7 @@ import com.b2c.orders.commons.exceptions.OrderException; | ||
13 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; | 13 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
14 | import com.b2c.orders.commons.exceptions.ProductException; | 14 | import com.b2c.orders.commons.exceptions.ProductException; |
15 | import com.b2c.orders.commons.exceptions.SellerException; | 15 | import com.b2c.orders.commons.exceptions.SellerException; |
16 | +import com.b2c.orders.domain.Order; | ||
16 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | 17 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
17 | import com.b2c.orders.enums.PayType; | 18 | import com.b2c.orders.enums.PayType; |
18 | import com.b2c.orders.manager.OrderManager; | 19 | import com.b2c.orders.manager.OrderManager; |
@@ -31,7 +32,8 @@ public class OrderServiceBean implements OrderService { | @@ -31,7 +32,8 @@ public class OrderServiceBean implements OrderService { | ||
31 | private OrderManager orderManager; | 32 | private OrderManager orderManager; |
32 | 33 | ||
33 | @Override | 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 | this.orderManager.submit(order); | 37 | this.orderManager.submit(order); |
36 | } | 38 | } |
37 | 39 | ||
@@ -42,14 +44,14 @@ public class OrderServiceBean implements OrderService { | @@ -42,14 +44,14 @@ public class OrderServiceBean implements OrderService { | ||
42 | } | 44 | } |
43 | 45 | ||
44 | @Override | 46 | @Override |
45 | - public void pay(Long orderId, Long buyerId, PayType payType) | 47 | + public void pay(Long orderId, Long shopBuyerId, PayType payType) |
46 | throws OrderRepositoryException, OrderException, DtmsRPCException { | 48 | throws OrderRepositoryException, OrderException, DtmsRPCException { |
47 | - this.orderManager.pay(orderId, buyerId, payType); | 49 | + this.orderManager.pay(orderId, shopBuyerId, payType); |
48 | } | 50 | } |
49 | 51 | ||
50 | @Override | 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 | @Override | 57 | @Override |
@@ -58,13 +60,14 @@ public class OrderServiceBean implements OrderService { | @@ -58,13 +60,14 @@ public class OrderServiceBean implements OrderService { | ||
58 | } | 60 | } |
59 | 61 | ||
60 | @Override | 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 | this.orderManager.refuse(orderId, sellerId, refuseReason); | 65 | this.orderManager.refuse(orderId, sellerId, refuseReason); |
63 | } | 66 | } |
64 | 67 | ||
65 | @Override | 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 | @Override | 73 | @Override |
@@ -92,6 +95,12 @@ public class OrderServiceBean implements OrderService { | @@ -92,6 +95,12 @@ public class OrderServiceBean implements OrderService { | ||
92 | 95 | ||
93 | @Transactional(propagation = Propagation.SUPPORTS) | 96 | @Transactional(propagation = Propagation.SUPPORTS) |
94 | @Override | 97 | @Override |
98 | + public Order detail(Long orderId) { | ||
99 | + return this.orderManager.detail(orderId); | ||
100 | + } | ||
101 | + | ||
102 | + @Transactional(propagation = Propagation.SUPPORTS) | ||
103 | + @Override | ||
95 | public PageTemplate list(BaseQuery query) { | 104 | public PageTemplate list(BaseQuery query) { |
96 | return this.orderManager.list(query); | 105 | return this.orderManager.list(query); |
97 | } | 106 | } |
b2c-orders-web/pom.xml
@@ -108,10 +108,6 @@ | @@ -108,10 +108,6 @@ | ||
108 | <groupId>ch.qos.logback</groupId> | 108 | <groupId>ch.qos.logback</groupId> |
109 | <artifactId>logback-core</artifactId> | 109 | <artifactId>logback-core</artifactId> |
110 | </dependency> | 110 | </dependency> |
111 | - <dependency> | ||
112 | - <groupId>org.slf4j</groupId> | ||
113 | - <artifactId>slf4j-api</artifactId> | ||
114 | - </dependency> | ||
115 | <!-- if you enable @AspectJ style AOP in spring. --> | 111 | <!-- if you enable @AspectJ style AOP in spring. --> |
116 | <dependency> | 112 | <dependency> |
117 | <groupId>org.aspectj</groupId> | 113 | <groupId>org.aspectj</groupId> |
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
1 | package com.b2c.orders.web.restful; | 1 | package com.b2c.orders.web.restful; |
2 | 2 | ||
3 | +import java.text.DateFormat; | ||
4 | +import java.text.SimpleDateFormat; | ||
3 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
4 | import java.util.List; | 6 | import java.util.List; |
5 | 7 | ||
6 | import javax.validation.Valid; | 8 | import javax.validation.Valid; |
7 | 9 | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | +import org.springframework.cglib.beans.BeanCopier; | ||
9 | import org.springframework.http.MediaType; | 12 | import org.springframework.http.MediaType; |
10 | import org.springframework.util.CollectionUtils; | 13 | import org.springframework.util.CollectionUtils; |
11 | import org.springframework.validation.BindingResult; | 14 | import org.springframework.validation.BindingResult; |
@@ -24,14 +27,17 @@ import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; | @@ -24,14 +27,17 @@ import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; | ||
24 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; | 27 | import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; |
25 | import com.b2c.orders.domain.client.dto.request.DtmsConfirmRequestDto; | 28 | import com.b2c.orders.domain.client.dto.request.DtmsConfirmRequestDto; |
26 | import com.b2c.orders.domain.client.dto.request.DtmsTimeoutRequestDto; | 29 | import com.b2c.orders.domain.client.dto.request.DtmsTimeoutRequestDto; |
30 | +import com.b2c.orders.domain.client.dto.request.OrderDetailRequestDto; | ||
27 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; | 31 | import com.b2c.orders.domain.client.dto.request.OrderListRequestDto; |
28 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; | 32 | import com.b2c.orders.domain.client.dto.request.PayOrderRequestDto; |
29 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; | 33 | import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; |
30 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; | 34 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; |
31 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; | 35 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
32 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; | 36 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; |
37 | +import com.b2c.orders.domain.client.dto.response.ApiDataResponse; | ||
33 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; | 38 | import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; |
34 | import com.b2c.orders.domain.client.dto.response.ApiResponse; | 39 | import com.b2c.orders.domain.client.dto.response.ApiResponse; |
40 | +import com.b2c.orders.domain.client.dto.response.OrderDetailResponseDto; | ||
35 | import com.b2c.orders.domain.client.dto.response.OrderItemResponseDto; | 41 | import com.b2c.orders.domain.client.dto.response.OrderItemResponseDto; |
36 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; | 42 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
37 | import com.b2c.orders.enums.PayType; | 43 | import com.b2c.orders.enums.PayType; |
@@ -41,7 +47,6 @@ import com.diligrp.website.util.web.PageTemplate; | @@ -41,7 +47,6 @@ import com.diligrp.website.util.web.PageTemplate; | ||
41 | 47 | ||
42 | import io.swagger.annotations.Api; | 48 | import io.swagger.annotations.Api; |
43 | import io.swagger.annotations.ApiOperation; | 49 | import io.swagger.annotations.ApiOperation; |
44 | -import net.sf.cglib.beans.BeanCopier; | ||
45 | 50 | ||
46 | @Api("订单api") | 51 | @Api("订单api") |
47 | @RestController | 52 | @RestController |
@@ -86,7 +91,8 @@ public class OrderRestController { | @@ -86,7 +91,8 @@ public class OrderRestController { | ||
86 | public ApiResponse pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { | 91 | public ApiResponse pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { |
87 | ApiResponse dto = new ApiResponse(); | 92 | ApiResponse dto = new ApiResponse(); |
88 | try { | 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 | dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | 96 | dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
91 | dto.setSuccess(true); | 97 | dto.setSuccess(true); |
92 | } catch (ApplicationException e) { | 98 | } catch (ApplicationException e) { |
@@ -100,7 +106,7 @@ public class OrderRestController { | @@ -100,7 +106,7 @@ public class OrderRestController { | ||
100 | public ApiResponse buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) { | 106 | public ApiResponse buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) { |
101 | ApiResponse response = new ApiResponse(); | 107 | ApiResponse response = new ApiResponse(); |
102 | try { | 108 | try { |
103 | - this.orderService.buyerConfirm(request.getOrderId(), request.getBuyerId()); | 109 | + this.orderService.buyerConfirm(request.getOrderId(), request.getShopBuyerId()); |
104 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | 110 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
105 | response.setSuccess(true); | 111 | response.setSuccess(true); |
106 | } catch (ApplicationException e) { | 112 | } catch (ApplicationException e) { |
@@ -155,7 +161,7 @@ public class OrderRestController { | @@ -155,7 +161,7 @@ public class OrderRestController { | ||
155 | public ApiResponse buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) { | 161 | public ApiResponse buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) { |
156 | ApiResponse response = new ApiResponse(); | 162 | ApiResponse response = new ApiResponse(); |
157 | try { | 163 | try { |
158 | - this.orderService.cancel(request.getOrderId(), request.getBuyerId()); | 164 | + this.orderService.cancel(request.getOrderId(), request.getShopBuyerId()); |
159 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | 165 | response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); |
160 | response.setSuccess(true); | 166 | response.setSuccess(true); |
161 | } catch (ApplicationException e) { | 167 | } catch (ApplicationException e) { |
@@ -190,6 +196,30 @@ public class OrderRestController { | @@ -190,6 +196,30 @@ public class OrderRestController { | ||
190 | return response; | 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 | @ApiOperation("查询订单") | 223 | @ApiOperation("查询订单") |
194 | @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | 224 | @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
195 | public ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request) { | 225 | public ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request) { |
b2c-orders-web/src/main/resources/spring-mvc.xml
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | <context:annotation-config /> | 37 | <context:annotation-config /> |
38 | 38 | ||
39 | <!-- static resources --> | 39 | <!-- static resources --> |
40 | - <mvc:resources location="/assets/" mapping="/static/**" | 40 | + <mvc:resources location="/assets/" mapping="/assets/**" |
41 | cache-period="864000" /><!-- 24 * 3600 * 10 --> | 41 | cache-period="864000" /><!-- 24 * 3600 * 10 --> |
42 | 42 | ||
43 | <!-- template view --> | 43 | <!-- template view --> |
b2c-orders-web/src/main/resources/spring.xml
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | <value>classpath:conf/orders-production.properties</value> | 32 | <value>classpath:conf/orders-production.properties</value> |
33 | <value>classpath:conf/manage.properties</value> | 33 | <value>classpath:conf/manage.properties</value> |
34 | <value>classpath:rpc.properties</value> | 34 | <value>classpath:rpc.properties</value> |
35 | + <value>classpath:redis-config.properties</value> | ||
35 | </list> | 36 | </list> |
36 | </property> | 37 | </property> |
37 | </bean> | 38 | </bean> |
b2c-orders-web/src/main/webapp/WEB-INF/vm/list.vm
@@ -148,9 +148,10 @@ | @@ -148,9 +148,10 @@ | ||
148 | <th #sorting($!{orders} "sellerName")>卖家帐号</th> | 148 | <th #sorting($!{orders} "sellerName")>卖家帐号</th> |
149 | <th>订单预估金额</th> | 149 | <th>订单预估金额</th> |
150 | <th>订单实际金额</th> | 150 | <th>订单实际金额</th> |
151 | - <th>配送类型</th> | ||
152 | <th>付款方式</th> | 151 | <th>付款方式</th> |
152 | + <th>配送方式</th> | ||
153 | <th>订单状态</th> | 153 | <th>订单状态</th> |
154 | + <th>下单时间</th> | ||
154 | <th>操作</th> | 155 | <th>操作</th> |
155 | </tr> | 156 | </tr> |
156 | </thead> | 157 | </thead> |
@@ -168,19 +169,20 @@ | @@ -168,19 +169,20 @@ | ||
168 | <td class="textC">$!{item.sellerName}</td> | 169 | <td class="textC">$!{item.sellerName}</td> |
169 | <td class="textC">$!{item.totalPrice}</td> | 170 | <td class="textC">$!{item.totalPrice}</td> |
170 | <td class="textC">$!{item.realTotalPrice}</td> | 171 | <td class="textC">$!{item.realTotalPrice}</td> |
171 | - <td class="textC"> | ||
172 | - $!{item.deliveryType.name} | ||
173 | - </td> | ||
174 | <td class="textC"> | 172 | <td class="textC"> |
175 | $!{item.payType.name} | 173 | $!{item.payType.name} |
176 | </td> | 174 | </td> |
175 | + <td class="textC"> | ||
176 | + $!{item.deliveryType.name} | ||
177 | + </td> | ||
177 | <td class="textC"> | 178 | <td class="textC"> |
178 | $!{item.orderStatus.name} | 179 | $!{item.orderStatus.name} |
179 | </td> | 180 | </td> |
181 | + <td class="textC"> | ||
182 | + $dateTool.format('yyyy-MM-dd HH:mm:ss',$!{item.submitTime}) | ||
183 | + </td> | ||
180 | <td class="textC"> | 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 | </td> | 186 | </td> |
185 | </tr> | 187 | </tr> |
186 | <tr id="collapseOrderItem$!{item.id}" class="accordion-body collapse"> | 188 | <tr id="collapseOrderItem$!{item.id}" class="accordion-body collapse"> |
pom.xml
@@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
47 | <user.client.devlop.version>0.0.1-SNAPSHOT</user.client.devlop.version> | 47 | <user.client.devlop.version>0.0.1-SNAPSHOT</user.client.devlop.version> |
48 | <user.client.product.version>0.0.3-SNAPSHOT</user.client.product.version> | 48 | <user.client.product.version>0.0.3-SNAPSHOT</user.client.product.version> |
49 | <fastjson.version>1.2.7</fastjson.version> | 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 | <guava.version>20.0</guava.version> | 51 | <guava.version>20.0</guava.version> |
52 | <pnr-shop-develop.version>0.0.1-SNAPSHOT</pnr-shop-develop.version> | 52 | <pnr-shop-develop.version>0.0.1-SNAPSHOT</pnr-shop-develop.version> |
53 | <pnr-shop-product.version>0.0.1-SNAPSHOT</pnr-shop-product.version> | 53 | <pnr-shop-product.version>0.0.1-SNAPSHOT</pnr-shop-product.version> |
@@ -360,15 +360,13 @@ | @@ -360,15 +360,13 @@ | ||
360 | <dependency> | 360 | <dependency> |
361 | <groupId>org.mybatis</groupId> | 361 | <groupId>org.mybatis</groupId> |
362 | <artifactId>mybatis-spring</artifactId> | 362 | <artifactId>mybatis-spring</artifactId> |
363 | - <version>1.2.0</version> | 363 | + <version>1.2.5</version> |
364 | </dependency> | 364 | </dependency> |
365 | <dependency> | 365 | <dependency> |
366 | <groupId>com.alibaba</groupId> | 366 | <groupId>com.alibaba</groupId> |
367 | <artifactId>druid</artifactId> | 367 | <artifactId>druid</artifactId> |
368 | <version>1.0.27</version> | 368 | <version>1.0.27</version> |
369 | </dependency> | 369 | </dependency> |
370 | - <!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> | ||
371 | - <version>5.1.25</version> </dependency> --> | ||
372 | <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client --> | 370 | <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client --> |
373 | <dependency> | 371 | <dependency> |
374 | <groupId>org.mariadb.jdbc</groupId> | 372 | <groupId>org.mariadb.jdbc</groupId> |
@@ -422,9 +420,6 @@ | @@ -422,9 +420,6 @@ | ||
422 | <artifactId>hibernate-validator</artifactId> | 420 | <artifactId>hibernate-validator</artifactId> |
423 | <version>5.1.3.Final</version> | 421 | <version>5.1.3.Final</version> |
424 | </dependency> | 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 | <!-- if you use fileupload in spring mvc --> | 423 | <!-- if you use fileupload in spring mvc --> |
429 | <dependency> | 424 | <dependency> |
430 | <groupId>commons-fileupload</groupId> | 425 | <groupId>commons-fileupload</groupId> |
@@ -506,6 +501,7 @@ | @@ -506,6 +501,7 @@ | ||
506 | <properties> | 501 | <properties> |
507 | <!-- 数据库 --> | 502 | <!-- 数据库 --> |
508 | <orders.jdbc.driver>org.mariadb.jdbc.Driver</orders.jdbc.driver> | 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 | <orders.jdbc.url>jdbc:mariadb://10.28.11.162:3306/orders?characterEncoding=UTF-8</orders.jdbc.url> | 505 | <orders.jdbc.url>jdbc:mariadb://10.28.11.162:3306/orders?characterEncoding=UTF-8</orders.jdbc.url> |
510 | <orders.jdbc.username>root</orders.jdbc.username> | 506 | <orders.jdbc.username>root</orders.jdbc.username> |
511 | <orders.jdbc.password>123456</orders.jdbc.password> | 507 | <orders.jdbc.password>123456</orders.jdbc.password> |
@@ -565,8 +561,9 @@ | @@ -565,8 +561,9 @@ | ||
565 | <path>/</path> | 561 | <path>/</path> |
566 | <port>80</port> | 562 | <port>80</port> |
567 | <uriEncoding>UTF-8</uriEncoding> | 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 | </configuration> | 567 | </configuration> |
571 | </plugin> | 568 | </plugin> |
572 | <plugin> | 569 | <plugin> |
@@ -600,7 +597,6 @@ | @@ -600,7 +597,6 @@ | ||
600 | </plugin> | 597 | </plugin> |
601 | </plugins> | 598 | </plugins> |
602 | </pluginManagement> | 599 | </pluginManagement> |
603 | - <defaultGoal>compile</defaultGoal> | ||
604 | <resources> | 600 | <resources> |
605 | <resource> | 601 | <resource> |
606 | <directory>${project.basedir}/src/main/resources</directory> | 602 | <directory>${project.basedir}/src/main/resources</directory> |