1
|
package com.yohoufo.order.service.impl;
|
1
|
package com.yohoufo.order.service.impl;
|
2
|
|
2
|
|
3
|
import com.alibaba.fastjson.JSON;
|
3
|
import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.google.common.collect.Lists;
|
4
|
import com.yoho.error.ServiceError;
|
5
|
import com.yoho.error.ServiceError;
|
5
|
import com.yoho.error.exception.ServiceException;
|
6
|
import com.yoho.error.exception.ServiceException;
|
6
|
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
|
7
|
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
|
|
@@ -36,6 +37,7 @@ import com.yohoufo.order.service.proxy.OrderOperateRecordService; |
|
@@ -36,6 +37,7 @@ import com.yohoufo.order.service.proxy.OrderOperateRecordService; |
36
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
37
|
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
|
37
|
import com.yohoufo.order.utils.PaymentHelper;
|
38
|
import com.yohoufo.order.utils.PaymentHelper;
|
38
|
import com.yohoufo.order.utils.PubThreadFactory;
|
39
|
import com.yohoufo.order.utils.PubThreadFactory;
|
|
|
40
|
+import lombok.Data;
|
39
|
import org.apache.commons.lang3.StringUtils;
|
41
|
import org.apache.commons.lang3.StringUtils;
|
40
|
import org.slf4j.Logger;
|
42
|
import org.slf4j.Logger;
|
41
|
import org.slf4j.LoggerFactory;
|
43
|
import org.slf4j.LoggerFactory;
|
|
@@ -45,6 +47,7 @@ import org.springframework.stereotype.Service; |
|
@@ -45,6 +47,7 @@ import org.springframework.stereotype.Service; |
45
|
|
47
|
|
46
|
import java.math.BigDecimal;
|
48
|
import java.math.BigDecimal;
|
47
|
import java.util.Arrays;
|
49
|
import java.util.Arrays;
|
|
|
50
|
+import java.util.List;
|
48
|
import java.util.Objects;
|
51
|
import java.util.Objects;
|
49
|
import java.util.concurrent.ArrayBlockingQueue;
|
52
|
import java.util.concurrent.ArrayBlockingQueue;
|
50
|
import java.util.concurrent.ExecutorService;
|
53
|
import java.util.concurrent.ExecutorService;
|
|
@@ -169,7 +172,7 @@ public class AppraiseService { |
|
@@ -169,7 +172,7 @@ public class AppraiseService { |
169
|
/**
|
172
|
/**
|
170
|
* 鉴定不通过退回
|
173
|
* 鉴定不通过退回
|
171
|
* (1)记录物流
|
174
|
* (1)记录物流
|
172
|
- * (2)消息 :寄回有三种情形: 质检不通过的而商品、瑕疵不接受的 、瑕疵不接受(超时)的
|
175
|
+ * (2)消息 :寄回有4种情形: 鉴定不通过、质检不通过的商品、瑕疵不接受的 、瑕疵不接受(超时)的
|
173
|
*/
|
176
|
*/
|
174
|
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
177
|
public void returnBackOrderCauseOfJudgeFailure(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
175
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
178
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
|
@@ -185,12 +188,46 @@ public class AppraiseService { |
|
@@ -185,12 +188,46 @@ public class AppraiseService { |
185
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
188
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
186
|
}
|
189
|
}
|
187
|
|
190
|
|
188
|
- OrderStatus expectStatus = OrderStatus.CHECKING_FAKE;
|
|
|
189
|
- if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
190
|
- LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
191
|
+ OrderStatus expectStatus ;
|
|
|
192
|
+
|
|
|
193
|
+ int type = 0 ;//鉴定不通过
|
|
|
194
|
+ if (buyerOrder.getStatus() == OrderStatus.CHECKING_FAKE.getCode()){
|
|
|
195
|
+ expectStatus = OrderStatus.CHECKING_FAKE;
|
|
|
196
|
+
|
|
|
197
|
+ //TODO 新版本6.8.7以后,判断type可直接根据状态,而不再需要根据qualityCheck,可去掉以下if判断
|
|
|
198
|
+ //TODO 现在6.8.6.5手机质检版本上线,还需要保留,存在过度订单,鉴定不通过都是类型:13
|
|
|
199
|
+ QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
|
|
|
200
|
+ if(qualityCheck!=null&&qualityCheck.getType()!=null){
|
|
|
201
|
+ if(EnumQualityCheckType.CHECK_NOT_PASS.getCode().intValue()==qualityCheck.getType().intValue()){
|
|
|
202
|
+ type = 1;//质检不通过
|
|
|
203
|
+ }else if(EnumQualityCheckType.MINI_FAULT.getCode().intValue()==qualityCheck.getType().intValue()){
|
|
|
204
|
+ if(qualityCheck.getStatus()!=null){
|
|
|
205
|
+ if(EnumQualityCheckStatus.REJECT_BY_BUYER.getCode().intValue()==qualityCheck.getStatus().intValue()){
|
|
|
206
|
+ type = 2;//用户不接受瑕疵
|
|
|
207
|
+ }else if(EnumQualityCheckStatus.REJECT_BY_OUTER_TIME.getCode().intValue()==qualityCheck.getStatus().intValue()){
|
|
|
208
|
+ type = 3;//用户不接受超时
|
|
|
209
|
+ }
|
|
|
210
|
+ }
|
|
|
211
|
+ }
|
|
|
212
|
+ }
|
|
|
213
|
+ }else if(buyerOrder.getStatus() == OrderStatus.QUALITY_CHECK_FAKE.getCode()){
|
|
|
214
|
+ type = 1;//质检不通过
|
|
|
215
|
+ expectStatus = OrderStatus.QUALITY_CHECK_FAKE;
|
|
|
216
|
+ }else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_REJECT.getCode()){
|
|
|
217
|
+ type = 2;//用户不接受瑕疵
|
|
|
218
|
+ expectStatus = OrderStatus.MINI_FAULT_REJECT;
|
|
|
219
|
+ }else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_OUT_TIME_REJECT.getCode()){
|
|
|
220
|
+ type = 3;//用户不接受超时
|
|
|
221
|
+ expectStatus = OrderStatus.MINI_FAULT_OUT_TIME_REJECT;
|
|
|
222
|
+ }else{
|
|
|
223
|
+ //if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
224
|
+ LOGGER.warn("returnBackOrderCauseOfJudgeFailure expectStatus CHECKING_FAKE QUALITY_CHECK_FAKE MINI_FAULT_REJECT or MINI_FAULT_OUT_TIME_REJECT, actual status {}, orderCode {}",
|
191
|
buyerOrder.getStatus(), orderCode);
|
225
|
buyerOrder.getStatus(), orderCode);
|
192
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
226
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
193
|
}
|
227
|
}
|
|
|
228
|
+ LOGGER.info("returnBackOrderCauseOfJudgeFailure check status ok expectStatus {}, actual status {}, orderCode {}",expectStatus,
|
|
|
229
|
+ buyerOrder.getStatus(), orderCode);
|
|
|
230
|
+
|
194
|
|
231
|
|
195
|
//更新物流信息
|
232
|
//更新物流信息
|
196
|
int sellerUid = buyerOrder.getSellerUid();
|
233
|
int sellerUid = buyerOrder.getSellerUid();
|
|
@@ -199,6 +236,7 @@ public class AppraiseService { |
|
@@ -199,6 +236,7 @@ public class AppraiseService { |
199
|
//清缓存
|
236
|
//清缓存
|
200
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
|
237
|
SellerOrderGoods sellerOrderGoods = cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
|
201
|
|
238
|
|
|
|
239
|
+ /*
|
202
|
//发消息给卖家
|
240
|
//发消息给卖家
|
203
|
QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
|
241
|
QualityCheck qualityCheck = qualityCheckMapper.selectByOrderCode(orderCode);
|
204
|
int type = 1 ;//鉴定不通过
|
242
|
int type = 1 ;//鉴定不通过
|
|
@@ -211,6 +249,7 @@ public class AppraiseService { |
|
@@ -211,6 +249,7 @@ public class AppraiseService { |
211
|
}
|
249
|
}
|
212
|
|
250
|
|
213
|
}
|
251
|
}
|
|
|
252
|
+ */
|
214
|
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods,orderCode,wayBillCode, type);
|
253
|
inBoxFacade.sellerQualityCheckNotPass_send_back(sellerOrderGoods,orderCode,wayBillCode, type);
|
215
|
}
|
254
|
}
|
216
|
|
255
|
|
|
@@ -271,9 +310,12 @@ public class AppraiseService { |
|
@@ -271,9 +310,12 @@ public class AppraiseService { |
271
|
* @outTimeFlag 超时
|
310
|
* @outTimeFlag 超时
|
272
|
* @return
|
311
|
* @return
|
273
|
*/
|
312
|
*/
|
274
|
- public ApiResponse miniFaultReject(Long orderCode,boolean outTimeFlag){
|
|
|
275
|
- LOGGER.info("miniFaultReject enter , orderCode {} ,outTimeFlag {}", orderCode ,outTimeFlag);
|
|
|
276
|
- OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
313
|
+ public ApiResponse miniFaultReject(Long orderCode,OrderStatus targetStatus,boolean outTimeFlag){
|
|
|
314
|
+ LOGGER.info("miniFaultReject enter , orderCode {} ,targetStatus {},outTimeFlag {}", orderCode ,targetStatus ,outTimeFlag);
|
|
|
315
|
+ OrderStatus expectStatusNew = OrderStatus.MINI_FAULT_WAITING;
|
|
|
316
|
+ //拆分状态,版本升级之后存在的特殊订单
|
|
|
317
|
+ OrderStatus expectStatusAnother = OrderStatus.PLATFORM_RECEIVE;
|
|
|
318
|
+ List<Integer> expectStatusList= Lists.newArrayList(expectStatusNew.getCode(),expectStatusAnother.getCode());
|
277
|
ApiResponse apiResponse=new ApiResponse();
|
319
|
ApiResponse apiResponse=new ApiResponse();
|
278
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
320
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
279
|
|
321
|
|
|
@@ -282,16 +324,18 @@ public class AppraiseService { |
|
@@ -282,16 +324,18 @@ public class AppraiseService { |
282
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
324
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
283
|
}
|
325
|
}
|
284
|
|
326
|
|
285
|
- if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
286
|
- LOGGER.warn("miniFaultReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
327
|
+ //if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
328
|
+ if (!expectStatusList.contains(buyerOrder.getStatus())){
|
|
|
329
|
+ LOGGER.warn("miniFaultReject expectStatus {}, actual status {}, orderCode {}", expectStatusList,
|
287
|
buyerOrder.getStatus(), orderCode);
|
330
|
buyerOrder.getStatus(), orderCode);
|
288
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
331
|
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
289
|
}
|
332
|
}
|
290
|
- // 更新买家订单状态 为鉴定不通过
|
333
|
+ // 更新买家订单状态
|
291
|
int buyerUid = buyerOrder.getUid();
|
334
|
int buyerUid = buyerOrder.getUid();
|
292
|
- OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
293
|
LOGGER.info("miniFaultReject update buyer order {} ", buyerOrder);
|
335
|
LOGGER.info("miniFaultReject update buyer order {} ", buyerOrder);
|
294
|
- int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
336
|
+ /* int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
337
|
+ DateUtil.getCurrentTimeSecond());*/
|
|
|
338
|
+ int rows = buyerOrderMapper.updateStatusByOrderCodeMoreExpectStatus(orderCode, buyerUid, expectStatusList, targetStatus.getCode(),
|
295
|
DateUtil.getCurrentTimeSecond());
|
339
|
DateUtil.getCurrentTimeSecond());
|
296
|
|
340
|
|
297
|
if (rows > 0){
|
341
|
if (rows > 0){
|
|
@@ -383,7 +427,7 @@ public class AppraiseService { |
|
@@ -383,7 +427,7 @@ public class AppraiseService { |
383
|
|
427
|
|
384
|
}else{
|
428
|
}else{
|
385
|
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
|
429
|
LOGGER.warn("in miniFaultReject, buyer Order now status {}, expect expectStatus {}",
|
386
|
- buyerOrder.getStatus(), expectStatus);
|
430
|
+ buyerOrder.getStatus(), expectStatusList);
|
387
|
apiResponse.setCode(400);
|
431
|
apiResponse.setCode(400);
|
388
|
apiResponse.setMessage("订单状态发生变化");
|
432
|
apiResponse.setMessage("订单状态发生变化");
|
389
|
}
|
433
|
}
|
|
@@ -418,11 +462,12 @@ public class AppraiseService { |
|
@@ -418,11 +462,12 @@ public class AppraiseService { |
418
|
* 更新发到卖家的物流信息
|
462
|
* 更新发到卖家的物流信息
|
419
|
* 将卖家的保证金分账给平台和买家
|
463
|
* 将卖家的保证金分账给平台和买家
|
420
|
* 更新买家订单状态
|
464
|
* 更新买家订单状态
|
421
|
- * appraiseFlag 鉴定标志,//true 鉴定不通过 ;false 质检不通过 ;
|
|
|
422
|
* @return
|
465
|
* @return
|
423
|
*/
|
466
|
*/
|
424
|
- public ApiResponse appraiseFail(AppraiseExpressInfoBo appraiseExpressInfoBo,OrderStatus expectStatus,boolean appraiseNotPassFlag){
|
|
|
425
|
- LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo ,appraiseNotPassFlag);
|
467
|
+ public ApiResponse appraiseFailAndDelivery(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
468
|
+ LOGGER.info("appraiseFail enter , appraiseExpressInfoBo {} ,appraiseNotPassFlag {}", appraiseExpressInfoBo );
|
|
|
469
|
+ OrderStatus expectStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
470
|
+ OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
426
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
471
|
Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
427
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
472
|
Integer expressCompanyId = appraiseExpressInfoBo.getExpressCompanyId();
|
428
|
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
473
|
String wayBillCode = appraiseExpressInfoBo.getWayBillCode();
|
|
@@ -444,18 +489,19 @@ public class AppraiseService { |
|
@@ -444,18 +489,19 @@ public class AppraiseService { |
444
|
}
|
489
|
}
|
445
|
// 更新买家订单状态 为鉴定不通过
|
490
|
// 更新买家订单状态 为鉴定不通过
|
446
|
int buyerUid = buyerOrder.getUid();
|
491
|
int buyerUid = buyerOrder.getUid();
|
447
|
- OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
492
|
+ int sellerUid = buyerOrder.getSellerUid();
|
448
|
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
493
|
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
|
449
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
494
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
450
|
DateUtil.getCurrentTimeSecond());
|
495
|
DateUtil.getCurrentTimeSecond());
|
451
|
|
496
|
|
452
|
if (rows > 0){
|
497
|
if (rows > 0){
|
|
|
498
|
+ /*
|
453
|
//refund coupons of buyer
|
499
|
//refund coupons of buyer
|
454
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
500
|
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
455
|
.uid(buyerUid).orderCode(orderCode).build();
|
501
|
.uid(buyerUid).orderCode(orderCode).build();
|
456
|
EventBusPublisher.publishEvent(brce);
|
502
|
EventBusPublisher.publishEvent(brce);
|
457
|
//
|
503
|
//
|
458
|
- int sellerUid = buyerOrder.getSellerUid();
|
504
|
+
|
459
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
505
|
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
460
|
int skup = bog.getSkup();
|
506
|
int skup = bog.getSkup();
|
461
|
|
507
|
|
|
@@ -512,6 +558,11 @@ public class AppraiseService { |
|
@@ -512,6 +558,11 @@ public class AppraiseService { |
512
|
.loadRefundAction(payRefundService::refund)
|
558
|
.loadRefundAction(payRefundService::refund)
|
513
|
.loadLogger(LOGGER)
|
559
|
.loadLogger(LOGGER)
|
514
|
.refund();
|
560
|
.refund();
|
|
|
561
|
+ */
|
|
|
562
|
+ RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
563
|
+ boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
564
|
+ SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
565
|
+
|
515
|
if (!refundGoodsMoneyFlag){
|
566
|
if (!refundGoodsMoneyFlag){
|
516
|
apiResponse.setCode(400);
|
567
|
apiResponse.setCode(400);
|
517
|
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
568
|
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
@@ -524,15 +575,9 @@ public class AppraiseService { |
|
@@ -524,15 +575,9 @@ public class AppraiseService { |
524
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
575
|
orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
525
|
|
576
|
|
526
|
//TODO 消息
|
577
|
//TODO 消息
|
527
|
- if(appraiseNotPassFlag){
|
|
|
528
|
- //鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
|
|
|
529
|
- inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
|
|
|
530
|
- inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
531
|
- }else {
|
|
|
532
|
- //质检不通过
|
|
|
533
|
- inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
534
|
- inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
535
|
- }
|
578
|
+ //鉴定不通过 ,其余的情况不发消息,改成寄回的时候再发消息
|
|
|
579
|
+ inBoxFacade.noticeSellerWhenAppraiseFail(sellerOrderGoods, orderCode, wayBillCode);
|
|
|
580
|
+ inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
536
|
|
581
|
|
537
|
}catch(Exception ex) {
|
582
|
}catch(Exception ex) {
|
538
|
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
583
|
LOGGER.warn("in appraiseFail orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
@@ -541,30 +586,15 @@ public class AppraiseService { |
|
@@ -541,30 +586,15 @@ public class AppraiseService { |
541
|
executorService.execute(()->{
|
586
|
executorService.execute(()->{
|
542
|
//更新物流信息,写到最后
|
587
|
//更新物流信息,写到最后
|
543
|
//鉴定不通过,发物流
|
588
|
//鉴定不通过,发物流
|
544
|
- if(appraiseNotPassFlag){
|
|
|
545
|
- //补:鉴定不通过
|
|
|
546
|
- EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
547
|
- EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
548
|
- EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
|
|
|
549
|
- expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
589
|
+ //补:鉴定不通过
|
|
|
590
|
+ EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
591
|
+ EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
592
|
+ EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
|
|
|
593
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
550
|
|
594
|
|
551
|
- //发货物流(平台已发货)
|
|
|
552
|
- expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
|
|
553
|
- }else {
|
|
|
554
|
- //质检不通过,不发物流
|
595
|
+ //发货物流(平台已发货)
|
|
|
596
|
+ expressInfoService.returnBackOrderCauseOfJudgeFailure(sellerUid, expressCompanyId, orderCode, wayBillCode, depotNum,mobile);
|
555
|
|
597
|
|
556
|
- //先补加一条鉴定中物流
|
|
|
557
|
- EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
558
|
- EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
559
|
- EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
560
|
- expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
561
|
-
|
|
|
562
|
- //再加一个鉴定不通过的物流
|
|
|
563
|
- operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
564
|
- expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
565
|
- expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
566
|
- expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
567
|
- }
|
|
|
568
|
});
|
598
|
});
|
569
|
|
599
|
|
570
|
}
|
600
|
}
|
|
@@ -648,7 +678,418 @@ public class AppraiseService { |
|
@@ -648,7 +678,418 @@ public class AppraiseService { |
648
|
}
|
678
|
}
|
649
|
}
|
679
|
}
|
650
|
|
680
|
|
651
|
- public ApiResponse appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
|
681
|
+ @Data
|
|
|
682
|
+ class RefundMoneyResultModel{
|
|
|
683
|
+ boolean refundGoodsMoneyFlag;
|
|
|
684
|
+ SellerOrderGoods sellerOrderGoods;
|
|
|
685
|
+ }
|
|
|
686
|
+
|
|
|
687
|
+ /**
|
|
|
688
|
+ * 鉴定不通或者质检不通过
|
|
|
689
|
+ * 操作钱
|
|
|
690
|
+ */
|
|
|
691
|
+ private RefundMoneyResultModel operateMoneyWhenCheckFail(BuyerOrder buyerOrder, Long orderCode, OrderStatus targetStatus){
|
|
|
692
|
+ LOGGER.info("operateMoney enter , orderCode {},targetStatus {} ", orderCode ,targetStatus);
|
|
|
693
|
+ RefundMoneyResultModel model = new RefundMoneyResultModel();
|
|
|
694
|
+ int buyerUid = buyerOrder.getUid();
|
|
|
695
|
+ int sellerUid = buyerOrder.getSellerUid();
|
|
|
696
|
+
|
|
|
697
|
+ //refund coupons of buyer
|
|
|
698
|
+ BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
|
|
|
699
|
+ .uid(buyerUid).orderCode(orderCode).build();
|
|
|
700
|
+ EventBusPublisher.publishEvent(brce);
|
|
|
701
|
+ //
|
|
|
702
|
+
|
|
|
703
|
+ BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
|
|
704
|
+ int skup = bog.getSkup();
|
|
|
705
|
+
|
|
|
706
|
+ SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
707
|
+ long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
708
|
+
|
|
|
709
|
+ final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
|
|
|
710
|
+ final SellerOrderStatus targetSoStatus = SellerOrderStatus.APPRAISAL_FAIL_COMPENSATE;
|
|
|
711
|
+
|
|
|
712
|
+ SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
|
|
|
713
|
+ skup, orderCode, buyerUid);
|
|
|
714
|
+
|
|
|
715
|
+ //将卖家的保证金分账给平台和买家
|
|
|
716
|
+ PenaltyResult penaltyResult = SellerEarnestMoney2BuyerPenaltyCalculator.from(sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"))
|
|
|
717
|
+ .calculate()
|
|
|
718
|
+ .orElse(null);
|
|
|
719
|
+ if(Objects.nonNull(penaltyResult)){
|
|
|
720
|
+ TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER;
|
|
|
721
|
+ TranseferCellNode transeferCellNode = new TranseferCellNode();
|
|
|
722
|
+ transeferCellNode.setUid(buyerUid);
|
|
|
723
|
+ transeferCellNode.setAmount(penaltyResult.getPenaltyAmountWithoutYhServiceAmount());
|
|
|
724
|
+ TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
|
|
|
725
|
+ .sellerUid(sellerUid)
|
|
|
726
|
+ .buyerOrderCode(orderCode)
|
|
|
727
|
+ .type(transferCase.getCode())
|
|
|
728
|
+ .transferCase(transferCase)
|
|
|
729
|
+ .transeferCellNode(transeferCellNode)
|
|
|
730
|
+ .swdType(SellerWalletDetail.Type.APPRAISE_FAIL)
|
|
|
731
|
+ .alarmConfig(AlarmConfig.APPRAISE_FAIL)
|
|
|
732
|
+ .build();
|
|
|
733
|
+
|
|
|
734
|
+ //先校验,提前把错误抛出
|
|
|
735
|
+ paymentService.transferMonCheck(tmReq);
|
|
|
736
|
+ //再分账
|
|
|
737
|
+
|
|
|
738
|
+ //改成异步的分账,不关心分账执行结果
|
|
|
739
|
+ executorService.execute(()->{
|
|
|
740
|
+ LOGGER.info("in appraiseFail,begin transfer async");
|
|
|
741
|
+ transferService.transfer(tmReq);
|
|
|
742
|
+ });
|
|
|
743
|
+ }
|
|
|
744
|
+
|
|
|
745
|
+
|
|
|
746
|
+ //退钱给买家
|
|
|
747
|
+ BigDecimal goodsMoney = buyerOrder.getAmount();
|
|
|
748
|
+ BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
|
|
|
749
|
+ .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
|
|
|
750
|
+ .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
|
|
|
751
|
+ .amount(goodsMoney)
|
|
|
752
|
+ .skup(skup);
|
|
|
753
|
+ boolean refundGoodsMoneyFlag = new RefundGoodsMoneyHandler().loadPaymentRequest(buyerUid,orderCode,goodsMoney)
|
|
|
754
|
+ .loadBillLogEventBuilder(bleb)
|
|
|
755
|
+ .loadTargetOrderStatus(targetStatus)
|
|
|
756
|
+ .loadRefundAction(payRefundService::refund)
|
|
|
757
|
+ .loadLogger(LOGGER)
|
|
|
758
|
+ .refund();
|
|
|
759
|
+
|
|
|
760
|
+ model.setRefundGoodsMoneyFlag(refundGoodsMoneyFlag);
|
|
|
761
|
+ model.setSellerOrderGoods(sellerOrderGoods);
|
|
|
762
|
+ return model;
|
|
|
763
|
+ }
|
|
|
764
|
+
|
|
|
765
|
+ /**
|
|
|
766
|
+ * 鉴定不通过 3->13 或者 MINI_FAULT_ACCEPT ->13
|
|
|
767
|
+ * 不发物流
|
|
|
768
|
+ */
|
|
|
769
|
+ public ApiResponse judgeCenterNotPass(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
770
|
+ LOGGER.info("judgeCenterNotPass enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo );
|
|
|
771
|
+ OrderStatus expectStatus ;
|
|
|
772
|
+ OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
|
|
|
773
|
+ Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
774
|
+
|
|
|
775
|
+ ApiResponse apiResponse=new ApiResponse();
|
|
|
776
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
777
|
+
|
|
|
778
|
+ if (buyerOrder == null){
|
|
|
779
|
+ LOGGER.warn("judgeCenterNotPass getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
780
|
+ throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
781
|
+ }
|
|
|
782
|
+
|
|
|
783
|
+ if(buyerOrder.getStatus() == OrderStatus.PLATFORM_CHECKING.getCode()){
|
|
|
784
|
+ expectStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
785
|
+ }else if(buyerOrder.getStatus() == OrderStatus.MINI_FAULT_ACCEPT.getCode()){
|
|
|
786
|
+ expectStatus = OrderStatus.MINI_FAULT_ACCEPT;
|
|
|
787
|
+ }else{
|
|
|
788
|
+ LOGGER.warn("judgeCenterNotPass expectStatus PLATFORM_CHECKING or MINI_FAULT_ACCEPT, actual status {}, orderCode {}",
|
|
|
789
|
+ buyerOrder.getStatus(), orderCode);
|
|
|
790
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
791
|
+ }
|
|
|
792
|
+ // 更新买家订单状态
|
|
|
793
|
+ int buyerUid = buyerOrder.getUid();
|
|
|
794
|
+ int sellerUid = buyerOrder.getSellerUid();
|
|
|
795
|
+ LOGGER.info("judgeCenterNotPass update buyer order {} ", buyerOrder);
|
|
|
796
|
+ int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
797
|
+ DateUtil.getCurrentTimeSecond());
|
|
|
798
|
+
|
|
|
799
|
+ if (rows > 0){
|
|
|
800
|
+ RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
801
|
+ boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
802
|
+ SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
803
|
+ if (!refundGoodsMoneyFlag){
|
|
|
804
|
+ apiResponse.setCode(400);
|
|
|
805
|
+ String content = "后台鉴定商品不通过,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
|
806
|
+ apiResponse.setMessage(content);
|
|
|
807
|
+ }
|
|
|
808
|
+
|
|
|
809
|
+ //记录订单的状态变更信息
|
|
|
810
|
+ LOGGER.info("in judgeCenterNotPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
|
|
|
811
|
+ try {
|
|
|
812
|
+ orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
813
|
+
|
|
|
814
|
+ //鉴定不通过
|
|
|
815
|
+ inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
816
|
+ inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
817
|
+
|
|
|
818
|
+ }catch(Exception ex) {
|
|
|
819
|
+ LOGGER.warn("in judgeCenterNotPass orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
|
820
|
+ }finally {
|
|
|
821
|
+ /// 物流信息异步执行
|
|
|
822
|
+ executorService.execute(()->{
|
|
|
823
|
+ //鉴定通过,不发物流
|
|
|
824
|
+ EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
825
|
+ EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
826
|
+ EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_reject;
|
|
|
827
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
828
|
+
|
|
|
829
|
+ });
|
|
|
830
|
+
|
|
|
831
|
+ }
|
|
|
832
|
+
|
|
|
833
|
+ }else{
|
|
|
834
|
+ LOGGER.warn("in judgeCenterNotPass, buyer Order now status {}, expect expectStatus {}",
|
|
|
835
|
+ buyerOrder.getStatus(), expectStatus);
|
|
|
836
|
+ apiResponse.setCode(400);
|
|
|
837
|
+ apiResponse.setMessage("订单状态发生变化");
|
|
|
838
|
+ }
|
|
|
839
|
+ return apiResponse;
|
|
|
840
|
+ }
|
|
|
841
|
+
|
|
|
842
|
+ /**
|
|
|
843
|
+ * 质检不通过 31->20
|
|
|
844
|
+ * 不发物流
|
|
|
845
|
+ */
|
|
|
846
|
+ public ApiResponse qualityCheckReject(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
847
|
+ LOGGER.info("qualityCheckReject enter , appraiseExpressInfoBo {} ", appraiseExpressInfoBo );
|
|
|
848
|
+ OrderStatus expectStatus = OrderStatus.PLATFORM_RECEIVE;
|
|
|
849
|
+ OrderStatus targetStatus = OrderStatus.QUALITY_CHECK_FAKE;
|
|
|
850
|
+ Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
851
|
+
|
|
|
852
|
+ ApiResponse apiResponse=new ApiResponse();
|
|
|
853
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
854
|
+
|
|
|
855
|
+ if (buyerOrder == null){
|
|
|
856
|
+ LOGGER.warn("qualityCheckReject getOrderInfo order not exist, orderCode {}", orderCode);
|
|
|
857
|
+ throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
858
|
+ }
|
|
|
859
|
+
|
|
|
860
|
+ if (buyerOrder.getStatus() != expectStatus.getCode()){
|
|
|
861
|
+ LOGGER.warn("qualityCheckReject expectStatus {}, actual status {}, orderCode {}", expectStatus,
|
|
|
862
|
+ buyerOrder.getStatus(), orderCode);
|
|
|
863
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
864
|
+ }
|
|
|
865
|
+ // 更新买家订单状态
|
|
|
866
|
+ int buyerUid = buyerOrder.getUid();
|
|
|
867
|
+ int sellerUid = buyerOrder.getSellerUid();
|
|
|
868
|
+ LOGGER.info("qualityCheckReject update buyer order {} ", buyerOrder);
|
|
|
869
|
+ int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expectStatus.getCode(), targetStatus.getCode(),
|
|
|
870
|
+ DateUtil.getCurrentTimeSecond());
|
|
|
871
|
+
|
|
|
872
|
+ if (rows > 0){
|
|
|
873
|
+ RefundMoneyResultModel refundMoneyResultModel= operateMoneyWhenCheckFail(buyerOrder,orderCode,targetStatus);
|
|
|
874
|
+ boolean refundGoodsMoneyFlag = refundMoneyResultModel.isRefundGoodsMoneyFlag();
|
|
|
875
|
+ SellerOrderGoods sellerOrderGoods = refundMoneyResultModel.getSellerOrderGoods();
|
|
|
876
|
+ if (!refundGoodsMoneyFlag){
|
|
|
877
|
+ apiResponse.setCode(400);
|
|
|
878
|
+ String content = "后台质检不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
|
|
|
879
|
+ apiResponse.setMessage(content);
|
|
|
880
|
+ }
|
|
|
881
|
+
|
|
|
882
|
+ //记录订单的状态变更信息
|
|
|
883
|
+ LOGGER.info("in qualityCheckReject record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
|
|
|
884
|
+ try {
|
|
|
885
|
+ orderStatusFlowService.addAsy(buyerOrder.getOrderCode(), targetStatus.getCode());
|
|
|
886
|
+
|
|
|
887
|
+ //质检不通过
|
|
|
888
|
+ inBoxFacade.noticeBuyerWhenQualityCheckNotPass(buyerUid, buyerOrder.getOrderCode(), sellerOrderGoods.getProductName());
|
|
|
889
|
+ inBoxFacade.sellerQualityCheckNotPass(sellerOrderGoods,orderCode);
|
|
|
890
|
+
|
|
|
891
|
+ }catch(Exception ex) {
|
|
|
892
|
+ LOGGER.warn("in qualityCheckReject orderStatusFlowService or notice fail orderCode {}", orderCode, ex);
|
|
|
893
|
+ }finally {
|
|
|
894
|
+ /// 物流信息异步执行
|
|
|
895
|
+ executorService.execute(()->{
|
|
|
896
|
+ //质检不通过,不发物流
|
|
|
897
|
+ //先补加一条鉴定中物流
|
|
|
898
|
+ EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
899
|
+ EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
900
|
+ EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judging;
|
|
|
901
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
902
|
+
|
|
|
903
|
+ //再加一个鉴定不通过的物流
|
|
|
904
|
+ operateTransferCode = EnumExpressDataOperateTransferCode.quality_check_reject;
|
|
|
905
|
+ expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
906
|
+ expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
907
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
908
|
+
|
|
|
909
|
+ });
|
|
|
910
|
+
|
|
|
911
|
+ }
|
|
|
912
|
+
|
|
|
913
|
+ }else{
|
|
|
914
|
+ LOGGER.warn("in qualityCheckReject, buyer Order now status {}, expect expectStatus {}",
|
|
|
915
|
+ buyerOrder.getStatus(), expectStatus);
|
|
|
916
|
+ apiResponse.setCode(400);
|
|
|
917
|
+ apiResponse.setMessage("订单状态发生变化");
|
|
|
918
|
+ }
|
|
|
919
|
+ return apiResponse;
|
|
|
920
|
+ }
|
|
|
921
|
+
|
|
|
922
|
+ /**
|
|
|
923
|
+ * 正常发货
|
|
|
924
|
+ * 鉴定通过 -- 待收货
|
|
|
925
|
+ */
|
|
|
926
|
+ public void deliveryGoodsToBuyer(AppraiseExpressInfoBo appraiseExpressInfoBo){
|
|
|
927
|
+ LOGGER.info("deliveryGoodsToBuyer enter req {}", appraiseExpressInfoBo);
|
|
|
928
|
+ final OrderStatus expectOrderStatus = OrderStatus.JUDGE_PASS;
|
|
|
929
|
+ final OrderStatus targetOrderStatus = OrderStatus.WAITING_RECEIVE;
|
|
|
930
|
+ Long orderCode = appraiseExpressInfoBo.getOrderCode();
|
|
|
931
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
932
|
+
|
|
|
933
|
+ if (buyerOrder == null){
|
|
|
934
|
+ LOGGER.warn("deliveryGoodsToBuyer getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
935
|
+ throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
936
|
+ }
|
|
|
937
|
+
|
|
|
938
|
+ if (expectOrderStatus.getCode() != buyerOrder.getStatus().intValue()){
|
|
|
939
|
+ LOGGER.warn("in deliveryGoodsToBuyer, buyer Order orderCode {} pstatus {}, expect Order Status {}",
|
|
|
940
|
+ orderCode, buyerOrder.getStatus(), expectOrderStatus);
|
|
|
941
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
942
|
+ }
|
|
|
943
|
+
|
|
|
944
|
+ Integer buyerUid = buyerOrder.getUid();
|
|
|
945
|
+ int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
|
|
|
946
|
+ expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
947
|
+ if (updateBuyerCnt == 1){
|
|
|
948
|
+ //发货,这个时候产生:买家确认收货的mq
|
|
|
949
|
+ BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
|
|
950
|
+ EventBusPublisher.publishEvent(buyerConfirmEvent);
|
|
|
951
|
+
|
|
|
952
|
+ //记录物流信息
|
|
|
953
|
+ //发物流
|
|
|
954
|
+ expressInfoService.deliverGoods(buyerUid, appraiseExpressInfoBo.getExpressCompanyId(), orderCode, appraiseExpressInfoBo.getWayBillCode(), appraiseExpressInfoBo.getDepotNum(),appraiseExpressInfoBo.getMobile());
|
|
|
955
|
+
|
|
|
956
|
+ //记录订单的状态变更信息
|
|
|
957
|
+ orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
|
|
|
958
|
+
|
|
|
959
|
+ //TODO 平台已发货给买家
|
|
|
960
|
+
|
|
|
961
|
+ //清缓存
|
|
|
962
|
+ cleanCacheAfterUpdateStatus(buyerOrder.getOrderCode(),buyerOrder.getUid(),buyerOrder.getSellerUid());
|
|
|
963
|
+ }else{
|
|
|
964
|
+ LOGGER.warn("in deliveryGoodsToBuyer update status number zero, buyer Order orderCode {} pstatus {}, expect Order Status {}",
|
|
|
965
|
+ orderCode, buyerOrder.getStatus(), expectOrderStatus);
|
|
|
966
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
967
|
+ }
|
|
|
968
|
+ }
|
|
|
969
|
+
|
|
|
970
|
+ /**
|
|
|
971
|
+ * 鉴定通过,但是不发货
|
|
|
972
|
+ * @return
|
|
|
973
|
+ */
|
|
|
974
|
+ public ApiResponse judgeCenterPass(Long orderCode){
|
|
|
975
|
+ LOGGER.info("judgeCenterPass enter orderCode {}", orderCode);
|
|
|
976
|
+ ApiResponse apiResponse=new ApiResponse();
|
|
|
977
|
+ BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
|
|
978
|
+
|
|
|
979
|
+ if (buyerOrder == null){
|
|
|
980
|
+ LOGGER.warn("judgeCenterPass getOrderInfo order not exist, orderCode is {}", orderCode);
|
|
|
981
|
+ throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
982
|
+ }
|
|
|
983
|
+ final OrderStatus expectOrderStatus ;
|
|
|
984
|
+ final OrderStatus targetOrderStatus = OrderStatus.JUDGE_PASS;
|
|
|
985
|
+ if( OrderStatus.PLATFORM_CHECKING.getCode() == buyerOrder.getStatus().intValue()){
|
|
|
986
|
+ expectOrderStatus = OrderStatus.PLATFORM_CHECKING;
|
|
|
987
|
+ }else if(OrderStatus.MINI_FAULT_ACCEPT.getCode() == buyerOrder.getStatus().intValue()){
|
|
|
988
|
+ expectOrderStatus = OrderStatus.MINI_FAULT_ACCEPT;
|
|
|
989
|
+ }else{
|
|
|
990
|
+ LOGGER.warn("in judgeCenterPass, buyer Order orderCode {} status {}, expect Order Status is OrderStatus.PLATFORM_CHECKING or OrderStatus.MINI_FAULT_ACCEPT ",
|
|
|
991
|
+ orderCode, buyerOrder.getStatus());
|
|
|
992
|
+ throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
|
|
|
993
|
+ }
|
|
|
994
|
+ LOGGER.info("judgeCenterPass enter orderCode {} ,expectOrderStatus {}", orderCode ,expectOrderStatus);
|
|
|
995
|
+
|
|
|
996
|
+ Integer buyerUid = buyerOrder.getUid();
|
|
|
997
|
+ BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
|
|
|
998
|
+ int skup = bog.getSkup();
|
|
|
999
|
+ SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
|
|
|
1000
|
+
|
|
|
1001
|
+
|
|
|
1002
|
+ int updateBuyerCnt = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid,
|
|
|
1003
|
+ expectOrderStatus.getCode(), targetOrderStatus.getCode(), DateUtil.getCurrentTimeSecond());
|
|
|
1004
|
+
|
|
|
1005
|
+ if (updateBuyerCnt == 1){
|
|
|
1006
|
+ final Integer sellerUid = sellerOrder.getUid();
|
|
|
1007
|
+ final Long sellerOrderCode = sellerOrder.getOrderCode();
|
|
|
1008
|
+ final SellerOrderStatus expectSOStatus = SellerOrderStatus.HAS_PAYED;
|
|
|
1009
|
+ final SellerOrderStatus targetSoStatus = SellerOrderStatus.FINISH;
|
|
|
1010
|
+
|
|
|
1011
|
+ /**
|
|
|
1012
|
+ * 更新卖家订单状态,
|
|
|
1013
|
+ */
|
|
|
1014
|
+ SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
|
|
|
1015
|
+ skup, orderCode, buyerUid);
|
|
|
1016
|
+
|
|
|
1017
|
+
|
|
|
1018
|
+ //退款给卖家(仅退一次)
|
|
|
1019
|
+ PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
|
|
|
1020
|
+
|
|
|
1021
|
+ try {
|
|
|
1022
|
+ //记录订单的状态变更信息
|
|
|
1023
|
+ LOGGER.info("in judgeCenterPass record status change, orderCode {},uid {} ,sellerUid {}", orderCode,buyerUid,sellerUid);
|
|
|
1024
|
+ orderStatusFlowService.addAsy(buyerOrder.getOrderCode(),targetOrderStatus.getCode());
|
|
|
1025
|
+
|
|
|
1026
|
+ //TODO 鉴定通过,等待发货,消息
|
|
|
1027
|
+ //inBoxFacade.appraisePassNotice(buyerUid, orderCode, sellerOrderGoods);
|
|
|
1028
|
+ }catch (Exception ex){
|
|
|
1029
|
+ LOGGER.warn("in judgeCenterPass,refund fail, refundReqOfSeller {}", refundReqOfSeller, ex);
|
|
|
1030
|
+ String content = "后台鉴定通过商品,订单"+ orderCode + "退还保证金失败";
|
|
|
1031
|
+ apiResponse.setCode(400);
|
|
|
1032
|
+ apiResponse.setMessage(content);
|
|
|
1033
|
+ }finally {
|
|
|
1034
|
+ //记录调拨信息
|
|
|
1035
|
+ EnumExpressType expressType = EnumExpressType.EXPRESS_TYPE_JUDGE_CENTER;
|
|
|
1036
|
+ EnumExpressDataType expressDataType = EnumExpressDataType.operate_transfer;
|
|
|
1037
|
+ EnumExpressDataOperateTransferCode operateTransferCode = EnumExpressDataOperateTransferCode.judge_pass;
|
|
|
1038
|
+ expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
|
|
1039
|
+ }
|
|
|
1040
|
+
|
|
|
1041
|
+ LOGGER.info("in judgeCenterPass, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
|
|
|
1042
|
+ sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
|
|
|
1043
|
+
|
|
|
1044
|
+
|
|
|
1045
|
+ }else{
|
|
|
1046
|
+ LOGGER.warn("in judgeCenterPass, buyer Order pstatus {}, expect expectOrderStatus {}",
|
|
|
1047
|
+ buyerOrder.getStatus(), expectOrderStatus);
|
|
|
1048
|
+ apiResponse.setCode(400);
|
|
|
1049
|
+ apiResponse.setMessage("订单状态发生变化");
|
|
|
1050
|
+ }
|
|
|
1051
|
+
|
|
|
1052
|
+ return apiResponse;
|
|
|
1053
|
+ }
|
|
|
1054
|
+
|
|
|
1055
|
+
|
|
|
1056
|
+ /**
|
|
|
1057
|
+ * 通过时 ,操作钱
|
|
|
1058
|
+ */
|
|
|
1059
|
+ private PaymentRequest operateMoneyWhenOk(Integer buyerUid,Long orderCode,int skup,SellerOrder sellerOrder,SellerOrderStatus targetSoStatus){
|
|
|
1060
|
+ final Integer sellerUid = sellerOrder.getUid();
|
|
|
1061
|
+ BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
|
|
|
1062
|
+
|
|
|
1063
|
+ TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
|
|
|
1064
|
+ TranseferCellNode transeferCellNode = new TranseferCellNode();
|
|
|
1065
|
+ transeferCellNode.setUid(sellerUid);
|
|
|
1066
|
+ transeferCellNode.setAmount(saleIncome);
|
|
|
1067
|
+ TransferMoneyRequest tmReq = TransferMoneyRequest.builder()
|
|
|
1068
|
+ .buyerOrderCode(orderCode)
|
|
|
1069
|
+ .type(transferCase.getCode())
|
|
|
1070
|
+ .transferCase(transferCase)
|
|
|
1071
|
+ .transeferCellNode(transeferCellNode)
|
|
|
1072
|
+ .alarmConfig(AlarmConfig.APPRAISE_SUCCESS)
|
|
|
1073
|
+ .build();
|
|
|
1074
|
+
|
|
|
1075
|
+ //先校验,提前把错误抛出
|
|
|
1076
|
+ paymentService.transferMonCheck(tmReq);
|
|
|
1077
|
+
|
|
|
1078
|
+ //改成异步的分账,不关心分账执行结果
|
|
|
1079
|
+ executorService.execute(()->{
|
|
|
1080
|
+ LOGGER.info("in appraiseSuccess,begin transfer async");
|
|
|
1081
|
+ transferService.transfer(tmReq);
|
|
|
1082
|
+ });
|
|
|
1083
|
+
|
|
|
1084
|
+ //退保证金给卖家
|
|
|
1085
|
+ //refund earnestMoney
|
|
|
1086
|
+ BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
|
|
1087
|
+ PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
|
|
|
1088
|
+ LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
|
|
|
1089
|
+ return refundReqOfSeller;
|
|
|
1090
|
+ }
|
|
|
1091
|
+
|
|
|
1092
|
+ public ApiResponse appraiseSuccessAndDelivery(Integer expressCompanyId, Long orderCode, String wayBillCode,Integer depotNum,String mobile){
|
652
|
ApiResponse apiResponse=new ApiResponse();
|
1093
|
ApiResponse apiResponse=new ApiResponse();
|
653
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
1094
|
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
|
654
|
|
1095
|
|
|
@@ -683,6 +1124,7 @@ public class AppraiseService { |
|
@@ -683,6 +1124,7 @@ public class AppraiseService { |
683
|
* 退款给卖家(仅退一次)
|
1124
|
* 退款给卖家(仅退一次)
|
684
|
*
|
1125
|
*
|
685
|
*/
|
1126
|
*/
|
|
|
1127
|
+ /*
|
686
|
SellerOrder tso = new SellerOrder();
|
1128
|
SellerOrder tso = new SellerOrder();
|
687
|
tso.setUid(sellerUid);
|
1129
|
tso.setUid(sellerUid);
|
688
|
tso.setOrderCode(sellerOrderCode);
|
1130
|
tso.setOrderCode(sellerOrderCode);
|
|
@@ -690,6 +1132,15 @@ public class AppraiseService { |
|
@@ -690,6 +1132,15 @@ public class AppraiseService { |
690
|
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
1132
|
tso.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
691
|
tso.setExceptStatus(expectSOStatus.getCode());
|
1133
|
tso.setExceptStatus(expectSOStatus.getCode());
|
692
|
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
|
1134
|
int soCnt = sellerOrderMapper.updateByOrderCode(tso);
|
|
|
1135
|
+ */
|
|
|
1136
|
+ //更新卖家订单状态
|
|
|
1137
|
+ SellerOrderGoods sellerOrderGoods = updateSellerOrderStatusAndCleanCache(sellerUid ,sellerOrderCode,expectSOStatus,targetSoStatus,
|
|
|
1138
|
+ skup, orderCode, buyerUid);
|
|
|
1139
|
+ //退款给卖家(仅退一次)
|
|
|
1140
|
+ PaymentRequest refundReqOfSeller = operateMoneyWhenOk(buyerUid,orderCode,skup,sellerOrder,targetSoStatus);
|
|
|
1141
|
+
|
|
|
1142
|
+
|
|
|
1143
|
+ /*
|
693
|
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
|
1144
|
BigDecimal saleIncome = getSaleIncome(sellerUid, skup);
|
694
|
|
1145
|
|
695
|
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
|
1146
|
TransferCase transferCase = TransferCase.ALL_GOODS_MONEY_TO_SELLER;
|
|
@@ -713,15 +1164,14 @@ public class AppraiseService { |
|
@@ -713,15 +1164,14 @@ public class AppraiseService { |
713
|
transferService.transfer(tmReq);
|
1164
|
transferService.transfer(tmReq);
|
714
|
});
|
1165
|
});
|
715
|
|
1166
|
|
716
|
- /**
|
|
|
717
|
- * 退保证金给卖家
|
|
|
718
|
- */
|
1167
|
+ //退保证金给卖家
|
719
|
//refund earnestMoney
|
1168
|
//refund earnestMoney
|
720
|
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
1169
|
BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
|
721
|
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
|
1170
|
PaymentRequest refundReqOfSeller = refundEarnestMoney(SellerWalletDetail.Type.APPRAISE_OK,orderCode,sellerUid ,sellerOrder,skup,buyerUid,targetSoStatus,earnestMoney.doubleValue());
|
722
|
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
|
1171
|
LOGGER.info("in appraiseSuccess,refund ok, refundReqOfSeller {}", refundReqOfSeller);
|
723
|
|
1172
|
|
724
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
1173
|
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
1174
|
+ */
|
725
|
try {
|
1175
|
try {
|
726
|
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
|
1176
|
//鉴定通过后自动发货,这个时候产生:买家确认收货的mq
|
727
|
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
1177
|
BuyerConfirmEvent buyerConfirmEvent = BuyerConfirmEvent.builder().uid(buyerUid).orderCode(orderCode).build();
|
|
@@ -749,6 +1199,7 @@ public class AppraiseService { |
|
@@ -749,6 +1199,7 @@ public class AppraiseService { |
749
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
1199
|
expressInfoService.saveOperateTransferExpressInfo(sellerUid,orderCode,expressType.getCode(),expressDataType,operateTransferCode);
|
750
|
}
|
1200
|
}
|
751
|
|
1201
|
|
|
|
1202
|
+ /*
|
752
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
1203
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
753
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
1204
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
754
|
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
|
1205
|
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
|
|
@@ -758,9 +1209,10 @@ public class AppraiseService { |
|
@@ -758,9 +1209,10 @@ public class AppraiseService { |
758
|
|
1209
|
|
759
|
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
|
1210
|
ErpBuyerOrderEvent event = new ErpBuyerOrderEvent(buyerUid);
|
760
|
EventBusPublisher.publishEvent(event);
|
1211
|
EventBusPublisher.publishEvent(event);
|
|
|
1212
|
+ */
|
761
|
|
1213
|
|
762
|
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
|
1214
|
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
|
763
|
- sellerUid, sellerOrderCode, skup, earnestMoney );
|
1215
|
+ sellerUid, sellerOrderCode, skup, sellerOrder.getEarnestMoney() );
|
764
|
|
1216
|
|
765
|
|
1217
|
|
766
|
}else{
|
1218
|
}else{
|