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 | 6 | * |
7 | 7 | */ |
8 | 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 | 36 | <groupId>commons-lang</groupId> |
37 | 37 | <artifactId>commons-lang</artifactId> |
38 | 38 | </dependency> |
39 | + <dependency> | |
40 | + <groupId>${project.groupId}</groupId> | |
41 | + <artifactId>orders-rpc</artifactId> | |
42 | + <version>${project.parent.version}</version> | |
43 | + </dependency> | |
39 | 44 | </dependencies> |
40 | 45 | </project> |
41 | 46 | \ No newline at end of file | ... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
... | ... | @@ -3,6 +3,7 @@ package com.b2c.orders.manager; |
3 | 3 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
4 | 4 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | 5 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
6 | +import com.b2c.orders.rpc.exception.DtmsRpcException; | |
6 | 7 | |
7 | 8 | public interface OrderManager { |
8 | 9 | /** |
... | ... | @@ -10,8 +11,9 @@ public interface OrderManager { |
10 | 11 | * |
11 | 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 | 22 | * 订单id |
21 | 23 | * @param sellerId |
22 | 24 | * 商家id |
23 | - * @param totalPrice TODO | |
25 | + * @param totalPrice | |
26 | + * TODO | |
24 | 27 | * @throws OrderException |
25 | 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 | 61 | * 订单id |
58 | 62 | * @param sellerId |
59 | 63 | * 商家id |
60 | - * @throws OrderRepositoryException | |
61 | - * @throws OrderException | |
64 | + * @throws OrderRepositoryException | |
65 | + * @throws OrderException | |
62 | 66 | */ |
63 | 67 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; |
64 | 68 | |
... | ... | @@ -95,4 +99,14 @@ public interface OrderManager { |
95 | 99 | * @throws OrderException |
96 | 100 | */ |
97 | 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 | 1 | package com.b2c.orders.manager.impl; |
2 | 2 | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
3 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 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 | 12 | import com.b2c.orders.client.domain.dto.request.SubmitOrderRequestDto; |
13 | +import com.b2c.orders.commons.constant.Constant; | |
7 | 14 | import com.b2c.orders.commons.exceptions.ApplicationException; |
8 | 15 | import com.b2c.orders.commons.exceptions.OrderException; |
9 | 16 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
... | ... | @@ -13,24 +20,40 @@ import com.b2c.orders.domain.Buyer; |
13 | 20 | import com.b2c.orders.domain.Order; |
14 | 21 | import com.b2c.orders.domain.Seller; |
15 | 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 | 26 | @Component |
18 | 27 | public class OrderManagerBean implements OrderManager { |
19 | 28 | |
29 | + private static final Logger LOG = LoggerFactory.getLogger(OrderManagerBean.class); | |
30 | + | |
20 | 31 | @Autowired |
21 | 32 | private OrderDao orderDao; |
22 | 33 | @Autowired |
23 | 34 | private OrderIdGenerator IdGenerator; |
35 | + @Autowired | |
36 | + private DtmsRPCService dtmsService; | |
24 | 37 | |
25 | 38 | @Override |
26 | - public void submit(SubmitOrderRequestDto orderVo) { | |
39 | + public void submit(SubmitOrderRequestDto orderVo) throws DtmsRpcException { | |
27 | 40 | Order po = new Order(); |
28 | 41 | po.submit(orderVo, this.IdGenerator); |
29 | 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 | 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 | 57 | Order po = this.orderDao.getById(orderId); |
35 | 58 | if (po == null) { |
36 | 59 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
... | ... | @@ -45,6 +68,16 @@ public class OrderManagerBean implements OrderManager { |
45 | 68 | } |
46 | 69 | po.take(totalPrice); |
47 | 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 | 83 | @Override |
... | ... | @@ -117,6 +150,7 @@ public class OrderManagerBean implements OrderManager { |
117 | 150 | } |
118 | 151 | po.refuse(); |
119 | 152 | this.orderDao.update(po); |
153 | + | |
120 | 154 | } |
121 | 155 | |
122 | 156 | @Override |
... | ... | @@ -148,4 +182,15 @@ public class OrderManagerBean implements OrderManager { |
148 | 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 | 24 | \ No newline at end of file | ... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/DtmsRPCService.java
0 → 100644
1 | +package com.b2c.orders.rpc; | |
2 | + | |
3 | +import com.b2c.dtms.client.domain.dto.request.DtmsProduceRequestDto; | |
4 | +import com.b2c.orders.rpc.exception.DtmsRpcException; | |
5 | + | |
6 | +public interface DtmsRPCService { | |
7 | + | |
8 | + void produceDtmsMessage(DtmsProduceRequestDto request) throws DtmsRpcException; | |
9 | +} | ... | ... |
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 | 21 | * 订单id |
22 | 22 | * @param sellerId |
23 | 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 | 29 | void take(Long orderId, Long sellerId, Long totalPrice) throws OrderException, OrderRepositoryException; |
29 | 30 | |
... | ... | @@ -58,8 +59,8 @@ public interface OrderService { |
58 | 59 | * 订单id |
59 | 60 | * @param sellerId |
60 | 61 | * 卖家id |
61 | - * @throws OrderException | |
62 | - * @throws OrderRepositoryException | |
62 | + * @throws OrderException | |
63 | + * @throws OrderRepositoryException | |
63 | 64 | */ |
64 | 65 | void sellerConfirm(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; |
65 | 66 | |
... | ... | @@ -82,8 +83,8 @@ public interface OrderService { |
82 | 83 | * 订单id |
83 | 84 | * @param buyerId |
84 | 85 | * 买家id |
85 | - * @throws OrderException | |
86 | - * @throws OrderRepositoryException | |
86 | + * @throws OrderException | |
87 | + * @throws OrderRepositoryException | |
87 | 88 | */ |
88 | 89 | void cancel(Long orderId, Long buyerId) throws OrderRepositoryException, OrderException; |
89 | 90 | |
... | ... | @@ -96,4 +97,14 @@ public interface OrderService { |
96 | 97 | * @throws OrderRepositoryException |
97 | 98 | */ |
98 | 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 | 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 | 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 | 23 | <dependency-type>uses</dependency-type> |
24 | 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 | 29 | <dependency-type>uses</dependency-type> |
27 | 30 | </dependent-module> |
28 | 31 | <property name="context-root" value="b2c-orders-web"/> | ... | ... |
b2c-orders-web/pom.xml
... | ... | @@ -15,5 +15,16 @@ |
15 | 15 | <artifactId>orders-service</artifactId> |
16 | 16 | <version>${project.version}</version> |
17 | 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 | 29 | </dependencies> |
19 | 30 | </project> |
20 | 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 | import org.springframework.web.bind.annotation.RequestMapping; |
7 | 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 | 11 | import com.b2c.orders.client.domain.dto.request.BuyerCancelRequestDto; |
10 | 12 | import com.b2c.orders.client.domain.dto.request.BuyerConfirmRequestDto; |
11 | 13 | import com.b2c.orders.client.domain.dto.request.DtmsConfirmRequestDto; |
... | ... | @@ -21,7 +23,7 @@ import com.b2c.orders.commons.exceptions.ApplicationException; |
21 | 23 | import com.b2c.orders.service.OrderService; |
22 | 24 | |
23 | 25 | @RestController |
24 | -@RequestMapping("/order/api") | |
26 | +@RequestMapping("/api") | |
25 | 27 | public class OrderRestController { |
26 | 28 | |
27 | 29 | @Autowired |
... | ... | @@ -88,8 +90,17 @@ public class OrderRestController { |
88 | 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 | 106 | @RequestMapping(value = "/seller/refuse", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
... | ... | @@ -119,8 +130,16 @@ public class OrderRestController { |
119 | 130 | } |
120 | 131 | |
121 | 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 | 60 | |
61 | 61 | <dependencyManagement> |
62 | 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 | 69 | <!-- https://mvnrepository.com/artifact/cglib/cglib --> |
64 | 70 | <dependency> |
65 | 71 | <groupId>cglib</groupId> |
... | ... | @@ -537,5 +543,6 @@ |
537 | 543 | <module>orders-client</module> |
538 | 544 | <module>orders-service</module> |
539 | 545 | <module>orders-web</module> |
546 | + <module>orders-rpc</module> | |
540 | 547 | </modules> |
541 | 548 | </project> |
542 | 549 | \ No newline at end of file | ... | ... |