Commit 628d2af81535b6371e9f8714dc065067fe9656de
1 parent
f8a64fa5
[modify buyer]
Showing
4 changed files
with
62 additions
and
47 deletions
src/main/java/com/diligrp/xtrade/order/domain/emuns/OrderStatus.java
src/main/java/com/diligrp/xtrade/order/exception/OrderException.java
1 | -package com.diligrp.xtrade.order.exception; | |
2 | - | |
3 | -public class OrderException extends RuntimeException{ | |
4 | - | |
5 | - private static final long serialVersionUID = 1L; | |
6 | - | |
7 | - private static final int DEFAULT_CODE = 1000; | |
8 | - | |
9 | - private int code; | |
10 | - | |
11 | - public OrderException() { | |
12 | - super(); | |
13 | - } | |
14 | - | |
15 | - public OrderException(String message, int code){ | |
16 | - super(message); | |
17 | - this.code = code; | |
18 | - } | |
19 | - | |
20 | - public OrderException(String message) { | |
21 | - this(message, DEFAULT_CODE); | |
22 | - } | |
23 | - | |
24 | - public OrderException(String message, Throwable cause) { | |
25 | - super(message, cause); | |
26 | - this.code = DEFAULT_CODE; | |
27 | - } | |
28 | - | |
29 | - public OrderException(Throwable cause) { | |
30 | - super(cause); | |
31 | - this.code = DEFAULT_CODE; | |
32 | - } | |
33 | - | |
34 | - public int getCode() { | |
35 | - return code; | |
36 | - } | |
37 | - | |
38 | - public void setCode(int code) { | |
39 | - this.code = code; | |
40 | - } | |
41 | - | |
42 | -} | |
1 | +package com.diligrp.xtrade.order.exception; | |
2 | + | |
3 | +public class OrderException extends RuntimeException{ | |
4 | + | |
5 | + private static final long serialVersionUID = 1L; | |
6 | + | |
7 | + private static final int DEFAULT_CODE = 1000; | |
8 | + | |
9 | + private int code; | |
10 | + | |
11 | + public OrderException() { | |
12 | + super(); | |
13 | + } | |
14 | + | |
15 | + public OrderException(String message, int code){ | |
16 | + super(message); | |
17 | + this.code = code; | |
18 | + } | |
19 | + | |
20 | + public OrderException(OrderError orderError){ | |
21 | + super(orderError.getName()); | |
22 | + this.code = orderError.getCode(); | |
23 | + } | |
24 | + | |
25 | + public OrderException(String message) { | |
26 | + this(message, DEFAULT_CODE); | |
27 | + } | |
28 | + | |
29 | + public OrderException(String message, Throwable cause) { | |
30 | + super(message, cause); | |
31 | + this.code = DEFAULT_CODE; | |
32 | + } | |
33 | + | |
34 | + public OrderException(Throwable cause) { | |
35 | + super(cause); | |
36 | + this.code = DEFAULT_CODE; | |
37 | + } | |
38 | + | |
39 | + public int getCode() { | |
40 | + return code; | |
41 | + } | |
42 | + | |
43 | + public void setCode(int code) { | |
44 | + this.code = code; | |
45 | + } | |
46 | + | |
47 | +} | ... | ... |
src/main/java/com/diligrp/xtrade/order/service/impl/OrderServiceImpl.java
... | ... | @@ -19,7 +19,10 @@ import com.diligrp.xtrade.order.domain.dto.OrderItemDto; |
19 | 19 | import com.diligrp.xtrade.order.domain.dto.OrderRequestDto; |
20 | 20 | import com.diligrp.xtrade.order.domain.dto.OrderResponseDto; |
21 | 21 | import com.diligrp.xtrade.order.domain.emuns.IdGenerator; |
22 | +import com.diligrp.xtrade.order.domain.emuns.OrderStatus; | |
22 | 23 | import com.diligrp.xtrade.order.domain.entity.OrderDo; |
24 | +import com.diligrp.xtrade.order.exception.OrderError; | |
25 | +import com.diligrp.xtrade.order.exception.OrderException; | |
23 | 26 | import com.diligrp.xtrade.order.rpc.feign.AccountResolver; |
24 | 27 | import com.diligrp.xtrade.order.service.OrderService; |
25 | 28 | import com.diligrp.xtrade.shared.domain.Page; |
... | ... | @@ -66,11 +69,18 @@ public class OrderServiceImpl implements OrderService { |
66 | 69 | orderDao.insertEntity(defaultOrderCreator.createOrder()); |
67 | 70 | } |
68 | 71 | |
69 | - | |
72 | + // TODO need modify because of change | |
70 | 73 | @Override |
71 | 74 | public void updateBuyer(OrderRequestDto orderRequestDto) { |
72 | 75 | OrderDo orderDo = orderDao.selectEntityByOrderId(orderRequestDto.getOrderId()); |
73 | - | |
76 | + if (orderDo == null ) { | |
77 | + throw new OrderException(OrderError.ORDER_NOT_EXIST); | |
78 | + } | |
79 | + if (orderDo.getOrderStatus() == OrderStatus.PAIED.getCode()) { | |
80 | + throw new OrderException(OrderError.ORDER_IS_PAIED); | |
81 | + } | |
82 | + AccountDto baccountDto = accountResolver.getAccount(orderRequestDto.getBaccount()); | |
83 | + //TODO | |
74 | 84 | } |
75 | 85 | |
76 | 86 | // TODO need modify because of change | ... | ... |
src/main/java/com/diligrp/xtrade/product/exception/ExceptionEnum.java