...
|
...
|
@@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database; |
|
|
import com.yoho.core.transaction.annoation.YHTransaction;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.order.common.ClientType;
|
...
|
...
|
@@ -45,41 +46,45 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { |
|
|
BuyerOrderSubmitResult result = null;
|
|
|
try {
|
|
|
// 减库存
|
|
|
if(productProxyService.subtractStorage(orderBuilder.getProductId(), orderBuilder.getSkup())) {
|
|
|
productProxyService.subtractStorage(orderBuilder.getProductId(), orderBuilder.getSkup());
|
|
|
|
|
|
try{
|
|
|
//使用优惠券
|
|
|
if (orderBuilder.getCouponBo().getCouponAmount().doubleValue() > 0) {
|
|
|
couponProxyService.orderUseCoupon(orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getCouponBo());
|
|
|
}
|
|
|
// 创建订单
|
|
|
return orderCreateService.createOrder(orderBuilder);
|
|
|
}catch (Exception e){
|
|
|
returnStrorageEx(orderBuilder);
|
|
|
throw e;
|
|
|
}
|
|
|
|
|
|
}catch (Exception ex){
|
|
|
|
|
|
try{
|
|
|
boolean returnStorageFlag = productProxyService.returnStorage(orderBuilder.getSkup());
|
|
|
logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ",
|
|
|
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex);
|
|
|
if (!(ex instanceof ServiceException)) {
|
|
|
//上报告警事件
|
|
|
//EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败"));
|
|
|
throw new ServiceException(ServiceError.SHOPPING_SUBMIT_ORDER_FAIL, ex);
|
|
|
}
|
|
|
throw ex;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 补库存失败,需要报警手动补库存 TODO
|
|
|
if (!returnStorageFlag){
|
|
|
logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ",
|
|
|
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup());
|
|
|
}
|
|
|
private void returnStrorageEx(OrderBuilder orderBuilder) {
|
|
|
try{
|
|
|
productProxyService.returnStorage(orderBuilder.getSkup());
|
|
|
|
|
|
}catch (Exception ex0){
|
|
|
|
|
|
CommonAlarmEventPublisher.publish("还库存失败", "ufo.product.cancelSaleSkup", "sku:["+orderBuilder.getSkup()+"]");
|
|
|
// 还库存失败,上报到influxdb
|
|
|
logger.warn("in buyer createOrder fail, return storage fail, uid {},ordercode {},Skup {}",
|
|
|
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex0);
|
|
|
|
|
|
}catch (Exception ex0){
|
|
|
logger.warn("in buyer createOrder fail, return storage fail, uid {},ordercode {},Skup {}",
|
|
|
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex0);
|
|
|
}finally {
|
|
|
logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ",
|
|
|
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex);
|
|
|
if (!(ex instanceof ServiceException)) {
|
|
|
//上报告警事件
|
|
|
//EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败"));
|
|
|
throw new ServiceException(ServiceError.SHOPPING_SUBMIT_ORDER_FAIL, ex);
|
|
|
}
|
|
|
throw ex;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|