Commit 1d49e3c849778987325cdb4328e3be9e88b21daa
1 parent
4939f4b5
增加dtms RPC接口
Showing
17 changed files
with
307 additions
and
21 deletions
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/DtmsTimeoutRequestDto.java
@@ -6,5 +6,16 @@ public class DtmsTimeoutRequestDto extends BaseRequestDto { | @@ -6,5 +6,16 @@ public class DtmsTimeoutRequestDto extends BaseRequestDto { | ||
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | private static final long serialVersionUID = 8454009010057359942L; | 8 | private static final long serialVersionUID = 8454009010057359942L; |
9 | + | ||
10 | + private Long orderId; | ||
11 | + | ||
12 | + public Long getOrderId() { | ||
13 | + return orderId; | ||
14 | + } | ||
15 | + | ||
16 | + public void setOrderId(Long orderId) { | ||
17 | + this.orderId = orderId; | ||
18 | + } | ||
19 | + | ||
9 | 20 | ||
10 | } | 21 | } |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/constant/Constant.java
0 → 100644
1 | +package com.b2c.orders.commons.constant; | ||
2 | + | ||
3 | +public class Constant { | ||
4 | + | ||
5 | + /** | ||
6 | + * 商家未接单,订单超时api接口地址 | ||
7 | + */ | ||
8 | + public static final String ORDER_TAKE_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/timeout"; | ||
9 | + /** | ||
10 | + * 买家未付款,订单超时api接口 | ||
11 | + */ | ||
12 | + public static final String ORDER_PAY_TIMEOUT_CALL_URL = "http://orders.zandeapp.com/api/dtms/timeout"; | ||
13 | + /** | ||
14 | + * 商家未接单,订单超时时间 | ||
15 | + */ | ||
16 | + public static final int ORDER_TAKE_TIMEOUT_SECONDS = 24 * 60 * 60; | ||
17 | + /** | ||
18 | + * 买家未支付,订单超时时间 | ||
19 | + */ | ||
20 | + public static final int ORDER_PAY_TIMEOUT_SECONDS = 24 * 60 * 60; | ||
21 | +} |
b2c-orders-domain/pom.xml
@@ -36,5 +36,10 @@ | @@ -36,5 +36,10 @@ | ||
36 | <groupId>commons-lang</groupId> | 36 | <groupId>commons-lang</groupId> |
37 | <artifactId>commons-lang</artifactId> | 37 | <artifactId>commons-lang</artifactId> |
38 | </dependency> | 38 | </dependency> |
39 | + <dependency> | ||
40 | + <groupId>${project.groupId}</groupId> | ||
41 | + <artifactId>orders-rpc</artifactId> | ||
42 | + <version>${project.parent.version}</version> | ||
43 | + </dependency> | ||
39 | </dependencies> | 44 | </dependencies> |
40 | </project> | 45 | </project> |
41 | \ No newline at end of file | 46 | \ No newline at end of file |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
@@ -102,7 +102,7 @@ public class Order extends BaseDomain { | @@ -102,7 +102,7 @@ public class Order extends BaseDomain { | ||
102 | * 商家接单 | 102 | * 商家接单 |
103 | * | 103 | * |
104 | * @param totalPrice | 104 | * @param totalPrice |
105 | - * TODO | 105 | + * 订单总价(根据需求文档,商家接单接单需要手动修改订单价格) |
106 | * | 106 | * |
107 | * @throws OrderException | 107 | * @throws OrderException |
108 | */ | 108 | */ |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
@@ -3,6 +3,7 @@ package com.b2c.orders.manager; | @@ -3,6 +3,7 @@ package com.b2c.orders.manager; | ||
3 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; | 3 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
4 | import com.b2c.orders.commons.exceptions.OrderException; | 4 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; | 5 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
6 | +import com.b2c.orders.rpc.exception.DtmsRpcException; | ||
6 | 7 | ||
7 | public interface OrderManager { | 8 | public interface OrderManager { |
8 | /** | 9 | /** |
@@ -10,8 +11,9 @@ public interface OrderManager { | @@ -10,8 +11,9 @@ public interface OrderManager { | ||
10 | * | 11 | * |
11 | * @param orderVo | 12 | * @param orderVo |
12 | * 订单属性 | 13 | * 订单属性 |
14 | + * @throws DtmsRpcException | ||
13 | */ | 15 | */ |
14 | - void submit(SubmitOrderRequestDto orderVo); | 16 | + void submit(SubmitOrderRequestDto orderVo) throws DtmsRpcException; |
15 | 17 | ||
16 | /** | 18 | /** |
17 | * 接单 | 19 | * 接单 |
@@ -20,11 +22,13 @@ public interface OrderManager { | @@ -20,11 +22,13 @@ public interface OrderManager { | ||
20 | * 订单id | 22 | * 订单id |
21 | * @param sellerId | 23 | * @param sellerId |
22 | * 商家id | 24 | * 商家id |
23 | - * @param totalPrice TODO | 25 | + * @param totalPrice |
26 | + * TODO | ||
24 | * @throws OrderException | 27 | * @throws OrderException |
25 | * @throws OrderRepositoryException | 28 | * @throws OrderRepositoryException |
29 | + * @throws DtmsRpcException | ||
26 | */ | 30 | */ |
27 | - void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException; | 31 | + void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException, DtmsRpcException; |
28 | 32 | ||
29 | /** | 33 | /** |
30 | * 支付 | 34 | * 支付 |
@@ -57,8 +61,8 @@ public interface OrderManager { | @@ -57,8 +61,8 @@ public interface OrderManager { | ||
57 | * 订单id | 61 | * 订单id |
58 | * @param sellerId | 62 | * @param sellerId |
59 | * 商家id | 63 | * 商家id |
60 | - * @throws OrderRepositoryException | ||
61 | - * @throws OrderException | 64 | + * @throws OrderRepositoryException |
65 | + * @throws OrderException | ||
62 | */ | 66 | */ |
63 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; | 67 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; |
64 | 68 | ||
@@ -95,4 +99,14 @@ public interface OrderManager { | @@ -95,4 +99,14 @@ public interface OrderManager { | ||
95 | * @throws OrderException | 99 | * @throws OrderException |
96 | */ | 100 | */ |
97 | void timeout(Long orderId) throws OrderRepositoryException, OrderException; | 101 | void timeout(Long orderId) throws OrderRepositoryException, OrderException; |
102 | + | ||
103 | + /** | ||
104 | + * 商家24小时没有确认收款或者买家24小时没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) | ||
105 | + * | ||
106 | + * @param orderId | ||
107 | + * 订单id | ||
108 | + * @throws OrderRepositoryException | ||
109 | + * @throws OrderException | ||
110 | + */ | ||
111 | + void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; | ||
98 | } | 112 | } |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
1 | package com.b2c.orders.manager.impl; | 1 | package com.b2c.orders.manager.impl; |
2 | 2 | ||
3 | +import org.slf4j.Logger; | ||
4 | +import org.slf4j.LoggerFactory; | ||
3 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
4 | import org.springframework.stereotype.Component; | 6 | import org.springframework.stereotype.Component; |
5 | 7 | ||
8 | +import com.alibaba.fastjson.JSON; | ||
9 | +import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; | ||
10 | +import com.b2c.dtms.common.enums.dtms.DtmsMessageType; | ||
11 | +import com.b2c.orders.client.domain.dto.request.DtmsTimeoutRequestDto; | ||
6 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; | 12 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
13 | +import com.b2c.orders.commons.constant.Constant; | ||
7 | import com.b2c.orders.commons.exceptions.ApplicationException; | 14 | import com.b2c.orders.commons.exceptions.ApplicationException; |
8 | import com.b2c.orders.commons.exceptions.OrderException; | 15 | import com.b2c.orders.commons.exceptions.OrderException; |
9 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; | 16 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
@@ -13,24 +20,40 @@ import com.b2c.orders.domain.Buyer; | @@ -13,24 +20,40 @@ import com.b2c.orders.domain.Buyer; | ||
13 | import com.b2c.orders.domain.Order; | 20 | import com.b2c.orders.domain.Order; |
14 | import com.b2c.orders.domain.Seller; | 21 | import com.b2c.orders.domain.Seller; |
15 | import com.b2c.orders.manager.OrderManager; | 22 | import com.b2c.orders.manager.OrderManager; |
23 | +import com.b2c.orders.rpc.DtmsRPCService; | ||
24 | +import com.b2c.orders.rpc.exception.DtmsRpcException; | ||
16 | 25 | ||
17 | @Component | 26 | @Component |
18 | public class OrderManagerBean implements OrderManager { | 27 | public class OrderManagerBean implements OrderManager { |
19 | 28 | ||
29 | + private static final Logger LOG = LoggerFactory.getLogger(OrderManagerBean.class); | ||
30 | + | ||
20 | @Autowired | 31 | @Autowired |
21 | private OrderDao orderDao; | 32 | private OrderDao orderDao; |
22 | @Autowired | 33 | @Autowired |
23 | private OrderIdGenerator IdGenerator; | 34 | private OrderIdGenerator IdGenerator; |
35 | + @Autowired | ||
36 | + private DtmsRPCService dtmsService; | ||
24 | 37 | ||
25 | @Override | 38 | @Override |
26 | - public void submit(SubmitOrderRequestDto orderVo) { | 39 | + public void submit(SubmitOrderRequestDto orderVo) throws DtmsRpcException { |
27 | Order po = new Order(); | 40 | Order po = new Order(); |
28 | po.submit(orderVo, this.IdGenerator); | 41 | po.submit(orderVo, this.IdGenerator); |
29 | this.orderDao.save(po); | 42 | this.orderDao.save(po); |
43 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | ||
44 | + request.setBizId(po.getId().toString()); | ||
45 | + request.setCallUrl(Constant.ORDER_TAKE_TIMEOUT_CALL_URL); | ||
46 | + DtmsTimeoutRequestDto param = new DtmsTimeoutRequestDto(); | ||
47 | + param.setOrderId(po.getId()); | ||
48 | + request.setContent(JSON.toJSONString(param)); | ||
49 | + request.setDelaySeconds(Constant.ORDER_TAKE_TIMEOUT_SECONDS); | ||
50 | + request.setType(DtmsMessageType.Timer.code()); | ||
51 | + this.dtmsService.produceDtmsMessage(request); | ||
30 | } | 52 | } |
31 | 53 | ||
32 | @Override | 54 | @Override |
33 | - public void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException { | 55 | + public void take(Long orderId, Long sellerId, Long totalPrice) |
56 | + throws OrderException, OrderRepositoryException, DtmsRpcException { | ||
34 | Order po = this.orderDao.getById(orderId); | 57 | Order po = this.orderDao.getById(orderId); |
35 | if (po == null) { | 58 | if (po == null) { |
36 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | 59 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
@@ -45,6 +68,16 @@ public class OrderManagerBean implements OrderManager { | @@ -45,6 +68,16 @@ public class OrderManagerBean implements OrderManager { | ||
45 | } | 68 | } |
46 | po.take(totalPrice); | 69 | po.take(totalPrice); |
47 | this.orderDao.update(po); | 70 | this.orderDao.update(po); |
71 | + DtmsProduceRequestDto request = new DtmsProduceRequestDto(); | ||
72 | + request.setBizId(po.getId().toString()); | ||
73 | + request.setCallUrl(Constant.ORDER_PAY_TIMEOUT_CALL_URL); | ||
74 | + DtmsTimeoutRequestDto param = new DtmsTimeoutRequestDto(); | ||
75 | + param.setOrderId(po.getId()); | ||
76 | + request.setContent(JSON.toJSONString(param)); | ||
77 | + request.setDelaySeconds(Constant.ORDER_PAY_TIMEOUT_SECONDS); | ||
78 | + request.setType(DtmsMessageType.Timer.code()); | ||
79 | + this.dtmsService.produceDtmsMessage(request); | ||
80 | + | ||
48 | } | 81 | } |
49 | 82 | ||
50 | @Override | 83 | @Override |
@@ -117,6 +150,7 @@ public class OrderManagerBean implements OrderManager { | @@ -117,6 +150,7 @@ public class OrderManagerBean implements OrderManager { | ||
117 | } | 150 | } |
118 | po.refuse(); | 151 | po.refuse(); |
119 | this.orderDao.update(po); | 152 | this.orderDao.update(po); |
153 | + | ||
120 | } | 154 | } |
121 | 155 | ||
122 | @Override | 156 | @Override |
@@ -148,4 +182,15 @@ public class OrderManagerBean implements OrderManager { | @@ -148,4 +182,15 @@ public class OrderManagerBean implements OrderManager { | ||
148 | this.orderDao.update(po); | 182 | this.orderDao.update(po); |
149 | } | 183 | } |
150 | 184 | ||
185 | + @Override | ||
186 | + public void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException { | ||
187 | + Order po = this.orderDao.getById(orderId); | ||
188 | + if (po == null) { | ||
189 | + throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, | ||
190 | + String.format("未找到id为%s的订单", orderId)); | ||
191 | + } | ||
192 | + po.confirm(); | ||
193 | + this.orderDao.update(po); | ||
194 | + } | ||
195 | + | ||
151 | } | 196 | } |
b2c-orders-rpc/pom.xml
0 → 100644
1 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
2 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
3 | + <modelVersion>4.0.0</modelVersion> | ||
4 | + <parent> | ||
5 | + <groupId>com.b2c.orders</groupId> | ||
6 | + <artifactId>orders-parent</artifactId> | ||
7 | + <version>0.0.1-SNAPSHOT</version> | ||
8 | + </parent> | ||
9 | + <artifactId>orders-rpc</artifactId> | ||
10 | + | ||
11 | + <dependencies> | ||
12 | + <dependency> | ||
13 | + <groupId>${project.groupId}</groupId> | ||
14 | + <artifactId>orders-commons</artifactId> | ||
15 | + <version>${project.parent.version}</version> | ||
16 | + </dependency> | ||
17 | + <dependency> | ||
18 | + <groupId>com.b2c.dtms</groupId> | ||
19 | + <artifactId>dtms-client</artifactId> | ||
20 | + <version>0.0.1-SNAPSHOT</version> | ||
21 | + </dependency> | ||
22 | + </dependencies> | ||
23 | +</project> | ||
0 | \ No newline at end of file | 24 | \ No newline at end of file |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/DtmsRPCService.java
0 → 100644
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/exception/DtmsRpcException.java
0 → 100644
1 | +package com.b2c.orders.rpc.exception; | ||
2 | + | ||
3 | +import com.b2c.orders.commons.exceptions.ApplicationException; | ||
4 | + | ||
5 | +public class DtmsRpcException extends ApplicationException { | ||
6 | + | ||
7 | + /** | ||
8 | + * | ||
9 | + */ | ||
10 | + private static final long serialVersionUID = 6485664433664748337L; | ||
11 | + | ||
12 | + public DtmsRpcException(int code, String message, Throwable cause, boolean enableSuppression, | ||
13 | + boolean writableStackTrace) { | ||
14 | + super(code, message, cause, enableSuppression, writableStackTrace); | ||
15 | + // TODO Auto-generated constructor stub | ||
16 | + } | ||
17 | + | ||
18 | + public DtmsRpcException(int code, String message, Throwable cause) { | ||
19 | + super(code, message, cause); | ||
20 | + // TODO Auto-generated constructor stub | ||
21 | + } | ||
22 | + | ||
23 | + public DtmsRpcException(int code, String message) { | ||
24 | + super(code, message); | ||
25 | + // TODO Auto-generated constructor stub | ||
26 | + } | ||
27 | + | ||
28 | + public DtmsRpcException(int code, Throwable cause) { | ||
29 | + super(code, cause); | ||
30 | + // TODO Auto-generated constructor stub | ||
31 | + } | ||
32 | + | ||
33 | + public DtmsRpcException(int code) { | ||
34 | + super(code); | ||
35 | + // TODO Auto-generated constructor stub | ||
36 | + } | ||
37 | + | ||
38 | +} |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/DtmsRPCServiceBean.java
0 → 100644
1 | +package com.b2c.orders.rpc.impl; | ||
2 | + | ||
3 | +import com.b2c.dtms.client.DtmsClient; | ||
4 | +import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; | ||
5 | +import com.b2c.dtms.client.domain.dto.response.DtmsResponseDto; | ||
6 | +import com.b2c.dtms.common.enums.dtms.HandleCode; | ||
7 | +import com.b2c.orders.commons.exceptions.ApplicationException; | ||
8 | +import com.b2c.orders.rpc.DtmsRPCService; | ||
9 | +import com.b2c.orders.rpc.exception.DtmsRpcException; | ||
10 | + | ||
11 | +public class DtmsRPCServiceBean implements DtmsRPCService { | ||
12 | + | ||
13 | + private DtmsClient dtmsClient = new DtmsClient(); | ||
14 | + | ||
15 | + @Override | ||
16 | + public void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRpcException { | ||
17 | + DtmsResponseDto response = this.dtmsClient.produceMessage(request); | ||
18 | + String code = response.getCode(); | ||
19 | + if (code.equals(HandleCode.FAILED.code())) { | ||
20 | + throw new DtmsRpcException(ApplicationException.DATA_EXCEPTION, "创建dtms消息失败"); | ||
21 | + } | ||
22 | + if (code.equals(HandleCode.SUCCESS)) { | ||
23 | + return; | ||
24 | + } | ||
25 | + throw new DtmsRpcException(ApplicationException.DATA_EXCEPTION, "未知的返回类型"); | ||
26 | + } | ||
27 | + | ||
28 | +} |
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
@@ -21,9 +21,10 @@ public interface OrderService { | @@ -21,9 +21,10 @@ public interface OrderService { | ||
21 | * 订单id | 21 | * 订单id |
22 | * @param sellerId | 22 | * @param sellerId |
23 | * 商家id | 23 | * 商家id |
24 | - * @param totalPrice TODO | ||
25 | - * @throws OrderRepositoryException | ||
26 | - * @throws OrderException | 24 | + * @param totalPrice |
25 | + * TODO | ||
26 | + * @throws OrderRepositoryException | ||
27 | + * @throws OrderException | ||
27 | */ | 28 | */ |
28 | void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException; | 29 | void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException; |
29 | 30 | ||
@@ -58,8 +59,8 @@ public interface OrderService { | @@ -58,8 +59,8 @@ public interface OrderService { | ||
58 | * 订单id | 59 | * 订单id |
59 | * @param sellerId | 60 | * @param sellerId |
60 | * 卖家id | 61 | * 卖家id |
61 | - * @throws OrderException | ||
62 | - * @throws OrderRepositoryException | 62 | + * @throws OrderException |
63 | + * @throws OrderRepositoryException | ||
63 | */ | 64 | */ |
64 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; | 65 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; |
65 | 66 | ||
@@ -82,8 +83,8 @@ public interface OrderService { | @@ -82,8 +83,8 @@ public interface OrderService { | ||
82 | * 订单id | 83 | * 订单id |
83 | * @param buyerId | 84 | * @param buyerId |
84 | * 买家id | 85 | * 买家id |
85 | - * @throws OrderException | ||
86 | - * @throws OrderRepositoryException | 86 | + * @throws OrderException |
87 | + * @throws OrderRepositoryException | ||
87 | */ | 88 | */ |
88 | void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; | 89 | void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; |
89 | 90 | ||
@@ -96,4 +97,14 @@ public interface OrderService { | @@ -96,4 +97,14 @@ public interface OrderService { | ||
96 | * @throws OrderRepositoryException | 97 | * @throws OrderRepositoryException |
97 | */ | 98 | */ |
98 | void timeout(Long orderId) throws OrderRepositoryException, OrderException; | 99 | void timeout(Long orderId) throws OrderRepositoryException, OrderException; |
100 | + | ||
101 | + /** | ||
102 | + * 商家24小时没有确认收款或者买家24小时没确认收货由dtms确认收款、收货(需求文档要求商家确认收款或者买家确认收货则订单完成) | ||
103 | + * | ||
104 | + * @param orderId | ||
105 | + * 订单id | ||
106 | + * @throws OrderException | ||
107 | + * @throws OrderRepositoryException | ||
108 | + */ | ||
109 | + void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException; | ||
99 | } | 110 | } |
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
@@ -59,4 +59,9 @@ public class OrderServiceBean implements OrderService { | @@ -59,4 +59,9 @@ public class OrderServiceBean implements OrderService { | ||
59 | this.orderManager.timeout(orderId); | 59 | this.orderManager.timeout(orderId); |
60 | } | 60 | } |
61 | 61 | ||
62 | + @Override | ||
63 | + public void dtmsConfirm(Long orderId) throws OrderRepositoryException, OrderException { | ||
64 | + this.orderManager.dtmsConfirm(orderId); | ||
65 | + } | ||
66 | + | ||
62 | } | 67 | } |
b2c-orders-web/.settings/org.eclipse.wst.common.component
@@ -22,7 +22,10 @@ | @@ -22,7 +22,10 @@ | ||
22 | <dependent-module archiveName="orders-client-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/b2c-orders-client/b2c-orders-client"> | 22 | <dependent-module archiveName="orders-client-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/b2c-orders-client/b2c-orders-client"> |
23 | <dependency-type>uses</dependency-type> | 23 | <dependency-type>uses</dependency-type> |
24 | </dependent-module> | 24 | </dependent-module> |
25 | - <dependent-module archiveName="diligrp-website-util-0.0.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/diligrp-website-util/diligrp-website-util"> | 25 | + <dependent-module archiveName="orders-rpc-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/b2c-orders-rpc/b2c-orders-rpc"> |
26 | + <dependency-type>uses</dependency-type> | ||
27 | + </dependent-module> | ||
28 | + <dependent-module archiveName="dtms-client-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/dtms-client/dtms-client"> | ||
26 | <dependency-type>uses</dependency-type> | 29 | <dependency-type>uses</dependency-type> |
27 | </dependent-module> | 30 | </dependent-module> |
28 | <property name="context-root" value="b2c-orders-web"/> | 31 | <property name="context-root" value="b2c-orders-web"/> |
b2c-orders-web/pom.xml
@@ -15,5 +15,16 @@ | @@ -15,5 +15,16 @@ | ||
15 | <artifactId>orders-service</artifactId> | 15 | <artifactId>orders-service</artifactId> |
16 | <version>${project.version}</version> | 16 | <version>${project.version}</version> |
17 | </dependency> | 17 | </dependency> |
18 | + <!-- https://mvnrepository.com/artifact/com.mangofactory/swagger-springmvc --> | ||
19 | + <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> | ||
20 | + <dependency> | ||
21 | + <groupId>io.springfox</groupId> | ||
22 | + <artifactId>springfox-swagger2</artifactId> | ||
23 | + </dependency> | ||
24 | + <dependency> | ||
25 | + <groupId>com.b2c.dtms</groupId> | ||
26 | + <artifactId>dtms-client</artifactId> | ||
27 | + <version>0.0.1-SNAPSHOT</version> | ||
28 | + </dependency> | ||
18 | </dependencies> | 29 | </dependencies> |
19 | </project> | 30 | </project> |
20 | \ No newline at end of file | 31 | \ No newline at end of file |
b2c-orders-web/src/main/java/com/b2c/orders/configuration/SwaggerConfiguration.java
0 → 100644
1 | +package com.b2c.orders.configuration; | ||
2 | + | ||
3 | +import org.springframework.context.annotation.Bean; | ||
4 | +import org.springframework.context.annotation.ComponentScan; | ||
5 | +import org.springframework.context.annotation.Configuration; | ||
6 | +import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
7 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
8 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
9 | + | ||
10 | +import springfox.documentation.service.ApiInfo; | ||
11 | +import springfox.documentation.spi.DocumentationType; | ||
12 | +import springfox.documentation.spring.web.plugins.Docket; | ||
13 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
14 | + | ||
15 | +@Configuration | ||
16 | +@EnableWebMvc | ||
17 | +@EnableSwagger2 | ||
18 | +@ComponentScan(basePackages = "com.b2c.orders.web.restful") | ||
19 | +public class SwaggerConfiguration extends WebMvcConfigurerAdapter { | ||
20 | + | ||
21 | + @Override | ||
22 | + public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
23 | + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | ||
24 | + | ||
25 | + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | ||
26 | + | ||
27 | + } | ||
28 | + | ||
29 | + @Bean | ||
30 | + public Docket swaggerSpringMvcPlugin() { | ||
31 | + Docket docket = new Docket(DocumentationType.SWAGGER_2); | ||
32 | + ApiInfo apiInfo = new ApiInfo("一体化", "网关接口", "1.1", "urn:tos", "dili", "logistics-park", "http://dili.com"); | ||
33 | + docket.apiInfo(apiInfo); | ||
34 | + return docket; | ||
35 | + } | ||
36 | +} |
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
@@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.RequestBody; | @@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.RequestBody; | ||
6 | import org.springframework.web.bind.annotation.RequestMapping; | 6 | import org.springframework.web.bind.annotation.RequestMapping; |
7 | import org.springframework.web.bind.annotation.RestController; | 7 | import org.springframework.web.bind.annotation.RestController; |
8 | 8 | ||
9 | +import com.b2c.dtms.common.enums.dtms.HandleCode; | ||
10 | +import com.b2c.dtms.domain.DtmsCallBackReturn; | ||
9 | import com.b2c.orders.client.domain.dto.request.BuyerCancelRequestDto; | 11 | import com.b2c.orders.client.domain.dto.request.BuyerCancelRequestDto; |
10 | import com.b2c.orders.client.domain.dto.request.BuyerConfirmRequestDto; | 12 | import com.b2c.orders.client.domain.dto.request.BuyerConfirmRequestDto; |
11 | import com.b2c.orders.client.domain.dto.request.DtmsConfirmRequestDto; | 13 | import com.b2c.orders.client.domain.dto.request.DtmsConfirmRequestDto; |
@@ -21,7 +23,7 @@ import com.b2c.orders.commons.exceptions.ApplicationException; | @@ -21,7 +23,7 @@ import com.b2c.orders.commons.exceptions.ApplicationException; | ||
21 | import com.b2c.orders.service.OrderService; | 23 | import com.b2c.orders.service.OrderService; |
22 | 24 | ||
23 | @RestController | 25 | @RestController |
24 | -@RequestMapping("/order/api") | 26 | +@RequestMapping("/api") |
25 | public class OrderRestController { | 27 | public class OrderRestController { |
26 | 28 | ||
27 | @Autowired | 29 | @Autowired |
@@ -88,8 +90,17 @@ public class OrderRestController { | @@ -88,8 +90,17 @@ public class OrderRestController { | ||
88 | return response; | 90 | return response; |
89 | } | 91 | } |
90 | 92 | ||
91 | - public BaseResponseDto dtmsConfirm(@RequestBody DtmsConfirmRequestDto dto) { | ||
92 | - throw new RuntimeException("这个方法还没实现"); | 93 | + @RequestMapping(value = "/dtms/confirm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
94 | + public DtmsCallBackReturn dtmsConfirm(@RequestBody DtmsConfirmRequestDto dto) { | ||
95 | + DtmsCallBackReturn response = new DtmsCallBackReturn(); | ||
96 | + try { | ||
97 | + this.orderService.dtmsConfirm(dto.getOrderId()); | ||
98 | + response.setCode(HandleCode.SUCCESS.code()); | ||
99 | + } catch (ApplicationException e) { | ||
100 | + response.setCode(HandleCode.FAILED.code()); | ||
101 | + response.setMessage(e.getMessage()); | ||
102 | + } | ||
103 | + return response; | ||
93 | } | 104 | } |
94 | 105 | ||
95 | @RequestMapping(value = "/seller/refuse", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | 106 | @RequestMapping(value = "/seller/refuse", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
@@ -119,8 +130,16 @@ public class OrderRestController { | @@ -119,8 +130,16 @@ public class OrderRestController { | ||
119 | } | 130 | } |
120 | 131 | ||
121 | @RequestMapping(value = "/dtms/timeout", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | 132 | @RequestMapping(value = "/dtms/timeout", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
122 | - public BaseResponseDto dtmsTimeout(@RequestBody DtmsTimeoutRequestDto request) { | ||
123 | - throw new RuntimeException("这个方法还没实现"); | 133 | + public DtmsCallBackReturn dtmsTimeout(@RequestBody DtmsTimeoutRequestDto request) { |
134 | + DtmsCallBackReturn response = new DtmsCallBackReturn(); | ||
135 | + try { | ||
136 | + this.orderService.timeout(request.getOrderId()); | ||
137 | + response.setCode(HandleCode.SUCCESS.code()); | ||
138 | + } catch (ApplicationException e) { | ||
139 | + response.setCode(HandleCode.FAILED.code()); | ||
140 | + response.setMessage(e.getMessage()); | ||
141 | + } | ||
142 | + return response; | ||
124 | } | 143 | } |
125 | 144 | ||
126 | } | 145 | } |
pom.xml
@@ -60,6 +60,12 @@ | @@ -60,6 +60,12 @@ | ||
60 | 60 | ||
61 | <dependencyManagement> | 61 | <dependencyManagement> |
62 | <dependencies> | 62 | <dependencies> |
63 | + <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> | ||
64 | + <dependency> | ||
65 | + <groupId>io.springfox</groupId> | ||
66 | + <artifactId>springfox-swagger2</artifactId> | ||
67 | + <version>2.6.1</version> | ||
68 | + </dependency> | ||
63 | <!-- https://mvnrepository.com/artifact/cglib/cglib --> | 69 | <!-- https://mvnrepository.com/artifact/cglib/cglib --> |
64 | <dependency> | 70 | <dependency> |
65 | <groupId>cglib</groupId> | 71 | <groupId>cglib</groupId> |
@@ -537,5 +543,6 @@ | @@ -537,5 +543,6 @@ | ||
537 | <module>orders-client</module> | 543 | <module>orders-client</module> |
538 | <module>orders-service</module> | 544 | <module>orders-service</module> |
539 | <module>orders-web</module> | 545 | <module>orders-web</module> |
546 | + <module>orders-rpc</module> | ||
540 | </modules> | 547 | </modules> |
541 | </project> | 548 | </project> |
542 | \ No newline at end of file | 549 | \ No newline at end of file |