|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.response.UserAddressRspBO;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
...
|
...
|
@@ -12,11 +14,13 @@ import com.yohoufo.order.common.Payment; |
|
|
import com.yohoufo.order.common.TabType;
|
|
|
import com.yohoufo.order.constants.MetaKey;
|
|
|
import com.yohoufo.order.constants.OrderConstant;
|
|
|
import com.yohoufo.order.convert.AddressInfoConvertor;
|
|
|
import com.yohoufo.order.model.AddressInfo;
|
|
|
import com.yohoufo.order.model.request.OrderRequest;
|
|
|
import com.yohoufo.order.model.response.GoodsInfo;
|
|
|
import com.yohoufo.order.model.response.OrderDetailInfo;
|
|
|
import com.yohoufo.order.service.IOrderDetailService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
...
|
...
|
@@ -51,11 +55,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
|
}
|
|
|
|
|
|
TabType actor = orderRequest.getActor();
|
|
|
if (actor == null){
|
|
|
logger.warn("getOrderDetail tabType invalidate, uid is {}, orderCode is {}",
|
|
|
orderRequest.getUid(), orderRequest.getOrderCode());
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
boolean isBuyer = actor.equals(TabType.BUY);
|
|
|
|
|
|
// 查询订单状态
|
|
|
BuyerOrder buyerOrder = getBuyerOrder(orderRequest.getUid(), orderRequest.getOrderCode());
|
...
|
...
|
@@ -74,9 +74,7 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
}
|
|
|
|
|
|
// 收货地址 and 用户信息 TODO
|
|
|
BuyerOrderMeta buyerOrderMeta = getBuyerOrderMeta(buyerUid,
|
|
|
orderRequest.getOrderCode(), MetaKey.BUYER_DELIVERY_ADDRESS);
|
|
|
|
|
|
|
|
|
BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(buyerUid, orderRequest.getOrderCode());
|
|
|
if (buyerOrderGoods == null){
|
...
|
...
|
@@ -91,16 +89,24 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
|
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrderGoods.getSkup());
|
|
|
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
OrderDetailInfo orderDetailInfo = buildOrderDetail(buyerOrder, orderStatus, buyerOrderGoods, sellerOrderGoods, actor);
|
|
|
// 收货地址 and 用户信息
|
|
|
BuyerOrderMeta buyerOrderMeta = getBuyerOrderMeta(buyerUid,
|
|
|
orderRequest.getOrderCode(), MetaKey.BUYER_DELIVERY_ADDRESS);
|
|
|
AddressInfo userAddress = null;
|
|
|
if (isBuyer && null != buyerOrderMeta && StringUtils.isNotBlank(buyerOrderMeta.getMetaValue())){
|
|
|
UserAddressRspBO addressRsp = JSONObject.parseObject(buyerOrderMeta.getMetaValue(), UserAddressRspBO.class);
|
|
|
userAddress = AddressInfoConvertor.userAddressRsp2AddressInfo(addressRsp);
|
|
|
}
|
|
|
OrderDetailInfo orderDetailInfo = buildOrderDetail(buyerOrder, orderStatus, buyerOrderGoods, sellerOrderGoods,
|
|
|
userAddress, actor);
|
|
|
|
|
|
return orderDetailInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
OrderDetailInfo buildOrderDetail(BuyerOrder buyerOrder, OrderStatus orderStatus,
|
|
|
BuyerOrderGoods buyerOrderGoods, SellerOrderGoods sellerOrderGoods,
|
|
|
TabType tabType) {
|
|
|
BuyerOrderGoods buyerOrderGoods, SellerOrderGoods sellerOrderGoods,
|
|
|
AddressInfo userAddress, TabType tabType) {
|
|
|
OrderDetailInfo orderDetailInfo = new OrderDetailInfo();
|
|
|
orderDetailInfo.setUid(buyerOrder.getUid());
|
|
|
orderDetailInfo.setOrderCode(buyerOrder.getOrderCode());
|
...
|
...
|
@@ -108,9 +114,12 @@ public abstract class AbsOrderDetailService implements IOrderDetailService{ |
|
|
orderDetailInfo.setButtons(orderStatus.getDetailButtons(tabType));
|
|
|
OrderDetailInfo.StatusDetail statusDetail = getStatusDetail(buyerOrder, orderStatus, tabType);
|
|
|
orderDetailInfo.setStatusDetail(statusDetail);
|
|
|
//good info
|
|
|
GoodsInfo goodsInfo = getGoodsInfo(sellerOrderGoods);
|
|
|
orderDetailInfo.setGoodsInfo(goodsInfo);
|
|
|
|
|
|
//user address
|
|
|
orderDetailInfo.setUserAddress(userAddress);
|
|
|
//priceInfo
|
|
|
OrderDetailInfo.PriceInfo priceInfo = OrderDetailInfo.PriceInfo.builder()
|
|
|
.goodPrice(buyerOrderGoods.getGoodsPrice() == null ? "0" : buyerOrderGoods.getGoodsPrice().toPlainString() )
|
|
|
.feePrice(buyerOrder.getShipFee() == null ? "0" : buyerOrder.getShipFee().toPlainString())
|
...
|
...
|
|