Authored by chenchao

fix refund earnest money logic

@@ -55,7 +55,8 @@ public class SellerWalletDetail { @@ -55,7 +55,8 @@ public class SellerWalletDetail {
55 APPRAISE_OK("鉴定通过", 51), 55 APPRAISE_OK("鉴定通过", 51),
56 APPRAISE_UNSURE("商品无法鉴定", 52), 56 APPRAISE_UNSURE("商品无法鉴定", 52),
57 MERCHANT_EXIT("商家退出入驻", 61), 57 MERCHANT_EXIT("商家退出入驻", 61),
58 - CANCEL_DELIVER("不寄了", 71); 58 + CANCEL_DELIVER("不寄了", 71),
  59 + FLAW("瑕疵品",72);
59 60
60 private String name; 61 private String name;
61 private int value; 62 private int value;
@@ -42,5 +42,17 @@ public interface IGoodsService { @@ -42,5 +42,17 @@ public interface IGoodsService {
42 42
43 OrderAttributes getOrderAttributes(); 43 OrderAttributes getOrderAttributes();
44 44
  45 + /**
  46 + * 虚假发货
  47 + * @param appraiseOrder
  48 + * @return
  49 + */
45 int shamDeliver(AppraiseOrder appraiseOrder); 50 int shamDeliver(AppraiseOrder appraiseOrder);
  51 +
  52 + /**
  53 + * 瑕疵
  54 + * @param appraiseOrder
  55 + * @return
  56 + */
  57 + int findFlaw(AppraiseOrder appraiseOrder);
46 } 58 }
@@ -3,6 +3,7 @@ package com.yohoufo.order.service.handler; @@ -3,6 +3,7 @@ package com.yohoufo.order.service.handler;
3 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; 3 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
4 import com.yohoufo.common.alarm.EventBusPublisher; 4 import com.yohoufo.common.alarm.EventBusPublisher;
5 import com.yohoufo.common.alarm.SmsAlarmEvent; 5 import com.yohoufo.common.alarm.SmsAlarmEvent;
  6 +import com.yohoufo.common.exception.UfoServiceException;
6 import com.yohoufo.dal.order.model.SellerWalletDetail; 7 import com.yohoufo.dal.order.model.SellerWalletDetail;
7 import com.yohoufo.order.common.BillTradeStatus; 8 import com.yohoufo.order.common.BillTradeStatus;
8 import com.yohoufo.order.common.RefundCase; 9 import com.yohoufo.order.common.RefundCase;
@@ -61,7 +62,9 @@ public class GoodsServiceRefundHandler extends AbsRefundOrderHandler { @@ -61,7 +62,9 @@ public class GoodsServiceRefundHandler extends AbsRefundOrderHandler {
61 62
62 @Override 63 @Override
63 public boolean refund() { 64 public boolean refund() {
64 - 65 + if (paidOrderCode == null){
  66 + throw new UfoServiceException(400, "退款订单不存在");
  67 + }
65 68
66 try { 69 try {
67 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder() 70 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder()
@@ -137,4 +137,15 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -137,4 +137,15 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
137 logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows); 137 logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
138 return rows; 138 return rows;
139 } 139 }
  140 +
  141 + @Override
  142 + public int findFlaw(AppraiseOrder appraiseOrder){
  143 + long orderCode = appraiseOrder.getOrderCode();
  144 + AppraiseOrderStatus targetStatus = AppraiseOrderStatus.FLAW,
  145 + expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
  146 +
  147 + int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
  148 + logger.info("appraise order appraiseFake update status, orderCode {} rows {}", orderCode, rows);
  149 + return rows;
  150 + }
140 } 151 }
@@ -1284,7 +1284,8 @@ public class AppraiseService { @@ -1284,7 +1284,8 @@ public class AppraiseService {
1284 ApiResponse apiResponse = new ApiResponse(); 1284 ApiResponse apiResponse = new ApiResponse();
1285 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1285 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1286 LOGGER.info("judgeCenterPass isGoodsServiceOrder orderCode {}", orderCode); 1286 LOGGER.info("judgeCenterPass isGoodsServiceOrder orderCode {}", orderCode);
1287 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraisePass(orderCode); 1287 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1288 + existenceNode.getGoodsService().appraisePass(existenceNode.getAppraiseOrder());
1288 apiResponse.setCode(200); 1289 apiResponse.setCode(200);
1289 return apiResponse; 1290 return apiResponse;
1290 } 1291 }
@@ -279,7 +279,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -279,7 +279,7 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
279 new GoodsServiceRefundHandler() 279 new GoodsServiceRefundHandler()
280 .loadLogger(logger) 280 .loadLogger(logger)
281 .loadUser(pao.getUid()) 281 .loadUser(pao.getUid())
282 - .loadActionCase(SellerWalletDetail.Type.CANCEL_DELIVER) 282 + .loadActionCase(SellerWalletDetail.Type.APPRAISE_OK)
283 .loadRefundAction(payRefundService::refund) 283 .loadRefundAction(payRefundService::refund)
284 .loadOrder(orderCode, paidCode, pao.getPayment(), left) 284 .loadOrder(orderCode, paidCode, pao.getPayment(), left)
285 .refund(); 285 .refund();
@@ -350,12 +350,25 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -350,12 +350,25 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
350 return rows; 350 return rows;
351 } 351 }
352 352
  353 + /**
  354 + * 确认收货环节发现少件,取消订单保证金原路退回
  355 + * @param appraiseOrder
  356 + * @return
  357 + */
353 @Override 358 @Override
354 public int shamDeliver(AppraiseOrder appraiseOrder){ 359 public int shamDeliver(AppraiseOrder appraiseOrder){
355 int rows = super.shamDeliver(appraiseOrder); 360 int rows = super.shamDeliver(appraiseOrder);
356 if (rows == 0){ 361 if (rows == 0){
357 return rows; 362 return rows;
358 } 363 }
  364 + //refund amount
  365 + new GoodsServiceRefundHandler()
  366 + .loadLogger(logger)
  367 + .loadUser(appraiseOrder.getUid())
  368 + .loadActionCase(SellerWalletDetail.Type.SELLER_SHAM_SEND_OUT)
  369 + .loadRefundAction(payRefundService::refund)
  370 + .loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
  371 + .refund();
359 depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode()); 372 depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
360 return rows; 373 return rows;
361 } 374 }
@@ -456,5 +469,27 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -456,5 +469,27 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
456 return rows; 469 return rows;
457 } 470 }
458 471
  472 + /**
  473 + * 瑕疵
  474 + * 退回对应保证金至卖家账户
  475 + * @param appraiseOrder
  476 + * @return
  477 + */
  478 + public int findFlaw(AppraiseOrder appraiseOrder){
  479 + int rows = super.findFlaw(appraiseOrder);
  480 + if (rows == 0){
  481 + return rows;
  482 + }
  483 + new GoodsServiceRefundHandler()
  484 + .loadLogger(logger)
  485 + .loadUser(appraiseOrder.getUid())
  486 + .loadActionCase(SellerWalletDetail.Type.FLAW)
  487 + .loadRefundAction(payRefundService::refund)
  488 + .loadOrder(appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode(), appraiseOrder.getPayment(), appraiseOrder.getAmount())
  489 + .refund();
  490 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
  491 + return rows;
  492 + }
  493 +
459 494
460 } 495 }