Authored by LUOXC

fixbug

@@ -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;
@@ -310,13 +311,21 @@ public class AppraiseService { @@ -310,13 +311,21 @@ public class AppraiseService {
310 buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(), 311 buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(),
311 () -> cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()), 312 () -> cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()),
312 sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null)); 313 sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
313 - }else { 314 + }
  315 + // 买家接受瑕疵,走非寄存流程
  316 + else if (buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()) {
  317 + deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo,buyerOrder,sog -> {
  318 + // 通知买家已发货
  319 + buyerNoticeFacade.deliveryDepositGoodsToBuyer(buyerOrder.getUid(), appraiseExpressInfoBo.getWayBillCode(), sog,
  320 + sellerOrderGoods -> Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null));
  321 + });
  322 + } else {
314 LOGGER.warn("in deliveryGoodsToBuyer, buyer Deposit Order orderCode {}", buyerOrder.getOrderCode()); 323 LOGGER.warn("in deliveryGoodsToBuyer, buyer Deposit Order orderCode {}", buyerOrder.getOrderCode());
315 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 324 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
316 } 325 }
317 } 326 }
318 327
319 - private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) { 328 + private void deliveryNonDepositGoodsToBuyerAndRun(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder, Consumer<SellerOrderGoods> run) {
320 final Long orderCode = buyerOrder.getOrderCode(); 329 final Long orderCode = buyerOrder.getOrderCode();
321 final OrderStatus expectOrderStatus; 330 final OrderStatus expectOrderStatus;
322 final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE; 331 final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
@@ -350,11 +359,12 @@ public class AppraiseService { @@ -350,11 +359,12 @@ public class AppraiseService {
350 }); 359 });
351 //记录订单的状态变更信息 360 //记录订单的状态变更信息
352 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode()); 361 orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetOrderStatus.getCode());
353 -  
354 //清缓存 362 //清缓存
355 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid()); 363 SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(), buyerOrder.getUid(), buyerOrder.getSellerUid());
356 - Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);  
357 - buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product); 364 + if(Objects.nonNull(run)){
  365 + run.accept(sellerOrderGoods);
  366 + }
  367 +
358 } else { 368 } else {
359 LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}", 369 LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
360 orderCode, buyerOrder.getStatus(), expectOrderStatus); 370 orderCode, buyerOrder.getStatus(), expectOrderStatus);
@@ -362,6 +372,13 @@ public class AppraiseService { @@ -362,6 +372,13 @@ public class AppraiseService {
362 } 372 }
363 } 373 }
364 374
  375 + private void deliveryNonDepositGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo, BuyerOrder buyerOrder) {
  376 + deliveryNonDepositGoodsToBuyerAndRun(appraiseExpressInfoBo, buyerOrder, sellerOrderGoods -> {
  377 + Product product = Optional.ofNullable(sellerOrderGoods).map(SellerOrderGoods::getProductId).map(productMapper::selectByPrimaryKey).orElse(null);
  378 + buyerNoticeFacade.deliveryGoodsToBuyer(buyerOrder, sellerOrderGoods, product);
  379 + });
  380 + }
  381 +
365 /** 382 /**
366 * 鉴定不通过退回 383 * 鉴定不通过退回
367 * (1)记录物流 384 * (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);