...
|
...
|
@@ -45,30 +45,38 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { |
|
|
private UfoServiceCaller serviceCaller;
|
|
|
|
|
|
|
|
|
public void doSumbitOrder(OrderBuilder orderBuilder){
|
|
|
|
|
|
// 减库存
|
|
|
descreaseStorage(orderBuilder);
|
|
|
|
|
|
// 创建订单
|
|
|
createOrder(orderBuilder);
|
|
|
}
|
|
|
|
|
|
|
|
|
public void descreaseStorage(OrderBuilder orderBuilder){
|
|
|
|
|
|
ApiResponse apiResponse = serviceCaller.call("ufo.product.saleSkup",
|
|
|
ApiResponse.class, orderBuilder.getProductId(), orderBuilder.getSkup());
|
|
|
// 减库存失败
|
|
|
if (apiResponse.getCode() != 200){
|
|
|
logger.warn("submit create order, decrease storage faile, orderCode is {}, uid is {}, skup is {}, productId is {}",
|
|
|
orderBuilder.getOrderCode(), orderBuilder.getUid(), orderBuilder.getSkup(), orderBuilder.getProductId());
|
|
|
throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 创建订单
|
|
|
* @param orderBuilder
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void create(OrderBuilder orderBuilder){
|
|
|
public void createOrder(OrderBuilder orderBuilder){
|
|
|
|
|
|
boolean increaseNeed = false;
|
|
|
try{
|
|
|
|
|
|
// 扣减库存
|
|
|
// 入口参数:skup, product_id
|
|
|
ApiResponse apiResponse = serviceCaller.call("ufo.product.saleSkup",
|
|
|
ApiResponse.class, orderBuilder.getProductId(), orderBuilder.getSkup());
|
|
|
// 减库存失败
|
|
|
if (apiResponse.getCode() != 200){
|
|
|
logger.warn("submit create order, decrease storage faile, orderCode is {}, uid is {}, skup is {}, productId is {}",
|
|
|
orderBuilder.getOrderCode(), orderBuilder.getUid(), orderBuilder.getSkup(), orderBuilder.getProductId());
|
|
|
throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL);
|
|
|
}
|
|
|
|
|
|
// product处减库存失败
|
|
|
increaseNeed = true;
|
|
|
|
|
|
/**
|
|
|
* 1.更新 表seller_order_goods skup的状态为不可售
|
|
|
* 2.更新 表seller_order 状态为已经售出
|
...
|
...
|
@@ -95,16 +103,13 @@ public class OrdeCreationServiceImpl implements IOrdeCreationService { |
|
|
|
|
|
}catch (Exception ex){
|
|
|
|
|
|
if (increaseNeed){
|
|
|
// order处 更新状态失败,需要补库存
|
|
|
ApiResponse apiResponse = serviceCaller.call("ufo.product.cancelSaleSkup",ApiResponse.class, orderBuilder.getSkup());
|
|
|
// 补库存失败,需要报警手动补库存 TODO
|
|
|
if (apiResponse.getCode() != 200){
|
|
|
// order处 更新状态失败,需要补库存
|
|
|
ApiResponse apiResponse = serviceCaller.call("ufo.product.cancelSaleSkup",ApiResponse.class, orderBuilder.getSkup());
|
|
|
// 补库存失败,需要报警手动补库存 TODO
|
|
|
if (apiResponse.getCode() != 200){
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!(ex instanceof ServiceException)) {
|
|
|
//上报告警事件
|
|
|
// EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败"));
|
...
|
...
|
|