赵冬冬 пре 4 година
родитељ
комит
5eafdcc67f

+ 12 - 2
forest-portal/portal-server/src/main/java/com/hwrj/cloud/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -507,7 +507,6 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
     }
 
 
-
     @Autowired
     private RedissonClient redissonClient;
     //商品秒杀核心业务逻辑的处理-redisson的分布式锁
@@ -523,6 +522,14 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
             //加锁 操作很类似Java的ReentrantLock机制
             lock.lock();
             PmsProduct pmsProduct = pmsProductMapper.selectByPrimaryKey(orderFrom.getProductId());
+            Integer deleteStatus = pmsProduct.getDeleteStatus();
+            if (1 == deleteStatus.intValue()) {
+                throw new RuntimeException("商品已删除!");
+            }
+            Integer publishStatus = pmsProduct.getPublishStatus();
+            if (0 == publishStatus.intValue()) {
+                throw new RuntimeException("商品已下架!");
+            }
             BigDecimal price = pmsProduct.getPrice();
             if (StringUtils.isEmpty(price)) {
                 throw new RuntimeException("暂无价格无法下单!");
@@ -1126,14 +1133,17 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
         calcAmount.setPayAmount(totalAmount.subtract(promotionAmount));
         return calcAmount;
     }
+
     @Autowired
     private OmsOrderDao omsOrderDao;
+
     @Override
     public OmsOrder selectById(Long orderId) {
         return orderMapper.selectByPrimaryKey(orderId);
     }
+
     @Override
-    public String getProductName(Long orderId){
+    public String getProductName(Long orderId) {
         return omsOrderDao.getProductName(orderId);
     }