|
@@ -32,6 +32,7 @@ import com.yohoufo.order.service.proxy.OrderOperateRecordService; |
|
@@ -32,6 +32,7 @@ import com.yohoufo.order.service.proxy.OrderOperateRecordService; |
32
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
32
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
33
|
import com.yohoufo.order.utils.PaymentHelper;
|
33
|
import com.yohoufo.order.utils.PaymentHelper;
|
34
|
import com.yohoufo.order.utils.PubThreadFactory;
|
34
|
import com.yohoufo.order.utils.PubThreadFactory;
|
|
|
35
|
+import lombok.Data;
|
35
|
import org.apache.commons.lang3.StringUtils;
|
36
|
import org.apache.commons.lang3.StringUtils;
|
36
|
import org.slf4j.Logger;
|
37
|
import org.slf4j.Logger;
|
37
|
import org.slf4j.LoggerFactory;
|
38
|
import org.slf4j.LoggerFactory;
|
|
@@ -408,47 +409,105 @@ public class AppraiseService { |
|
@@ -408,47 +409,105 @@ public class AppraiseService { |
408
|
}
|
409
|
}
|
409
|
|
410
|
|
410
|
/**
|
411
|
/**
|
411
|
- * 更新发到卖家的物流信息
|
|
|
412
|
- * 将卖家的保证金分账给平台和买家
|
|
|
413
|
- * 更新买家订单状态
|
|
|
414
|
- * appraiseFlag 鉴定标志,//true 鉴定不通过 ;false 质检不通过 ;
|
|
|
415
|
- * @return
|
412
|
+ * 质检不通过 31->20
|
|
|
413
|
+ * 不发物流
|
416
|
*/
|
414
|
*/
|
417
|
- public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo,OrderStatus expectStatus,boolean appraiseNotPassFlag){
|
|
|
418
|
- LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo ,appraiseNotPassFlag);
|
415
|
+ public ApiResponse qualityCheckReject(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
416
|
+ LOGGER.info("qualityCheckReject enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo );
|
|
|
417
|
+ OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
|
|
418
|
+ OrderStatus targetStatus = OrderStatus.QUALITY_CHECK_FAKE;
|
419
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
419
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
420
|
- Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
421
|
- String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
|
422
|
- Integer depotNum = appraiseExpressInfoBo.getDepotNum();
|
|
|
423
|
- String mobile = appraiseExpressInfoBo.getMobile();
|
|
|
424
|
|
420
|
|
425
|
ApiResponse apiResponse=new ApiResponse();
|
421
|
ApiResponse apiResponse=new ApiResponse();
|
426
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
422
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
427
|
|
423
|
|
428
|
if (buyerOrder == null){
|
424
|
if (buyerOrder == null){
|
429
|
- LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode {}", orderCode);
|
425
|
+ LOGGER.warn("qualityCheckReject getOrderInfo order not exist, orderCode {}", orderCode);
|
430
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
426
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
431
|
}
|
427
|
}
|
432
|
|
428
|
|
433
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
429
|
if (buyerOrder.getStatus() != expectStatus.getCode()){
|
434
|
- LOGGER.warn("appraiseFail expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
430
|
+ LOGGER.warn("qualityCheckReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
435
|
buyerOrder.getStatus(), orderCode);
|
431
|
buyerOrder.getStatus(), orderCode);
|
436
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
432
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
437
|
}
|
433
|
}
|
438
|
- // 更新买家订单状态 为鉴定不通过
|
434
|
+ // 更新买家订单状态
|
439
|
int buyerUid = buyerOrder.getUid();
|
435
|
int buyerUid = buyerOrder.getUid();
|
440
|
- OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
441
|
- LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
436
|
+ int sellerUid = buyerOrder.getSellerUid();
|
|
|
437
|
+ LOGGER.info("qualityCheckReject update buyer order {} ", buyerOrder);
|
442
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
438
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
443
|
DateUtil.getCurrentTimeSecond());
|
439
|
DateUtil.getCurrentTimeSecond());
|
444
|
|
440
|
|
445
|
if (rows > 0){
|
441
|
if (rows > 0){
|
|
|
442
|
+ RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
443
|
+ boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
444
|
+ SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
445
|
+ if (!refundGoodsMoneyFlag){
|
|
|
446
|
+ apiResponse.setCode(400);
|
|
|
447
|
+ String content = "质检不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
|
448
|
+ apiResponse.setMessage(content);
|
|
|
449
|
+ }
|
|
|
450
|
+
|
|
|
451
|
+ //记录订单的状态变更信息
|
|
|
452
|
+ LOGGER.info("in qualityCheckReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
|
|
|
453
|
+ try {
|
|
|
454
|
+ orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
455
|
+
|
|
|
456
|
+ //质检不通过
|
|
|
457
|
+ inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
458
|
+ inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
459
|
+
|
|
|
460
|
+ }catch(Exception ex) {
|
|
|
461
|
+ LOGGER.warn("in qualityCheckReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
|
462
|
+ }finally {
|
|
|
463
|
+ /// 物流信息异步执行
|
|
|
464
|
+ executorService.execute(()->{
|
|
|
465
|
+ //质检不通过,不发物流
|
|
|
466
|
+ //先补加一条鉴定中物流
|
|
|
467
|
+ EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
468
|
+ EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
469
|
+ EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
470
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
471
|
+
|
|
|
472
|
+ //再加一个鉴定不通过的物流
|
|
|
473
|
+ operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
474
|
+ expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
475
|
+ expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
476
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
477
|
+
|
|
|
478
|
+ });
|
|
|
479
|
+
|
|
|
480
|
+ }
|
|
|
481
|
+
|
|
|
482
|
+ }else{
|
|
|
483
|
+ LOGGER.warn("in qualityCheckReject, buyer Order now status {}, expect expectStatus {}",
|
|
|
484
|
+ buyerOrder.getStatus(), expectStatus);
|
|
|
485
|
+ apiResponse.setCode(400);
|
|
|
486
|
+ apiResponse.setMessage("订单状态发生变化");
|
|
|
487
|
+ }
|
|
|
488
|
+ return apiResponse;
|
|
|
489
|
+ }
|
|
|
490
|
+
|
|
|
491
|
+ @Data
|
|
|
492
|
+ class RefundMoneyResultModel{
|
|
|
493
|
+ boolean refundGoodsMoneyFlag;
|
|
|
494
|
+ SellerOrderGoods sellerOrderGoods;
|
|
|
495
|
+ }
|
|
|
496
|
+
|
|
|
497
|
+ /**
|
|
|
498
|
+ * 鉴定不通或者直接不通过
|
|
|
499
|
+ * 操作钱
|
|
|
500
|
+ */
|
|
|
501
|
+ private RefundMoneyResultModel operateMoneyWhenCheckFail(BuyerOrder buyerOrder,Long orderCode,OrderStatus targetStatus){
|
|
|
502
|
+ LOGGER.info("operateMoney enter , orderCode {},targetStatus {} ", orderCode ,targetStatus);
|
|
|
503
|
+ RefundMoneyResultModel model = new RefundMoneyResultModel();
|
|
|
504
|
+ int buyerUid = buyerOrder.getUid();
|
|
|
505
|
+ int sellerUid = buyerOrder.getSellerUid();
|
446
|
//refund coupons of buyer
|
506
|
//refund coupons of buyer
|
447
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
507
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
448
|
.uid(buyerUid).orderCode(orderCode).build();
|
508
|
.uid(buyerUid).orderCode(orderCode).build();
|
449
|
EventBusPublisher.publishEvent(brce);
|
509
|
EventBusPublisher.publishEvent(brce);
|
450
|
//
|
510
|
//
|
451
|
- int sellerUid = buyerOrder.getSellerUid();
|
|
|
452
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
511
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
453
|
int skup = bog.getSkup();
|
512
|
int skup = bog.getSkup();
|
454
|
|
513
|
|
|
@@ -478,7 +537,7 @@ public class AppraiseService { |
|
@@ -478,7 +537,7 @@ public class AppraiseService { |
478
|
|
537
|
|
479
|
//改成异步的分账,不关心分账执行结果
|
538
|
//改成异步的分账,不关心分账执行结果
|
480
|
executorService.execute(()->{
|
539
|
executorService.execute(()->{
|
481
|
- LOGGER.info("in appraiseFail,begin transfer async");
|
540
|
+ LOGGER.info("in operateMoney,begin transfer async");
|
482
|
transferService.transfer(tmReq);
|
541
|
transferService.transfer(tmReq);
|
483
|
});
|
542
|
});
|
484
|
|
543
|
|
|
@@ -495,6 +554,54 @@ public class AppraiseService { |
|
@@ -495,6 +554,54 @@ public class AppraiseService { |
495
|
.loadRefundAction(payRefundService::refund)
|
554
|
.loadRefundAction(payRefundService::refund)
|
496
|
.loadLogger(LOGGER)
|
555
|
.loadLogger(LOGGER)
|
497
|
.refund();
|
556
|
.refund();
|
|
|
557
|
+
|
|
|
558
|
+ model.setRefundGoodsMoneyFlag(refundGoodsMoneyFlag);
|
|
|
559
|
+ model.setSellerOrderGoods(sellerOrderGoods);
|
|
|
560
|
+ return model;
|
|
|
561
|
+ }
|
|
|
562
|
+
|
|
|
563
|
+ /**
|
|
|
564
|
+ * 鉴定不通过 3->13
|
|
|
565
|
+ * 更新发到卖家的物流信息
|
|
|
566
|
+ * 将卖家的保证金分账给平台和买家
|
|
|
567
|
+ * 更新买家订单状态
|
|
|
568
|
+ * @return
|
|
|
569
|
+ */
|
|
|
570
|
+ public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo ){
|
|
|
571
|
+ LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo );
|
|
|
572
|
+ OrderStatus expectStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
573
|
+ OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
574
|
+ Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
575
|
+ Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
|
576
|
+ String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
|
577
|
+ Integer depotNum = appraiseExpressInfoBo.getDepotNum();
|
|
|
578
|
+ String mobile = appraiseExpressInfoBo.getMobile();
|
|
|
579
|
+
|
|
|
580
|
+ ApiResponse apiResponse=new ApiResponse();
|
|
|
581
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
582
|
+
|
|
|
583
|
+ if (buyerOrder == null){
|
|
|
584
|
+ LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
585
|
+ throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
586
|
+ }
|
|
|
587
|
+
|
|
|
588
|
+ if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
589
|
+ LOGGER.warn("appraiseFail expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
590
|
+ buyerOrder.getStatus(), orderCode);
|
|
|
591
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
592
|
+ }
|
|
|
593
|
+ // 更新买家订单状态 为鉴定不通过
|
|
|
594
|
+ int buyerUid = buyerOrder.getUid();
|
|
|
595
|
+ int sellerUid = buyerOrder.getSellerUid();
|
|
|
596
|
+ LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
|
|
597
|
+ int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
598
|
+ DateUtil.getCurrentTimeSecond());
|
|
|
599
|
+
|
|
|
600
|
+ if (rows > 0){
|
|
|
601
|
+ RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
602
|
+ boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
603
|
+ SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
604
|
+
|
498
|
if (!refundGoodsMoneyFlag){
|
605
|
if (!refundGoodsMoneyFlag){
|
499
|
apiResponse.setCode(400);
|
606
|
apiResponse.setCode(400);
|
500
|
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
607
|
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
@@ -506,16 +613,9 @@ public class AppraiseService { |
|
@@ -506,16 +613,9 @@ public class AppraiseService { |
506
|
try {
|
613
|
try {
|
507
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
614
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
508
|
|
615
|
|
509
|
- //TODO 消息
|
|
|
510
|
- if(appraiseNotPassFlag){
|
|
|
511
|
//鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
|
616
|
//鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
|
512
|
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
|
617
|
inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
|
513
|
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
618
|
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
514
|
- }else {
|
|
|
515
|
- //质检不通过
|
|
|
516
|
- inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
517
|
- inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
518
|
- }
|
|
|
519
|
|
619
|
|
520
|
}catch(Exception ex) {
|
620
|
}catch(Exception ex) {
|
521
|
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
621
|
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
@@ -524,7 +624,6 @@ public class AppraiseService { |
|
@@ -524,7 +624,6 @@ public class AppraiseService { |
524
|
executorService.execute(()->{
|
624
|
executorService.execute(()->{
|
525
|
//更新物流信息,写到最后
|
625
|
//更新物流信息,写到最后
|
526
|
//鉴定不通过,发物流
|
626
|
//鉴定不通过,发物流
|
527
|
- if(appraiseNotPassFlag){
|
|
|
528
|
//补:鉴定不通过
|
627
|
//补:鉴定不通过
|
529
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
628
|
EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
530
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
629
|
EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
@@ -533,21 +632,6 @@ public class AppraiseService { |
|
@@ -533,21 +632,6 @@ public class AppraiseService { |
533
|
|
632
|
|
534
|
//发货物流(平台已发货)
|
633
|
//发货物流(平台已发货)
|
535
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
634
|
expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
536
|
- }else {
|
|
|
537
|
- //质检不通过,不发物流
|
|
|
538
|
-
|
|
|
539
|
- //先补加一条鉴定中物流
|
|
|
540
|
- EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
541
|
- EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
542
|
- EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
543
|
- expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
544
|
-
|
|
|
545
|
- //再加一个鉴定不通过的物流
|
|
|
546
|
- operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
547
|
- expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
548
|
- expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
549
|
- expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
550
|
- }
|
|
|
551
|
});
|
635
|
});
|
552
|
|
636
|
|
553
|
}
|
637
|
}
|