Commit 628d2af81535b6371e9f8714dc065067fe9656de

Authored by zhangxing
1 parent f8a64fa5

[modify buyer]

src/main/java/com/diligrp/xtrade/order/domain/emuns/OrderStatus.java
@@ -11,7 +11,9 @@ public enum OrderStatus { @@ -11,7 +11,9 @@ public enum OrderStatus {
11 /** 11 /**
12 * 未支付 12 * 未支付
13 */ 13 */
14 - UNPAIED(1, "未支付"); 14 + UNPAIED(1, "未支付"),
  15 +
  16 + PAIED(3, "未支付");
15 17
16 // 编码 18 // 编码
17 private int code; 19 private int code;
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,7 +19,10 @@ import com.diligrp.xtrade.order.domain.dto.OrderItemDto;
19 import com.diligrp.xtrade.order.domain.dto.OrderRequestDto; 19 import com.diligrp.xtrade.order.domain.dto.OrderRequestDto;
20 import com.diligrp.xtrade.order.domain.dto.OrderResponseDto; 20 import com.diligrp.xtrade.order.domain.dto.OrderResponseDto;
21 import com.diligrp.xtrade.order.domain.emuns.IdGenerator; 21 import com.diligrp.xtrade.order.domain.emuns.IdGenerator;
  22 +import com.diligrp.xtrade.order.domain.emuns.OrderStatus;
22 import com.diligrp.xtrade.order.domain.entity.OrderDo; 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 import com.diligrp.xtrade.order.rpc.feign.AccountResolver; 26 import com.diligrp.xtrade.order.rpc.feign.AccountResolver;
24 import com.diligrp.xtrade.order.service.OrderService; 27 import com.diligrp.xtrade.order.service.OrderService;
25 import com.diligrp.xtrade.shared.domain.Page; 28 import com.diligrp.xtrade.shared.domain.Page;
@@ -66,11 +69,18 @@ public class OrderServiceImpl implements OrderService { @@ -66,11 +69,18 @@ public class OrderServiceImpl implements OrderService {
66 orderDao.insertEntity(defaultOrderCreator.createOrder()); 69 orderDao.insertEntity(defaultOrderCreator.createOrder());
67 } 70 }
68 71
69 - 72 + // TODO need modify because of change
70 @Override 73 @Override
71 public void updateBuyer(OrderRequestDto orderRequestDto) { 74 public void updateBuyer(OrderRequestDto orderRequestDto) {
72 OrderDo orderDo = orderDao.selectEntityByOrderId(orderRequestDto.getOrderId()); 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 // TODO need modify because of change 86 // TODO need modify because of change
src/main/java/com/diligrp/xtrade/product/exception/ExceptionEnum.java
@@ -2,8 +2,6 @@ package com.diligrp.xtrade.product.exception; @@ -2,8 +2,6 @@ package com.diligrp.xtrade.product.exception;
2 2
3 import java.util.Arrays; 3 import java.util.Arrays;
4 4
5 -import javax.validation.constraints.NotBlank;  
6 -  
7 import com.diligrp.xtrade.shared.type.IEnumType; 5 import com.diligrp.xtrade.shared.type.IEnumType;
8 6
9 /** 7 /**