...
|
...
|
@@ -9,6 +9,7 @@ import com.yohobuy.ufo.model.order.common.OrderStatus; |
|
|
import com.yohobuy.ufo.model.order.common.SkupStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
|
|
|
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
|
|
|
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
|
|
|
import com.yohobuy.ufo.model.order.resp.PageResp;
|
...
|
...
|
@@ -20,6 +21,7 @@ import com.yohoufo.common.utils.UserInfoHiddenHelper; |
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyOrderNums;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
...
|
...
|
@@ -45,6 +47,7 @@ import com.yohoufo.order.service.pay.AbstractPayService; |
|
|
import com.yohoufo.order.service.proxy.InBoxFacade;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -52,7 +55,9 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class BuyerOrderServiceImpl implements IBuyerOrderService {
|
...
|
...
|
@@ -119,7 +124,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(sog),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode)));
|
|
|
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode),
|
|
|
CacheKeyBuilder.buyerOrderNums(uid)));
|
|
|
} else {
|
|
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
|
|
|
}
|
...
|
...
|
@@ -398,7 +404,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(psog),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),
|
|
|
CacheKeyBuilder.buyerOrderNums(buyerUid)));
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -482,6 +489,58 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { |
|
|
return orderDetailInfo;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询订单数量
|
|
|
* @param uid
|
|
|
* @return
|
|
|
*/
|
|
|
public BuyerOrderNums getBuyerOrderNums(int uid){
|
|
|
|
|
|
if (uid < 0){
|
|
|
logger.warn("buyer delete, uid or orderCode empty, uid {}", uid);
|
|
|
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
|
|
|
}
|
|
|
|
|
|
BuyerOrderNums buyerOrderNumsCache = orderCacheService.getBuyerOrderNums(uid);
|
|
|
if (buyerOrderNumsCache != null){
|
|
|
logger.info("getBuyerOrderNums result uid is {}, result is {}", uid, buyerOrderNumsCache);
|
|
|
return buyerOrderNumsCache;
|
|
|
}
|
|
|
|
|
|
|
|
|
List<BuyOrderNums> buyOrderNumList = buyerOrderMapper.selectCntByUidStatusAll(uid);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(buyOrderNumList)){
|
|
|
return BuyerOrderNums.builder().build();
|
|
|
}
|
|
|
|
|
|
Map<Integer, Integer> buyOrderNumsMap = buyOrderNumList.stream().collect(Collectors.toMap(BuyOrderNums::getStatus, BuyOrderNums::getNum));
|
|
|
|
|
|
// 待付款
|
|
|
// 待发货
|
|
|
// 待收货
|
|
|
BuyerOrderNums buyerOrderNums = BuyerOrderNums.builder().uid(uid)
|
|
|
.waitingPayNum(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_PAY.getStatusQuery()))
|
|
|
.waitingSendNums(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_SEND.getStatusQuery()))
|
|
|
.waitingDeliveryNums(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_DELIVERY.getStatusQuery())).build();
|
|
|
|
|
|
orderCacheService.saveBuyerOrderNums(uid, buyerOrderNums);
|
|
|
|
|
|
return buyerOrderNums;
|
|
|
}
|
|
|
|
|
|
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status){
|
|
|
|
|
|
int sum = 0;
|
|
|
for(Integer key : status){
|
|
|
int num = Objects.isNull(map.get(key)) ? 0 : map.get(key);
|
|
|
sum+=num;
|
|
|
}
|
|
|
|
|
|
return sum;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResp getOrderList(OrderListRequest request) {
|
|
|
|
...
|
...
|
|