yujian
2019-11-11 3ce9e928e082ff8abf697dba560cbfbb412e89f8
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
@@ -7,7 +7,6 @@
import javax.annotation.Resource;
import org.omg.CORBA.LongHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +18,7 @@
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackBalance;
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
@@ -89,12 +89,19 @@
         throw new RedPackExchangeException(1, "参数不正确");
      String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
      BigDecimal balance = redPackBalanceService.getBalance(uid);
      if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
      RedPackBalance balance = redPackBalanceService.selectByPrimaryKey(uid);
      if (balance == null)
         throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
      
      if (balance.compareTo(amount) < 0)
      if (balance.getState() != null && balance.getState() == RedPackBalance.STATE_LOCKED)
         throw new RedPackExchangeException(1, "红包已封禁,感谢使用");
      BigDecimal balanceMoney = balance.getMoney();
      if (balanceMoney == null || balanceMoney.compareTo(new BigDecimal(extractBanlenMin)) < 0)
         throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
      if (balanceMoney.compareTo(amount) < 0)
         throw new RedPackExchangeException(1, "提现余额不足");
      
      
@@ -195,7 +202,7 @@
      
      // 退回红包
      try {
         redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchange(record));
         redPackBalanceService.addRedPack(record.getUid(), record.getMoney(), RedPackDetailFactory.createExchangeReject(record));
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
         throw new RedPackExchangeException(1, "红包退回时出错");