Authored by LUOXC

Merge branch 'hotfix-20190723' into test6.9.9

@@ -11,6 +11,7 @@ import java.util.concurrent.ArrayBlockingQueue; @@ -11,6 +11,7 @@ import java.util.concurrent.ArrayBlockingQueue;
11 import java.util.concurrent.ExecutorService; 11 import java.util.concurrent.ExecutorService;
12 import java.util.concurrent.ThreadPoolExecutor; 12 import java.util.concurrent.ThreadPoolExecutor;
13 import java.util.concurrent.TimeUnit; 13 import java.util.concurrent.TimeUnit;
  14 +import java.util.function.Consumer;
14 import java.util.stream.Collectors; 15 import java.util.stream.Collectors;
15 16
16 import javax.annotation.Resource; 17 import javax.annotation.Resource;
@@ -300,19 +301,32 @@ public class AppraiseService { @@ -300,19 +301,32 @@ public class AppraiseService {
300 } 301 }
301 302
302 private void deliveryDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) { 303 private void deliveryDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) {
303 - expressInfoService.deliverGoods(buyerOrder.getUid(),  
304 - appraiseExpressInfoBo.getExpressCompanyId(),  
305 - buyerOrder.getOrderCode(),  
306 - appraiseExpressInfoBo.getWayBillCode(),  
307 - appraiseExpressInfoBo.getDepotNum(),  
308 - appraiseExpressInfoBo.getMobile());  
309 - // 通知买家已发货  
310 - buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(),  
311 - () -> cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()),  
312 - sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null)); 304 + if(buyerOrder.getStatus() == OrderStatus.DONE.getCode()){
  305 + expressInfoService.deliverGoods(buyerOrder.getUid(),
  306 + appraiseExpressInfoBo.getExpressCompanyId(),
  307 + buyerOrder.getOrderCode(),
  308 + appraiseExpressInfoBo.getWayBillCode(),
  309 + appraiseExpressInfoBo.getDepotNum(),
  310 + appraiseExpressInfoBo.getMobile());
  311 + // 通知买家已发货
  312 + buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(),
  313 + () -> cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()),
  314 + sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
  315 + }
  316 + // 买家接受瑕疵,走非寄存流程
  317 + else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()) {
  318 + deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo,buyerOrder,sog -> {
  319 + // 通知买家已发货
  320 + buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(), sog,
  321 + sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
  322 + });
  323 + } else {
  324 + LOGGER.warn("in deliveryGoodsToBuyer, buyer Deposit Order orderCode {}", buyerOrder.getOrderCode());
  325 + throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
  326 + }
313 } 327 }
314 328
315 - private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) { 329 + private void deliveryNonDepositGoodsToBuyerAndRun(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder, Consumer<SellerOrderGoods> run) {
316 final Long orderCode = buyerOrder.getOrderCode(); 330 final Long orderCode = buyerOrder.getOrderCode();
317 final OrderStatus expectOrderStatus; 331 final OrderStatus expectOrderStatus;
318 final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE; 332 final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
@@ -346,11 +360,12 @@ public class AppraiseService { @@ -346,11 +360,12 @@ public class AppraiseService {
346 }); 360 });
347 //记录订单的状态变更信息 361 //记录订单的状态变更信息
348 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode()); 362 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
349 -  
350 //清缓存 363 //清缓存
351 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()); 364 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
352 - Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);  
353 - buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product); 365 + if(Objects.nonNull(run)){
  366 + run.accept(sellerOrderGoods);
  367 + }
  368 +
354 } else { 369 } else {
355 LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}", 370 LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
356 orderCode, buyerOrder.getStatus(), expectOrderStatus); 371 orderCode, buyerOrder.getStatus(), expectOrderStatus);
@@ -358,6 +373,13 @@ public class AppraiseService { @@ -358,6 +373,13 @@ public class AppraiseService {
358 } 373 }
359 } 374 }
360 375
  376 + private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) {
  377 + deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo, buyerOrder, sellerOrderGoods -> {
  378 + Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
  379 + buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product);
  380 + });
  381 + }
  382 +
361 /** 383 /**
362 * 鉴定不通过退回 384 * 鉴定不通过退回
363 * (1)记录物流 385 * (1)记录物流
@@ -345,11 +345,24 @@ public class BuyerNoticeFacade extends BaseNoticeFacade { @@ -345,11 +345,24 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
345 */ 345 */
346 public void deliveryDepositGoodsToBuyer(int buyerUid, String wayBillCode, Supplier<SellerOrderGoods> psogSupplier, Function<SellerOrderGoods, Product> productFunction) { 346 public void deliveryDepositGoodsToBuyer(int buyerUid, String wayBillCode, Supplier<SellerOrderGoods> psogSupplier, Function<SellerOrderGoods, Product> productFunction) {
347 try { 347 try {
348 - log.info("notice buyer delivery deposit goods to buyer, uid {}, wayBillCode {}", buyerUid, wayBillCode);  
349 SellerOrderGoods psog = psogSupplier.get(); 348 SellerOrderGoods psog = psogSupplier.get();
350 - Product product = productFunction.apply(psog);  
351 - String prdName = psog.getProductName();  
352 - String sizeName = psog.getSizeName(); 349 + deliveryDepositGoodsToBuyer(buyerUid, wayBillCode, psog, productFunction);
  350 + } catch (Exception e) {
  351 + log.warn("notice buyer delivery deposit goods to buyer fail, uid {}, wayBillCode {}", buyerUid, wayBillCode, e);
  352 + }
  353 +
  354 + }
  355 +
  356 + /**
  357 + * 平台发货寄存商品给买家
  358 + *
  359 + * @return
  360 + */
  361 + public void deliveryDepositGoodsToBuyer(int buyerUid, String wayBillCode, SellerOrderGoods sog, Function<SellerOrderGoods, Product> productFunction) {
  362 + try {
  363 + Product product = productFunction.apply(sog);
  364 + String prdName = sog.getProductName();
  365 + String sizeName = sog.getSizeName();
353 String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse(""); 366 String productCode = Optional.ofNullable(product).map(Product::getProductCode).orElse("");
354 newNotice(buyerUid) 367 newNotice(buyerUid)
355 .withLogPrefix("notice buyer delivery deposit goods to buyer") 368 .withLogPrefix("notice buyer delivery deposit goods to buyer")
@@ -413,20 +426,20 @@ public class BuyerNoticeFacade extends BaseNoticeFacade { @@ -413,20 +426,20 @@ public class BuyerNoticeFacade extends BaseNoticeFacade {
413 try { 426 try {
414 newNotice(buyerUid) 427 newNotice(buyerUid)
415 .withLogPrefix("notice buyer buyer cancel before depot receive") 428 .withLogPrefix("notice buyer buyer cancel before depot receive")
416 - .withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_DELIVERY, orderCode,compesant) 429 + .withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_DELIVERY, orderCode, compesant)
417 .send(); 430 .send();
418 } catch (Exception e) { 431 } catch (Exception e) {
419 log.warn("notice buyer buyer cancel before depot receive, buyerUid {}, orderCode {}", buyerUid, orderCode, e); 432 log.warn("notice buyer buyer cancel before depot receive, buyerUid {}, orderCode {}", buyerUid, orderCode, e);
420 } 433 }
421 } 434 }
422 435
423 - public void buyerCancelBeforeSellerDeliver(@NonNull BuyerOrder buyerOrder,String compesant, SellerOrderGoods sog) { 436 + public void buyerCancelBeforeSellerDeliver(@NonNull BuyerOrder buyerOrder, String compesant, SellerOrderGoods sog) {
424 Integer buyerUid = buyerOrder.getUid(); 437 Integer buyerUid = buyerOrder.getUid();
425 Long orderCode = buyerOrder.getOrderCode(); 438 Long orderCode = buyerOrder.getOrderCode();
426 try { 439 try {
427 newNotice(buyerUid) 440 newNotice(buyerUid)
428 .withLogPrefix("notice buyer buyer cancel before seller receive") 441 .withLogPrefix("notice buyer buyer cancel before seller receive")
429 - .withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_PAID, orderCode,compesant) 442 + .withInBox(InboxBusinessTypeEnum.PURCHASE_CLOSED_BY_BUYER_AFTER_PAID, orderCode, compesant)
430 .send(); 443 .send();
431 } catch (Exception e) { 444 } catch (Exception e) {
432 log.warn("notice buyer buyer cancel before seller receive fail, buyerUid {}, orderCode {}", buyerUid, orderCode, e); 445 log.warn("notice buyer buyer cancel before seller receive fail, buyerUid {}, orderCode {}", buyerUid, orderCode, e);