Authored by chenchao

adaptor deliver

@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 <foreach collection="statusList" item="status" open="(" close=")" separator=","> 55 <foreach collection="statusList" item="status" open="(" close=")" separator=",">
56 #{status,jdbcType=TINYINT} 56 #{status,jdbcType=TINYINT}
57 </foreach> 57 </foreach>
58 - limit #{offset},#{limit} 58 + order by id desc limit #{offset},#{limit}
59 </select> 59 </select>
60 60
61 61
@@ -4,6 +4,8 @@ import com.yohobuy.ufo.model.order.req.*; @@ -4,6 +4,8 @@ import com.yohobuy.ufo.model.order.req.*;
4 import com.yohobuy.ufo.model.order.resp.*; 4 import com.yohobuy.ufo.model.order.resp.*;
5 import com.yohobuy.ufo.model.order.vo.ProductVo; 5 import com.yohobuy.ufo.model.order.vo.ProductVo;
6 import com.yohoufo.common.ApiResponse; 6 import com.yohoufo.common.ApiResponse;
  7 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderDetailService;
  8 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderListService;
7 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService; 9 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
8 import com.yohoufo.order.utils.LoggerUtils; 10 import com.yohoufo.order.utils.LoggerUtils;
9 import org.slf4j.Logger; 11 import org.slf4j.Logger;
@@ -21,6 +23,12 @@ public class SellerDepositOrderController { @@ -21,6 +23,12 @@ public class SellerDepositOrderController {
21 @Autowired 23 @Autowired
22 private SellerDepositOrderService sellerDepositOrderService; 24 private SellerDepositOrderService sellerDepositOrderService;
23 25
  26 + @Autowired
  27 + private SellerDepositOrderDetailService sellerDepositOrderDetailService;
  28 +
  29 + @Autowired
  30 + private SellerDepositOrderListService sellerDepositOrderListService;
  31 +
24 @RequestMapping(params = "method=ufo.depositOrder.compute") 32 @RequestMapping(params = "method=ufo.depositOrder.compute")
25 public ApiResponse compute(@RequestParam(name = "uid")int uid, 33 public ApiResponse compute(@RequestParam(name = "uid")int uid,
26 @RequestParam(name = "goodsList")String goodsList){ 34 @RequestParam(name = "goodsList")String goodsList){
@@ -84,7 +92,7 @@ public class SellerDepositOrderController { @@ -84,7 +92,7 @@ public class SellerDepositOrderController {
84 .uid(uid).listType(listType).limit(limit).page(page).build(); 92 .uid(uid).listType(listType).limit(limit).page(page).build();
85 93
86 logger.info("in ufo.depositOrder.list req {}", req); 94 logger.info("in ufo.depositOrder.list req {}", req);
87 - PageResp<SellerDepositOrderListResp> resp = sellerDepositOrderService.getOrderList(req); 95 + PageResp<SellerDepositOrderListResp> resp = sellerDepositOrderListService.getOrderList(req);
88 return new ApiResponse.ApiResponseBuilder() 96 return new ApiResponse.ApiResponseBuilder()
89 .code(200) 97 .code(200)
90 .data(resp) 98 .data(resp)
@@ -99,7 +107,7 @@ public class SellerDepositOrderController { @@ -99,7 +107,7 @@ public class SellerDepositOrderController {
99 SellerDepositOrderDetailReq req = SellerDepositOrderDetailReq.builder() 107 SellerDepositOrderDetailReq req = SellerDepositOrderDetailReq.builder()
100 .uid(uid).orderCode(orderCode).build(); 108 .uid(uid).orderCode(orderCode).build();
101 logger.info("in ufo.depositOrder.detail req {}", req); 109 logger.info("in ufo.depositOrder.detail req {}", req);
102 - SellerDepositOrderDetailResp resp = sellerDepositOrderService.getOrderDetail(req); 110 + SellerDepositOrderDetailResp resp = sellerDepositOrderDetailService.getOrderDetail(req);
103 return new ApiResponse.ApiResponseBuilder() 111 return new ApiResponse.ApiResponseBuilder()
104 .code(200) 112 .code(200)
105 .data(resp) 113 .data(resp)
@@ -130,13 +138,14 @@ public class SellerDepositOrderController { @@ -130,13 +138,14 @@ public class SellerDepositOrderController {
130 .wayBillCode(wayBillCode) 138 .wayBillCode(wayBillCode)
131 .expressCompanyId(expressCompanyId) 139 .expressCompanyId(expressCompanyId)
132 .build(); 140 .build();
133 - sellerDepositOrderService.deliverToDepot(req); 141 + sellerDepositOrderService.deliver2Depot(req);
134 return new ApiResponse.ApiResponseBuilder() 142 return new ApiResponse.ApiResponseBuilder()
135 .code(200) 143 .code(200)
136 .message("寄存订单发货录入成功") 144 .message("寄存订单发货录入成功")
137 .build(); 145 .build();
138 } 146 }
139 147
  148 +
140 @RequestMapping(params = "method=ufo.depositOrder.productList") 149 @RequestMapping(params = "method=ufo.depositOrder.productList")
141 public ApiResponse getProductList(@RequestParam(name = "uid")int uid, 150 public ApiResponse getProductList(@RequestParam(name = "uid")int uid,
142 @RequestParam(name = "orderCode")long orderCode, 151 @RequestParam(name = "orderCode")long orderCode,
@@ -148,7 +157,7 @@ public class SellerDepositOrderController { @@ -148,7 +157,7 @@ public class SellerDepositOrderController {
148 .page(page) 157 .page(page)
149 .limit(limit).build(); 158 .limit(limit).build();
150 logger.info("in method=ufo.depositOrder.skuList req {}", req); 159 logger.info("in method=ufo.depositOrder.skuList req {}", req);
151 - PageResp<ProductVo> resp = sellerDepositOrderService.getSknList(req); 160 + PageResp<ProductVo> resp = sellerDepositOrderListService.getSknList(req);
152 return new ApiResponse.ApiResponseBuilder() 161 return new ApiResponse.ApiResponseBuilder()
153 .code(200) 162 .code(200)
154 .data(resp) 163 .data(resp)
@@ -167,7 +176,7 @@ public class SellerDepositOrderController { @@ -167,7 +176,7 @@ public class SellerDepositOrderController {
167 .page(page) 176 .page(page)
168 .limit(limit).build(); 177 .limit(limit).build();
169 logger.info("in method=ufo.depositOrder.skuList req {}", req); 178 logger.info("in method=ufo.depositOrder.skuList req {}", req);
170 - PageResp<ProductVo> resp = sellerDepositOrderService.getSkuList(req); 179 + PageResp<ProductVo> resp = sellerDepositOrderListService.getSkuList(req);
171 return new ApiResponse.ApiResponseBuilder() 180 return new ApiResponse.ApiResponseBuilder()
172 .code(200) 181 .code(200)
173 .data(resp) 182 .data(resp)
@@ -3,10 +3,14 @@ package com.yohoufo.order.convert; @@ -3,10 +3,14 @@ package com.yohoufo.order.convert;
3 import com.yohobuy.ufo.model.order.bo.GoodsBo; 3 import com.yohobuy.ufo.model.order.bo.GoodsBo;
4 import com.yohobuy.ufo.model.order.bo.ProductBo; 4 import com.yohobuy.ufo.model.order.bo.ProductBo;
5 import com.yohobuy.ufo.model.order.vo.GoodsVo; 5 import com.yohobuy.ufo.model.order.vo.GoodsVo;
  6 +import com.yohobuy.ufo.model.order.vo.ProductVo;
6 import com.yohobuy.ufo.model.response.StorageDataResp; 7 import com.yohobuy.ufo.model.response.StorageDataResp;
  8 +import com.yohoufo.common.helper.ImageUrlAssist;
  9 +import com.yohoufo.dal.order.model.AppraiseOrderGoods;
7 import com.yohoufo.dal.order.model.AppraiseOrderStorage; 10 import com.yohoufo.dal.order.model.AppraiseOrderStorage;
8 11
9 import java.math.BigDecimal; 12 import java.math.BigDecimal;
  13 +import java.util.Objects;
10 14
11 public final class ProductConvertor { 15 public final class ProductConvertor {
12 16
@@ -41,4 +45,17 @@ public final class ProductConvertor { @@ -41,4 +45,17 @@ public final class ProductConvertor {
41 aosc.setNum(goodsBo.getNum()); 45 aosc.setNum(goodsBo.getNum());
42 return aosc; 46 return aosc;
43 } 47 }
  48 +
  49 + public static ProductVo convertProductVo(AppraiseOrderGoods paog, ProductVo temp){
  50 + ProductVo productVo = ProductVo.builder()
  51 + .imgUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))
  52 + .productName(paog.getProductName())
  53 + .productId(paog.getProductId())
  54 + .total(paog.getNum()).build();
  55 + if (Objects.nonNull(temp)){
  56 + productVo.setSizeNum(temp.getSizeNum());
  57 + productVo.setGoodsList(temp.getGoodsList());
  58 + }
  59 + return productVo;
  60 + }
44 } 61 }
  1 +package com.yohoufo.order.service;
  2 +
  3 +import com.yohobuy.ufo.model.order.common.OrderAttributes;
  4 +import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
  5 +
  6 +public interface IGoodsService {
  7 +
  8 +
  9 + /**
  10 + * 发货
  11 + * @param req
  12 + */
  13 + int deliver2Depot(DeliverToDepotReq req);
  14 +
  15 + /**
  16 + * 平台收货
  17 + * @param orderCode
  18 + */
  19 + void platformReceiveGoods(long orderCode);
  20 +
  21 + /**
  22 + * 鉴定通过
  23 + * @param orderCode
  24 + */
  25 + void appraisePass(long orderCode);
  26 +
  27 + /**
  28 + * 鉴别为假
  29 + * @param orderCode
  30 + */
  31 + void appraiseFake(long orderCode);
  32 +
  33 + /**
  34 + * 无法鉴别
  35 + * @param orderCode
  36 + */
  37 + void unsure(long orderCode);
  38 +
  39 + OrderAttributes getOrderAttributes();
  40 +}
@@ -58,7 +58,7 @@ public class OrderPaymentServiceFactory { @@ -58,7 +58,7 @@ public class OrderPaymentServiceFactory {
58 log.info("orderCode is {}, type is {}", orderCode, codeMeta.getType()); 58 log.info("orderCode is {}, type is {}", orderCode, codeMeta.getType());
59 // 买家订单 59 // 买家订单
60 if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()) { 60 if (codeMeta.getType() == OrderCodeType.BUYER_TYPE.getType()) {
61 - paymentService = appraiseOrderService.isAppraiseOrder(orderCode) ? this.appraiseOrderPaymentService : this.buyerOrderPaymentService; 61 + paymentService = appraiseOrderService.isAppraiseOrder(orderCode).isExisted() ? this.appraiseOrderPaymentService : this.buyerOrderPaymentService;
62 } else if (codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()) { 62 } else if (codeMeta.getType() == OrderCodeType.SELLER_TYPE.getType()) {
63 paymentService = this.sellerOrderPaymentService; 63 paymentService = this.sellerOrderPaymentService;
64 } else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) { 64 } else if (codeMeta.getType() == OrderCodeType.SELLER_RECHARGE_EARNEST_TYPE.getType()) {
@@ -8,10 +8,7 @@ import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo; @@ -8,10 +8,7 @@ import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
8 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus; 8 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
9 import com.yohobuy.ufo.model.order.common.OrderAttributes; 9 import com.yohobuy.ufo.model.order.common.OrderAttributes;
10 import com.yohobuy.ufo.model.order.common.OrderCodeType; 10 import com.yohobuy.ufo.model.order.common.OrderCodeType;
11 -import com.yohobuy.ufo.model.order.req.AppraiseOrderComputeReq;  
12 -import com.yohobuy.ufo.model.order.req.AppraiseOrderDetailReq;  
13 -import com.yohobuy.ufo.model.order.req.AppraiseOrderListReq;  
14 -import com.yohobuy.ufo.model.order.req.AppraiseOrderSubmitReq; 11 +import com.yohobuy.ufo.model.order.req.*;
15 import com.yohobuy.ufo.model.order.resp.*; 12 import com.yohobuy.ufo.model.order.resp.*;
16 import com.yohobuy.ufo.model.order.vo.AddressInfo; 13 import com.yohobuy.ufo.model.order.vo.AddressInfo;
17 import com.yohoufo.common.exception.UfoServiceException; 14 import com.yohoufo.common.exception.UfoServiceException;
@@ -29,6 +26,7 @@ import com.yohoufo.order.constants.MetaKey; @@ -29,6 +26,7 @@ import com.yohoufo.order.constants.MetaKey;
29 import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor; 26 import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor;
30 import com.yohoufo.order.convert.SellerOrderConvertor; 27 import com.yohoufo.order.convert.SellerOrderConvertor;
31 import com.yohoufo.order.model.dto.AppraiseOrderContext; 28 import com.yohoufo.order.model.dto.AppraiseOrderContext;
  29 +import com.yohoufo.order.service.IGoodsService;
32 import com.yohoufo.order.service.proxy.ProductProxyService; 30 import com.yohoufo.order.service.proxy.ProductProxyService;
33 import com.yohoufo.order.service.proxy.UserProxyService; 31 import com.yohoufo.order.service.proxy.UserProxyService;
34 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 32 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
@@ -49,7 +47,7 @@ import java.util.function.Function; @@ -49,7 +47,7 @@ import java.util.function.Function;
49 import java.util.stream.Collectors; 47 import java.util.stream.Collectors;
50 48
51 @Service 49 @Service
52 -public class AppraiseOrderService { 50 +public class AppraiseOrderService implements IGoodsService {
53 private final Logger logger = LoggerUtils.getBuyerOrderLogger(); 51 private final Logger logger = LoggerUtils.getBuyerOrderLogger();
54 52
55 @Autowired 53 @Autowired
@@ -159,7 +157,8 @@ public class AppraiseOrderService { @@ -159,7 +157,8 @@ public class AppraiseOrderService {
159 AppraiseOrderGoodsBo appraiseOrderGoodsBo; 157 AppraiseOrderGoodsBo appraiseOrderGoodsBo;
160 } 158 }
161 159
162 - OrderAttributes getOrderAttributes(){ 160 + @Override
  161 + public OrderAttributes getOrderAttributes(){
163 return OrderAttributes.APPRAISE; 162 return OrderAttributes.APPRAISE;
164 } 163 }
165 164
@@ -342,13 +341,21 @@ public class AppraiseOrderService { @@ -342,13 +341,21 @@ public class AppraiseOrderService {
342 * @param orderCode 341 * @param orderCode
343 * @return 342 * @return
344 */ 343 */
345 - public boolean isAppraiseOrder(long orderCode){ 344 + public ExistenceNode isAppraiseOrder(long orderCode){
346 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode); 345 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
347 boolean flag = Objects.nonNull(pao); 346 boolean flag = Objects.nonNull(pao);
348 Integer aoac = flag ? pao.getAttributes() : null; 347 Integer aoac = flag ? pao.getAttributes() : null;
349 logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}", 348 logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",
350 orderCode, aoac, flag); 349 orderCode, aoac, flag);
351 - return flag; 350 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
  351 + }
  352 +
  353 + @Data
  354 + @Builder
  355 + public static class ExistenceNode{
  356 + boolean isExisted;
  357 + AppraiseOrder appraiseOrder;
  358 +
352 } 359 }
353 360
354 /** 361 /**
@@ -357,7 +364,7 @@ public class AppraiseOrderService { @@ -357,7 +364,7 @@ public class AppraiseOrderService {
357 * @param orderCode 364 * @param orderCode
358 * @return 365 * @return
359 */ 366 */
360 - public boolean isPaidAppraiseOrder(int uid, long orderCode){ 367 + public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){
361 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode); 368 AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
362 Integer aoac = null; 369 Integer aoac = null;
363 OrderAttributes oa = null; 370 OrderAttributes oa = null;
@@ -367,22 +374,24 @@ public class AppraiseOrderService { @@ -367,22 +374,24 @@ public class AppraiseOrderService {
367 && Objects.equals(oa, OrderAttributes.APPRAISE); 374 && Objects.equals(oa, OrderAttributes.APPRAISE);
368 logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}", 375 logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
369 uid, orderCode, aoac, oa, flag); 376 uid, orderCode, aoac, oa, flag);
370 - return flag; 377 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
371 } 378 }
372 379
373 /** 380 /**
374 * 发货 381 * 发货
375 - * @param orderCode  
376 - * @param depotNum 382 + * @param req
377 */ 383 */
378 - public void deliver2Depot(long orderCode, int depotNum){ 384 + @Override
  385 + public int deliver2Depot(DeliverToDepotReq req){
379 386
  387 + return 0;
380 } 388 }
381 389
382 /** 390 /**
383 * 平台收货 391 * 平台收货
384 * @param orderCode 392 * @param orderCode
385 */ 393 */
  394 + @Override
386 public void platformReceiveGoods(long orderCode){ 395 public void platformReceiveGoods(long orderCode){
387 396
388 } 397 }
@@ -391,6 +400,7 @@ public class AppraiseOrderService { @@ -391,6 +400,7 @@ public class AppraiseOrderService {
391 * 鉴定通过 400 * 鉴定通过
392 * @param orderCode 401 * @param orderCode
393 */ 402 */
  403 + @Override
394 public void appraisePass(long orderCode){ 404 public void appraisePass(long orderCode){
395 405
396 } 406 }
@@ -399,6 +409,7 @@ public class AppraiseOrderService { @@ -399,6 +409,7 @@ public class AppraiseOrderService {
399 * 鉴别为假 409 * 鉴别为假
400 * @param orderCode 410 * @param orderCode
401 */ 411 */
  412 + @Override
402 public void appraiseFake(long orderCode){ 413 public void appraiseFake(long orderCode){
403 414
404 } 415 }
@@ -407,6 +418,7 @@ public class AppraiseOrderService { @@ -407,6 +418,7 @@ public class AppraiseOrderService {
407 * 无法鉴别 418 * 无法鉴别
408 * @param orderCode 419 * @param orderCode
409 */ 420 */
  421 + @Override
410 public void unsure(long orderCode){ 422 public void unsure(long orderCode){
411 423
412 } 424 }
@@ -12,6 +12,7 @@ import com.yohobuy.ufo.model.order.common.*; @@ -12,6 +12,7 @@ import com.yohobuy.ufo.model.order.common.*;
12 import com.yohobuy.ufo.model.order.constants.DepotType; 12 import com.yohobuy.ufo.model.order.constants.DepotType;
13 import com.yohobuy.ufo.model.order.constants.SkupType; 13 import com.yohobuy.ufo.model.order.constants.SkupType;
14 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum; 14 import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
  15 +import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
15 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail; 16 import com.yohobuy.ufo.model.order.resp.ExpressInfoDetail;
16 import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo; 17 import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
17 import com.yohobuy.ufo.model.order.resp.MiniFaultConfirm; 18 import com.yohobuy.ufo.model.order.resp.MiniFaultConfirm;
@@ -37,6 +38,7 @@ import com.yohoufo.order.model.response.AppraiseAddressResp; @@ -37,6 +38,7 @@ import com.yohoufo.order.model.response.AppraiseAddressResp;
37 import com.yohoufo.order.service.IBuyerOrderMetaService; 38 import com.yohoufo.order.service.IBuyerOrderMetaService;
38 import com.yohoufo.order.service.IExpressCompanyService; 39 import com.yohoufo.order.service.IExpressCompanyService;
39 import com.yohoufo.order.service.IExpressInfoService; 40 import com.yohoufo.order.service.IExpressInfoService;
  41 +import com.yohoufo.order.service.IGoodsService;
40 import com.yohoufo.order.service.cache.CacheCleaner; 42 import com.yohoufo.order.service.cache.CacheCleaner;
41 import com.yohoufo.order.service.cache.CacheKeyBuilder; 43 import com.yohoufo.order.service.cache.CacheKeyBuilder;
42 import com.yohoufo.order.service.proxy.*; 44 import com.yohoufo.order.service.proxy.*;
@@ -124,6 +126,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -124,6 +126,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
124 @Autowired 126 @Autowired
125 private UserProxyService userProxyService; 127 private UserProxyService userProxyService;
126 128
  129 + @Autowired
  130 + private AppraiseOrderService appraiseOrderService;
  131 +
127 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data"; 132 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
128 133
129 //物流文案设置 134 //物流文案设置
@@ -135,42 +140,26 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -135,42 +140,26 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
135 @Autowired 140 @Autowired
136 private SkupService skupService; 141 private SkupService skupService;
137 142
138 - /**  
139 - * @param sellerUid 卖家的uid  
140 - * @param expressCompanyId 快递公司id  
141 - * @param orderCode 订单号 :一定是买家订单编号  
142 - * @param wayBillCode 快递单号  
143 - * @param depotNum 鉴定中心id  
144 - */  
145 - @Override  
146 - public void deliverToDepot(Integer sellerUid, Integer expressCompanyId, Long orderCode, String wayBillCode,  
147 - Integer depotNum) {  
148 - //用户扫描二维码,防止注入信息  
149 - if (StringUtils.isBlank(wayBillCode) || wayBillCode.toLowerCase().contains("http")) {  
150 - throw new UfoServiceException(400, "无效的快递单号");  
151 - }  
152 - wayBillCode = StringUtils.defaultString(wayBillCode).trim();  
153 - //保存物流信息+更新订单状态;  
154 - //本阶段的物流类型和订单状态 143 + @Autowired
  144 + private ServiceOrderProcessor serviceOrderProcessor;
  145 +
  146 + private int processBuyerOrder(BuyerOrder buyerOrder,
  147 + Integer expressCompanyId,
  148 + Integer expressType,
  149 + String wayBillCode,
  150 + Integer depotNum){
  151 + long orderCode = buyerOrder.getOrderCode();
  152 + Integer sellerUid = buyerOrder.getSellerUid();
155 final OrderStatus expectOrderStatus = OrderStatus.HAS_PAYED; 153 final OrderStatus expectOrderStatus = OrderStatus.HAS_PAYED;
156 final OrderStatus targetOrderStatus = OrderStatus.SELLER_SEND_OUT; 154 final OrderStatus targetOrderStatus = OrderStatus.SELLER_SEND_OUT;
157 - Integer expressType = EnumExpressType.EXPRESS_TYPE_1.getCode();  
158 -  
159 LOGGER.info("deliverToDepot saveExpressAndUpdateBuyerOrderStatus sellerUid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {} " + 155 LOGGER.info("deliverToDepot saveExpressAndUpdateBuyerOrderStatus sellerUid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
160 - ",expressType = {} ,expectOrderStatus = {} ,targetOrderStatus = {} ,depotNum = {}", new Object[]{sellerUid, expressCompanyId, orderCode, wayBillCode, expressType, expectOrderStatus, targetOrderStatus, depotNum});  
161 - //TODO 应该将卖家的id带进去查询买家订单,防止操作别人卖的订单  
162 - BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);  
163 -  
164 - if (buyerOrder == null) {  
165 - LOGGER.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);  
166 - throw new ServiceException(ServiceError.ORDER_NULL);  
167 - } 156 + ",expressType = {} ,expectOrderStatus = {} ,targetOrderStatus = {} ,depotNum = {}",
  157 + new Object[]{sellerUid, expressCompanyId, orderCode, wayBillCode, expressType, expectOrderStatus, targetOrderStatus, depotNum});
168 Integer orderStatus = buyerOrder.getStatus(); 158 Integer orderStatus = buyerOrder.getStatus();
169 if (orderStatus != expectOrderStatus.getCode()) { 159 if (orderStatus != expectOrderStatus.getCode()) {
170 LOGGER.warn("deliverToDepot order status changed , orderCode {} orderStatus {}", orderCode, orderStatus); 160 LOGGER.warn("deliverToDepot order status changed , orderCode {} orderStatus {}", orderCode, orderStatus);
171 throw new UfoServiceException(400, "订单状态已变更,不能发货"); 161 throw new UfoServiceException(400, "订单状态已变更,不能发货");
172 } 162 }
173 -  
174 int buyerUid; 163 int buyerUid;
175 //获取skup 164 //获取skup
176 BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerUid = buyerOrder.getUid(), orderCode); 165 BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerUid = buyerOrder.getUid(), orderCode);
@@ -189,30 +178,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -189,30 +178,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
189 // 更新买家订单状态 178 // 更新买家订单状态
190 int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerOrder.getUid(), 179 int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerOrder.getUid(),
191 expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond()); 180 expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
192 - SellerOrderGoods psog;  
193 - if (updateBuyerCnt > 0) { // 更新买家订单成功之后,插入物流信息。防止并发、重复提交  
194 - // 保存订单物流信息  
195 - EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;  
196 - EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.seller_send_out;  
197 - String mobile = "";  
198 - AppraiseAddressResp appraiseAddressResp = appraiseAddressService.queryInitAddressByDepotNum(depotNum);  
199 - if (appraiseAddressResp != null) {  
200 - mobile = appraiseAddressResp.getMobile();  
201 - }  
202 181
203 - LOGGER.info("deliverToDepot saveExpress expressCompanyId {}, orderCode {}, wayBillCode {} " +  
204 - ",expressType {},depotNum {},mobile {},expressDataType {},operateTransferCode {}",  
205 - new Object[]{expressCompanyId, orderCode, wayBillCode, expressType, depotNum, mobile, expressDataType, operateTransferCode});  
206 - saveExpressRecordAndOperateTransferExpressInfo(sellerUid, expressCompanyId, orderCode, wayBillCode, expressType, expressDataType, operateTransferCode, depotNum);  
207 -  
208 - // 发送mq获取物流信息  
209 - sendExpressMQ(sellerUid, expressCompanyId, orderCode, wayBillCode, mobile);  
210 - psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);  
211 - LOGGER.info("deliverToDepot end ! send express to erp "); 182 + if (updateBuyerCnt>0){
212 183
213 - //记录订单的状态变更信息  
214 - LOGGER.info("in deliverToDepot record status change, orderCode {},uid {} ,sellerUid {}", orderCode, buyerUid, sellerUid);  
215 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode()); 184 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
  185 + SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
216 186
217 buyerNoticeFacade.sellerDeliver2Depot(buyerOrder, psog); 187 buyerNoticeFacade.sellerDeliver2Depot(buyerOrder, psog);
218 188
@@ -234,10 +204,86 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -234,10 +204,86 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
234 204
235 ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid); 205 ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
236 EventBusPublisher.publishEvent(event); 206 EventBusPublisher.publishEvent(event);
  207 + }
  208 + return updateBuyerCnt;
  209 + }
  210 +
  211 + /**
  212 + * @param sellerUid 卖家的uid
  213 + * @param expressCompanyId 快递公司id
  214 + * @param orderCode 订单号 :一定是买家订单编号
  215 + * @param wayBillCode 快递单号
  216 + * @param depotNum 鉴定中心id
  217 + */
  218 + @Override
  219 + public void deliverToDepot(Integer sellerUid,
  220 + Integer expressCompanyId,
  221 + Long orderCode,
  222 + String wayBillCode,
  223 + Integer depotNum) {
  224 + //用户扫描二维码,防止注入信息
  225 + if (StringUtils.isBlank(wayBillCode) || wayBillCode.toLowerCase().contains("http")) {
  226 + throw new UfoServiceException(400, "无效的快递单号");
  227 + }
  228 + wayBillCode = StringUtils.defaultString(wayBillCode).trim();
  229 + //保存物流信息+更新订单状态;
  230 + //本阶段的物流类型和订单状态
  231 +
  232 + Integer expressType = EnumExpressType.EXPRESS_TYPE_1.getCode();
  233 +
  234 +
  235 + //TODO 应该将卖家的id带进去查询买家订单,防止操作别人卖的订单
  236 + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
  237 +
  238 + int updateOrderCnt = 0;
  239 + if (buyerOrder == null) {
  240 + AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode);
  241 + if (!existenceNode.isExisted) {
  242 + LOGGER.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
  243 + throw new ServiceException(ServiceError.ORDER_NULL);
  244 + }
  245 + AppraiseOrder appraiseOrder = existenceNode.appraiseOrder;
  246 + IGoodsService goodsService = serviceOrderProcessor.findGoodsSeriveInstance(appraiseOrder.getAttributes());
  247 +
  248 + DeliverToDepotReq deliverToDepotReq = DeliverToDepotReq.builder().orderCode(orderCode)
  249 + .depotNum(depotNum).uid(sellerUid).build();
  250 + updateOrderCnt = goodsService.deliver2Depot(deliverToDepotReq);
  251 +
  252 +
  253 + }else {
  254 + updateOrderCnt = processBuyerOrder(buyerOrder, expressCompanyId, expressType, wayBillCode, depotNum);
  255 + }
  256 +
  257 +
  258 +
  259 +
  260 + if (updateOrderCnt > 0) { // 更新买家订单成功之后,插入物流信息。防止并发、重复提交
  261 + // 保存订单物流信息
  262 + EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
  263 + EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.seller_send_out;
  264 + String mobile = "";
  265 + AppraiseAddressResp appraiseAddressResp = appraiseAddressService.queryInitAddressByDepotNum(depotNum);
  266 + if (appraiseAddressResp != null) {
  267 + mobile = appraiseAddressResp.getMobile();
  268 + }
  269 +
  270 + LOGGER.info("deliverToDepot saveExpress expressCompanyId {}, orderCode {}, wayBillCode {} " +
  271 + ",expressType {},depotNum {},mobile {},expressDataType {},operateTransferCode {}",
  272 + new Object[]{expressCompanyId, orderCode, wayBillCode, expressType, depotNum, mobile, expressDataType, operateTransferCode});
  273 + saveExpressRecordAndOperateTransferExpressInfo(sellerUid, expressCompanyId, orderCode, wayBillCode, expressType, expressDataType, operateTransferCode, depotNum);
  274 +
  275 + // 发送mq获取物流信息
  276 + sendExpressMQ(sellerUid, expressCompanyId, orderCode, wayBillCode, mobile);
  277 +
  278 + LOGGER.info("deliverToDepot end ! send express to erp ");
  279 +
  280 + //记录订单的状态变更信息
  281 + LOGGER.info("in deliverToDepot record status change, orderCode {}, sellerUid {}", orderCode, sellerUid);
  282 +
237 } else { 283 } else {
238 LOGGER.warn("deliverToDepot can not update order, orderCode {}", orderCode); 284 LOGGER.warn("deliverToDepot can not update order, orderCode {}", orderCode);
239 } 285 }
240 - LOGGER.info("deliverToDepot update buyer order status, orderCode {} result {} ", orderCode, updateBuyerCnt); 286 + LOGGER.info("deliverToDepot update buyer order status, orderCode {} result {} ", orderCode, updateOrderCnt);
241 } 287 }
242 288
243 @Override 289 @Override
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yohobuy.ufo.model.order.common.OrderAttributes;
  4 +import com.yohoufo.common.exception.UfoServiceException;
  5 +import com.yohoufo.order.service.IGoodsService;
  6 +import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +@Service
  11 +public class ServiceOrderProcessor {
  12 +
  13 + @Autowired
  14 + private AppraiseOrderService appraiseOrderService;
  15 +
  16 + @Autowired
  17 + private SellerDepositOrderService sellerDepositOrderService;
  18 +
  19 +
  20 + public IGoodsService findGoodsSeriveInstance(int oac){
  21 + OrderAttributes oa = OrderAttributes.getOrderAttributes(oac);
  22 + IGoodsService goodsService = null;
  23 + switch (oa){
  24 + case APPRAISE:
  25 + goodsService = appraiseOrderService;
  26 + break;
  27 +
  28 + case DEPOSITE:
  29 + goodsService = sellerDepositOrderService;
  30 + break;
  31 + default:
  32 + throw new UfoServiceException(500, "订单类型错误");
  33 + }
  34 + return goodsService;
  35 + }
  36 +
  37 +}
  1 +package com.yohoufo.order.service.seller.deposit;
  2 +
  3 +import com.google.common.collect.Lists;
  4 +import com.yohobuy.ufo.model.order.bo.TimeoutBo;
  5 +import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
  6 +import com.yohobuy.ufo.model.order.common.OrderAttributes;
  7 +import com.yohobuy.ufo.model.order.common.TabType;
  8 +import com.yohobuy.ufo.model.order.constants.DepotType;
  9 +import com.yohobuy.ufo.model.order.constants.SkupType;
  10 +import com.yohobuy.ufo.model.order.req.SellerDepositOrderDetailReq;
  11 +import com.yohobuy.ufo.model.order.req.SellerDepositOrderPrdListReq;
  12 +import com.yohobuy.ufo.model.order.resp.AppraiseAddressInfo;
  13 +import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
  14 +import com.yohobuy.ufo.model.order.resp.PageResp;
  15 +import com.yohobuy.ufo.model.order.resp.SellerDepositOrderDetailResp;
  16 +import com.yohobuy.ufo.model.order.vo.AddressInfo;
  17 +import com.yohobuy.ufo.model.order.vo.ProductVo;
  18 +import com.yohoufo.common.utils.DateUtil;
  19 +import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
  20 +import com.yohoufo.dal.order.AppraiseOrderMapper;
  21 +import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
  22 +import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
  23 +import com.yohoufo.dal.order.model.AppraiseOrder;
  24 +import com.yohoufo.dal.order.model.AppraiseOrderGoods;
  25 +import com.yohoufo.order.convert.SellerOrderConvertor;
  26 +import com.yohoufo.order.model.response.AppraiseAddressResp;
  27 +import com.yohoufo.order.service.impl.AbsOrderViewService;
  28 +import com.yohoufo.order.service.impl.AppraiseAddressService;
  29 +import com.yohoufo.order.utils.LoggerUtils;
  30 +import org.slf4j.Logger;
  31 +import org.springframework.beans.factory.annotation.Autowired;
  32 +import org.springframework.stereotype.Service;
  33 +
  34 +import java.util.Arrays;
  35 +import java.util.List;
  36 +
  37 +@Service
  38 +public class SellerDepositOrderDetailService extends AbsOrderViewService {
  39 +
  40 + private final Logger logger = LoggerUtils.getSellerOrderLogger();
  41 +
  42 +
  43 + @Autowired
  44 + private AppraiseOrderMapper appraiseOrderMapper;
  45 +
  46 + @Autowired
  47 + private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
  48 +
  49 + @Autowired
  50 + private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
  51 +
  52 + @Autowired
  53 + private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
  54 +
  55 + @Autowired
  56 + private AppraiseOrderMetaService appraiseOrderMetaService;
  57 +
  58 + @Autowired
  59 + private AppraiseAddressService appraiseAddressService;
  60 +
  61 + @Autowired
  62 + private SellerDepositOrderListService sellerDepositOrderListService;
  63 +
  64 +
  65 + private static final List<Integer> showEXpressInfoStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),
  66 + AppraiseOrderStatus.WAITING_RECEIVE.getCode(),
  67 + AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),
  68 + AppraiseOrderStatus.JUDGE_PASS.getCode(),
  69 + AppraiseOrderStatus.CHECKING_FAKE.getCode(),
  70 + AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()
  71 + );
  72 + private static final List<Integer> showUserAddressStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),
  73 + AppraiseOrderStatus.WAITING_RECEIVE.getCode(),
  74 + AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),
  75 + AppraiseOrderStatus.JUDGE_PASS.getCode(),
  76 + AppraiseOrderStatus.CHECKING_FAKE.getCode(),
  77 + AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()
  78 + );
  79 + private static final List<Integer> showAppraiseAddressStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),
  80 + AppraiseOrderStatus.WAITING_RECEIVE.getCode(),
  81 + AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),
  82 + AppraiseOrderStatus.JUDGE_PASS.getCode(),
  83 + AppraiseOrderStatus.CHECKING_FAKE.getCode(),
  84 + AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()
  85 + );
  86 +
  87 + private static final List<Integer> addressUpgradableStatusList = Lists.newArrayList(AppraiseOrderStatus.HAS_PAYED.getCode());
  88 +
  89 +
  90 + public SellerDepositOrderDetailResp getOrderDetail(SellerDepositOrderDetailReq req){
  91 + Long orderCode = req.getOrderCode();
  92 + int uid = req.getUid();
  93 + AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
  94 + OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
  95 +
  96 + //todo use another page list query
  97 + List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCodes(Arrays.asList(orderCode));
  98 + //
  99 + TimeoutBo timeout = calTimeout(TabType.BUY, uid, orderCode, pao.getStatus(),
  100 + pao.getCreateTime(), oa);
  101 + boolean expressShow = showEXpressInfoStatusList.contains(pao.getStatus());
  102 + //
  103 + AppraiseOrderStatus aos = AppraiseOrderStatus.getByCode(pao.getStatus());
  104 + OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail
  105 + .builder()
  106 + .statuStr(aos.statusStr(oa))
  107 + .detailDesc(aos.detailDesc(oa))
  108 + .expressShow(expressShow)
  109 + .build();
  110 + //
  111 + AppraiseAddressInfo appraiseAddressInfo = null;
  112 + if(showAppraiseAddressStatusList.contains(pao.getStatus())){
  113 + AppraiseAddressResp aaResp = appraiseAddressService.findByDepotType(DepotType.NJ.getCode());
  114 + appraiseAddressInfo = AppraiseAddressService.convert2AppraiseAddressInfo(aaResp);
  115 + }
  116 + AddressInfo userAddress = null;
  117 + if (showUserAddressStatusList.contains(pao.getStatus())){
  118 + userAddress = appraiseOrderMetaService.getHidderUserAddress(orderCode);
  119 + }
  120 + boolean addressUpgradable = addressUpgradableStatusList.contains(pao.getStatus());
  121 + SellerDepositOrderPrdListReq sknListReq = SellerDepositOrderPrdListReq.builder()
  122 + .orderCode(orderCode)
  123 + .page(1).limit(10).uid(uid).build();
  124 + PageResp<ProductVo> sknListPageResp = sellerDepositOrderListService.getSknList(sknListReq);
  125 + return SellerDepositOrderDetailResp.builder()
  126 + .orderCode(orderCode)
  127 + .uid(uid)
  128 + .earnestMoney(SellerOrderConvertor.formatFee(pao.getAmount()))
  129 + .createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))
  130 + .timeout(timeout)
  131 + .statusDetail(statusDetail)
  132 + .productList(sknListPageResp.getData())
  133 + .userAddress(userAddress)
  134 + .appraiseAddress(appraiseAddressInfo)
  135 + .addressUpgradable(addressUpgradable)
  136 + .build()
  137 + ;
  138 + }
  139 +
  140 +
  141 + @Override
  142 + public Logger getLogger() {
  143 + return logger;
  144 + }
  145 +
  146 + @Override
  147 + protected String buildOrderTypeTag(Integer orderAttr, SkupType skupType) {
  148 + return null;
  149 + }
  150 +}
  1 +package com.yohoufo.order.service.seller.deposit;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
  5 +import com.yohobuy.ufo.model.order.common.OrderAttributes;
  6 +import com.yohobuy.ufo.model.order.constants.SellerDepositOrderListType;
  7 +import com.yohobuy.ufo.model.order.req.SellerDepositOrderListReq;
  8 +import com.yohobuy.ufo.model.order.req.SellerDepositOrderPrdListReq;
  9 +import com.yohobuy.ufo.model.order.resp.PageResp;
  10 +import com.yohobuy.ufo.model.order.resp.SellerDepositOrderListResp;
  11 +import com.yohobuy.ufo.model.order.vo.GoodsVo;
  12 +import com.yohobuy.ufo.model.order.vo.ProductVo;
  13 +import com.yohoufo.common.helper.ImageUrlAssist;
  14 +import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
  15 +import com.yohoufo.dal.order.AppraiseOrderMapper;
  16 +import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
  17 +import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
  18 +import com.yohoufo.dal.order.model.AppraiseOrder;
  19 +import com.yohoufo.dal.order.model.AppraiseOrderGoods;
  20 +import com.yohoufo.dal.order.model.AppraiseOrderMeta;
  21 +import com.yohoufo.dal.order.model.AppraiseOrderStorage;
  22 +import com.yohoufo.order.constants.MetaKey;
  23 +import com.yohoufo.order.convert.ProductConvertor;
  24 +import com.yohoufo.order.convert.SellerOrderConvertor;
  25 +import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  26 +import com.yohoufo.order.utils.LoggerUtils;
  27 +import lombok.Builder;
  28 +import org.slf4j.Logger;
  29 +import org.springframework.beans.factory.annotation.Autowired;
  30 +import org.springframework.stereotype.Service;
  31 +
  32 +import java.math.BigDecimal;
  33 +import java.util.*;
  34 +import java.util.function.Function;
  35 +import java.util.stream.Collectors;
  36 +
  37 +@Service
  38 +public class SellerDepositOrderListService {
  39 + private final Logger logger = LoggerUtils.getSellerOrderLogger();
  40 +
  41 + @Autowired
  42 + private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
  43 +
  44 + @Autowired
  45 + private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
  46 +
  47 + @Autowired
  48 + private AppraiseOrderMapper appraiseOrderMapper;
  49 +
  50 +
  51 + @Autowired
  52 + private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
  53 +
  54 + public PageResp<SellerDepositOrderListResp> getOrderList(SellerDepositOrderListReq req ){
  55 + PageResp.PageRespBuilder<SellerDepositOrderListResp> respBuilder = PageResp.builder();
  56 + SellerDepositOrderListType sellerDepositOrderListType = SellerDepositOrderListType.getByCode(req.getListType());
  57 + if (Objects.isNull(sellerDepositOrderListType)){
  58 + return respBuilder.build();
  59 + }
  60 +
  61 + int uid = req.getUid();
  62 + OrderAttributes orderAttributes = getOrderAttributes();
  63 + final List<Integer> statusList = sellerDepositOrderListType.statusList();
  64 + int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList);
  65 + int limit = req.getLimit();
  66 + if (total == 0){
  67 + return respBuilder
  68 + .pageSize(limit)
  69 + .total(total)
  70 + .page(req.getPage())
  71 + .build();
  72 + }
  73 +
  74 + int offset = (req.getPage() - 1) * limit;
  75 +
  76 + List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, offset, limit);
  77 +
  78 + List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
  79 + List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
  80 +
  81 +
  82 + Map<Long,List<AppraiseOrderGoods>> orderCodeAOGMap = new HashMap<>(paogs.size());
  83 + for (AppraiseOrderGoods paog : paogs){
  84 + long orderCode;
  85 + List<AppraiseOrderGoods> list;
  86 + if (!orderCodeAOGMap.containsKey(orderCode=paog.getOrderCode())){
  87 + list = new ArrayList(16);
  88 + orderCodeAOGMap.put(orderCode, list);
  89 + }else{
  90 + list = orderCodeAOGMap.get(orderCode);
  91 + }
  92 + list.add(paog);
  93 + }
  94 +
  95 +
  96 + List<SellerDepositOrderListResp> aolrList = orderList.parallelStream()
  97 + .map(pao-> buildSellerDepositOrderListResp(pao, orderCodeAOGMap.get(pao.getOrderCode())))
  98 + .collect(Collectors.toList());
  99 +
  100 + respBuilder.page(req.getPage())
  101 + .pageSize(limit)
  102 + .total(total)
  103 + .pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1))
  104 + .data(aolrList);
  105 + return respBuilder.build();
  106 + }
  107 +
  108 + SellerDepositOrderListResp buildSellerDepositOrderListResp(AppraiseOrder pao, List<AppraiseOrderGoods> aogList){
  109 + int uid = pao.getUid();
  110 + long orderCode = pao.getOrderCode();
  111 + int status = pao.getStatus();
  112 + AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(status);
  113 + OrderAttributes oa = getOrderAttributes();
  114 + List<ProductVo> productList = aogList.parallelStream()
  115 + .sorted(Comparator.comparing(AppraiseOrderGoods::getOrderBy))
  116 + .map(paog -> ProductVo.builder()
  117 + .imgUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))
  118 + .build())
  119 + .collect(Collectors.toCollection(()->new ArrayList<>(aogList.size())));
  120 + return SellerDepositOrderListResp.builder()
  121 + .uid(uid)
  122 + .orderCode(orderCode)
  123 + .status(status)
  124 + .statuStr(appraiseOrderStatus.statusStr(oa))
  125 + .buttons(appraiseOrderStatus.listButtons(oa))
  126 + .productList(productList)
  127 + .build();
  128 + }
  129 + OrderAttributes getOrderAttributes(){
  130 + return OrderAttributes.DEPOSITE;
  131 + }
  132 +
  133 +
  134 + public PageResp<ProductVo> getSknList(SellerDepositOrderPrdListReq req){
  135 + Long orderCode = req.getOrderCode();
  136 + int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);
  137 + int limit = req.getLimit();
  138 + PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();
  139 + respBuilder.page(req.getPage()).pageSize(limit).total(total);
  140 + if (total == 0){
  141 + return respBuilder.build();
  142 + }
  143 + int offset = (req.getPage() - 1) * limit;
  144 + List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
  145 +
  146 + List<ProductVo> productVoList = buildProductVoListWithSkuSummary(paogs);
  147 +
  148 + respBuilder.data(productVoList);
  149 + return respBuilder.build();
  150 + }
  151 +
  152 + List<ProductVo> buildProductVoListWithSkuSummary(List<AppraiseOrderGoods> paogs){
  153 +
  154 + return paogs.parallelStream().map(paog-> ProductConvertor.convertProductVo(paog, null))
  155 + .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));
  156 + }
  157 +
  158 +
  159 + public PageResp<ProductVo> getSkuList(SellerDepositOrderPrdListReq req){
  160 + final Long orderCode = req.getOrderCode();
  161 + int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);
  162 + int limit = req.getLimit();
  163 + PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();
  164 + respBuilder.page(req.getPage()).pageSize(limit).total(total);
  165 + if (total == 0){
  166 + return respBuilder.build();
  167 + }
  168 + int offset = (req.getPage() - 1) * limit;
  169 + List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);
  170 + OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogs);
  171 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
  172 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
  173 +
  174 + List<ProductVo> productVoList = buildProductVoListWithSkuDetail(paogs, prdIdAOSListMap, storageIdSOCRMap);
  175 +
  176 + respBuilder.data(productVoList);
  177 + return respBuilder.build();
  178 + }
  179 +
  180 + List<ProductVo> buildProductVoListWithSkuDetail(List<AppraiseOrderGoods> paogs,
  181 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap,
  182 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap){
  183 +
  184 +
  185 +
  186 + Map<Integer,ProductVo> tempProductMap = new HashMap<>(paogs.size());
  187 + for(Map.Entry<Integer,List<AppraiseOrderStorage>> prdIdAOSListEntry : prdIdAOSListMap.entrySet()){
  188 + Integer prdId = prdIdAOSListEntry.getKey();
  189 + List<AppraiseOrderStorage> aosList = prdIdAOSListEntry.getValue();
  190 + int sizeNum = aosList.size();
  191 + List<GoodsVo> goodsList = new ArrayList<>(sizeNum);
  192 + for (AppraiseOrderStorage aos : aosList){
  193 + Integer storageId;
  194 + SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId=aos.getStorageId());
  195 + if (Objects.isNull(socr)){
  196 + logger.warn("in buildProductVoListWithSkuDetail ComputeResult null ,AppraiseOrderStorage {}", aos);
  197 + continue;
  198 + }
  199 + Integer storageNum;
  200 + BigDecimal emOfSku = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(storageNum=aos.getNum()));
  201 + GoodsVo goodsVo = GoodsVo.builder().sizeName(aos.getSizeName()).num(storageNum)
  202 + .earnestMoney(SellerOrderConvertor.formatFee(emOfSku)).build();
  203 + goodsList.add(goodsVo);
  204 + }
  205 +
  206 + tempProductMap.put(prdId, ProductVo.builder().sizeNum(sizeNum).goodsList(goodsList).build());
  207 + }
  208 +
  209 +
  210 + return paogs.parallelStream().map(paog-> ProductConvertor.convertProductVo(paog, tempProductMap.get(paog.getProductId())))
  211 + .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));
  212 + }
  213 +
  214 + @Builder
  215 + static class OrderDataNode{
  216 + int sknNum;
  217 + List<AppraiseOrderGoods> paogs;
  218 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap;
  219 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap;
  220 + Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap;
  221 + }
  222 +
  223 + OrderDataNode buildDataSourceOfParentOrder(long orderCode, List<AppraiseOrderGoods> paogs){
  224 + Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size());
  225 + Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(128);
  226 +
  227 + Function<AppraiseOrderMeta, SellerOrderComputeResult> socrFunction = aom -> {
  228 + SellerOrderComputeResult socr = null;
  229 + String metaVal = null;
  230 + try {
  231 + socr = JSONObject.parseObject(metaVal=aom.getMetaValue(), SellerOrderComputeResult.class);
  232 + }catch (Exception ex){
  233 + logger.warn("in convert SellerOrderComputeResult fail, ordercode {} metaVal {}", orderCode, metaVal);
  234 + }finally {
  235 + return socr;
  236 + }
  237 + };
  238 + Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = new HashMap<>(128);
  239 + for(AppraiseOrderGoods paog : paogs){
  240 + Integer prdId;
  241 + List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId=paog.getProductId());
  242 + prdIdAOSListMap.put(prdId, paosList);
  243 + List<Integer> storageIds = paosList.parallelStream().map(AppraiseOrderStorage::getStorageId).collect(Collectors.toList());
  244 + //
  245 + AppraiseOrderMeta aomc = new AppraiseOrderMeta();
  246 + aomc.setOrderCode(orderCode);
  247 + aomc.setMetaKey(MetaKey.SELLER_FEE);
  248 + List<AppraiseOrderMeta> paomList = appraiseOrderMetaMapper.selectByOrderCodeStorageIds(aomc, storageIds);
  249 + //
  250 + storageIdFeeMetaMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, Function.identity())));
  251 + storageIdSOCRMap.putAll(paomList.parallelStream().collect(Collectors.toMap(AppraiseOrderMeta::getStorageId, socrFunction::apply)));
  252 + }
  253 + return OrderDataNode.builder().paogs(paogs)
  254 + .prdIdAOSListMap(prdIdAOSListMap)
  255 + .storageIdFeeMetaMap(storageIdFeeMetaMap)
  256 + .storageIdSOCRMap(storageIdSOCRMap)
  257 + .build();
  258 + }
  259 +}
1 package com.yohoufo.order.service.seller.deposit; 1 package com.yohoufo.order.service.seller.deposit;
2 2
3 -import com.alibaba.fastjson.JSONObject;  
4 -import com.google.common.collect.Lists;  
5 -import com.yohobuy.ufo.model.order.bo.OrderInfo;  
6 -import com.yohobuy.ufo.model.order.bo.TimeoutBo;  
7 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus; 3 import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
8 import com.yohobuy.ufo.model.order.common.OrderAttributes; 4 import com.yohobuy.ufo.model.order.common.OrderAttributes;
9 import com.yohobuy.ufo.model.order.common.OrderCodeType; 5 import com.yohobuy.ufo.model.order.common.OrderCodeType;
10 -import com.yohobuy.ufo.model.order.common.TabType;  
11 -import com.yohobuy.ufo.model.order.constants.DepotType;  
12 import com.yohobuy.ufo.model.order.constants.SellerDepositOrderListType; 6 import com.yohobuy.ufo.model.order.constants.SellerDepositOrderListType;
13 -import com.yohobuy.ufo.model.order.constants.SkupType;  
14 import com.yohobuy.ufo.model.order.req.*; 7 import com.yohobuy.ufo.model.order.req.*;
15 import com.yohobuy.ufo.model.order.resp.*; 8 import com.yohobuy.ufo.model.order.resp.*;
16 -import com.yohobuy.ufo.model.order.vo.AddressInfo;  
17 import com.yohobuy.ufo.model.order.vo.GoodsVo; 9 import com.yohobuy.ufo.model.order.vo.GoodsVo;
18 import com.yohobuy.ufo.model.order.vo.ProductVo; 10 import com.yohobuy.ufo.model.order.vo.ProductVo;
19 import com.yohoufo.common.helper.ImageUrlAssist; 11 import com.yohoufo.common.helper.ImageUrlAssist;
@@ -24,32 +16,28 @@ import com.yohoufo.dal.order.AppraiseOrderMetaMapper; @@ -24,32 +16,28 @@ import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
24 import com.yohoufo.dal.order.AppraiseOrderStorageMapper; 16 import com.yohoufo.dal.order.AppraiseOrderStorageMapper;
25 import com.yohoufo.dal.order.model.AppraiseOrder; 17 import com.yohoufo.dal.order.model.AppraiseOrder;
26 import com.yohoufo.dal.order.model.AppraiseOrderGoods; 18 import com.yohoufo.dal.order.model.AppraiseOrderGoods;
27 -import com.yohoufo.dal.order.model.AppraiseOrderMeta;  
28 import com.yohoufo.dal.order.model.AppraiseOrderStorage; 19 import com.yohoufo.dal.order.model.AppraiseOrderStorage;
29 import com.yohoufo.order.common.ClientType; 20 import com.yohoufo.order.common.ClientType;
30 -import com.yohoufo.order.constants.MetaKey;  
31 import com.yohoufo.order.convert.SellerOrderConvertor; 21 import com.yohoufo.order.convert.SellerOrderConvertor;
32 import com.yohoufo.order.model.dto.SellerDepositOrderContext; 22 import com.yohoufo.order.model.dto.SellerDepositOrderContext;
33 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext; 23 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
34 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 24 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
35 -import com.yohoufo.order.model.response.AppraiseAddressResp;  
36 -import com.yohoufo.order.service.impl.AbsOrderViewService; 25 +import com.yohoufo.order.service.IGoodsService;
37 import com.yohoufo.order.service.impl.AppraiseAddressService; 26 import com.yohoufo.order.service.impl.AppraiseAddressService;
38 import com.yohoufo.order.service.impl.AppraiseOrderCreateService; 27 import com.yohoufo.order.service.impl.AppraiseOrderCreateService;
  28 +import com.yohoufo.order.service.proxy.OrderStatusFlowService;
39 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 29 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
40 import com.yohoufo.order.utils.LoggerUtils; 30 import com.yohoufo.order.utils.LoggerUtils;
41 -import lombok.Builder;  
42 import org.slf4j.Logger; 31 import org.slf4j.Logger;
43 import org.springframework.beans.factory.annotation.Autowired; 32 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.stereotype.Service; 33 import org.springframework.stereotype.Service;
45 34
46 import java.math.BigDecimal; 35 import java.math.BigDecimal;
47 import java.util.*; 36 import java.util.*;
48 -import java.util.function.Function;  
49 import java.util.stream.Collectors; 37 import java.util.stream.Collectors;
50 38
51 @Service 39 @Service
52 -public class SellerDepositOrderService extends AbsOrderViewService { 40 +public class SellerDepositOrderService implements IGoodsService {
53 private final Logger logger = LoggerUtils.getSellerOrderLogger(); 41 private final Logger logger = LoggerUtils.getSellerOrderLogger();
54 42
55 @Autowired 43 @Autowired
@@ -79,30 +67,11 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -79,30 +67,11 @@ public class SellerDepositOrderService extends AbsOrderViewService {
79 @Autowired 67 @Autowired
80 private AppraiseOrderMetaService appraiseOrderMetaService; 68 private AppraiseOrderMetaService appraiseOrderMetaService;
81 69
  70 + @Autowired
  71 + private SellerDepositOrderListService sellerDepositOrderListService;
82 72
83 - private static final List<Integer> showEXpressInfoStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),  
84 - AppraiseOrderStatus.WAITING_RECEIVE.getCode(),  
85 - AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),  
86 - AppraiseOrderStatus.JUDGE_PASS.getCode(),  
87 - AppraiseOrderStatus.CHECKING_FAKE.getCode(),  
88 - AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()  
89 - );  
90 - private static final List<Integer> showUserAddressStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),  
91 - AppraiseOrderStatus.WAITING_RECEIVE.getCode(),  
92 - AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),  
93 - AppraiseOrderStatus.JUDGE_PASS.getCode(),  
94 - AppraiseOrderStatus.CHECKING_FAKE.getCode(),  
95 - AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()  
96 - );  
97 - private static final List<Integer> showAppraiseAddressStatusList = Lists.newArrayList(AppraiseOrderStatus.SELLER_SEND_OUT.getCode(),  
98 - AppraiseOrderStatus.WAITING_RECEIVE.getCode(),  
99 - AppraiseOrderStatus.PLATFORM_RECEIVE.getCode(),  
100 - AppraiseOrderStatus.JUDGE_PASS.getCode(),  
101 - AppraiseOrderStatus.CHECKING_FAKE.getCode(),  
102 - AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE.getCode()  
103 - );  
104 -  
105 - private static final List<Integer> addressUpgradableStatusList = Lists.newArrayList(AppraiseOrderStatus.HAS_PAYED.getCode()); 73 + @Autowired
  74 + private OrderStatusFlowService orderStatusFlowService;
106 75
107 76
108 77
@@ -140,8 +109,8 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -140,8 +109,8 @@ public class SellerDepositOrderService extends AbsOrderViewService {
140 109
141 110
142 111
143 -  
144 - OrderAttributes getOrderAttributes(){ 112 + @Override
  113 + public OrderAttributes getOrderAttributes(){
145 return OrderAttributes.DEPOSITE; 114 return OrderAttributes.DEPOSITE;
146 } 115 }
147 116
@@ -182,291 +151,35 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -182,291 +151,35 @@ public class SellerDepositOrderService extends AbsOrderViewService {
182 } 151 }
183 152
184 153
185 - public PageResp<SellerDepositOrderListResp> getOrderList(SellerDepositOrderListReq req ){  
186 - PageResp.PageRespBuilder<SellerDepositOrderListResp> respBuilder = PageResp.builder();  
187 - SellerDepositOrderListType sellerDepositOrderListType = SellerDepositOrderListType.getByCode(req.getListType());  
188 - if (Objects.isNull(sellerDepositOrderListType)){  
189 - return respBuilder.build();  
190 - }  
191 -  
192 - int uid = req.getUid();  
193 - OrderAttributes orderAttributes = getOrderAttributes();  
194 - final List<Integer> statusList = sellerDepositOrderListType.statusList();  
195 - int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList);  
196 - int limit = req.getLimit();  
197 - if (total == 0){  
198 - return respBuilder  
199 - .pageSize(limit)  
200 - .total(total)  
201 - .page(req.getPage())  
202 - .build();  
203 - }  
204 -  
205 - int offset = (req.getPage() - 1) * limit;  
206 -  
207 - List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, offset, limit);  
208 -  
209 - List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());  
210 - List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);  
211 -  
212 -  
213 - Map<Long,List<AppraiseOrderGoods>> orderCodeAOGMap = new HashMap<>(paogs.size());  
214 - for (AppraiseOrderGoods paog : paogs){  
215 - long orderCode;  
216 - List<AppraiseOrderGoods> list;  
217 - if (!orderCodeAOGMap.containsKey(orderCode=paog.getOrderCode())){  
218 - list = new ArrayList(16);  
219 - orderCodeAOGMap.put(orderCode, list);  
220 - }else{  
221 - list = orderCodeAOGMap.get(orderCode);  
222 - }  
223 - list.add(paog);  
224 - }  
225 -  
226 -  
227 - List<SellerDepositOrderListResp> aolrList = orderList.parallelStream()  
228 - .map(pao-> buildSellerDepositOrderListResp(pao, orderCodeAOGMap.get(pao.getOrderCode())))  
229 - .collect(Collectors.toList());  
230 -  
231 - respBuilder.page(req.getPage())  
232 - .pageSize(limit)  
233 - .total(total)  
234 - .pagetotal((total % limit == 0) ? (total / limit) : (total / limit + 1))  
235 - .data(aolrList);  
236 - return respBuilder.build();  
237 - }  
238 -  
239 - SellerDepositOrderListResp buildSellerDepositOrderListResp(AppraiseOrder pao, List<AppraiseOrderGoods> aogList){  
240 - int uid = pao.getUid();  
241 - long orderCode = pao.getOrderCode();  
242 - int status = pao.getStatus();  
243 - AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(status);  
244 - OrderAttributes oa = getOrderAttributes();  
245 - List<ProductVo> productList = aogList.parallelStream()  
246 - .sorted(Comparator.comparing(AppraiseOrderGoods::getOrderBy))  
247 - .map(paog -> ProductVo.builder()  
248 - .imgUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))  
249 - .build())  
250 - .collect(Collectors.toCollection(()->new ArrayList<>(aogList.size())));  
251 - return SellerDepositOrderListResp.builder()  
252 - .uid(uid)  
253 - .orderCode(orderCode)  
254 - .status(status)  
255 - .statuStr(appraiseOrderStatus.statusStr(oa))  
256 - .buttons(appraiseOrderStatus.listButtons(oa))  
257 - .productList(productList)  
258 - .build();  
259 - }  
260 -  
261 -  
262 -  
263 - public SellerDepositOrderDetailResp getOrderDetail(SellerDepositOrderDetailReq req){  
264 - Long orderCode = req.getOrderCode();  
265 - int uid = req.getUid();  
266 - AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);  
267 - OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());  
268 -  
269 - //todo use another page list query  
270 - List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCodes(Arrays.asList(orderCode));  
271 - //  
272 - TimeoutBo timeout = calTimeout(TabType.BUY, uid, orderCode, pao.getStatus(),  
273 - pao.getCreateTime(), oa);  
274 - boolean expressShow = showEXpressInfoStatusList.contains(pao.getStatus());  
275 - //  
276 - AppraiseOrderStatus aos = AppraiseOrderStatus.getByCode(pao.getStatus());  
277 - OrderDetailInfo.StatusDetail statusDetail = OrderDetailInfo.StatusDetail  
278 - .builder()  
279 - .statuStr(aos.statusStr(oa))  
280 - .detailDesc(aos.detailDesc(oa))  
281 - .expressShow(expressShow)  
282 - .build();  
283 - //  
284 - AppraiseAddressInfo appraiseAddressInfo = null;  
285 - if(showAppraiseAddressStatusList.contains(pao.getStatus())){  
286 - AppraiseAddressResp aaResp = appraiseAddressService.findByDepotType(DepotType.NJ.getCode());  
287 - appraiseAddressInfo = AppraiseAddressService.convert2AppraiseAddressInfo(aaResp);  
288 - }  
289 - AddressInfo userAddress = null;  
290 - if (showUserAddressStatusList.contains(pao.getStatus())){  
291 - userAddress = appraiseOrderMetaService.getHidderUserAddress(orderCode);  
292 - }  
293 - boolean addressUpgradable = addressUpgradableStatusList.contains(pao.getStatus());  
294 - SellerDepositOrderPrdListReq sknListReq = SellerDepositOrderPrdListReq.builder()  
295 - .orderCode(orderCode)  
296 - .page(1).limit(10).uid(uid).build();  
297 - PageResp<ProductVo> sknListPageResp = getSknList(sknListReq);  
298 - return SellerDepositOrderDetailResp.builder()  
299 - .orderCode(orderCode)  
300 - .uid(uid)  
301 - .earnestMoney(SellerOrderConvertor.formatFee(pao.getAmount()))  
302 - .createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))  
303 - .timeout(timeout)  
304 - .statusDetail(statusDetail)  
305 - .productList(sknListPageResp.getData())  
306 - .userAddress(userAddress)  
307 - .appraiseAddress(appraiseAddressInfo)  
308 - .addressUpgradable(addressUpgradable)  
309 - .build()  
310 - ;  
311 - }  
312 -  
313 - public PageResp<ProductVo> getSknList(SellerDepositOrderPrdListReq req){  
314 - Long orderCode = req.getOrderCode();  
315 - int total = appraiseOrderGoodsMapper.selectCntByOrderCode(orderCode);  
316 - int limit = req.getLimit();  
317 - PageResp.PageRespBuilder<ProductVo> respBuilder = PageResp.builder();  
318 - respBuilder.page(req.getPage()).pageSize(limit).total(total);  
319 - if (total == 0){  
320 - return respBuilder.build();  
321 - }  
322 - int offset = (req.getPage() - 1) * limit;  
323 - List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectAllByOrderCode(orderCode, offset, limit);  
324 154
325 - List<ProductVo> productVoList = buildProductVoListWithSkuSummary(paogs);  
326 -  
327 - respBuilder.data(productVoList);  
328 - return respBuilder.build();  
329 - }  
330 -  
331 - List<ProductVo> buildProductVoListWithSkuSummary(List<AppraiseOrderGoods> paogs){  
332 -  
333 - return paogs.parallelStream().map(paog-> convertProductVo(paog, null))  
334 - .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));  
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 - }  
344 -  
345 - OrderDataNode buildDataSourceOfParentOrder(long orderCode, List<AppraiseOrderGoods> paogs){  
346 - Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = new HashMap<>(paogs.size());  
347 - Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = new HashMap<>(128);  
348 -  
349 - Function<AppraiseOrderMeta, SellerOrderComputeResult> socrFunction = aom -> {  
350 - SellerOrderComputeResult socr = null;  
351 - String metaVal = null;  
352 - try {  
353 - socr = JSONObject.parseObject(metaVal=aom.getMetaValue(), SellerOrderComputeResult.class);  
354 - }catch (Exception ex){  
355 - logger.warn("in convert SellerOrderComputeResult fail, ordercode {} metaVal {}", orderCode, metaVal);  
356 - }finally {  
357 - return socr;  
358 - }  
359 - };  
360 - Map<Integer, AppraiseOrderMeta> storageIdFeeMetaMap = new HashMap<>(128);  
361 - for(AppraiseOrderGoods paog : paogs){  
362 - Integer prdId;  
363 - List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectAllByOrderCodePrdId(orderCode, prdId=paog.getProductId());  
364 - prdIdAOSListMap.put(prdId, paosList);  
365 - List<Integer> storageIds = paosList.parallelStream().map(AppraiseOrderStorage::getStorageId).collect(Collectors.toList());  
366 - //  
367 - AppraiseOrderMeta aomc = new AppraiseOrderMeta();  
368 - aomc.setOrderCode(orderCode);  
369 - aomc.setMetaKey(MetaKey.SELLER_FEE);  
370 - List<AppraiseOrderMeta> paomList = appraiseOrderMetaMapper.selectByOrderCodeStorageIds(aomc, storageIds);  
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)));  
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;  
397 -  
398 - List<ProductVo> productVoList = buildProductVoListWithSkuDetail(paogs, prdIdAOSListMap, storageIdSOCRMap);  
399 -  
400 - respBuilder.data(productVoList);  
401 - return respBuilder.build(); 155 + public PageResp<DepositOrderInStorePrdListResp> getDepositOrderListInStore(SellerDepositOrderPrdListReq req){
  156 + return null;
402 } 157 }
403 158
404 - List<ProductVo> buildProductVoListWithSkuDetail(List<AppraiseOrderGoods> paogs,  
405 - Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap,  
406 - Map<Integer,SellerOrderComputeResult> storageIdSOCRMap){  
407 -  
408 -  
409 -  
410 - Map<Integer,ProductVo> tempProductMap = new HashMap<>(paogs.size());  
411 - for(Map.Entry<Integer,List<AppraiseOrderStorage>> prdIdAOSListEntry : prdIdAOSListMap.entrySet()){  
412 - Integer prdId = prdIdAOSListEntry.getKey();  
413 - List<AppraiseOrderStorage> aosList = prdIdAOSListEntry.getValue();  
414 - int sizeNum = aosList.size();  
415 - List<GoodsVo> goodsList = new ArrayList<>(sizeNum);  
416 - for (AppraiseOrderStorage aos : aosList){  
417 - Integer storageId;  
418 - SellerOrderComputeResult socr = storageIdSOCRMap.get(storageId=aos.getStorageId());  
419 - if (Objects.isNull(socr)){  
420 - logger.warn("in buildProductVoListWithSkuDetail ComputeResult null ,AppraiseOrderStorage {}", aos);  
421 - continue;  
422 - }  
423 - Integer storageNum;  
424 - BigDecimal emOfSku = socr.getEarnestMoney().getEarnestMoney().multiply(new BigDecimal(storageNum=aos.getNum()));  
425 - GoodsVo goodsVo = GoodsVo.builder().sizeName(aos.getSizeName()).num(storageNum)  
426 - .earnestMoney(SellerOrderConvertor.formatFee(emOfSku)).build();  
427 - goodsList.add(goodsVo);  
428 - }  
429 -  
430 - tempProductMap.put(prdId, ProductVo.builder().sizeNum(sizeNum).goodsList(goodsList).build());  
431 - }  
432 159
433 160
434 - return paogs.parallelStream().map(paog-> convertProductVo(paog, tempProductMap.get(paog.getProductId())))  
435 - .collect(Collectors.toCollection(()->new ArrayList<>(paogs.size())));  
436 - } 161 + public void cancel(SellerDepositOrderDetailReq req){
437 162
438 - ProductVo convertProductVo(AppraiseOrderGoods paog, ProductVo temp){  
439 - ProductVo productVo = ProductVo.builder()  
440 - .imgUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))  
441 - .productName(paog.getProductName())  
442 - .productId(paog.getProductId())  
443 - .total(paog.getNum()).build();  
444 - if (Objects.nonNull(temp)){  
445 - productVo.setSizeNum(temp.getSizeNum());  
446 - productVo.setGoodsList(temp.getGoodsList());  
447 - }  
448 - return productVo;  
449 } 163 }
450 164
451 165
452 - public PageResp<DepositOrderInStorePrdListResp> getDepositOrderListInStore(SellerDepositOrderPrdListReq req){  
453 - return null;  
454 - }  
455 166
456 - public void deliverToDepot(DeliverToDepotReq req){ 167 + @Override
  168 + public int deliver2Depot(DeliverToDepotReq req) {
457 // 169 //
458 Long orderCode = req.getOrderCode(); 170 Long orderCode = req.getOrderCode();
459 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.SELLER_SEND_OUT, 171 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.SELLER_SEND_OUT,
460 - expectedStatus = AppraiseOrderStatus.HAS_PAYED; 172 + expectedStatus = AppraiseOrderStatus.HAS_PAYED;
461 int cdt = DateUtil.getCurrentTimeSecond(); 173 int cdt = DateUtil.getCurrentTimeSecond();
462 int rows = appraiseOrderMapper.updateStatusByOrderCode(orderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt); 174 int rows = appraiseOrderMapper.updateStatusByOrderCode(orderCode, targetStatus.getCode(), expectedStatus.getCode(), cdt);
463 if (rows==0){ 175 if (rows==0){
464 logger.warn("appraise order deliverToDepot no need update status, req {}", req); 176 logger.warn("appraise order deliverToDepot no need update status, req {}", req);
465 - return; 177 + return 0;
466 } 178 }
  179 + orderStatusFlowService.addAsy(orderCode, targetStatus.getCode());
467 //split sku 2 order 180 //split sku 2 order
468 List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCode(orderCode); 181 List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCode(orderCode);
469 - OrderDataNode node = buildDataSourceOfParentOrder(orderCode, paogList); 182 + SellerDepositOrderListService.OrderDataNode node = sellerDepositOrderListService.buildDataSourceOfParentOrder(orderCode, paogList);
470 Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap; 183 Map<Integer,List<AppraiseOrderStorage>> prdIdAOSListMap = node.prdIdAOSListMap;
471 Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap; 184 Map<Integer,SellerOrderComputeResult> storageIdSOCRMap = node.storageIdSOCRMap;
472 185
@@ -482,19 +195,42 @@ public class SellerDepositOrderService extends AbsOrderViewService { @@ -482,19 +195,42 @@ public class SellerDepositOrderService extends AbsOrderViewService {
482 195
483 196
484 //todo add express info 197 //todo add express info
  198 + return rows;
485 } 199 }
486 200
  201 + /**
  202 + * 平台收货
  203 + * @param orderCode
  204 + */
  205 + @Override
  206 + public void platformReceiveGoods(long orderCode){
487 207
488 - public void cancel(SellerDepositOrderDetailReq req){ 208 + }
  209 +
  210 + /**
  211 + * 鉴定通过
  212 + * @param orderCode
  213 + */
  214 + @Override
  215 + public void appraisePass(long orderCode){
489 216
490 } 217 }
491 218
492 - public Logger getLogger() {  
493 - return logger; 219 + /**
  220 + * 鉴别为假
  221 + * @param orderCode
  222 + */
  223 + @Override
  224 + public void appraiseFake(long orderCode){
  225 +
494 } 226 }
495 227
  228 + /**
  229 + * 无法鉴别
  230 + * @param orderCode
  231 + */
496 @Override 232 @Override
497 - protected String buildOrderTypeTag(Integer orderAttr, SkupType skupType) {  
498 - return null; 233 + public void unsure(long orderCode){
  234 +
499 } 235 }
500 } 236 }