Authored by chenchao

add in Event trigger

@@ -2,6 +2,7 @@ package com.yohoufo.order.service; @@ -2,6 +2,7 @@ package com.yohoufo.order.service;
2 2
3 import com.yohobuy.ufo.model.order.common.OrderAttributes; 3 import com.yohobuy.ufo.model.order.common.OrderAttributes;
4 import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; 4 import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
  5 +import com.yohoufo.dal.order.model.AppraiseOrder;
5 6
6 public interface IGoodsService { 7 public interface IGoodsService {
7 8
@@ -31,13 +32,13 @@ public interface IGoodsService { @@ -31,13 +32,13 @@ public interface IGoodsService {
31 * 鉴别为假 32 * 鉴别为假
32 * @param orderCode 33 * @param orderCode
33 */ 34 */
34 - int appraiseFake(long orderCode); 35 + int appraiseFake(AppraiseOrder appraiseOrder);
35 36
36 /** 37 /**
37 * 无法鉴别 38 * 无法鉴别
38 - * @param orderCode 39 + * @param appraiseOrder
39 */ 40 */
40 - int unsure(long orderCode); 41 + int unsure(AppraiseOrder appraiseOrder);
41 42
42 OrderAttributes getOrderAttributes(); 43 OrderAttributes getOrderAttributes();
43 } 44 }
@@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.req.DeliverToDepotReq; @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
5 import com.yohoufo.common.utils.DateUtil; 5 import com.yohoufo.common.utils.DateUtil;
6 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper; 6 import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
7 import com.yohoufo.dal.order.AppraiseOrderMapper; 7 import com.yohoufo.dal.order.AppraiseOrderMapper;
  8 +import com.yohoufo.dal.order.model.AppraiseOrder;
8 import com.yohoufo.dal.order.model.AppraiseOrderGoods; 9 import com.yohoufo.dal.order.model.AppraiseOrderGoods;
9 import com.yohoufo.order.service.IGoodsService; 10 import com.yohoufo.order.service.IGoodsService;
10 import com.yohoufo.order.service.proxy.OrderStatusFlowService; 11 import com.yohoufo.order.service.proxy.OrderStatusFlowService;
@@ -97,11 +98,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -97,11 +98,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
97 98
98 /** 99 /**
99 * 鉴别为假 100 * 鉴别为假
100 - * @param orderCode 101 + * @param appraiseOrder
101 */ 102 */
102 @Override 103 @Override
103 - public int appraiseFake(long orderCode){  
104 - 104 + public int appraiseFake(AppraiseOrder appraiseOrder){
  105 + long orderCode = appraiseOrder.getOrderCode();
105 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.CHECKING_FAKE, 106 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.CHECKING_FAKE,
106 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING; 107 expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING;
107 108
@@ -112,10 +113,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService { @@ -112,10 +113,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
112 113
113 /** 114 /**
114 * 无法鉴别 115 * 无法鉴别
115 - * @param orderCode 116 + * @param appraiseOrder
116 */ 117 */
117 @Override 118 @Override
118 - public int unsure(long orderCode){ 119 + public int unsure(AppraiseOrder appraiseOrder){
  120 + long orderCode = appraiseOrder.getOrderCode();
119 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE, 121 AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE,
120 expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE; 122 expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
121 123
@@ -337,46 +337,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements @@ -337,46 +337,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
337 return aodResp; 337 return aodResp;
338 } 338 }
339 339
340 - /**  
341 - * 是否付费鉴定 or 卖家寄存订单  
342 - * @param orderCode  
343 - * @return  
344 - */  
345 - public ExistenceNode isAppraiseOrder(long orderCode){  
346 - AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);  
347 - boolean flag = Objects.nonNull(pao);  
348 - Integer aoac = flag ? pao.getAttributes() : null;  
349 - logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",  
350 - orderCode, aoac, flag);  
351 - return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();  
352 - }  
353 340
354 - @Data  
355 - @Builder  
356 - public static class ExistenceNode{  
357 - boolean isExisted;  
358 - AppraiseOrder appraiseOrder;  
359 -  
360 - }  
361 -  
362 - /**  
363 - * 是否付费鉴定订单  
364 - * @param uid  
365 - * @param orderCode  
366 - * @return  
367 - */  
368 - public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){  
369 - AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);  
370 - Integer aoac = null;  
371 - OrderAttributes oa = null;  
372 - boolean flag = Objects.nonNull(pao)  
373 - && Objects.nonNull(aoac=pao.getAttributes())  
374 - && Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))  
375 - && Objects.equals(oa, OrderAttributes.APPRAISE);  
376 - logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",  
377 - uid, orderCode, aoac, oa, flag);  
378 - return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();  
379 - }  
380 341
381 /** 342 /**
382 * 发货 343 * 发货
@@ -408,19 +369,19 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements @@ -408,19 +369,19 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
408 369
409 /** 370 /**
410 * 鉴别为假 371 * 鉴别为假
411 - * @param orderCode 372 + * @param appraiseOrder
412 */ 373 */
413 @Override 374 @Override
414 - public int appraiseFake(long orderCode){  
415 - return super.appraiseFake(orderCode); 375 + public int appraiseFake(AppraiseOrder appraiseOrder){
  376 + return super.appraiseFake(appraiseOrder);
416 } 377 }
417 378
418 /** 379 /**
419 * 无法鉴别 380 * 无法鉴别
420 - * @param orderCode 381 + * @param appraiseOrder
421 */ 382 */
422 @Override 383 @Override
423 - public int unsure(long orderCode){  
424 - return super.unsure(orderCode); 384 + public int unsure(AppraiseOrder appraiseOrder){
  385 + return super.unsure(appraiseOrder);
425 } 386 }
426 } 387 }
@@ -849,7 +849,9 @@ public class AppraiseService { @@ -849,7 +849,9 @@ public class AppraiseService {
849 Long orderCode = appraiseExpressInfoBo.getOrderCode(); 849 Long orderCode = appraiseExpressInfoBo.getOrderCode();
850 ApiResponse apiResponse = new ApiResponse(); 850 ApiResponse apiResponse = new ApiResponse();
851 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 851 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
852 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 852 + LOGGER.info("appraiseFailAndDelivery isGoodsServiceOrder, appraiseNotPassFlag {}", appraiseExpressInfoBo);
  853 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  854 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
853 apiResponse.setCode(200); 855 apiResponse.setCode(200);
854 return apiResponse; 856 return apiResponse;
855 } 857 }
@@ -1098,7 +1100,8 @@ public class AppraiseService { @@ -1098,7 +1100,8 @@ public class AppraiseService {
1098 LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode); 1100 LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode);
1099 ApiResponse apiResponse = new ApiResponse(); 1101 ApiResponse apiResponse = new ApiResponse();
1100 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1102 if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1101 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 1103 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1104 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
1102 apiResponse.setCode(200); 1105 apiResponse.setCode(200);
1103 return apiResponse; 1106 return apiResponse;
1104 } 1107 }
@@ -1181,7 +1184,8 @@ public class AppraiseService { @@ -1181,7 +1184,8 @@ public class AppraiseService {
1181 ApiResponse apiResponse = new ApiResponse(); 1184 ApiResponse apiResponse = new ApiResponse();
1182 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1185 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1183 LOGGER.info("qualityCheckReject isGoodsServiceOrder order code {}", orderCode); 1186 LOGGER.info("qualityCheckReject isGoodsServiceOrder order code {}", orderCode);
1184 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode); 1187 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1188 + existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
1185 apiResponse.setCode(200); 1189 apiResponse.setCode(200);
1186 return apiResponse; 1190 return apiResponse;
1187 } 1191 }
@@ -1537,7 +1541,9 @@ public class AppraiseService { @@ -1537,7 +1541,9 @@ public class AppraiseService {
1537 public void appraiseUnsure(Integer uid, Long orderCode) { 1541 public void appraiseUnsure(Integer uid, Long orderCode) {
1538 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){ 1542 if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
1539 LOGGER.info("in appraiseUnsure isGoodsServiceOrder ordercode {}", orderCode); 1543 LOGGER.info("in appraiseUnsure isGoodsServiceOrder ordercode {}", orderCode);
1540 - serviceOrderProcessor.findGoodsServiceInstance(orderCode).unsure(orderCode); 1544 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
  1545 + existenceNode.getGoodsService().unsure(existenceNode.getAppraiseOrder());
  1546 + return;
1541 } 1547 }
1542 1548
1543 1549
@@ -135,6 +135,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -135,6 +135,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
135 @Autowired 135 @Autowired
136 private OrderCodeGenerator orderCodeGenerator; 136 private OrderCodeGenerator orderCodeGenerator;
137 137
  138 + @Autowired
  139 + private ServiceOrderProcessor serviceOrderProcessor;
  140 +
138 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data"; 141 private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
139 142
140 //物流文案设置 143 //物流文案设置
@@ -146,8 +149,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -146,8 +149,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
146 @Autowired 149 @Autowired
147 private SkupService skupService; 150 private SkupService skupService;
148 151
149 - @Autowired  
150 - private ServiceOrderProcessor serviceOrderProcessor;  
151 152
152 153
153 private int processBuyerOrder(BuyerOrder buyerOrder, 154 private int processBuyerOrder(BuyerOrder buyerOrder,
@@ -1089,7 +1090,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService { @@ -1089,7 +1090,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
1089 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType()); 1090 OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
1090 AppraiseAddressResp resp = null; 1091 AppraiseAddressResp resp = null;
1091 if (OrderCodeType.GOODS_SERVICE.equals(orderCodeType)){ 1092 if (OrderCodeType.GOODS_SERVICE.equals(orderCodeType)){
1092 - AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode); 1093 + ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
1093 if (!existenceNode.isExisted()){ 1094 if (!existenceNode.isExisted()){
1094 throwServiceException(400,"订单不存在"); 1095 throwServiceException(400,"订单不存在");
1095 } 1096 }
@@ -5,22 +5,30 @@ import com.yoho.error.exception.ServiceException; @@ -5,22 +5,30 @@ import com.yoho.error.exception.ServiceException;
5 import com.yohobuy.ufo.model.order.common.OrderAttributes; 5 import com.yohobuy.ufo.model.order.common.OrderAttributes;
6 import com.yohobuy.ufo.model.order.common.OrderCodeType; 6 import com.yohobuy.ufo.model.order.common.OrderCodeType;
7 import com.yohoufo.common.exception.UfoServiceException; 7 import com.yohoufo.common.exception.UfoServiceException;
  8 +import com.yohoufo.dal.order.AppraiseOrderMapper;
8 import com.yohoufo.dal.order.model.AppraiseOrder; 9 import com.yohoufo.dal.order.model.AppraiseOrder;
9 import com.yohoufo.order.service.IGoodsService; 10 import com.yohoufo.order.service.IGoodsService;
10 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService; 11 import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
11 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator; 12 import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
12 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; 13 import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
13 import com.yohoufo.order.utils.LoggerUtils; 14 import com.yohoufo.order.utils.LoggerUtils;
  15 +import lombok.Builder;
  16 +import lombok.Data;
14 import org.slf4j.Logger; 17 import org.slf4j.Logger;
15 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
17 20
  21 +import java.util.Objects;
  22 +
18 @Service 23 @Service
19 public class ServiceOrderProcessor { 24 public class ServiceOrderProcessor {
20 25
21 private final Logger logger = LoggerUtils.getSellerOrderLogger(); 26 private final Logger logger = LoggerUtils.getSellerOrderLogger();
22 27
23 @Autowired 28 @Autowired
  29 + private AppraiseOrderMapper appraiseOrderMapper;
  30 +
  31 + @Autowired
24 private AppraiseOrderService appraiseOrderService; 32 private AppraiseOrderService appraiseOrderService;
25 33
26 @Autowired 34 @Autowired
@@ -54,7 +62,7 @@ public class ServiceOrderProcessor { @@ -54,7 +62,7 @@ public class ServiceOrderProcessor {
54 62
55 63
56 public IGoodsService findGoodsServiceInstance(long orderCode){ 64 public IGoodsService findGoodsServiceInstance(long orderCode){
57 - AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode); 65 + ExistenceNode existenceNode = isAppraiseOrder(orderCode);
58 if (!existenceNode.isExisted) { 66 if (!existenceNode.isExisted) {
59 logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode); 67 logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
60 throw new ServiceException(ServiceError.ORDER_NULL); 68 throw new ServiceException(ServiceError.ORDER_NULL);
@@ -63,4 +71,60 @@ public class ServiceOrderProcessor { @@ -63,4 +71,60 @@ public class ServiceOrderProcessor {
63 IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes()); 71 IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
64 return goodsService; 72 return goodsService;
65 } 73 }
  74 +
  75 +
  76 + public ExistenceNode findGoodsServiceInstanceAndExt(long orderCode){
  77 + ExistenceNode existenceNode = isAppraiseOrder(orderCode);
  78 + if (!existenceNode.isExisted) {
  79 + logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
  80 + throw new ServiceException(ServiceError.ORDER_NULL);
  81 + }
  82 + AppraiseOrder appraiseOrder = existenceNode.appraiseOrder;
  83 + IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
  84 + existenceNode.setGoodsService(goodsService);
  85 + return existenceNode;
  86 + }
  87 +
  88 + /**
  89 + * 是否付费鉴定 or 卖家寄存订单
  90 + * @param orderCode
  91 + * @return
  92 + */
  93 + public ExistenceNode isAppraiseOrder(long orderCode){
  94 + AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
  95 + boolean flag = Objects.nonNull(pao);
  96 + Integer aoac = flag ? pao.getAttributes() : null;
  97 + logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",
  98 + orderCode, aoac, flag);
  99 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
  100 + }
  101 +
  102 +
  103 +
  104 + /**
  105 + * 是否付费鉴定订单
  106 + * @param uid
  107 + * @param orderCode
  108 + * @return
  109 + */
  110 + public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){
  111 + AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
  112 + Integer aoac = null;
  113 + OrderAttributes oa = null;
  114 + boolean flag = Objects.nonNull(pao)
  115 + && Objects.nonNull(aoac=pao.getAttributes())
  116 + && Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))
  117 + && Objects.equals(oa, OrderAttributes.APPRAISE);
  118 + logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
  119 + uid, orderCode, aoac, oa, flag);
  120 + return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
  121 + }
  122 +
  123 + @Data
  124 + @Builder
  125 + public static class ExistenceNode{
  126 + boolean isExisted;
  127 + AppraiseOrder appraiseOrder;
  128 + IGoodsService goodsService;
  129 + }
66 } 130 }
@@ -21,6 +21,7 @@ import com.yohoufo.order.convert.SellerOrderConvertor; @@ -21,6 +21,7 @@ import com.yohoufo.order.convert.SellerOrderConvertor;
21 import com.yohoufo.order.model.dto.SellerDepositOrderContext; 21 import com.yohoufo.order.model.dto.SellerDepositOrderContext;
22 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext; 22 import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
23 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 23 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
  24 +import com.yohoufo.order.service.DepositService;
24 import com.yohoufo.order.service.IGoodsService; 25 import com.yohoufo.order.service.IGoodsService;
25 import com.yohoufo.order.service.impl.AbsGoodsServiceOrderService; 26 import com.yohoufo.order.service.impl.AbsGoodsServiceOrderService;
26 import com.yohoufo.order.service.impl.AppraiseAddressService; 27 import com.yohoufo.order.service.impl.AppraiseAddressService;
@@ -73,6 +74,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -73,6 +74,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
73 @Autowired 74 @Autowired
74 private OrderStatusFlowService orderStatusFlowService; 75 private OrderStatusFlowService orderStatusFlowService;
75 76
  77 + @Autowired
  78 + private DepositService depositService;
  79 +
76 80
77 81
78 82
@@ -215,21 +219,23 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple @@ -215,21 +219,23 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
215 219
216 /** 220 /**
217 * 鉴别为假 221 * 鉴别为假
218 - * @param orderCode 222 + * @param appraiseOrder
219 */ 223 */
220 @Override 224 @Override
221 - public int appraiseFake(long orderCode){  
222 - int rows = super.appraiseFake(orderCode); 225 + public int appraiseFake(AppraiseOrder appraiseOrder){
  226 + int rows = super.appraiseFake(appraiseOrder);
  227 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
223 return rows; 228 return rows;
224 } 229 }
225 230
226 /** 231 /**
227 * 无法鉴别 232 * 无法鉴别
228 - * @param orderCode 233 + * @param appraiseOrder
229 */ 234 */
230 @Override 235 @Override
231 - public int unsure(long orderCode){  
232 - int rows = super.unsure(orderCode); 236 + public int unsure(AppraiseOrder appraiseOrder){
  237 + int rows = super.unsure(appraiseOrder);
  238 + depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
233 return rows; 239 return rows;
234 } 240 }
235 } 241 }