1
|
package com.yohoufo.order.service.impl;
|
1
|
package com.yohoufo.order.service.impl;
|
2
|
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
3
|
import com.yoho.error.ServiceError;
|
4
|
import com.yoho.error.ServiceError;
|
4
|
import com.yoho.error.exception.ServiceException;
|
5
|
import com.yoho.error.exception.ServiceException;
|
|
|
6
|
+import com.yoho.service.model.response.UserAddressRspBO;
|
5
|
import com.yohoufo.common.utils.DateUtil;
|
7
|
import com.yohoufo.common.utils.DateUtil;
|
6
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
8
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
7
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
9
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
|
@@ -12,11 +14,13 @@ import com.yohoufo.order.common.Payment; |
|
@@ -12,11 +14,13 @@ import com.yohoufo.order.common.Payment; |
12
|
import com.yohoufo.order.common.TabType;
|
14
|
import com.yohoufo.order.common.TabType;
|
13
|
import com.yohoufo.order.constants.MetaKey;
|
15
|
import com.yohoufo.order.constants.MetaKey;
|
14
|
import com.yohoufo.order.constants.OrderConstant;
|
16
|
import com.yohoufo.order.constants.OrderConstant;
|
|
|
17
|
+import com.yohoufo.order.convert.AddressInfoConvertor;
|
15
|
import com.yohoufo.order.model.AddressInfo;
|
18
|
import com.yohoufo.order.model.AddressInfo;
|
16
|
import com.yohoufo.order.model.request.OrderRequest;
|
19
|
import com.yohoufo.order.model.request.OrderRequest;
|
17
|
import com.yohoufo.order.model.response.GoodsInfo;
|
20
|
import com.yohoufo.order.model.response.GoodsInfo;
|
18
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
21
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
19
|
import com.yohoufo.order.service.IOrderDetailService;
|
22
|
import com.yohoufo.order.service.IOrderDetailService;
|
|
|
23
|
+import org.apache.commons.lang3.StringUtils;
|
20
|
import org.slf4j.Logger;
|
24
|
import org.slf4j.Logger;
|
21
|
import org.slf4j.LoggerFactory;
|
25
|
import org.slf4j.LoggerFactory;
|
22
|
|
26
|
|
|
@@ -51,11 +55,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
@@ -51,11 +55,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
51
|
}
|
55
|
}
|
52
|
|
56
|
|
53
|
TabType actor = orderRequest.getActor();
|
57
|
TabType actor = orderRequest.getActor();
|
54
|
- if (actor == null){
|
|
|
55
|
- logger.warn("getOrderDetail tabType invalidate, uid is {}, orderCode is {}",
|
|
|
56
|
- orderRequest.getUid(), orderRequest.getOrderCode());
|
|
|
57
|
- throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
58
|
- }
|
58
|
+ boolean isBuyer = actor.equals(TabType.BUY);
|
59
|
|
59
|
|
60
|
// 查询订单状态
|
60
|
// 查询订单状态
|
61
|
BuyerOrder buyerOrder = getBuyerOrder(orderRequest.getUid(), orderRequest.getOrderCode());
|
61
|
BuyerOrder buyerOrder = getBuyerOrder(orderRequest.getUid(), orderRequest.getOrderCode());
|
|
@@ -74,9 +74,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
@@ -74,9 +74,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
74
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
74
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
75
|
}
|
75
|
}
|
76
|
|
76
|
|
77
|
- // 收货地址 and 用户信息 TODO
|
|
|
78
|
- BuyerOrderMeta buyerOrderMeta = getBuyerOrderMeta(buyerUid,
|
|
|
79
|
- orderRequest.getOrderCode(), MetaKey.BUYER_DELIVERY_ADDRESS);
|
77
|
+
|
80
|
|
78
|
|
81
|
BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(buyerUid, orderRequest.getOrderCode());
|
79
|
BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(buyerUid, orderRequest.getOrderCode());
|
82
|
if (buyerOrderGoods == null){
|
80
|
if (buyerOrderGoods == null){
|
|
@@ -91,16 +89,24 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
@@ -91,16 +89,24 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
91
|
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrderGoods.getSkup());
|
89
|
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrderGoods.getSkup());
|
92
|
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
|
90
|
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
|
93
|
}
|
91
|
}
|
94
|
-
|
|
|
95
|
- OrderDetailInfo orderDetailInfo = buildOrderDetail(buyerOrder, orderStatus, buyerOrderGoods, sellerOrderGoods, actor);
|
92
|
+ // 收货地址 and 用户信息
|
|
|
93
|
+ BuyerOrderMeta buyerOrderMeta = getBuyerOrderMeta(buyerUid,
|
|
|
94
|
+ orderRequest.getOrderCode(), MetaKey.BUYER_DELIVERY_ADDRESS);
|
|
|
95
|
+ AddressInfo userAddress = null;
|
|
|
96
|
+ if (isBuyer && null != buyerOrderMeta && StringUtils.isNotBlank(buyerOrderMeta.getMetaValue())){
|
|
|
97
|
+ UserAddressRspBO addressRsp = JSONObject.parseObject(buyerOrderMeta.getMetaValue(), UserAddressRspBO.class);
|
|
|
98
|
+ userAddress = AddressInfoConvertor.userAddressRsp2AddressInfo(addressRsp);
|
|
|
99
|
+ }
|
|
|
100
|
+ OrderDetailInfo orderDetailInfo = buildOrderDetail(buyerOrder, orderStatus, buyerOrderGoods, sellerOrderGoods,
|
|
|
101
|
+ userAddress, actor);
|
96
|
|
102
|
|
97
|
return orderDetailInfo;
|
103
|
return orderDetailInfo;
|
98
|
|
104
|
|
99
|
}
|
105
|
}
|
100
|
|
106
|
|
101
|
OrderDetailInfo buildOrderDetail(BuyerOrder buyerOrder, OrderStatus orderStatus,
|
107
|
OrderDetailInfo buildOrderDetail(BuyerOrder buyerOrder, OrderStatus orderStatus,
|
102
|
- BuyerOrderGoods buyerOrderGoods, SellerOrderGoods sellerOrderGoods,
|
|
|
103
|
- TabType tabType) {
|
108
|
+ BuyerOrderGoods buyerOrderGoods, SellerOrderGoods sellerOrderGoods,
|
|
|
109
|
+ AddressInfo userAddress, TabType tabType) {
|
104
|
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
|
110
|
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
|
105
|
orderDetailInfo.setUid(buyerOrder.getUid());
|
111
|
orderDetailInfo.setUid(buyerOrder.getUid());
|
106
|
orderDetailInfo.setOrderCode(buyerOrder.getOrderCode());
|
112
|
orderDetailInfo.setOrderCode(buyerOrder.getOrderCode());
|
|
@@ -108,9 +114,12 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
@@ -108,9 +114,12 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
108
|
orderDetailInfo.setButtons(orderStatus.getDetailButtons(tabType));
|
114
|
orderDetailInfo.setButtons(orderStatus.getDetailButtons(tabType));
|
109
|
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(buyerOrder, orderStatus, tabType);
|
115
|
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(buyerOrder, orderStatus, tabType);
|
110
|
orderDetailInfo.setStatusDetail(statusDetail);
|
116
|
orderDetailInfo.setStatusDetail(statusDetail);
|
|
|
117
|
+ //good info
|
111
|
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
|
118
|
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
|
112
|
orderDetailInfo.setGoodsInfo(goodsInfo);
|
119
|
orderDetailInfo.setGoodsInfo(goodsInfo);
|
113
|
-
|
120
|
+ //user address
|
|
|
121
|
+ orderDetailInfo.setUserAddress(userAddress);
|
|
|
122
|
+ //priceInfo
|
114
|
OrderDetailInfo.PriceInfo priceInfo = OrderDetailInfo.PriceInfo.builder()
|
123
|
OrderDetailInfo.PriceInfo priceInfo = OrderDetailInfo.PriceInfo.builder()
|
115
|
.goodPrice(buyerOrderGoods.getGoodsPrice() == null ? "0" : buyerOrderGoods.getGoodsPrice().toPlainString() )
|
124
|
.goodPrice(buyerOrderGoods.getGoodsPrice() == null ? "0" : buyerOrderGoods.getGoodsPrice().toPlainString() )
|
116
|
.feePrice(buyerOrder.getShipFee() == null ? "0" : buyerOrder.getShipFee().toPlainString())
|
125
|
.feePrice(buyerOrder.getShipFee() == null ? "0" : buyerOrder.getShipFee().toPlainString())
|