Commit d70f1fe985b72d8986bcdc6e3f4c4ead0c1391e3
1 parent
241c7fa0
增加卖家和买家dao实现,买家资金账户类修改
Showing
26 changed files
with
522 additions
and
165 deletions
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/OrderClient.java
0 → 100644
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/OrderService.java
0 → 100644
1 | +package com.b2c.orders.domain.client; | |
2 | + | |
3 | +import com.b2c.orders.domain.client.dto.request.BuyerCancelRequestDto; | |
4 | +import com.b2c.orders.domain.client.dto.request.BuyerConfirmRequestDto; | |
5 | +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.SellerConfirmRequestDto; | |
8 | +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.TakeOrderRequestDto; | |
11 | +import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; | |
12 | +import com.b2c.orders.domain.client.dto.response.ApiResponse; | |
13 | +import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; | |
14 | + | |
15 | +public interface OrderService { | |
16 | + | |
17 | + /** | |
18 | + * 提交订单 | |
19 | + * | |
20 | + * @param order | |
21 | + * @return | |
22 | + */ | |
23 | + ApiResponse submit(SubmitOrderRequestDto request); | |
24 | + | |
25 | + /** | |
26 | + * 卖家接单 | |
27 | + * | |
28 | + * @param request | |
29 | + * @return | |
30 | + */ | |
31 | + ApiResponse take(TakeOrderRequestDto request); | |
32 | + | |
33 | + /** | |
34 | + * 买家支付订单 | |
35 | + * | |
36 | + * @param request | |
37 | + * @return | |
38 | + */ | |
39 | + ApiResponse pay(PayOrderRequestDto request); | |
40 | + | |
41 | + /** | |
42 | + * 买家确认收货 | |
43 | + * | |
44 | + * @param request | |
45 | + * @return | |
46 | + */ | |
47 | + ApiResponse buyerConfirm(BuyerConfirmRequestDto request); | |
48 | + | |
49 | + /** | |
50 | + * 卖家确认收款 | |
51 | + * | |
52 | + * @param request | |
53 | + * @return | |
54 | + */ | |
55 | + ApiResponse sellerConfirm(SellerConfirmRequestDto request); | |
56 | + | |
57 | + /** | |
58 | + * 卖家拒绝接单 | |
59 | + * | |
60 | + * @param request | |
61 | + * @return | |
62 | + */ | |
63 | + ApiResponse refuse(SellerRefuseRequestDto request); | |
64 | + | |
65 | + /** | |
66 | + * 卖家取消订单 | |
67 | + * | |
68 | + * @param request | |
69 | + * @return | |
70 | + */ | |
71 | + ApiResponse cancel(BuyerCancelRequestDto request); | |
72 | + | |
73 | + /** | |
74 | + * 订单列表 | |
75 | + * | |
76 | + * @param request | |
77 | + * @return | |
78 | + */ | |
79 | + ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request); | |
80 | +} | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/request/SellerRefuseRequestDto.java
... | ... | @@ -17,6 +17,9 @@ public class SellerRefuseRequestDto extends BaseRequestDto { |
17 | 17 | @ApiParam(value = "商家id", required = true) |
18 | 18 | @NotNull(message = "商家id不能为空") |
19 | 19 | private Long sellerId; |
20 | + @ApiParam(value = "拒绝理由", required = true) | |
21 | + @NotNull(message = "请填写拒绝理由") | |
22 | + private String refuseReason; | |
20 | 23 | |
21 | 24 | public Long getOrderId() { |
22 | 25 | return orderId; |
... | ... | @@ -34,4 +37,12 @@ public class SellerRefuseRequestDto extends BaseRequestDto { |
34 | 37 | this.sellerId = sellerId; |
35 | 38 | } |
36 | 39 | |
40 | + public String getRefuseReason() { | |
41 | + return refuseReason; | |
42 | + } | |
43 | + | |
44 | + public void setRefuseReason(String refuseReason) { | |
45 | + this.refuseReason = refuseReason; | |
46 | + } | |
47 | + | |
37 | 48 | } |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/ApiDataResponse.java
0 → 100644
1 | +package com.b2c.orders.domain.client.dto.response; | |
2 | + | |
3 | +public class ApiDataResponse<T> extends ApiResponse { | |
4 | + | |
5 | + /** | |
6 | + * | |
7 | + */ | |
8 | + private static final long serialVersionUID = 70810226755012692L; | |
9 | + | |
10 | + private T data; | |
11 | + | |
12 | + public T getData() { | |
13 | + return data; | |
14 | + } | |
15 | + | |
16 | + public void setData(T data) { | |
17 | + this.data = data; | |
18 | + } | |
19 | + | |
20 | +} | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/ApiPageDataResponse.java
0 → 100644
1 | +package com.b2c.orders.domain.client.dto.response; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +public class ApiPageDataResponse<T> extends ApiResponse { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = 1868245419608300339L; | |
11 | + | |
12 | + /** | |
13 | + * 总页数 | |
14 | + */ | |
15 | + private int totalPage; | |
16 | + | |
17 | + /** | |
18 | + * 总数量 | |
19 | + */ | |
20 | + private int totalSize; | |
21 | + | |
22 | + /** | |
23 | + * 当前页 | |
24 | + */ | |
25 | + private int currentPage; | |
26 | + | |
27 | + /** | |
28 | + * 每页数量 | |
29 | + */ | |
30 | + private int pageSize; | |
31 | + | |
32 | + /** | |
33 | + * 数据集合 | |
34 | + */ | |
35 | + private List<T> list; | |
36 | + | |
37 | + public int getTotalPage() { | |
38 | + return totalPage; | |
39 | + } | |
40 | + | |
41 | + public void setTotalPage(int totalPage) { | |
42 | + this.totalPage = totalPage; | |
43 | + } | |
44 | + | |
45 | + public int getTotalSize() { | |
46 | + return totalSize; | |
47 | + } | |
48 | + | |
49 | + public void setTotalSize(int totalSize) { | |
50 | + this.totalSize = totalSize; | |
51 | + } | |
52 | + | |
53 | + public int getCurrentPage() { | |
54 | + return currentPage; | |
55 | + } | |
56 | + | |
57 | + public void setCurrentPage(int currentPage) { | |
58 | + this.currentPage = currentPage; | |
59 | + } | |
60 | + | |
61 | + public int getPageSize() { | |
62 | + return pageSize; | |
63 | + } | |
64 | + | |
65 | + public void setPageSize(int pageSize) { | |
66 | + this.pageSize = pageSize; | |
67 | + } | |
68 | + | |
69 | + public List<T> getList() { | |
70 | + return list; | |
71 | + } | |
72 | + | |
73 | + public void setList(List<T> list) { | |
74 | + this.list = list; | |
75 | + } | |
76 | + | |
77 | +} | |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/BaseResponseDto.java renamed to b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/ApiResponse.java
... | ... | @@ -2,12 +2,12 @@ package com.b2c.orders.domain.client.dto.response; |
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | |
5 | -public class BaseResponseDto implements Serializable { | |
5 | +public class ApiResponse implements Serializable { | |
6 | 6 | |
7 | 7 | /** |
8 | 8 | * |
9 | 9 | */ |
10 | - private static final long serialVersionUID = -5470014723504375260L; | |
10 | + private static final long serialVersionUID = 8705675193110838708L; | |
11 | 11 | |
12 | 12 | public static final int RESPONSE_CODE_SUCCESS = 1; |
13 | 13 | public static final int RESPONSE_CODE_FAILURE = -1; |
... | ... |
b2c-orders-client/src/main/java/com/b2c/orders/domain/client/dto/response/SubmitOrderResponseDto.java deleted
100644 → 0
b2c-orders-commons/src/main/java/com/b2c/orders/commons/exceptions/BuyerException.java
0 → 100644
1 | +package com.b2c.orders.commons.exceptions; | |
2 | + | |
3 | +public class BuyerException extends ApplicationException { | |
4 | + | |
5 | + /** | |
6 | + * | |
7 | + */ | |
8 | + private static final long serialVersionUID = -1284339481344739428L; | |
9 | + | |
10 | + public BuyerException(int code) { | |
11 | + super(code); | |
12 | + // TODO Auto-generated constructor stub | |
13 | + } | |
14 | + | |
15 | + public BuyerException(int code, String message, Throwable cause, boolean enableSuppression, | |
16 | + boolean writableStackTrace) { | |
17 | + super(code, message, cause, enableSuppression, writableStackTrace); | |
18 | + // TODO Auto-generated constructor stub | |
19 | + } | |
20 | + | |
21 | + public BuyerException(int code, String message, Throwable cause) { | |
22 | + super(code, message, cause); | |
23 | + // TODO Auto-generated constructor stub | |
24 | + } | |
25 | + | |
26 | + public BuyerException(int code, String message) { | |
27 | + super(code, message); | |
28 | + // TODO Auto-generated constructor stub | |
29 | + } | |
30 | + | |
31 | + public BuyerException(int code, Throwable cause) { | |
32 | + super(code, cause); | |
33 | + // TODO Auto-generated constructor stub | |
34 | + } | |
35 | + | |
36 | +} | |
... | ... |
b2c-orders-commons/src/main/java/com/b2c/orders/commons/exceptions/SellerException.java
0 → 100644
1 | +package com.b2c.orders.commons.exceptions; | |
2 | + | |
3 | +public class SellerException extends ApplicationException { | |
4 | + | |
5 | + /** | |
6 | + * | |
7 | + */ | |
8 | + private static final long serialVersionUID = 6187913101076249601L; | |
9 | + | |
10 | + public SellerException(int code) { | |
11 | + super(code); | |
12 | + // TODO Auto-generated constructor stub | |
13 | + } | |
14 | + | |
15 | + public SellerException(int code, String message, Throwable cause, boolean enableSuppression, | |
16 | + boolean writableStackTrace) { | |
17 | + super(code, message, cause, enableSuppression, writableStackTrace); | |
18 | + // TODO Auto-generated constructor stub | |
19 | + } | |
20 | + | |
21 | + public SellerException(int code, String message, Throwable cause) { | |
22 | + super(code, message, cause); | |
23 | + // TODO Auto-generated constructor stub | |
24 | + } | |
25 | + | |
26 | + public SellerException(int code, String message) { | |
27 | + super(code, message); | |
28 | + // TODO Auto-generated constructor stub | |
29 | + } | |
30 | + | |
31 | + public SellerException(int code, Throwable cause) { | |
32 | + super(code, cause); | |
33 | + // TODO Auto-generated constructor stub | |
34 | + } | |
35 | + | |
36 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/BuyerDao.java
1 | 1 | package com.b2c.orders.dao; |
2 | 2 | |
3 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
3 | 4 | import com.b2c.orders.domain.Buyer; |
4 | 5 | |
5 | 6 | public interface BuyerDao { |
6 | 7 | |
7 | - Buyer findByBuyerShopId(Long buyerShopId); | |
8 | + Buyer findByBuyerShopId(Long buyerShopId) throws BuyerException; | |
8 | 9 | } |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/SellerDao.java
1 | 1 | package com.b2c.orders.dao; |
2 | 2 | |
3 | +import com.b2c.orders.commons.exceptions.SellerException; | |
3 | 4 | import com.b2c.orders.domain.Seller; |
4 | 5 | |
5 | 6 | public interface SellerDao { |
6 | 7 | |
7 | - Seller findByBuyerShopId(Long buyerShopId); | |
8 | + Seller findByBuyerShopId(Long buyerShopId) throws SellerException; | |
8 | 9 | } |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/BuyerDaoBean.java
0 → 100644
1 | +package com.b2c.orders.dao.impl; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.stereotype.Repository; | |
5 | + | |
6 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | |
7 | +import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
8 | +import com.b2c.myapp.common.utils.BaseOutput; | |
9 | +import com.b2c.myapp.sdk.MyAppClient; | |
10 | +import com.b2c.myapp.sdk.service.BuyerInfoService; | |
11 | +import com.b2c.myapp.sdk.service.ShopBuyerService; | |
12 | +import com.b2c.orders.commons.exceptions.ApplicationException; | |
13 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
14 | +import com.b2c.orders.dao.BuyerDao; | |
15 | +import com.b2c.orders.domain.Buyer; | |
16 | + | |
17 | +@Repository | |
18 | +public class BuyerDaoBean implements BuyerDao { | |
19 | + | |
20 | + @Autowired | |
21 | + private MyAppClient myAppClient; | |
22 | + | |
23 | + @Override | |
24 | + public Buyer findByBuyerShopId(Long buyerShopId) throws BuyerException { | |
25 | + ShopBuyerService sbs = this.myAppClient.getShopBuyerService(); | |
26 | + BaseOutput<ShopBuyerKeyOutput> response = sbs.getShopBuyerKeys(buyerShopId); | |
27 | + if (response == null || !response.getCode().equals("200")) { | |
28 | + throw new BuyerException(ApplicationException.DATA_EXCEPTION, "获取买家信息失败"); | |
29 | + } | |
30 | + ShopBuyerKeyOutput output = response.getData(); | |
31 | + BuyerInfoService bis = this.myAppClient.getBuyerInfoService(); | |
32 | + BaseOutput<BuyerInfoOutput> bo = bis.getBuyerInfoById(output.getBuyerId()); | |
33 | + if (bo == null || !bo.getCode().equals("200")) { | |
34 | + throw new BuyerException(ApplicationException.DATA_EXCEPTION, "获取买家信息失败"); | |
35 | + } | |
36 | + BuyerInfoOutput bio = bo.getData(); | |
37 | + Buyer buyer = new Buyer(); | |
38 | + buyer.setId(bio.getId()); | |
39 | + buyer.setName(bio.getAccountName()); | |
40 | + buyer.setPhoneNumber(bio.getMobilePhone()); | |
41 | + return buyer; | |
42 | + } | |
43 | + | |
44 | +} | |
... | ... |
b2c-orders-dao/src/main/java/com/b2c/orders/dao/impl/SellerDaoBean.java
0 → 100644
1 | +package com.b2c.orders.dao.impl; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.stereotype.Repository; | |
5 | + | |
6 | +import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | |
7 | +import com.b2c.myapp.common.api.shopBuyer.output.ShopBuyerKeyOutput; | |
8 | +import com.b2c.myapp.common.utils.BaseOutput; | |
9 | +import com.b2c.myapp.sdk.MyAppClient; | |
10 | +import com.b2c.myapp.sdk.service.SellerInfoService; | |
11 | +import com.b2c.myapp.sdk.service.ShopBuyerService; | |
12 | +import com.b2c.orders.commons.exceptions.ApplicationException; | |
13 | +import com.b2c.orders.commons.exceptions.SellerException; | |
14 | +import com.b2c.orders.dao.SellerDao; | |
15 | +import com.b2c.orders.domain.Seller; | |
16 | + | |
17 | +@Repository | |
18 | +public class SellerDaoBean implements SellerDao { | |
19 | + | |
20 | + @Autowired | |
21 | + private MyAppClient myAppClient; | |
22 | + | |
23 | + @Override | |
24 | + public Seller findByBuyerShopId(Long buyerShopId) throws SellerException { | |
25 | + ShopBuyerService sbs = this.myAppClient.getShopBuyerService(); | |
26 | + BaseOutput<ShopBuyerKeyOutput> response = sbs.getShopBuyerKeys(buyerShopId); | |
27 | + if (response == null || !response.getCode().equals("200")) { | |
28 | + throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
29 | + } | |
30 | + ShopBuyerKeyOutput output = response.getData(); | |
31 | + SellerInfoService sis = this.myAppClient.getSellerInfoService(); | |
32 | + BaseOutput<SellerInfoOutput> bo = sis.getSellerInfoById(output.getSellerId()); | |
33 | + if (bo == null || !bo.getCode().equals("200")) { | |
34 | + throw new SellerException(ApplicationException.DATA_EXCEPTION, "获取卖家信息失败"); | |
35 | + } | |
36 | + SellerInfoOutput sio = bo.getData(); | |
37 | + Seller seller = new Seller(); | |
38 | + seller.setId(sio.getId()); | |
39 | + seller.setName(sio.getAccountName()); | |
40 | + return seller; | |
41 | + } | |
42 | + | |
43 | +} | |
... | ... |
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... | ... | @@ -211,11 +211,12 @@ public class Order extends BaseDomain { |
211 | 211 | this.orderStatus = OrderStatus.Completed; |
212 | 212 | } |
213 | 213 | |
214 | - public void refuse() throws OrderException { | |
214 | + public void refuse(String refuseReason) throws OrderException { | |
215 | 215 | if (!this.orderStatus.equals(OrderStatus.PendingTake)) { |
216 | 216 | throw new OrderException(OrderException.ORDER_STATUS_FLOW_EXCEPTION, "当前订单状态不能拒绝接单"); |
217 | 217 | } |
218 | 218 | this.orderStatus = OrderStatus.Refused; |
219 | + this.statusInReason = refuseReason; | |
219 | 220 | } |
220 | 221 | |
221 | 222 | public void cancel() throws OrderException { |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/BuyerManager.java
1 | 1 | package com.b2c.orders.manager; |
2 | 2 | |
3 | +import com.b2c.orders.rpc.param.DebitParam; | |
3 | 4 | import com.b2c.orders.rpc.param.LockBalanceParam; |
5 | +import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
4 | 6 | |
5 | 7 | public interface BuyerManager { |
6 | 8 | |
9 | + /** | |
10 | + * 锁定买家账户余额 | |
11 | + * | |
12 | + * @param | |
13 | + */ | |
7 | 14 | void lockBalance(LockBalanceParam param); |
15 | + | |
16 | + /** | |
17 | + * 买家账户扣款 | |
18 | + * | |
19 | + * @param param | |
20 | + * TODO | |
21 | + */ | |
22 | + void debit(DebitParam param); | |
23 | + | |
24 | + /** | |
25 | + * 解除买家账户锁定 | |
26 | + * | |
27 | + * @param param | |
28 | + * TODO | |
29 | + */ | |
30 | + void unlockBalance(UnlockBalanceParam param); | |
8 | 31 | } |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/OrderManager.java
1 | 1 | package com.b2c.orders.manager; |
2 | 2 | |
3 | 3 | import com.b2c.orders.commons.constant.Constant; |
4 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
4 | 5 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
6 | 7 | import com.b2c.orders.commons.exceptions.ProductException; |
8 | +import com.b2c.orders.commons.exceptions.SellerException; | |
7 | 9 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
8 | 10 | import com.b2c.orders.enums.PayType; |
9 | 11 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
... | ... | @@ -19,8 +21,10 @@ public interface OrderManager { |
19 | 21 | * @throws DtmsRPCException |
20 | 22 | * @throws OrderException |
21 | 23 | * @throws ProductException |
24 | + * @throws SellerException | |
25 | + * @throws BuyerException | |
22 | 26 | */ |
23 | - void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException; | |
27 | + void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
24 | 28 | |
25 | 29 | /** |
26 | 30 | * 接单 |
... | ... | @@ -85,10 +89,11 @@ public interface OrderManager { |
85 | 89 | * 订单id |
86 | 90 | * @param shopBuyerId |
87 | 91 | * 商家id |
92 | + * @param refuseReason TODO | |
88 | 93 | * @throws OrderRepositoryException |
89 | 94 | * @throws OrderException |
90 | 95 | */ |
91 | - void refuse(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException; | |
96 | + void refuse(Long orderId, Long shopBuyerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
92 | 97 | |
93 | 98 | /** |
94 | 99 | * 取消订单 |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/impl/BuyerAccountServiceBean.java renamed to b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/BuyerManagerBean.java
1 | -package com.b2c.orders.rpc.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 | 4 | import org.springframework.cglib.beans.BeanCopier; |
5 | +import org.springframework.stereotype.Component; | |
6 | 6 | |
7 | 7 | import com.b2c.myapp.common.api.foundTrade.input.FoundTradeInput; |
8 | +import com.b2c.myapp.common.api.foundTrade.input.FoundTradeSaveInput; | |
8 | 9 | import com.b2c.myapp.common.enums.TradeType; |
9 | 10 | import com.b2c.myapp.sdk.MyAppClient; |
10 | -import com.b2c.myapp.sdk.service.FoundTradeService; | |
11 | -import com.b2c.orders.rpc.BuyerAccountService; | |
11 | +import com.b2c.orders.manager.BuyerManager; | |
12 | 12 | import com.b2c.orders.rpc.param.DebitParam; |
13 | 13 | import com.b2c.orders.rpc.param.LockBalanceParam; |
14 | 14 | import com.b2c.orders.rpc.param.UnlockBalanceParam; |
15 | 15 | |
16 | -public class BuyerAccountServiceBean implements BuyerAccountService { | |
17 | - | |
18 | - private static final Logger LOG = LoggerFactory.getLogger(BuyerAccountServiceBean.class); | |
16 | +@Component | |
17 | +public class BuyerManagerBean implements BuyerManager { | |
19 | 18 | |
19 | + @Autowired | |
20 | 20 | private MyAppClient myAppClient; |
21 | - private FoundTradeService tradeService; | |
22 | - | |
23 | - public BuyerAccountServiceBean(String baseUrl, String token) { | |
24 | - this.myAppClient = new MyAppClient(token, baseUrl); | |
25 | - this.tradeService = this.myAppClient.getFoundTradeService(); | |
26 | - } | |
27 | 21 | |
28 | 22 | @Override |
29 | 23 | public void lockBalance(LockBalanceParam param) { |
30 | - FoundTradeInput rpcParam = new FoundTradeInput(); | |
24 | + FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
31 | 25 | BeanCopier copier = BeanCopier.create(LockBalanceParam.class, FoundTradeInput.class, false); |
32 | 26 | copier.copy(param, rpcParam, null); |
33 | 27 | rpcParam.setTradeType(TradeType.Freeze); |
34 | - this.tradeService.foundTrade(rpcParam); | |
28 | + this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
35 | 29 | } |
36 | 30 | |
37 | 31 | @Override |
38 | 32 | public void debit(DebitParam param) { |
33 | + FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
39 | 34 | BeanCopier copier = BeanCopier.create(DebitParam.class, FoundTradeInput.class, false); |
40 | - FoundTradeInput rpcParam = new FoundTradeInput(); | |
41 | 35 | copier.copy(param, rpcParam, null); |
42 | 36 | rpcParam.setTradeType(TradeType.Consume); |
43 | - this.tradeService.foundTrade(rpcParam); | |
37 | + this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
44 | 38 | } |
45 | 39 | |
46 | 40 | @Override |
47 | 41 | public void unlockBalance(UnlockBalanceParam param) { |
42 | + FoundTradeSaveInput rpcParam = new FoundTradeSaveInput(); | |
48 | 43 | BeanCopier copier = BeanCopier.create(UnlockBalanceParam.class, FoundTradeInput.class, false); |
49 | - FoundTradeInput rpcParam = new FoundTradeInput(); | |
50 | 44 | copier.copy(param, rpcParam, null); |
51 | 45 | rpcParam.setTradeType(TradeType.Unfreeze); |
52 | - this.tradeService.foundTrade(rpcParam); | |
46 | + this.myAppClient.getFoundTradeService().foundTrade(rpcParam); | |
53 | 47 | } |
54 | 48 | |
55 | 49 | } |
... | ... |
b2c-orders-manager/src/main/java/com/b2c/orders/manager/impl/OrderManagerBean.java
... | ... | @@ -15,9 +15,11 @@ import org.springframework.transaction.annotation.Propagation; |
15 | 15 | import org.springframework.transaction.annotation.Transactional; |
16 | 16 | |
17 | 17 | import com.b2c.orders.commons.exceptions.ApplicationException; |
18 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
18 | 19 | import com.b2c.orders.commons.exceptions.OrderException; |
19 | 20 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
20 | 21 | import com.b2c.orders.commons.exceptions.ProductException; |
22 | +import com.b2c.orders.commons.exceptions.SellerException; | |
21 | 23 | import com.b2c.orders.commons.utils.OrderIdGenerator; |
22 | 24 | import com.b2c.orders.dao.BuyerDao; |
23 | 25 | import com.b2c.orders.dao.OrderDao; |
... | ... | @@ -40,11 +42,14 @@ import com.b2c.orders.enums.OrderStatus; |
40 | 42 | import com.b2c.orders.enums.PayStatus; |
41 | 43 | import com.b2c.orders.enums.PayType; |
42 | 44 | import com.b2c.orders.enums.UserType; |
45 | +import com.b2c.orders.manager.BuyerManager; | |
43 | 46 | import com.b2c.orders.manager.OrderManager; |
44 | 47 | import com.b2c.orders.rpc.BuyerAccountService; |
45 | 48 | import com.b2c.orders.rpc.DtmsRPCService; |
46 | 49 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
50 | +import com.b2c.orders.rpc.param.DebitParam; | |
47 | 51 | import com.b2c.orders.rpc.param.LockBalanceParam; |
52 | +import com.b2c.orders.rpc.param.UnlockBalanceParam; | |
48 | 53 | import com.diligrp.website.util.dao.BaseQuery; |
49 | 54 | import com.diligrp.website.util.web.PageTemplate; |
50 | 55 | |
... | ... | @@ -72,9 +77,12 @@ public class OrderManagerBean implements OrderManager { |
72 | 77 | private SellerDao sellerDao; |
73 | 78 | @Autowired |
74 | 79 | private ShopDao shopDao; |
80 | + @Autowired | |
81 | + private BuyerManager buyerManager; | |
75 | 82 | |
76 | 83 | @Override |
77 | - public void submit(SubmitOrderRequestDto orderVo) throws DtmsRPCException, OrderException, ProductException { | |
84 | + public void submit(SubmitOrderRequestDto orderVo) | |
85 | + throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException { | |
78 | 86 | Order po = new Order(); |
79 | 87 | try { |
80 | 88 | Long orderId = idGenerator.getOrdersNewSeqNo(); |
... | ... | @@ -192,14 +200,11 @@ public class OrderManagerBean implements OrderManager { |
192 | 200 | this.dtmsService.sendOrderConfirmDtms(orderId); |
193 | 201 | if (payType.equals(PayType.Online)) { |
194 | 202 | LockBalanceParam param = new LockBalanceParam(); |
195 | - param.setBuyerId(po.getBuyer().getId()); | |
196 | 203 | param.setOrderId(orderId); |
197 | - param.setSellerId(po.getSeller().getId()); | |
198 | 204 | param.setShopBuyerId(shopBuyerId); |
199 | - param.setShopId(po.getShop().getId()); | |
200 | 205 | param.setTradeName(po.getTradeName()); |
201 | 206 | param.setTradePrice(po.getRealTotalPrice()); |
202 | - this.userAccountService.lockBalance(param); | |
207 | + this.buyerManager.lockBalance(param); | |
203 | 208 | } |
204 | 209 | } |
205 | 210 | |
... | ... | @@ -224,7 +229,12 @@ public class OrderManagerBean implements OrderManager { |
224 | 229 | log.setUserId(shopBuyerId); |
225 | 230 | log.setUserType(UserType.BUYER); |
226 | 231 | this.orderLogDao.save(log); |
227 | - this.userAccountService.debit(null); | |
232 | + DebitParam param = new DebitParam(); | |
233 | + param.setOrderId(po.getId()); | |
234 | + param.setShopBuyerId(shopBuyerId); | |
235 | + param.setTradeName(po.getTradeName()); | |
236 | + param.setTradePrice(po.getRealTotalPrice()); | |
237 | + this.buyerManager.debit(param); | |
228 | 238 | } |
229 | 239 | |
230 | 240 | @Override |
... | ... | @@ -248,23 +258,28 @@ public class OrderManagerBean implements OrderManager { |
248 | 258 | log.setUserId(po.getSeller().getId()); |
249 | 259 | log.setUserType(UserType.SELLER); |
250 | 260 | this.orderLogDao.save(log); |
251 | - this.userAccountService.debit(null); | |
261 | + DebitParam param = new DebitParam(); | |
262 | + param.setOrderId(po.getId()); | |
263 | + param.setShopBuyerId(shopBuyerId); | |
264 | + param.setTradeName(po.getTradeName()); | |
265 | + param.setTradePrice(po.getRealTotalPrice()); | |
266 | + this.buyerManager.debit(param); | |
252 | 267 | } |
253 | 268 | |
254 | 269 | @Override |
255 | - public void refuse(Long orderId, Long shopBuyerId) throws OrderRepositoryException, OrderException { | |
270 | + public void refuse(Long orderId, Long shopBuyerId, String refuseReason) throws OrderRepositoryException, OrderException { | |
256 | 271 | Order po = this.orderDao.getById(orderId); |
257 | 272 | if (po == null) { |
258 | 273 | throw new OrderRepositoryException(OrderRepositoryException.ENTITY_NOT_FOUND, |
259 | 274 | String.format("未找到id为%s的订单", orderId)); |
260 | 275 | } |
261 | - if (po.getSellerId() == null) { | |
276 | + if (po.getSeller().getId() == null) { | |
262 | 277 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "卖家信息不存在"); |
263 | 278 | } |
264 | - if (!po.getSellerId().equals(shopBuyerId)) { | |
279 | + if (!po.getSeller().getId().equals(shopBuyerId)) { | |
265 | 280 | throw new OrderException(ApplicationException.DATA_EXCEPTION, "订单的卖家信息不符,不能接单"); |
266 | 281 | } |
267 | - po.refuse(); | |
282 | + po.refuse(refuseReason); | |
268 | 283 | this.orderDao.update(po); |
269 | 284 | OrderLog log = new OrderLog(); |
270 | 285 | log.setAction(Action.SELLER_REFUSE); |
... | ... | @@ -297,7 +312,8 @@ public class OrderManagerBean implements OrderManager { |
297 | 312 | log.setDescription("买家取消订单"); |
298 | 313 | this.orderLogDao.save(log); |
299 | 314 | if (po.getPayStatus().equals(PayStatus.Paid)) { |
300 | - this.userAccountService.unlockBalance(null); | |
315 | + UnlockBalanceParam param=new UnlockBalanceParam(); | |
316 | + this.buyerManager.unlockBalance(param); | |
301 | 317 | } |
302 | 318 | } |
303 | 319 | |
... | ... |
b2c-orders-rpc/pom.xml
... | ... | @@ -34,6 +34,16 @@ |
34 | 34 | <dependency> |
35 | 35 | <groupId>com.b2c.myapp</groupId> |
36 | 36 | <artifactId>myapp-sdk</artifactId> |
37 | + <exclusions> | |
38 | + <exclusion> | |
39 | + <groupId>org.apache.velocity</groupId> | |
40 | + <artifactId>velocity</artifactId> | |
41 | + </exclusion> | |
42 | + <exclusion> | |
43 | + <groupId>velocity</groupId> | |
44 | + <artifactId>velocity-dep</artifactId> | |
45 | + </exclusion> | |
46 | + </exclusions> | |
37 | 47 | </dependency> |
38 | 48 | </dependencies> |
39 | 49 | </project> |
40 | 50 | \ No newline at end of file |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/DebitParam.java
1 | 1 | package com.b2c.orders.rpc.param; |
2 | 2 | |
3 | -public class DebitParam { | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class DebitParam implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = -2191626927881743493L; | |
4 | 11 | |
5 | 12 | private Long shopBuyerId; |
6 | - private Long buyerId; | |
7 | - private Long sellerId; | |
8 | - private Long shopId; | |
9 | 13 | private Long orderId; |
10 | 14 | private String tradeName; |
11 | 15 | private String remark; |
... | ... | @@ -19,30 +23,6 @@ public class DebitParam { |
19 | 23 | this.shopBuyerId = shopBuyerId; |
20 | 24 | } |
21 | 25 | |
22 | - public Long getBuyerId() { | |
23 | - return buyerId; | |
24 | - } | |
25 | - | |
26 | - public void setBuyerId(Long buyerId) { | |
27 | - this.buyerId = buyerId; | |
28 | - } | |
29 | - | |
30 | - public Long getSellerId() { | |
31 | - return sellerId; | |
32 | - } | |
33 | - | |
34 | - public void setSellerId(Long sellerId) { | |
35 | - this.sellerId = sellerId; | |
36 | - } | |
37 | - | |
38 | - public Long getShopId() { | |
39 | - return shopId; | |
40 | - } | |
41 | - | |
42 | - public void setShopId(Long shopId) { | |
43 | - this.shopId = shopId; | |
44 | - } | |
45 | - | |
46 | 26 | public Long getOrderId() { |
47 | 27 | return orderId; |
48 | 28 | } |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/LockBalanceParam.java
1 | 1 | package com.b2c.orders.rpc.param; |
2 | 2 | |
3 | -public class LockBalanceParam { | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class LockBalanceParam implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = 4192689726397131081L; | |
4 | 11 | |
5 | 12 | private Long shopBuyerId; |
6 | - private Long buyerId; | |
7 | - private Long sellerId; | |
8 | - private Long shopId; | |
9 | 13 | private Long orderId; |
10 | 14 | private String tradeName; |
11 | 15 | private String remark; |
... | ... | @@ -19,30 +23,6 @@ public class LockBalanceParam { |
19 | 23 | this.shopBuyerId = shopBuyerId; |
20 | 24 | } |
21 | 25 | |
22 | - public Long getBuyerId() { | |
23 | - return buyerId; | |
24 | - } | |
25 | - | |
26 | - public void setBuyerId(Long buyerId) { | |
27 | - this.buyerId = buyerId; | |
28 | - } | |
29 | - | |
30 | - public Long getSellerId() { | |
31 | - return sellerId; | |
32 | - } | |
33 | - | |
34 | - public void setSellerId(Long sellerId) { | |
35 | - this.sellerId = sellerId; | |
36 | - } | |
37 | - | |
38 | - public Long getShopId() { | |
39 | - return shopId; | |
40 | - } | |
41 | - | |
42 | - public void setShopId(Long shopId) { | |
43 | - this.shopId = shopId; | |
44 | - } | |
45 | - | |
46 | 26 | public Long getOrderId() { |
47 | 27 | return orderId; |
48 | 28 | } |
... | ... | @@ -74,4 +54,5 @@ public class LockBalanceParam { |
74 | 54 | public void setTradePrice(Long tradePrice) { |
75 | 55 | this.tradePrice = tradePrice; |
76 | 56 | } |
57 | + | |
77 | 58 | } |
... | ... |
b2c-orders-rpc/src/main/java/com/b2c/orders/rpc/param/UnlockBalanceParam.java
1 | 1 | package com.b2c.orders.rpc.param; |
2 | 2 | |
3 | -public class UnlockBalanceParam { | |
3 | +import java.io.Serializable; | |
4 | + | |
5 | +public class UnlockBalanceParam implements Serializable { | |
6 | + | |
7 | + /** | |
8 | + * | |
9 | + */ | |
10 | + private static final long serialVersionUID = -6620857066922902348L; | |
4 | 11 | |
5 | 12 | private Long shopBuyerId; |
6 | - private Long buyerId; | |
7 | - private Long sellerId; | |
8 | - private Long shopId; | |
9 | 13 | private Long orderId; |
10 | 14 | private String tradeName; |
11 | 15 | private String remark; |
... | ... | @@ -19,30 +23,6 @@ public class UnlockBalanceParam { |
19 | 23 | this.shopBuyerId = shopBuyerId; |
20 | 24 | } |
21 | 25 | |
22 | - public Long getBuyerId() { | |
23 | - return buyerId; | |
24 | - } | |
25 | - | |
26 | - public void setBuyerId(Long buyerId) { | |
27 | - this.buyerId = buyerId; | |
28 | - } | |
29 | - | |
30 | - public Long getSellerId() { | |
31 | - return sellerId; | |
32 | - } | |
33 | - | |
34 | - public void setSellerId(Long sellerId) { | |
35 | - this.sellerId = sellerId; | |
36 | - } | |
37 | - | |
38 | - public Long getShopId() { | |
39 | - return shopId; | |
40 | - } | |
41 | - | |
42 | - public void setShopId(Long shopId) { | |
43 | - this.shopId = shopId; | |
44 | - } | |
45 | - | |
46 | 26 | public Long getOrderId() { |
47 | 27 | return orderId; |
48 | 28 | } |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/OrderService.java
1 | 1 | package com.b2c.orders.service; |
2 | 2 | |
3 | 3 | import com.b2c.orders.commons.constant.Constant; |
4 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
4 | 5 | import com.b2c.orders.commons.exceptions.OrderException; |
5 | 6 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
7 | +import com.b2c.orders.commons.exceptions.ProductException; | |
8 | +import com.b2c.orders.commons.exceptions.SellerException; | |
6 | 9 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
7 | 10 | import com.b2c.orders.enums.PayType; |
8 | 11 | import com.b2c.orders.rpc.exception.DtmsRPCException; |
... | ... | @@ -18,8 +21,11 @@ public interface OrderService { |
18 | 21 | * 订单id |
19 | 22 | * @throws DtmsRPCException |
20 | 23 | * @throws OrderException |
24 | + * @throws ProductException | |
25 | + * @throws BuyerException | |
26 | + * @throws SellerException | |
21 | 27 | */ |
22 | - void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException; | |
28 | + void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException; | |
23 | 29 | |
24 | 30 | /** |
25 | 31 | * 商家接单 |
... | ... | @@ -84,10 +90,11 @@ public interface OrderService { |
84 | 90 | * 订单id |
85 | 91 | * @param sellerId |
86 | 92 | * 商家id |
93 | + * @param refuseReason TODO | |
87 | 94 | * @throws OrderException |
88 | 95 | * @throws OrderRepositoryException |
89 | 96 | */ |
90 | - void refuse(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException; | |
97 | + void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException; | |
91 | 98 | |
92 | 99 | /** |
93 | 100 | * 买家取消订单 |
... | ... |
b2c-orders-service/src/main/java/com/b2c/orders/service/impl/OrderServiceBean.java
... | ... | @@ -8,8 +8,11 @@ import org.springframework.transaction.annotation.Propagation; |
8 | 8 | import org.springframework.transaction.annotation.Transactional; |
9 | 9 | |
10 | 10 | import com.b2c.orders.commons.exceptions.ApplicationException; |
11 | +import com.b2c.orders.commons.exceptions.BuyerException; | |
11 | 12 | import com.b2c.orders.commons.exceptions.OrderException; |
12 | 13 | import com.b2c.orders.commons.exceptions.OrderRepositoryException; |
14 | +import com.b2c.orders.commons.exceptions.ProductException; | |
15 | +import com.b2c.orders.commons.exceptions.SellerException; | |
13 | 16 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
14 | 17 | import com.b2c.orders.enums.PayType; |
15 | 18 | import com.b2c.orders.manager.OrderManager; |
... | ... | @@ -28,7 +31,7 @@ public class OrderServiceBean implements OrderService { |
28 | 31 | private OrderManager orderManager; |
29 | 32 | |
30 | 33 | @Override |
31 | - public void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException { | |
34 | + public void submit(SubmitOrderRequestDto order) throws DtmsRPCException, OrderException, ProductException, SellerException, BuyerException { | |
32 | 35 | this.orderManager.submit(order); |
33 | 36 | } |
34 | 37 | |
... | ... | @@ -55,8 +58,8 @@ public class OrderServiceBean implements OrderService { |
55 | 58 | } |
56 | 59 | |
57 | 60 | @Override |
58 | - public void refuse(Long orderId, Long sellerId) throws OrderRepositoryException, OrderException { | |
59 | - this.orderManager.refuse(orderId, sellerId); | |
61 | + public void refuse(Long orderId, Long sellerId, String refuseReason) throws OrderRepositoryException, OrderException { | |
62 | + this.orderManager.refuse(orderId, sellerId, refuseReason); | |
60 | 63 | } |
61 | 64 | |
62 | 65 | @Override |
... | ... |
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
... | ... | @@ -30,11 +30,10 @@ import com.b2c.orders.domain.client.dto.request.SellerConfirmRequestDto; |
30 | 30 | import com.b2c.orders.domain.client.dto.request.SellerRefuseRequestDto; |
31 | 31 | import com.b2c.orders.domain.client.dto.request.SubmitOrderRequestDto; |
32 | 32 | import com.b2c.orders.domain.client.dto.request.TakeOrderRequestDto; |
33 | -import com.b2c.orders.domain.client.dto.response.BaseResponseDto; | |
33 | +import com.b2c.orders.domain.client.dto.response.ApiPageDataResponse; | |
34 | +import com.b2c.orders.domain.client.dto.response.ApiResponse; | |
34 | 35 | import com.b2c.orders.domain.client.dto.response.OrderItemResponseDto; |
35 | 36 | import com.b2c.orders.domain.client.dto.response.OrderListResponseDto; |
36 | -import com.b2c.orders.domain.client.dto.response.PageResponseDto; | |
37 | -import com.b2c.orders.domain.client.dto.response.SubmitOrderResponseDto; | |
38 | 37 | import com.b2c.orders.enums.PayType; |
39 | 38 | import com.b2c.orders.service.OrderService; |
40 | 39 | import com.diligrp.website.util.dao.BaseQuery; |
... | ... | @@ -56,11 +55,11 @@ public class OrderRestController { |
56 | 55 | |
57 | 56 | @ApiOperation("提交订单") |
58 | 57 | @RequestMapping(value = "/submit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
59 | - public SubmitOrderResponseDto submit(@RequestBody @Valid SubmitOrderRequestDto order, BindingResult br) { | |
60 | - SubmitOrderResponseDto dto = new SubmitOrderResponseDto(); | |
58 | + public ApiResponse submit(@RequestBody @Valid SubmitOrderRequestDto order, BindingResult br) { | |
59 | + ApiResponse dto = new ApiResponse(); | |
61 | 60 | try { |
62 | 61 | this.orderService.submit(order); |
63 | - dto.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
62 | + dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
64 | 63 | dto.setSuccess(true); |
65 | 64 | } catch (ApplicationException e) { |
66 | 65 | dto.setMessage(e.getMessage()); |
... | ... | @@ -70,11 +69,11 @@ public class OrderRestController { |
70 | 69 | |
71 | 70 | @ApiOperation("商家接单") |
72 | 71 | @RequestMapping(value = "/take", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
73 | - public BaseResponseDto take(@RequestBody @Valid TakeOrderRequestDto request, BindingResult br) { | |
74 | - BaseResponseDto dto = new BaseResponseDto(); | |
72 | + public ApiResponse take(@RequestBody @Valid TakeOrderRequestDto request, BindingResult br) { | |
73 | + ApiResponse dto = new ApiResponse(); | |
75 | 74 | try { |
76 | 75 | this.orderService.take(request.getOrderId(), request.getSellerId(), request.getTotalPrice()); |
77 | - dto.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
76 | + dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
78 | 77 | dto.setSuccess(true); |
79 | 78 | } catch (ApplicationException e) { |
80 | 79 | dto.setMessage(e.getMessage()); |
... | ... | @@ -84,11 +83,11 @@ public class OrderRestController { |
84 | 83 | |
85 | 84 | @ApiOperation("买家支付") |
86 | 85 | @RequestMapping(value = "/pay", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
87 | - public BaseResponseDto pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { | |
88 | - BaseResponseDto dto = new BaseResponseDto(); | |
86 | + public ApiResponse pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) { | |
87 | + ApiResponse dto = new ApiResponse(); | |
89 | 88 | try { |
90 | 89 | this.orderService.pay(request.getOrderId(), request.getBuyerId(), PayType.getPayType(request.getPayType())); |
91 | - dto.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
90 | + dto.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
92 | 91 | dto.setSuccess(true); |
93 | 92 | } catch (ApplicationException e) { |
94 | 93 | dto.setMessage(e.getMessage()); |
... | ... | @@ -98,11 +97,11 @@ public class OrderRestController { |
98 | 97 | |
99 | 98 | @ApiOperation("买家确认收货") |
100 | 99 | @RequestMapping(value = "/buyerConfirm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
101 | - public BaseResponseDto buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) { | |
102 | - BaseResponseDto response = new BaseResponseDto(); | |
100 | + public ApiResponse buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) { | |
101 | + ApiResponse response = new ApiResponse(); | |
103 | 102 | try { |
104 | 103 | this.orderService.buyerConfirm(request.getOrderId(), request.getBuyerId()); |
105 | - response.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
104 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
106 | 105 | response.setSuccess(true); |
107 | 106 | } catch (ApplicationException e) { |
108 | 107 | response.setMessage(e.getMessage()); |
... | ... | @@ -112,11 +111,11 @@ public class OrderRestController { |
112 | 111 | |
113 | 112 | @ApiOperation("商家确认收款") |
114 | 113 | @RequestMapping(value = "/sellerConfirm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
115 | - public BaseResponseDto sellerConfirm(@RequestBody @Valid SellerConfirmRequestDto request, BindingResult br) { | |
116 | - BaseResponseDto response = new BaseResponseDto(); | |
114 | + public ApiResponse sellerConfirm(@RequestBody @Valid SellerConfirmRequestDto request, BindingResult br) { | |
115 | + ApiResponse response = new ApiResponse(); | |
117 | 116 | try { |
118 | 117 | this.orderService.sellerConfirm(request.getOrderId(), request.getSellerId()); |
119 | - response.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
118 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
120 | 119 | response.setSuccess(true); |
121 | 120 | } catch (ApplicationException e) { |
122 | 121 | response.setMessage(e.getMessage()); |
... | ... | @@ -139,11 +138,11 @@ public class OrderRestController { |
139 | 138 | |
140 | 139 | @ApiOperation("商家拒绝接单") |
141 | 140 | @RequestMapping(value = "/refuse", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
142 | - public BaseResponseDto sellerRefuse(@RequestBody @Valid SellerRefuseRequestDto request, BindingResult br) { | |
143 | - BaseResponseDto response = new BaseResponseDto(); | |
141 | + public ApiResponse sellerRefuse(@RequestBody @Valid SellerRefuseRequestDto request, BindingResult br) { | |
142 | + ApiResponse response = new ApiResponse(); | |
144 | 143 | try { |
145 | - this.orderService.refuse(request.getOrderId(), request.getSellerId()); | |
146 | - response.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
144 | + this.orderService.refuse(request.getOrderId(), request.getSellerId(), request.getRefuseReason()); | |
145 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
147 | 146 | response.setSuccess(true); |
148 | 147 | } catch (ApplicationException e) { |
149 | 148 | response.setMessage(e.getMessage()); |
... | ... | @@ -153,11 +152,11 @@ public class OrderRestController { |
153 | 152 | |
154 | 153 | @ApiOperation("买家取消订单") |
155 | 154 | @RequestMapping(value = "/cancel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
156 | - public BaseResponseDto buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) { | |
157 | - BaseResponseDto response = new BaseResponseDto(); | |
155 | + public ApiResponse buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) { | |
156 | + ApiResponse response = new ApiResponse(); | |
158 | 157 | try { |
159 | 158 | this.orderService.cancel(request.getOrderId(), request.getBuyerId()); |
160 | - response.setCode(BaseResponseDto.RESPONSE_CODE_SUCCESS); | |
159 | + response.setCode(ApiResponse.RESPONSE_CODE_SUCCESS); | |
161 | 160 | response.setSuccess(true); |
162 | 161 | } catch (ApplicationException e) { |
163 | 162 | response.setMessage(e.getMessage()); |
... | ... | @@ -193,10 +192,10 @@ public class OrderRestController { |
193 | 192 | |
194 | 193 | @ApiOperation("查询订单") |
195 | 194 | @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) |
196 | - public PageResponseDto<OrderListResponseDto> list(OrderListRequestDto request) { | |
195 | + public ApiPageDataResponse<OrderListResponseDto> list(OrderListRequestDto request) { | |
197 | 196 | BaseQuery query = this.buildQuery(request); |
198 | 197 | PageTemplate page = this.orderService.list(query); |
199 | - PageResponseDto<OrderListResponseDto> pageResponse = new PageResponseDto<>(); | |
198 | + ApiPageDataResponse<OrderListResponseDto> pageResponse = new ApiPageDataResponse<>(); | |
200 | 199 | pageResponse.setCurrentPage(page.getCurrPage()); |
201 | 200 | pageResponse.setPageSize(page.getPageSize()); |
202 | 201 | pageResponse.setTotalPage(page.getTotalPage()); |
... | ... |
pom.xml
... | ... | @@ -189,6 +189,12 @@ |
189 | 189 | <groupId>com.b2c.myapp</groupId> |
190 | 190 | <artifactId>myapp-common</artifactId> |
191 | 191 | <version>1.0-SNAPSHOT</version> |
192 | + <exclusions> | |
193 | + <exclusion> | |
194 | + <groupId>velocity</groupId> | |
195 | + <artifactId>velocity-dep</artifactId> | |
196 | + </exclusion> | |
197 | + </exclusions> | |
192 | 198 | </dependency> |
193 | 199 | <dependency> |
194 | 200 | <groupId>com.b2c.myapp</groupId> |
... | ... |