Authored by chenchao

fix

... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.model.dto;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.dal.order.model.AppraiseOrderStorage;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
... ... @@ -18,9 +19,11 @@ public class SellerDepositSubOrderContext {
private AppraiseOrder sellerDepositOrder;
private Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap;
private Map<Integer, SellerOrderComputeResult> storageIdSOCRMap;
private List<AppraiseOrderGoods> appraiseOrderGoodsList;
Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
private Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
}
... ...
... ... @@ -194,12 +194,11 @@ public class AppraiseOrderCreateService {
Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = ctx.getStorageIdFeeMetaMap();
Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = ctx.getStorageIdSOCRMap();
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = ctx.getPrdIdAOSListMap();
//fee of sku
for(AppraiseOrderGoods aog : appraiseOrderGoodsList){
List<AppraiseOrderStorage> aosList = aog.getAppraiseOrderStorageList() ;
Integer prdId = aog.getProductId();
List<AppraiseOrderStorage> aosList = prdIdAOSListMap.get(prdId) ;
for(AppraiseOrderStorage aos : aosList){
Integer storageId = aos.getStorageId();
SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId);
... ...
... ... @@ -93,7 +93,7 @@ public class AppraiseOrderService {
}
private double computeFee(){
double fee = 15D;
double fee = 0.01D;
return fee;
}
... ...
... ... @@ -30,6 +30,7 @@ import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.impl.AbsOrderViewService;
... ... @@ -37,6 +38,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService;
import com.yohoufo.order.service.impl.AppraiseOrderCreateService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.utils.LoggerUtils;
import lombok.Builder;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -331,19 +333,16 @@ public class SellerDepositOrderService extends AbsOrderViewService {
return paogs.parallelStream().map(paog-> convertProductVo(paog, null))
.collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));
}
@Builder
private class OrderDataNode{
int sknNum;
List<AppraiseOrderGoods> paogs;
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap;
Map<Integer,SellerOrderComputeResult> storageIdSOCRMap;
Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
}
public PageResp<ProductVo> getSkuList(SellerDepositOrderPrdListReq req){
final Long orderCode = req.getOrderCode();
int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);
int limit = req.getLimit();
PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();
respBuilder.page(req.getPage()).pageSize(limit).total(total);
if (total == 0){
return respBuilder.build();
}
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
OrderDataNode buildDataSourceOfParentOrder(long orderCode, List<AppraiseOrderGoods> paogs){
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size());
Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(128);
... ... @@ -358,7 +357,7 @@ public class SellerDepositOrderService extends AbsOrderViewService {
return socr;
}
};
Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = new HashMap<>(128);
for(AppraiseOrderGoods paog : paogs){
Integer prdId;
List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId=paog.getProductId());
... ... @@ -370,8 +369,31 @@ public class SellerDepositOrderService extends AbsOrderViewService {
aomc.setMetaKey(MetaKey.SELLER_FEE);
List<AppraiseOrderMeta> paomList = appraiseOrderMetaMapper.selectByOrderCodeStorageIds(aomc, storageIds);
//
storageIdFeeMetaMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, Function.identity())));
storageIdSOCRMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, socrFunction::apply)));
}
return OrderDataNode.builder().paogs(paogs)
.prdIdAOSListMap(prdIdAOSListMap)
.storageIdFeeMetaMap(storageIdFeeMetaMap)
.storageIdSOCRMap(storageIdSOCRMap)
.build();
}
public PageResp<ProductVo> getSkuList(SellerDepositOrderPrdListReq req){
final Long orderCode = req.getOrderCode();
int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);
int limit = req.getLimit();
PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();
respBuilder.page(req.getPage()).pageSize(limit).total(total);
if (total == 0){
return respBuilder.build();
}
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogs);
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
List<ProductVo> productVoList = buildProductVoListWithSkuDetail(paogs, prdIdAOSListMap, storageIdSOCRMap);
... ... @@ -443,7 +465,20 @@ public class SellerDepositOrderService extends AbsOrderViewService {
return;
}
//split sku 2 order
List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogList);
Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
AppraiseOrder sellerDepositOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
SellerDepositSubOrderContext context = SellerDepositSubOrderContext.builder()
.appraiseOrderGoodsList(paogList)
.sellerDepositOrder(sellerDepositOrder)
.storageIdFeeMetaMap(node.storageIdFeeMetaMap)
.storageIdSOCRMap(storageIdSOCRMap)
.prdIdAOSListMap(prdIdAOSListMap)
.build();
appraiseOrderCreateService.createSellerDepoistOrderOfSku(context);
//todo add express info
... ...