Authored by chenchao

fix

@@ -3,6 +3,7 @@ package com.yohoufo.order.model.dto; @@ -3,6 +3,7 @@ package com.yohoufo.order.model.dto;
3 import com.yohoufo.dal.order.model.AppraiseOrder; 3 import com.yohoufo.dal.order.model.AppraiseOrder;
4 import com.yohoufo.dal.order.model.AppraiseOrderGoods; 4 import com.yohoufo.dal.order.model.AppraiseOrderGoods;
5 import com.yohoufo.dal.order.model.AppraiseOrderMeta; 5 import com.yohoufo.dal.order.model.AppraiseOrderMeta;
  6 +import com.yohoufo.dal.order.model.AppraiseOrderStorage;
6 import lombok.AllArgsConstructor; 7 import lombok.AllArgsConstructor;
7 import lombok.Builder; 8 import lombok.Builder;
8 import lombok.Data; 9 import lombok.Data;
@@ -18,9 +19,11 @@ public class SellerDepositSubOrderContext { @@ -18,9 +19,11 @@ public class SellerDepositSubOrderContext {
18 19
19 private AppraiseOrder sellerDepositOrder; 20 private AppraiseOrder sellerDepositOrder;
20 21
  22 + private Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap;
  23 +
21 private Map<Integer, SellerOrderComputeResult> storageIdSOCRMap; 24 private Map<Integer, SellerOrderComputeResult> storageIdSOCRMap;
22 25
23 private List<AppraiseOrderGoods> appraiseOrderGoodsList; 26 private List<AppraiseOrderGoods> appraiseOrderGoodsList;
24 27
25 - Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap; 28 + private Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
26 } 29 }
@@ -194,12 +194,11 @@ public class AppraiseOrderCreateService { @@ -194,12 +194,11 @@ public class AppraiseOrderCreateService {
194 194
195 Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = ctx.getStorageIdFeeMetaMap(); 195 Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = ctx.getStorageIdFeeMetaMap();
196 Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = ctx.getStorageIdSOCRMap(); 196 Map<Integer, SellerOrderComputeResult> storageIdSOCRMap = ctx.getStorageIdSOCRMap();
197 - 197 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = ctx.getPrdIdAOSListMap();
198 //fee of sku 198 //fee of sku
199 for(AppraiseOrderGoods aog : appraiseOrderGoodsList){ 199 for(AppraiseOrderGoods aog : appraiseOrderGoodsList){
200 - List<AppraiseOrderStorage> aosList = aog.getAppraiseOrderStorageList() ;  
201 -  
202 - 200 + Integer prdId = aog.getProductId();
  201 + List<AppraiseOrderStorage> aosList = prdIdAOSListMap.get(prdId) ;
203 for(AppraiseOrderStorage aos : aosList){ 202 for(AppraiseOrderStorage aos : aosList){
204 Integer storageId = aos.getStorageId(); 203 Integer storageId = aos.getStorageId();
205 SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId); 204 SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId);
@@ -93,7 +93,7 @@ public class AppraiseOrderService { @@ -93,7 +93,7 @@ public class AppraiseOrderService {
93 } 93 }
94 94
95 private double computeFee(){ 95 private double computeFee(){
96 - double fee = 15D; 96 + double fee = 0.01D;
97 return fee; 97 return fee;
98 } 98 }
99 99
@@ -30,6 +30,7 @@ import com.yohoufo.order.common.ClientType; @@ -30,6 +30,7 @@ import com.yohoufo.order.common.ClientType;
30 import com.yohoufo.order.constants.MetaKey; 30 import com.yohoufo.order.constants.MetaKey;
31 import com.yohoufo.order.convert.SellerOrderConvertor; 31 import com.yohoufo.order.convert.SellerOrderConvertor;
32 import com.yohoufo.order.model.dto.SellerDepositOrderContext; 32 import com.yohoufo.order.model.dto.SellerDepositOrderContext;
  33 +import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
33 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 34 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
34 import com.yohoufo.order.model.response.AppraiseAddressResp; 35 import com.yohoufo.order.model.response.AppraiseAddressResp;
35 import com.yohoufo.order.service.impl.AbsOrderViewService; 36 import com.yohoufo.order.service.impl.AbsOrderViewService;
@@ -37,6 +38,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService; @@ -37,6 +38,7 @@ import com.yohoufo.order.service.impl.AppraiseAddressService;
37 import com.yohoufo.order.service.impl.AppraiseOrderCreateService; 38 import com.yohoufo.order.service.impl.AppraiseOrderCreateService;
38 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 39 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
39 import com.yohoufo.order.utils.LoggerUtils; 40 import com.yohoufo.order.utils.LoggerUtils;
  41 +import lombok.Builder;
40 import org.slf4j.Logger; 42 import org.slf4j.Logger;
41 import org.springframework.beans.factory.annotation.Autowired; 43 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.stereotype.Service; 44 import org.springframework.stereotype.Service;
@@ -331,19 +333,16 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -331,19 +333,16 @@ public class SellerDepositOrderService extends AbsOrderViewService {
331 return paogs.parallelStream().map(paog-> convertProductVo(paog, null)) 333 return paogs.parallelStream().map(paog-> convertProductVo(paog, null))
332 .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size()))); 334 .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));
333 } 335 }
  336 + @Builder
  337 + private class OrderDataNode{
  338 + int sknNum;
  339 + List<AppraiseOrderGoods> paogs;
  340 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap;
  341 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap;
  342 + Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
  343 + }
334 344
335 -  
336 - public PageResp<ProductVo> getSkuList(SellerDepositOrderPrdListReq req){  
337 - final Long orderCode = req.getOrderCode();  
338 - int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);  
339 - int limit = req.getLimit();  
340 - PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();  
341 - respBuilder.page(req.getPage()).pageSize(limit).total(total);  
342 - if (total == 0){  
343 - return respBuilder.build();  
344 - }  
345 - int offset = (req.getPage() - 1) * limit;  
346 - List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit); 345 + OrderDataNode buildDataSourceOfParentOrder(long orderCode, List<AppraiseOrderGoods> paogs){
347 Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size()); 346 Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size());
348 Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(128); 347 Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(128);
349 348
@@ -358,7 +357,7 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -358,7 +357,7 @@ public class SellerDepositOrderService extends AbsOrderViewService {
358 return socr; 357 return socr;
359 } 358 }
360 }; 359 };
361 - 360 + Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = new HashMap<>(128);
362 for(AppraiseOrderGoods paog : paogs){ 361 for(AppraiseOrderGoods paog : paogs){
363 Integer prdId; 362 Integer prdId;
364 List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId=paog.getProductId()); 363 List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId=paog.getProductId());
@@ -370,8 +369,31 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -370,8 +369,31 @@ public class SellerDepositOrderService extends AbsOrderViewService {
370 aomc.setMetaKey(MetaKey.SELLER_FEE); 369 aomc.setMetaKey(MetaKey.SELLER_FEE);
371 List<AppraiseOrderMeta> paomList = appraiseOrderMetaMapper.selectByOrderCodeStorageIds(aomc, storageIds); 370 List<AppraiseOrderMeta> paomList = appraiseOrderMetaMapper.selectByOrderCodeStorageIds(aomc, storageIds);
372 // 371 //
  372 + storageIdFeeMetaMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, Function.identity())));
373 storageIdSOCRMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, socrFunction::apply))); 373 storageIdSOCRMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, socrFunction::apply)));
374 } 374 }
  375 + return OrderDataNode.builder().paogs(paogs)
  376 + .prdIdAOSListMap(prdIdAOSListMap)
  377 + .storageIdFeeMetaMap(storageIdFeeMetaMap)
  378 + .storageIdSOCRMap(storageIdSOCRMap)
  379 + .build();
  380 + }
  381 +
  382 +
  383 + public PageResp<ProductVo> getSkuList(SellerDepositOrderPrdListReq req){
  384 + final Long orderCode = req.getOrderCode();
  385 + int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);
  386 + int limit = req.getLimit();
  387 + PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();
  388 + respBuilder.page(req.getPage()).pageSize(limit).total(total);
  389 + if (total == 0){
  390 + return respBuilder.build();
  391 + }
  392 + int offset = (req.getPage() - 1) * limit;
  393 + List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
  394 + OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogs);
  395 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
  396 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
375 397
376 List<ProductVo> productVoList = buildProductVoListWithSkuDetail(paogs, prdIdAOSListMap, storageIdSOCRMap); 398 List<ProductVo> productVoList = buildProductVoListWithSkuDetail(paogs, prdIdAOSListMap, storageIdSOCRMap);
377 399
@@ -443,7 +465,20 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -443,7 +465,20 @@ public class SellerDepositOrderService extends AbsOrderViewService {
443 return; 465 return;
444 } 466 }
445 //split sku 2 order 467 //split sku 2 order
446 - 468 + List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
  469 + OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogList);
  470 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
  471 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
  472 +
  473 + AppraiseOrder sellerDepositOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
  474 + SellerDepositSubOrderContext context = SellerDepositSubOrderContext.builder()
  475 + .appraiseOrderGoodsList(paogList)
  476 + .sellerDepositOrder(sellerDepositOrder)
  477 + .storageIdFeeMetaMap(node.storageIdFeeMetaMap)
  478 + .storageIdSOCRMap(storageIdSOCRMap)
  479 + .prdIdAOSListMap(prdIdAOSListMap)
  480 + .build();
  481 + appraiseOrderCreateService.createSellerDepoistOrderOfSku(context);
447 482
448 483
449 //todo add express info 484 //todo add express info