|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.sun.corba.se.spi.ior.IOR;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
...
|
...
|
@@ -12,6 +13,7 @@ import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq; |
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.exception.GatewayException;
|
|
|
import com.yohoufo.common.utils.BigDecimalHelper;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.common.utils.PriceFormater;
|
|
|
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
...
|
...
|
@@ -19,10 +21,9 @@ 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.order.common.OrderCodeType;
|
|
|
import com.yohoufo.order.common.OrderListType;
|
|
|
import com.yohoufo.order.common.SellerOrderListType;
|
|
|
import com.yohoufo.order.common.*;
|
|
|
import com.yohoufo.order.model.AddressInfo;
|
|
|
import com.yohoufo.order.model.GoodsInfo;
|
|
|
import com.yohoufo.order.model.SellerOrderContext;
|
...
|
...
|
@@ -47,7 +48,9 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by chenchao on 2018/9/13.
|
...
|
...
|
@@ -74,6 +77,15 @@ public class SellerOrderService extends AbsOrderListService implements IOrderLis |
|
|
@Autowired
|
|
|
private UserProxyService userProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderMapper buyerOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
|
|
|
|
|
|
|
|
|
|
|
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
|
...
|
...
|
@@ -311,28 +323,86 @@ public class SellerOrderService extends AbsOrderListService implements IOrderLis |
|
|
return PriceFormater.addCnCurrencySymbol(BigDecimalHelper.formatNumber(fee, BigDecimalHelper.FORMAT_TWOBITAFTERPOINT));
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
BuyerOrderMapper buyerOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
|
|
|
|
|
@Override
|
|
|
public OrderListInfoRsp getOrderList(OrderListRequest request){
|
|
|
int type;
|
|
|
if ((type=request.getType()) == SellerOrderListType.IN_SALE.getType()){
|
|
|
|
|
|
//todo
|
|
|
log.info("in seller getOrderList");
|
|
|
return null;
|
|
|
List<Integer> statusList = initOrderListRequest(request);
|
|
|
|
|
|
int total = sellerOrderGoodsMapper.selectCntByUidStatusList(request.getUid(), statusList);
|
|
|
int limit = request.getLimit();
|
|
|
int currentTotal = 0;
|
|
|
OrderListInfoRsp.OrderListInfoRspBuilder respBuilder = OrderListInfoRsp.builder()
|
|
|
.currPage(request.getPage())
|
|
|
.limit(limit)
|
|
|
.total(total)
|
|
|
.currTotal(currentTotal)
|
|
|
.pageSize((total % limit == 0) ? (total / limit) : (total / limit + 1));
|
|
|
if (total == 0){
|
|
|
return respBuilder.build();
|
|
|
}
|
|
|
int offset = (request.getPage() - 1) * limit;
|
|
|
List<SellerOrderGoods> sogList = sellerOrderGoodsMapper.selectByUidStatusList(request.getUid(),
|
|
|
statusList, offset, limit);
|
|
|
Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream()
|
|
|
.collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog)-> sog));
|
|
|
List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
|
|
|
List<SellerOrder> sellerOrders = sellerOrderMapper.selectBySkups(skupList);
|
|
|
List<OrderListInfo> data = sellerOrders.parallelStream()
|
|
|
.map(sellerOrder -> buildOrderListInfo(skupSellerOrderGoodsMap.get(sellerOrder.getSkup()), sellerOrder))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
OrderListInfoRsp orderListInfoRsp = respBuilder.data(data).currTotal(data.size()).build();
|
|
|
return orderListInfoRsp;
|
|
|
}else{
|
|
|
return super.getOrderList(request);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
|
|
|
SellerOrder buyerOrder) {
|
|
|
|
|
|
OrderListInfo orderListInfo = new OrderListInfo();
|
|
|
orderListInfo.setUid(buyerOrder.getUid());
|
|
|
orderListInfo.setOrderCode(buyerOrder.getOrderCode());
|
|
|
orderListInfo.setRealPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
|
|
|
// 订单中状态显示
|
|
|
orderListInfo.setStatus(buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus());
|
|
|
SkupStatus orderStatus = SkupStatus.getSkupStatus(orderListInfo.getStatus());
|
|
|
|
|
|
if (orderStatus == null){
|
|
|
log.warn("getOrderList orderStatus not exist, uid is {}, orderCode is {}, status is {}",
|
|
|
buyerOrder.getUid(), orderListInfo.getOrderCode(), buyerOrder.getStatus());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
orderListInfo.setStatuStr(orderStatus.getDetailShowDesc());
|
|
|
|
|
|
// 按钮显示
|
|
|
orderListInfo.setButtons(orderStatus.getListButtons());
|
|
|
|
|
|
// 当订单状态是待付款, 显示leftTime
|
|
|
if (orderListInfo.getStatus() == SellerOrderStatus.WAITING_PAY.getCode()){
|
|
|
orderListInfo.setLeftTime(DateUtil.getCurrentTimeSecond() - buyerOrder.getCreateTime());
|
|
|
}
|
|
|
|
|
|
|
|
|
orderListInfo.setSkup(sellerOrderGoods.getId());
|
|
|
//
|
|
|
com.yohoufo.order.response.GoodsInfo goodsInfo = new com.yohoufo.order.response.GoodsInfo();
|
|
|
goodsInfo.setColorName(sellerOrderGoods.getColorName());
|
|
|
goodsInfo.setProductName(sellerOrderGoods.getProductName());
|
|
|
goodsInfo.setGoodImg(sellerOrderGoods.getImageUrl());
|
|
|
goodsInfo.setSizeName(sellerOrderGoods.getSizeName());
|
|
|
goodsInfo.setGoodPrice(sellerOrderGoods.getGoodsPrice().toPlainString());
|
|
|
|
|
|
orderListInfo.setGoodsInfo(goodsInfo);
|
|
|
|
|
|
return orderListInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected List<Integer> initOrderListRequest(OrderListRequest request) {
|
|
|
if (request.getUid() < 0){
|
...
|
...
|
|