From f4a0f2acc63d7785eab108419a4e16f5f688cb95 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 18 一月 2020 12:06:27 +0800
Subject: [PATCH] 用户注册信息

---
 fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/redpack/RedPackMessageListener.java |   90 ++++++++++++++++++++++++++++----------------
 1 files changed, 57 insertions(+), 33 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 5f74637..c739be7 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
@@ -8,13 +8,12 @@
 import com.aliyun.openservices.ons.api.ConsumeContext;
 import com.aliyun.openservices.ons.api.Message;
 import com.aliyun.openservices.ons.api.MessageListener;
+import com.aliyun.openservices.ons.api.Producer;
 import com.google.gson.Gson;
-import com.yeshi.fanli.dto.mq.BaseMQMsgBody;
 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;
@@ -23,6 +22,7 @@
 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;
 
 /**
@@ -39,9 +39,12 @@
 
 	@Resource
 	private RedPackWinInviteService redPackWinInviteService;
-	
+
 	@Resource
 	private RedPackGiveRecordService redPackGiveRecordService;
+
+	@Resource(name = "producer")
+	private Producer producer;
 
 	@Override
 	public Action consume(Message message, ConsumeContext context) {
@@ -52,29 +55,56 @@
 			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()) {
+				// 鍙戦��24灏忔椂寤舵椂娑堟伅
+				// 娴嬭瘯鏃跺彂閫�
+				int hour = 24;
+				if (Constant.IS_TEST) {
+					hour = 1;
+				}
+				orderMQMsg.setDelayHour(hour);
+				Message msg = new Message(message.getTopic(), OrderTopicTagEnum.orderStatisticDelay.name(),
+						new Gson().toJson(orderMQMsg).getBytes());
+				if (orderMQMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour > System.currentTimeMillis())// 鏃堕棿鏄惁宸茬粡杩囦簡
+					msg.setStartDeliverTime(orderMQMsg.getStaticticDate().getTime() + 1000 * 60 * 60L * hour);
+				else
+					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) {
 					try {// 閭�璇峰鍔�
 						redPackWinInviteService.inviteSucceedReward(orderMQMsg.getUid());
 					} catch (Exception e) {
-						e.printStackTrace();
+						LogHelper.errorDetailInfo(e);
+						return Action.ReconsumeLater;
 					}
 				}
-			}
+				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_INVITE) {
+					if (!StringUtil.isNullOrEmpty(orderMoneyRecievedMQMsg.getOrderId())
+							&& orderMoneyRecievedMQMsg.getUid() != null) {
+						try {
+							redPackWinInviteService.inviteOrderArriveReward(orderMoneyRecievedMQMsg.getUid(),
+									orderMoneyRecievedMQMsg.getSourceType(), orderMoneyRecievedMQMsg.getOrderId());
+						} catch (Exception e) {
+							e.printStackTrace();
+						}
+					}
+				}
+				return Action.CommitMessage;
+			}
 		} else if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
 			boolean inviteSucceedReward = false;
 			Long uid = null;
@@ -82,7 +112,8 @@
 				UserAccountBindingMQMsg userAccountBindingMQMsg = new Gson().fromJson(new String(message.getBody()),
 						UserAccountBindingMQMsg.class);
 				Integer type = userAccountBindingMQMsg.getType();
-				if (type == UserAccountBindingMQMsg.TYPE_PHONE || type == UserAccountBindingMQMsg.TYPE_TAOBAO) {
+				if (type == UserAccountBindingMQMsg.TYPE_PHONE || type == UserAccountBindingMQMsg.TYPE_WX
+						|| type == UserAccountBindingMQMsg.TYPE_TAOBAO) {
 					inviteSucceedReward = true;
 					uid = userAccountBindingMQMsg.getUid();
 				}
@@ -91,16 +122,14 @@
 						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();
+
+				redPackWinInviteService.initCreateRedPackWin(userInviteMQMsg.getBossId(),
+						userInviteMQMsg.getWorkerId());
+
 			} else if (tag.equalsIgnoreCase(UserTopicTagEnum.redPackGiftDrawback.name())) {// 绾㈠寘璧犻��
 				UserRedPackGiftMQMsg userRedPackGiftMQMsg = new Gson().fromJson(new String(message.getBody()),
 						UserRedPackGiftMQMsg.class);
-				// 绾㈠寘璧犻�佸埌鏈熸湭棰嗗彇
-				try {
+				try { // 绾㈠寘璧犻�佸埌鏈熸湭棰嗗彇
 					redPackGiveRecordService.overdueByPrimaryKey(userRedPackGiftMQMsg.getId());
 				} catch (Exception e) {
 					e.printStackTrace();
@@ -110,16 +139,11 @@
 
 			if (inviteSucceedReward) {
 				try {// 閭�璇峰鍔�
-					if(uid==6269748)
-					{
-						System.out.println(uid);
-					}
-//					redPackWinInviteService.inviteSucceedReward(uid);
+					redPackWinInviteService.inviteSucceedReward(uid);
 				} catch (Exception e) {
 					e.printStackTrace();
 				}
 			}
-
 		}
 		return Action.CommitMessage;
 	}

--
Gitblit v1.8.0