yujian
2019-12-12 8c04d27e5cebb7e654c208533e9567c4df2c8acc
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,18 +121,15 @@
      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, "余额不足");
@@ -175,8 +176,8 @@
      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);
      try {
         producer.send(message);
      } catch (Exception e) {