Showing
1 changed file
with
20 additions
and
15 deletions
@@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database; | @@ -6,6 +6,7 @@ import com.yoho.core.dal.datasource.annotation.Database; | ||
6 | import com.yoho.core.transaction.annoation.YHTransaction; | 6 | import com.yoho.core.transaction.annoation.YHTransaction; |
7 | import com.yoho.error.ServiceError; | 7 | import com.yoho.error.ServiceError; |
8 | import com.yoho.error.exception.ServiceException; | 8 | import com.yoho.error.exception.ServiceException; |
9 | +import com.yohoufo.common.alarm.CommonAlarmEventPublisher; | ||
9 | import com.yohoufo.dal.order.*; | 10 | import com.yohoufo.dal.order.*; |
10 | import com.yohoufo.dal.order.model.*; | 11 | import com.yohoufo.dal.order.model.*; |
11 | import com.yohoufo.order.common.ClientType; | 12 | import com.yohoufo.order.common.ClientType; |
@@ -45,30 +46,22 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -45,30 +46,22 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
45 | BuyerOrderSubmitResult result = null; | 46 | BuyerOrderSubmitResult result = null; |
46 | try { | 47 | try { |
47 | // 减库存 | 48 | // 减库存 |
48 | - if(productProxyService.subtractStorage(orderBuilder.getProductId(), orderBuilder.getSkup())) { | 49 | + productProxyService.subtractStorage(orderBuilder.getProductId(), orderBuilder.getSkup()); |
49 | 50 | ||
51 | + try{ | ||
50 | //使用优惠券 | 52 | //使用优惠券 |
51 | if (orderBuilder.getCouponBo().getCouponAmount().doubleValue() > 0) { | 53 | if (orderBuilder.getCouponBo().getCouponAmount().doubleValue() > 0) { |
52 | couponProxyService.orderUseCoupon(orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getCouponBo()); | 54 | couponProxyService.orderUseCoupon(orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getCouponBo()); |
53 | } | 55 | } |
54 | // 创建订单 | 56 | // 创建订单 |
55 | return orderCreateService.createOrder(orderBuilder); | 57 | return orderCreateService.createOrder(orderBuilder); |
58 | + }catch (Exception e){ | ||
59 | + returnStrorageEx(orderBuilder); | ||
60 | + throw e; | ||
56 | } | 61 | } |
57 | - }catch (Exception ex){ | ||
58 | 62 | ||
59 | - try{ | ||
60 | - boolean returnStorageFlag = productProxyService.returnStorage(orderBuilder.getSkup()); | ||
61 | - | ||
62 | - // 补库存失败,需要报警手动补库存 TODO | ||
63 | - if (!returnStorageFlag){ | ||
64 | - logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ", | ||
65 | - orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup()); | ||
66 | - } | 63 | + }catch (Exception ex){ |
67 | 64 | ||
68 | - }catch (Exception ex0){ | ||
69 | - logger.warn("in buyer createOrder fail, return storage fail, uid {},ordercode {},Skup {}", | ||
70 | - orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex0); | ||
71 | - }finally { | ||
72 | logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ", | 65 | logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ", |
73 | orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex); | 66 | orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex); |
74 | if (!(ex instanceof ServiceException)) { | 67 | if (!(ex instanceof ServiceException)) { |
@@ -79,7 +72,19 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -79,7 +72,19 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
79 | throw ex; | 72 | throw ex; |
80 | } | 73 | } |
81 | } | 74 | } |
82 | - return result; | 75 | + |
76 | + private void returnStrorageEx(OrderBuilder orderBuilder) { | ||
77 | + try{ | ||
78 | + productProxyService.returnStorage(orderBuilder.getSkup()); | ||
79 | + | ||
80 | + }catch (Exception ex0){ | ||
81 | + | ||
82 | + CommonAlarmEventPublisher.publish("还库存失败", "ufo.product.cancelSaleSkup", "sku:["+orderBuilder.getSkup()+"]"); | ||
83 | + // 还库存失败,上报到influxdb | ||
84 | + logger.warn("in buyer createOrder fail, return storage fail, uid {},ordercode {},Skup {}", | ||
85 | + orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup(), ex0); | ||
86 | + | ||
87 | + } | ||
83 | } | 88 | } |
84 | 89 | ||
85 | 90 |
-
Please register or login to post a comment