From 8f5ca1d337950be2a20cdb1a91a29a86fde1b07d Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 12 十一月 2019 09:39:36 +0800 Subject: [PATCH] 红包封禁功能 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java | 46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java index d27acd5..21b6d72 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java @@ -18,10 +18,10 @@ 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; +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; @@ -90,20 +90,18 @@ String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min"); - RedPackBalance balance = redPackBalanceService.selectByPrimaryKey(uid); - if (balance == null) + BigDecimal balance = null; + try { + balance = redPackBalanceService.getBalance(uid); + } catch (RedPackBalanceException e1) { + throw new RedPackExchangeException(1, e1.getMsg()); + } + + if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0) throw new RedPackExchangeException(1, "浣欓涓嶈冻" + extractBanlenMin + "鍏�"); - 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) + if (balance.compareTo(amount) < 0) throw new RedPackExchangeException(1, "鎻愮幇浣欓涓嶈冻"); - String moneyMin = redPackConfigService.getValueByKey("extract_money_min"); String moneyMax = redPackConfigService.getValueByKey("extract_money_max"); @@ -171,16 +169,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()); + } } -- Gitblit v1.8.0