yujian
2019-11-12 46a33cb062800fe051a75dd025a57d70994217d5
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java
@@ -17,7 +17,9 @@
import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
import com.yeshi.fanli.dto.mq.user.body.UserRedPackGiftMQMsg;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
@@ -34,13 +36,16 @@
   @Resource
   private UserSystemCouponService userSystemCouponService;
   @Resource
   private RedPackWinInviteService redPackWinInviteService;
   @Resource
   private RedPackGiveRecordService redPackGiveRecordService;
   @Override
   public Action consume(Message message, ConsumeContext context) {
      LogHelper.mqInfo("consumer-RedPackMessageListener", message.getTopic(), message.getTag(),
      LogHelper.mqInfo("consumer-RedPackMessageListener", message.getMsgID(), message.getTopic(), message.getTag(),
            new String(message.getBody()));
      String tag = message.getTag();
      if (tag == null)
@@ -49,7 +54,6 @@
      if (baseBody.isTest() != Constant.IS_TEST)
         return Action.ReconsumeLater;
      if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
         if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {// 返利到账
            OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()),
@@ -63,8 +67,7 @@
               }
            }
         } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 订单统计
            OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()),
                  OrderMQMsg.class);
            OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class);
            if (orderMQMsg.isValid()) {
               try {// 邀请奖励
                  redPackWinInviteService.inviteSucceedReward(orderMQMsg.getUid());
@@ -73,7 +76,7 @@
               }
            }
         }
      } else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
         boolean inviteSucceedReward = false;
         Long uid = null;
@@ -95,16 +98,26 @@
                  IntegralTaskMQMsg.class);
            inviteSucceedReward = true;
            uid = integralTaskMQMsg.getUid();
         } else if (tag.equalsIgnoreCase(UserTopicTagEnum.redPackGiftDrawback.name())) {// 红包赠送
            UserRedPackGiftMQMsg userRedPackGiftMQMsg = new Gson().fromJson(new String(message.getBody()),
                  UserRedPackGiftMQMsg.class);
            // 红包赠送到期未领取
            try {
               redPackGiveRecordService.overdueByPrimaryKey(userRedPackGiftMQMsg.getId());
            } catch (Exception e) {
               e.printStackTrace();
            }
            return Action.CommitMessage;
         }
         if (inviteSucceedReward ) {
         if (inviteSucceedReward) {
            try {// 邀请奖励
               redPackWinInviteService.inviteSucceedReward(uid);
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      }
      return Action.CommitMessage;
   }