Authored by tanling

提交订单归还库存

... ... @@ -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,30 +46,22 @@ 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());
// 补库存失败,需要报警手动补库存 TODO
if (!returnStorageFlag){
logger.warn("in buyer createOrder fail, need return storage SaleSkup, uid {},ordercode {},Skup {} ",
orderBuilder.getUid(), orderBuilder.getOrderCode(), orderBuilder.getSkup());
}
}catch (Exception ex){
}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)) {
... ... @@ -79,7 +72,19 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService {
throw ex;
}
}
return result;
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);
}
}
... ...