From 880238957a973ecd9676237672276b0e99d31115 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期一, 29 六月 2020 13:55:28 +0800 Subject: [PATCH] 免单 --- fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java | 107 +++++++---------------------------------------------- 1 files changed, 14 insertions(+), 93 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java index 30be42b..5416749 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java @@ -12,18 +12,11 @@ import com.google.gson.Gson; import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum; import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg; -import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg; -import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; -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; -import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.rocketmq.MQTopicName; /** @@ -56,31 +49,11 @@ tag = ""; if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) { - if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {// 杩斿埄鍒拌处 - OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()), - OrderMoneyRecievedMQMsg.class); - // 鍒嗕韩璁㈠崟濂栧姳 - if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) { - // try { - // redPackWinInviteService.orderArriveReward(orderMoneyRecievedMQMsg.getUid(), - // orderMoneyRecievedMQMsg.getSourceType(), - // orderMoneyRecievedMQMsg.getOrderId()); - // } catch (Exception e) { - // e.printStackTrace(); - // } - } - } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 璁㈠崟缁熻 + if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatistic.name())) {// 璁㈠崟缁� OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class); - if (orderMQMsg.isValid()) { - try {// 閭�璇峰鍔� - redPackWinInviteService.inviteSucceedReward(orderMQMsg.getUid()); - } catch (Exception e) { - e.printStackTrace(); - } - } // 鍙戦��24灏忔椂寤舵椂娑堟伅 // 娴嬭瘯鏃跺彂閫� - int hour = 24; + int hour = 48; if (Constant.IS_TEST) { hour = 1; } @@ -93,75 +66,23 @@ msg.setStartDeliverTime(System.currentTimeMillis() + 1000 * 60); producer.send(msg); return Action.CommitMessage; - } - - } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatisticDelay.name())) {// 璁㈠崟缁熻 - OrderMQMsg orderMQMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class); - int hour = 24; - if (Constant.IS_TEST) { - hour = 1; - } - - if (orderMQMsg.getDelayHour() == hour) { - // TODO 澶勭悊寤舵椂娑堟伅 - } - return Action.CommitMessage; - } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiSeparateByOrderNo.name())) {// 璁㈠崟鍒拌处锛堟寜璁㈠崟鍙峰鐞嗭級 - OrderMoneyRecievedMQMsg orderMoneyRecievedMQMsg = new Gson().fromJson(new String(message.getBody()), - OrderMoneyRecievedMQMsg.class); - if (orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU - || orderMoneyRecievedMQMsg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) { - if (!StringUtil.isNullOrEmpty(orderMoneyRecievedMQMsg.getOrderId()) - && orderMoneyRecievedMQMsg.getUid() != null) { - // TODO 鑷喘涓庡垎浜鍗曞埌璐﹀鐞� + } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderStatisticDelay.name())) {// 璁㈠崟缁熻 + OrderMQMsg mqMsg = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class); + int hour = 48; + if (Constant.IS_TEST) { + hour = 1; } - } - return Action.CommitMessage; - } else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) { - boolean inviteSucceedReward = false; - Long uid = null; - if (tag.equalsIgnoreCase(UserTopicTagEnum.userAccountBinding.name())) {// 璐﹀彿缁戝畾 - UserAccountBindingMQMsg userAccountBindingMQMsg = new Gson().fromJson(new String(message.getBody()), - UserAccountBindingMQMsg.class); - Integer type = userAccountBindingMQMsg.getType(); - if (type == UserAccountBindingMQMsg.TYPE_PHONE || type == UserAccountBindingMQMsg.TYPE_TAOBAO) { - inviteSucceedReward = true; - uid = userAccountBindingMQMsg.getUid(); - } - } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 閭�璇锋垚鍔� - UserInviteMQMsg userInviteMQMsg = new Gson().fromJson(new String(message.getBody()), - UserInviteMQMsg.class); - inviteSucceedReward = true; - uid = userInviteMQMsg.getWorkerId(); - } else if (tag.equalsIgnoreCase(UserTopicTagEnum.integralTaskFinish.name())) {// 閲戝竵浠诲姟瀹屾垚 - IntegralTaskMQMsg integralTaskMQMsg = new Gson().fromJson(new String(message.getBody()), - 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(); + if (mqMsg.getDelayHour() == hour) { + try {// 閭�璇峰鍔� + redPackWinInviteService.winRedPackByOrder(mqMsg.getUid(), mqMsg.getOrderId(), mqMsg.getType()); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + return Action.ReconsumeLater; + } } return Action.CommitMessage; } - - if (inviteSucceedReward) { - try {// 閭�璇峰鍔� - if (uid == 6269748) { - System.out.println(uid); - } - // redPackWinInviteService.inviteSucceedReward(uid); - } catch (Exception e) { - e.printStackTrace(); - } - } - } return Action.CommitMessage; } -- Gitblit v1.8.0