|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
...
|
...
|
@@ -16,10 +17,7 @@ import com.yohoufo.dal.order.BuyerOrderGoodsMapper; |
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.SellerOrderMapper;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.SellerOrder;
|
|
|
import com.yohoufo.dal.order.model.SellerOrderGoods;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.constants.ViewType;
|
|
|
import com.yohoufo.order.model.request.OrderListRequest;
|
|
|
import com.yohoufo.order.service.AbsSellerOrderViewService;
|
...
|
...
|
@@ -41,6 +39,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
...
|
...
|
@@ -86,10 +85,19 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde |
|
|
SkupStatus.SELLER_CANCEL_SELL.getCode()
|
|
|
);
|
|
|
|
|
|
|
|
|
private static List<Integer> skupStatusListErpGW = Arrays.asList(
|
|
|
SkupStatus.SELL_OUT.getCode()
|
|
|
);
|
|
|
|
|
|
public static List<Integer> getSkupStatusListV683(){
|
|
|
return skupStatusListV683;
|
|
|
}
|
|
|
|
|
|
public static List<Integer> getSkupStatusListErpGW(){
|
|
|
return skupStatusListErpGW;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<OrderListInfo> buildOrderList(List<SellerOrderGoods> sogList, SellerType sellerType){
|
|
|
sogList.stream().forEach(item -> {
|
...
|
...
|
@@ -109,6 +117,45 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde |
|
|
return data;
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageResp<OrderListInfo> getOrderListForErpGW(OrderListRequest request){
|
|
|
// 只给erp显示售出的订单
|
|
|
List<Integer> statusList = getSkupStatusListErpGW();
|
|
|
|
|
|
int total = sellerOrderGoodsMapper.selectCntByStatusAndOrderCode(request.getUid(), request.getOrderCode(), statusList);
|
|
|
int limit = request.getLimit();
|
|
|
PageResp.PageRespBuilder respBuilder = PageResp.builder()
|
|
|
.page(request.getPage())
|
|
|
.pageSize(limit)
|
|
|
.total(total)
|
|
|
.pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1));
|
|
|
if (total == 0){
|
|
|
return respBuilder.build();
|
|
|
}
|
|
|
int offset = (request.getPage() - 1) * limit;
|
|
|
List<SellerOrderInfo> sellerOrderInfoList = sellerOrderGoodsMapper.selectByStatusAndOrderCode(request.getUid(), request.getOrderCode(),
|
|
|
statusList, offset, limit);
|
|
|
if (CollectionUtils.isEmpty(sellerOrderInfoList)){
|
|
|
log.warn("seller get order list SellerOrderGoods is empty,req {}", request);
|
|
|
return respBuilder.build();
|
|
|
}
|
|
|
|
|
|
// 查询skup的买家订单号
|
|
|
List<BuyerOrderGoods> buyerOrderGoods = buyerOrderGoodsMapper.selectBySkups(sellerOrderInfoList.stream().map(SellerOrderInfo::getSkup).collect(Collectors.toList()));
|
|
|
Map<Integer, Long> buyerOrderMap = Maps.newHashMap();
|
|
|
if (CollectionUtils.isNotEmpty(buyerOrderGoods)){
|
|
|
buyerOrderMap = buyerOrderGoods.stream().collect(Collectors.toMap(BuyerOrderGoods::getSkup, BuyerOrderGoods::getOrderCode, (key1, key2) -> key2));
|
|
|
}
|
|
|
|
|
|
// 将查询结果转换成想要结果
|
|
|
List<OrderListInfo> data = Lists.newArrayList();
|
|
|
Map<Integer, Long> finalBuyerOrderMap = buyerOrderMap;
|
|
|
sellerOrderInfoList.stream().forEach(x -> data.add(this.convertOrderInfo(x, finalBuyerOrderMap)));
|
|
|
PageResp orderListInfoRsp = respBuilder.data(data).build();
|
|
|
|
|
|
return orderListInfoRsp;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageResp<OrderListInfo> getOrderList(OrderListRequest request){
|
|
|
OrderListVo orderListVo = orderCacheService.getOrderListInfos(request);
|
...
|
...
|
@@ -236,9 +283,6 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
|
|
|
SellerOrder sellerOrder, SellerType st, Map<String,String> overPriceTipsMap) {
|
|
|
|
...
|
...
|
@@ -307,6 +351,41 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OrderListInfo convertOrderInfo(SellerOrderInfo sellerOrderInfo, Map<Integer, Long> buyerOrderMap) {
|
|
|
|
|
|
OrderListInfo orderListInfo = new OrderListInfo();
|
|
|
orderListInfo.setUid(sellerOrderInfo.getUid());
|
|
|
orderListInfo.setOrderCode(sellerOrderInfo.getOrderCode());
|
|
|
orderListInfo.setRealPrice(sellerOrderInfo.getGoodsPrice().toPlainString());
|
|
|
|
|
|
// 订单中状态显示
|
|
|
SkupStatus skupStatus = SkupStatus.getSkupStatus(sellerOrderInfo.getStatus().intValue());
|
|
|
if (skupStatus != null){
|
|
|
orderListInfo.setStatus(skupStatus.getCode());
|
|
|
orderListInfo.setStatuStr(skupStatus.getDesc());
|
|
|
}
|
|
|
|
|
|
orderListInfo.setSkup(sellerOrderInfo.getSkup());
|
|
|
|
|
|
GoodsInfo goodsInfo = new GoodsInfo();
|
|
|
goodsInfo.setColorName(sellerOrderInfo.getColorName());
|
|
|
goodsInfo.setProductName(sellerOrderInfo.getProductName());
|
|
|
goodsInfo.setGoodImg(ImageUrlAssist.getAllProductPicUrl(sellerOrderInfo.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
|
|
|
goodsInfo.setSizeName(sellerOrderInfo.getSizeName());
|
|
|
goodsInfo.setProductId(sellerOrderInfo.getProductId());
|
|
|
goodsInfo.setGoodPrice(sellerOrderInfo.getGoodsPrice().toPlainString());
|
|
|
orderListInfo.setGoodsInfo(goodsInfo);
|
|
|
|
|
|
orderListInfo.setCreateTime(DateUtil.formatDate(sellerOrderInfo.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
|
|
|
|
|
|
// 查询skup的买家订单号
|
|
|
orderListInfo.setBuyerOrderCode(buyerOrderMap.get(sellerOrderInfo.getSkup()));
|
|
|
|
|
|
return orderListInfo;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
protected List<Integer> initOrderListRequest(OrderListRequest request) {
|
|
|
if (request.getUid() < 0){
|
...
|
...
|
@@ -326,12 +405,12 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
int getTotal(int uid, List<Integer> statusQuery) {
|
|
|
int getTotal(int uid, Long orderCode, List<Integer> statusQuery) {
|
|
|
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
List<BuyerOrder> getOrderList(int uid, List<Integer> statusQuery, int offset, int limit){
|
|
|
List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit){
|
|
|
List<BuyerOrder> buyerOrderList = buyerOrderMapper.selectListBySellerUidStatus(uid, statusQuery, offset, limit);
|
|
|
return buyerOrderList;
|
|
|
}
|
...
|
...
|
|