...
|
...
|
@@ -3,16 +3,20 @@ package com.yohoufo.order.service.listener.processor; |
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yoho.core.rabbitmq.YhProducer;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderAttributes;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.alarm.SmsAlarmEvent;
|
|
|
import com.yohoufo.dal.order.model.BuyerOrder;
|
|
|
import com.yohoufo.order.constants.ActivityTypeEnum;
|
|
|
import com.yohoufo.order.constants.MetaKey;
|
|
|
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
|
|
|
import com.yohoufo.order.model.bo.ActivityBo;
|
|
|
import com.yohoufo.order.service.proxy.BaseServiceCaller;
|
|
|
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
|
|
|
import com.yohoufo.order.service.proxy.BargainProxyService;
|
|
|
import com.yohoufo.order.service.proxy.BaseServiceCaller;
|
|
|
import com.yohoufo.order.service.stats.StatsConfigManager;
|
|
|
import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration;
|
|
|
import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry;
|
|
|
import com.yohoufo.order.service.support.BuyerOrderMetaMapperSupport;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -46,8 +50,12 @@ public class BuyerOrderChangeBusinessPostProcessor { |
|
|
@Autowired
|
|
|
private BaseServiceCaller baseServiceCaller;
|
|
|
|
|
|
@Autowired
|
|
|
private StatsConfigManager<SellerOrderStatsEntry, SellerOrderStatsConfiguration> statsConfigurationManager;
|
|
|
|
|
|
//业务处理器
|
|
|
private List<BusinessProcessor> processors = Lists.newArrayList(
|
|
|
new SellerOrderQuantityStatsBusinessProcessor(),
|
|
|
new NotifyProcessor(),
|
|
|
new DefaultBusinessProcessor(),
|
|
|
//砍价
|
...
|
...
|
@@ -124,6 +132,52 @@ public class BuyerOrderChangeBusinessPostProcessor { |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 鉴定通过
|
|
|
*
|
|
|
* @param buyerOrder
|
|
|
* @param bizCase
|
|
|
* @param targetStatus
|
|
|
*/
|
|
|
public void fireAppraiseSuccess(BuyerOrder buyerOrder, BuyerOrderChangeEvent.BizCase bizCase, OrderStatus targetStatus) {
|
|
|
BusinessProcessorContext context = buildBusinessProcessorContext(buyerOrder, bizCase, targetStatus);
|
|
|
for (BusinessProcessor processor : processors) {
|
|
|
try {
|
|
|
processor.appraiseSuccess(context);
|
|
|
} catch (Exception ex) {
|
|
|
logger.warn("{} appraiseSuccess error,context:{}", processor.getClass().getName(), context, ex);
|
|
|
//告警
|
|
|
EventBusPublisher.publishEvent(
|
|
|
new SmsAlarmEvent("ufo.buyerOrderBusinessPostProcessor", "appraiseSuccess_exception",
|
|
|
processor.getClass().getName() + "(" + buyerOrder.getOrderCode() + ")", ex)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 瑕疵接受
|
|
|
*
|
|
|
* @param buyerOrder
|
|
|
* @param bizCase
|
|
|
* @param targetStatus
|
|
|
*/
|
|
|
public void fireFaultAccept(BuyerOrder buyerOrder, BuyerOrderChangeEvent.BizCase bizCase, OrderStatus targetStatus) {
|
|
|
BusinessProcessorContext context = buildBusinessProcessorContext(buyerOrder, bizCase, targetStatus);
|
|
|
for (BusinessProcessor processor : processors) {
|
|
|
try {
|
|
|
processor.acceptFault(context);
|
|
|
} catch (Exception ex) {
|
|
|
logger.warn("{} acceptFault error,context:{}", processor.getClass().getName(), context, ex);
|
|
|
//告警
|
|
|
EventBusPublisher.publishEvent(
|
|
|
new SmsAlarmEvent("ufo.buyerOrderBusinessPostProcessor", "acceptFault_exception",
|
|
|
processor.getClass().getName() + "(" + buyerOrder.getOrderCode() + ")", ex)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public BusinessProcessorContext buildBusinessProcessorContext(BuyerOrder buyerOrder, BuyerOrderChangeEvent.BizCase bizCase, OrderStatus targetStatus) {
|
|
|
BusinessProcessorContext context = new BusinessProcessorContext();
|
...
|
...
|
@@ -170,6 +224,12 @@ public class BuyerOrderChangeBusinessPostProcessor { |
|
|
|
|
|
//支付成功
|
|
|
void paySuccess(BusinessProcessorContext context);
|
|
|
|
|
|
//鉴定通过
|
|
|
void appraiseSuccess(BusinessProcessorContext context);
|
|
|
|
|
|
//接受瑕疵
|
|
|
void acceptFault(BusinessProcessorContext context);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -190,6 +250,44 @@ public class BuyerOrderChangeBusinessPostProcessor { |
|
|
public void paySuccess(BusinessProcessorContext context) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void appraiseSuccess(BusinessProcessorContext context) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void acceptFault(BusinessProcessorContext context) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 卖家订单统计
|
|
|
*/
|
|
|
private class SellerOrderQuantityStatsBusinessProcessor extends BusinessProcessorAdapter {
|
|
|
@Override
|
|
|
public void appraiseSuccess(BusinessProcessorContext context) {
|
|
|
doProcess(context.buyerOrder);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void acceptFault(BusinessProcessorContext context) {
|
|
|
doProcess(context.buyerOrder);
|
|
|
}
|
|
|
|
|
|
private void doProcess(BuyerOrder buyerOrder) {
|
|
|
SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder()
|
|
|
.buyerUid(buyerOrder.getUid())
|
|
|
.buyerOrderCode(buyerOrder.getOrderCode())
|
|
|
.sellerUid(buyerOrder.getSellerUid())
|
|
|
.orderAttribute(OrderAttributes.getOrderAttributes(buyerOrder.getAttributes()))
|
|
|
.build();
|
|
|
|
|
|
SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry);
|
|
|
|
|
|
statsConfigurationManager.getStatsProcessor(statsConfig.getStatsProcessorName()).accept(statsEntry, statsConfig);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -241,7 +339,7 @@ public class BuyerOrderChangeBusinessPostProcessor { |
|
|
}
|
|
|
|
|
|
//砍价业务
|
|
|
private class BargainBusinessProcessor implements BusinessProcessor {
|
|
|
private class BargainBusinessProcessor extends BusinessProcessorAdapter {
|
|
|
|
|
|
@Override
|
|
|
public void create(BusinessProcessorContext context) {
|
...
|
...
|
|