Authored by chenchao

add in Event trigger

... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
import com.yohoufo.dal.order.model.AppraiseOrder;
public interface IGoodsService {
... ... @@ -31,13 +32,13 @@ public interface IGoodsService {
* 鉴别为假
* @param orderCode
*/
int appraiseFake(long orderCode);
int appraiseFake(AppraiseOrder appraiseOrder);
/**
* 无法鉴别
* @param orderCode
* @param appraiseOrder
*/
int unsure(long orderCode);
int unsure(AppraiseOrder appraiseOrder);
OrderAttributes getOrderAttributes();
}
... ...
... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.order.req.DeliverToDepotReq;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderGoods;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
... ... @@ -97,11 +98,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
/**
* 鉴别为假
* @param orderCode
* @param appraiseOrder
*/
@Override
public int appraiseFake(long orderCode){
public int appraiseFake(AppraiseOrder appraiseOrder){
long orderCode = appraiseOrder.getOrderCode();
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.CHECKING_FAKE,
expectedStatus = AppraiseOrderStatus.PLATFORM_CHECKING;
... ... @@ -112,10 +113,11 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
/**
* 无法鉴别
* @param orderCode
* @param appraiseOrder
*/
@Override
public int unsure(long orderCode){
public int unsure(AppraiseOrder appraiseOrder){
long orderCode = appraiseOrder.getOrderCode();
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.PLATFORM_APPRAISE_UNSURE,
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
... ...
... ... @@ -337,46 +337,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
return aodResp;
}
/**
* 是否付费鉴定 or 卖家寄存订单
* @param orderCode
* @return
*/
public ExistenceNode isAppraiseOrder(long orderCode){
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
boolean flag = Objects.nonNull(pao);
Integer aoac = flag ? pao.getAttributes() : null;
logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",
orderCode, aoac, flag);
return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
}
@Data
@Builder
public static class ExistenceNode{
boolean isExisted;
AppraiseOrder appraiseOrder;
}
/**
* 是否付费鉴定订单
* @param uid
* @param orderCode
* @return
*/
public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
Integer aoac = null;
OrderAttributes oa = null;
boolean flag = Objects.nonNull(pao)
&& Objects.nonNull(aoac=pao.getAttributes())
&& Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))
&& Objects.equals(oa, OrderAttributes.APPRAISE);
logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
uid, orderCode, aoac, oa, flag);
return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
}
/**
* 发货
... ... @@ -408,19 +369,19 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
/**
* 鉴别为假
* @param orderCode
* @param appraiseOrder
*/
@Override
public int appraiseFake(long orderCode){
return super.appraiseFake(orderCode);
public int appraiseFake(AppraiseOrder appraiseOrder){
return super.appraiseFake(appraiseOrder);
}
/**
* 无法鉴别
* @param orderCode
* @param appraiseOrder
*/
@Override
public int unsure(long orderCode){
return super.unsure(orderCode);
public int unsure(AppraiseOrder appraiseOrder){
return super.unsure(appraiseOrder);
}
}
... ...
... ... @@ -849,7 +849,9 @@ public class AppraiseService {
Long orderCode = appraiseExpressInfoBo.getOrderCode();
ApiResponse apiResponse = new ApiResponse();
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode);
LOGGER.info("appraiseFailAndDelivery isGoodsServiceOrder, appraiseNotPassFlag {}", appraiseExpressInfoBo);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
apiResponse.setCode(200);
return apiResponse;
}
... ... @@ -1098,7 +1100,8 @@ public class AppraiseService {
LOGGER.info("judgeCenterNotPass enter , orderCode {} ", orderCode);
ApiResponse apiResponse = new ApiResponse();
if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
apiResponse.setCode(200);
return apiResponse;
}
... ... @@ -1181,7 +1184,8 @@ public class AppraiseService {
ApiResponse apiResponse = new ApiResponse();
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
LOGGER.info("qualityCheckReject isGoodsServiceOrder order code {}", orderCode);
serviceOrderProcessor.findGoodsServiceInstance(orderCode).appraiseFake(orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
existenceNode.getGoodsService().appraiseFake(existenceNode.getAppraiseOrder());
apiResponse.setCode(200);
return apiResponse;
}
... ... @@ -1537,7 +1541,9 @@ public class AppraiseService {
public void appraiseUnsure(Integer uid, Long orderCode) {
if (serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
LOGGER.info("in appraiseUnsure isGoodsServiceOrder ordercode {}", orderCode);
serviceOrderProcessor.findGoodsServiceInstance(orderCode).unsure(orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.findGoodsServiceInstanceAndExt(orderCode);
existenceNode.getGoodsService().unsure(existenceNode.getAppraiseOrder());
return;
}
... ...
... ... @@ -135,6 +135,9 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private OrderCodeGenerator orderCodeGenerator;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
private static String EXPRESS_MQ_SEND = "third.logistics.logistics_data";
//物流文案设置
... ... @@ -146,8 +149,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private SkupService skupService;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
private int processBuyerOrder(BuyerOrder buyerOrder,
... ... @@ -1089,7 +1090,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
OrderCodeType orderCodeType = OrderCodeType.getOrderCodeType(codeMeta.getType());
AppraiseAddressResp resp = null;
if (OrderCodeType.GOODS_SERVICE.equals(orderCodeType)){
AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode);
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
if (!existenceNode.isExisted()){
throwServiceException(400,"订单不存在");
}
... ...
... ... @@ -5,22 +5,30 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.order.utils.LoggerUtils;
import lombok.Builder;
import lombok.Data;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
public class ServiceOrderProcessor {
private final Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
private AppraiseOrderMapper appraiseOrderMapper;
@Autowired
private AppraiseOrderService appraiseOrderService;
@Autowired
... ... @@ -54,7 +62,7 @@ public class ServiceOrderProcessor {
public IGoodsService findGoodsServiceInstance(long orderCode){
AppraiseOrderService.ExistenceNode existenceNode = appraiseOrderService.isAppraiseOrder(orderCode);
ExistenceNode existenceNode = isAppraiseOrder(orderCode);
if (!existenceNode.isExisted) {
logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
... ... @@ -63,4 +71,60 @@ public class ServiceOrderProcessor {
IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
return goodsService;
}
public ExistenceNode findGoodsServiceInstanceAndExt(long orderCode){
ExistenceNode existenceNode = isAppraiseOrder(orderCode);
if (!existenceNode.isExisted) {
logger.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
AppraiseOrder appraiseOrder = existenceNode.appraiseOrder;
IGoodsService goodsService = findGoodsServiceInstance(appraiseOrder.getAttributes());
existenceNode.setGoodsService(goodsService);
return existenceNode;
}
/**
* 是否付费鉴定 or 卖家寄存订单
* @param orderCode
* @return
*/
public ExistenceNode isAppraiseOrder(long orderCode){
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
boolean flag = Objects.nonNull(pao);
Integer aoac = flag ? pao.getAttributes() : null;
logger.info("in isAppraiseOrder orderCode {} aoac {} flag {}",
orderCode, aoac, flag);
return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
}
/**
* 是否付费鉴定订单
* @param uid
* @param orderCode
* @return
*/
public ExistenceNode isPaidAppraiseOrder(int uid, long orderCode){
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
Integer aoac = null;
OrderAttributes oa = null;
boolean flag = Objects.nonNull(pao)
&& Objects.nonNull(aoac=pao.getAttributes())
&& Objects.nonNull(oa = OrderAttributes.getOrderAttributes(aoac))
&& Objects.equals(oa, OrderAttributes.APPRAISE);
logger.info("in isAppraiseOrder uid {} orderCode {} aoac {} oa {} flag {}",
uid, orderCode, aoac, oa, flag);
return ExistenceNode.builder().isExisted(flag).appraiseOrder(pao).build();
}
@Data
@Builder
public static class ExistenceNode{
boolean isExisted;
AppraiseOrder appraiseOrder;
IGoodsService goodsService;
}
}
... ...
... ... @@ -21,6 +21,7 @@ import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.impl.AbsGoodsServiceOrderService;
import com.yohoufo.order.service.impl.AppraiseAddressService;
... ... @@ -73,6 +74,9 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
@Autowired
private OrderStatusFlowService orderStatusFlowService;
@Autowired
private DepositService depositService;
... ... @@ -215,21 +219,23 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
/**
* 鉴别为假
* @param orderCode
* @param appraiseOrder
*/
@Override
public int appraiseFake(long orderCode){
int rows = super.appraiseFake(orderCode);
public int appraiseFake(AppraiseOrder appraiseOrder){
int rows = super.appraiseFake(appraiseOrder);
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
return rows;
}
/**
* 无法鉴别
* @param orderCode
* @param appraiseOrder
*/
@Override
public int unsure(long orderCode){
int rows = super.unsure(orderCode);
public int unsure(AppraiseOrder appraiseOrder){
int rows = super.unsure(appraiseOrder);
depositService.insertFakeDeposit(appraiseOrder.getUid(), appraiseOrder.getOrderCode(), appraiseOrder.getParentOrderCode());
return rows;
}
}
... ...