|
|
@@ -223,6 +223,38 @@ public class VoyageApiImpl implements VoyageApi {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.NESTED,rollbackFor = Exception.class)
|
|
|
+ public void cancelReduceStockNew(ReduceStockReqDTO reqDTO) {
|
|
|
+ log.error("开始确定订单还库存:请求参数:{}", JSONObject.toJSONString(reqDTO));
|
|
|
+ //TODO: 当前阶段不考虑门店库存
|
|
|
+ Long voyageId = reqDTO.getVoyageId();
|
|
|
+ //现在给整个航次的库存加锁
|
|
|
+ String lockKey = String.format(ProductRedisKeyConstants.STOCK_REDIS_KEY_PREFIX, voyageId);
|
|
|
+ RLock lock = redissonClient.getLock(lockKey);
|
|
|
+ try {
|
|
|
+ lock.lock(60, TimeUnit.SECONDS);
|
|
|
+ String uuid = UuidUtils.getUUID();
|
|
|
+ //判断是分销商还是门店下单 1:分销商,2:门店
|
|
|
+ Integer type = reqDTO.getType();
|
|
|
+ //分销商下单,当前阶段不考虑门店下单
|
|
|
+ if (Objects.equals(type, DistributorOrStoreEnum.DISTRIBUTOR.getValue())) {
|
|
|
+ //分销商下单只扣分销商库存,默认是OTA,默认OTC只能门店下单
|
|
|
+ //初定扣分销商库存
|
|
|
+ cancelReduceStockDistributor(reqDTO.getOrderId(), reqDTO.getType(),reqDTO.getOrderRoomList(), uuid);
|
|
|
+ if (reqDTO.getOldOrderId() != null && !reqDTO.getOldOrderId().equals(reqDTO.getOrderId())) {
|
|
|
+ cancelReduceStockDistributor(reqDTO.getOldOrderId(), reqDTO.getType(),reqDTO.getOrderRoomList(), uuid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ if (lock.isHeldByCurrentThread() && lock.isLocked()) {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 确定状态时取消订单还库存
|
|
|
* roomUseDTOList 需要退的房间
|