From 6dfb4599cee5c19f4d1c5cc344a4f84de1c1633c Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期一, 16 十二月 2019 15:26:57 +0800 Subject: [PATCH] 冲突信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java index 1865f83..64a5c9c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java @@ -23,12 +23,12 @@ import com.yeshi.fanli.entity.redpack.RedPackDetail; import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum; import com.yeshi.fanli.entity.redpack.RedPackGiveRecord; -import com.yeshi.fanli.exception.redpack.RedPackBalanceException; import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException; import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService; import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService; import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; import com.yeshi.fanli.service.inter.redpack.RedPackDetailService; +import com.yeshi.fanli.service.inter.redpack.RedPackForbidService; import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService; import com.yeshi.fanli.service.inter.user.TokenRecordService; import com.yeshi.fanli.util.Constant; @@ -36,6 +36,7 @@ import com.yeshi.fanli.util.TokenUtil; import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService; import com.yeshi.fanli.util.factory.RedPackDetailFactory; +import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; @Service @@ -59,6 +60,9 @@ @Resource private UserMoneyMsgNotificationService userMoneyMsgNotificationService; + @Resource + private RedPackForbidService redPackForbidService; + @Resource(name = "producer") private Producer producer; @@ -117,29 +121,27 @@ if (uid == null || amount == null) throw new RedPackGiveRecordException(1, "鍙傛暟涓嶆纭�"); + if(redPackForbidService.verifyForbid(uid)) + throw new RedPackGiveRecordException(1, "绾㈠寘鍔熻兘宸茶灏佺"); + String giveMin = redPackConfigService.getValueByKey("give_money_min"); String giveMax = redPackConfigService.getValueByKey("give_money_max"); if (amount.compareTo(new BigDecimal(giveMin)) < 0 || amount.compareTo(new BigDecimal(giveMax)) > 0) throw new RedPackGiveRecordException(1, "璧犻�侀噾棰濊嚦灏�" + giveMin + "鍏冭嚦澶�" + giveMax + "鍏�"); - BigDecimal balance = null; - try { - balance = redPackBalanceService.getBalance(uid); - } catch (RedPackBalanceException e1) { - throw new RedPackGiveRecordException(1, e1.getMsg()); - } - + BigDecimal balance = redPackBalanceService.getBalance(uid); if (balance == null || amount.compareTo(balance) > 0) throw new RedPackGiveRecordException(1, "浣欓涓嶈冻"); Date nowDate = new Date(); + Date endTime = DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()); // 璧犻�佽褰� RedPackGiveRecord giveRecord = new RedPackGiveRecord(); giveRecord.setAmount(amount); giveRecord.setGiveUid(uid); giveRecord.setState(RedPackGiveRecord.STATE_INIT); giveRecord.setGiveTime(nowDate); - giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date())); + giveRecord.setEndTime(endTime); redPackGiveRecordMapper.insertSelective(giveRecord); // 鍙d护璁板綍 @@ -148,7 +150,7 @@ tokenRecord.setIdentify(giveRecord.getId() + ""); tokenRecord.setType(TokenTypeEnum.redPack); tokenRecord.setStartTime(nowDate); - tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date())); + tokenRecord.setEndTime(endTime); tokenRecord.setState(0); tokenRecordService.insertSelective(tokenRecord); @@ -175,15 +177,15 @@ UserRedPackGiftMQMsg msg = new UserRedPackGiftMQMsg(); msg.setId(giveRecord.getId()); msg.setUid(uid); - Message message = new Message(MQTopicName.TOPIC_USER.name(), UserTopicTagEnum.redPackGiftDrawback.name(), - new Gson().toJson(msg).getBytes()); + Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.redPackGiftDrawback, + msg); + // 寤惰繜涓�鍒嗛挓 + message.setStartDeliverTime(endTime.getTime() + 1000 * 60); try { producer.send(message); } catch (Exception e) { throw new RedPackGiveRecordException(1, "绾㈠寘鍒涘缓澶辫触"); } - - return tips; } -- Gitblit v1.8.0