Преглед на файлове

bug:1337 选择已售罄团购 修改库存数为1 变更状态

qxy преди 1 месец
родител
ревизия
e1f50d955a

+ 20 - 4
alien-store/src/main/java/shop/alien/store/service/impl/LifeCouponServiceImpl.java

@@ -123,10 +123,26 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
      */
     @Override
     public boolean updateCouponSingleQty(Integer id, Integer singleQty) {
-        LifeCoupon lifeCoupon = new LifeCoupon();
-        lifeCoupon.setId(String.valueOf(id));
-        lifeCoupon.setSingleQty(singleQty);
-        return this.updateById(lifeCoupon);
+        //判断库存数为0 增加库存数修改状态为进行中
+        LambdaQueryWrapper<LifeCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(LifeCoupon :: getId, id);
+        LifeCoupon lifeCoupon = lifeCouponMapper.selectOne(lambdaQueryWrapper);
+
+        if(lifeCoupon.getSingleQty() == 0){
+        LambdaUpdateWrapper<LifeCoupon> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+        lambdaUpdateWrapper.eq(LifeCoupon :: getId, id);
+        lambdaUpdateWrapper.set(LifeCoupon :: getSingleQty,singleQty);
+        lambdaUpdateWrapper.set(LifeCoupon :: getStatus, 5);
+        lifeCouponMapper.update(null, lambdaUpdateWrapper);
+        }
+        else{
+            LambdaUpdateWrapper<LifeCoupon> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            lambdaUpdateWrapper.eq(LifeCoupon :: getId, id);
+            lambdaUpdateWrapper.set(LifeCoupon :: getSingleQty,singleQty);
+            lifeCouponMapper.update(null, lambdaUpdateWrapper);
+        }
+
+        return true;
     }
 
     @Override

+ 19 - 1
alien-store/src/main/java/shop/alien/store/service/impl/LifeGroupBuyServiceImpl.java

@@ -230,7 +230,25 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
 
     @Override
     public boolean updateNum(String id, String num) {
-        lifeGroupBuyMainMapper.update(null, new LambdaUpdateWrapper<LifeGroupBuyMain>().eq(LifeGroupBuyMain::getId, id).set(LifeGroupBuyMain::getInventoryNum, num));
+        //判断库存数为0 增加库存数修改状态为进行中
+        LambdaQueryWrapper<LifeGroupBuyMain> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(LifeGroupBuyMain :: getId, id);
+        LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyMainMapper.selectOne(lambdaQueryWrapper);
+
+        if(lifeGroupBuyMain.getInventoryNum() == 0){
+            LambdaUpdateWrapper<LifeGroupBuyMain> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            lambdaUpdateWrapper.eq(LifeGroupBuyMain :: getId, id);
+            lambdaUpdateWrapper.set(LifeGroupBuyMain :: getStatus, 5);
+            lambdaUpdateWrapper.set(LifeGroupBuyMain :: getInventoryNum, num);
+            lifeGroupBuyMainMapper.update(null, lambdaUpdateWrapper);
+        }
+        else {
+            LambdaUpdateWrapper<LifeGroupBuyMain> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            lambdaUpdateWrapper.eq(LifeGroupBuyMain::getId, id);
+            lambdaUpdateWrapper.set(LifeGroupBuyMain::getInventoryNum, num);
+            lifeGroupBuyMainMapper.update(null, lambdaUpdateWrapper);
+        }
+
         return true;
     }