admin
2019-11-01 56bcbcf230f4ce53376c7ccc99b91990d3375f9d
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
@@ -41,7 +41,6 @@
      return null;
   }
   
   @Override
   public void addRedPack(Long uid, BigDecimal money) {
      if (uid == null || uid == 0 || money == null)
@@ -59,7 +58,6 @@
      }
   }
   
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
@@ -71,7 +69,6 @@
      redPackBalanceMapper.addRedPack(uid, money);
   }
   
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
@@ -79,6 +76,14 @@
         throw new RedPackBalanceException(1, "参数传递不完整");
      // 加入明细
      redPackDetailService.insertSelective(detail);
      RedPackBalance balance = redPackBalanceMapper.selectForUpdate(uid);
      if (balance.getMoney() == null)
         throw new RedPackBalanceException(2, "红包余额不足");
      if (balance.getMoney().compareTo(money) < 0)
         throw new RedPackBalanceException(2, "红包余额不足");
      // 减少红包
      redPackBalanceMapper.subRedPack(uid, money);
   }