admin
2019-11-13 221b5c8d0de3f6b17a00d543503a79c13b28ba12
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;
@@ -22,6 +21,7 @@
import com.yeshi.fanli.entity.redpack.RedPackDetail;
import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
import com.yeshi.fanli.entity.redpack.RedPackExchange;
import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.money.UserMoneyService;
@@ -89,22 +89,33 @@
         throw new RedPackExchangeException(1, "参数不正确");
      String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
      BigDecimal balance = null;
      try {
         balance = redPackBalanceService.getBalance(uid);
      } catch (RedPackBalanceException e1) {
         throw new RedPackExchangeException(1, e1.getMsg());
      }
      
      BigDecimal balance = redPackBalanceService.getBalance(uid);
      if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
         throw new RedPackExchangeException(1, "余额不足" + extractBanlenMin + "元");
      
      if (balance.compareTo(amount) < 0)
         throw new RedPackExchangeException(1, "提现余额不足");
      
      String moneyMin = redPackConfigService.getValueByKey("extract_money_min");
      String moneyMax = redPackConfigService.getValueByKey("extract_money_max");
      if (amount.compareTo(new BigDecimal(moneyMin)) < 0 || amount.compareTo(new BigDecimal(moneyMax)) > 0)
         throw new RedPackExchangeException(1, "提现金额至少" + moneyMin + "元至多" + moneyMax + "元");
      
      Date nowDate = new Date();
      
      long countToday = redPackExchangeMapper.countTodayByUid(uid);
      String extractDayMax = redPackConfigService.getValueByKey("extract_day_max");
      if (!StringUtil.isNullOrEmpty(extractDayMax) && countToday >= Long.parseLong(extractDayMax))
         throw new RedPackExchangeException(1, "今日红包提现次数超限");
      Date nowDate = new Date();
      // 提现申请
      RedPackExchange exchange = new RedPackExchange();
      exchange.setUid(uid);
@@ -164,16 +175,20 @@
         throw new RedPackExchangeException(1,"更新提现明细出错");
      }
      
      //消息
      SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
      String beizu = "红包提现成功后请到“我的-账户余额”中查看";
      MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
      dto.setTitle("红包提现");
      dto.setTime(sd.format(record.getCreateTime()));
      dto.setHandle("人工审核" + sd.format(new Date()));
      dto.setMoney("¥" + record.getMoney().setScale(2));
      dto.setBalance("¥" + redPackBalanceService.getBalance(record.getUid()));
      userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
      try {
         //消息
         SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
         String beizu = "红包提现成功后请到“我的-账户余额”中查看";
         MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
         dto.setTitle("红包提现");
         dto.setTime(sd.format(record.getCreateTime()));
         dto.setHandle("人工审核" + sd.format(new Date()));
         dto.setMoney("¥" + record.getMoney().setScale(2));
         dto.setBalance("¥" + redPackBalanceService.getBalance(record.getUid()));
         userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
      } catch (RedPackBalanceException e) {
         throw new RedPackExchangeException(1, e.getMsg());
      }
   }