yujian
2020-05-09 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackGiveRecordServiceImpl.java
@@ -26,7 +26,9 @@
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.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
import com.yeshi.fanli.log.LogHelper;
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;
@@ -179,21 +181,25 @@
      try {
         redPackBalanceService.subRedPack(uid, amount, RedPackDetailFactory.createGiveOthers(giveRecord));
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
         throw new RedPackGiveRecordException(1, "红包创建失败");
      }
      UserRedPackGiftMQMsg msg = new UserRedPackGiftMQMsg();
      msg.setId(giveRecord.getId());
      msg.setUid(uid);
      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, "红包创建失败");
      // 发送消息(非测试下)
      if (!Constant.IS_TEST) {
         UserRedPackGiftMQMsg msg = new UserRedPackGiftMQMsg();
         msg.setId(giveRecord.getId());
         msg.setUid(uid);
         Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.redPackGiftDrawback,   msg);
         message.setStartDeliverTime(endTime.getTime() + 1000 * 60); // 延迟一分钟
         try {
            producer.send(message);
         } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            throw new RedPackGiveRecordException(1, "红包创建失败");
         }
      }
      return tips;
   }