From 62a447d89331aee1feae7724c7616aa1bb2cfe79 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 16 十月 2024 14:28:37 +0800
Subject: [PATCH] 将CMQ替换为rabbitmq

---
 fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java |  153 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 90 insertions(+), 63 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java b/fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java
index 1155a17..cb3bd94 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java
@@ -1,63 +1,90 @@
-package com.yeshi.fanli.service.manger.user;
-
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Component;
-
-import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
-import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
-import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
-import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
-
-@Component
-public class UserLevelManager {
-	@Resource
-	private UserVIPInfoService userVIPInfoService;
-
-	@Resource
-	private UserVIPPreInfoService userVIPPreInfoService;
-
-	/**
-	 * 鑾峰彇鐢ㄦ埛绛夌骇
-	 * @Title: getUserLevel
-	 * @Description: 
-	 * @param uid
-	 * @return 
-	 * UserLevelEnum 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public UserLevelEnum getUserLevel(Long uid) {
-		if (userVIPInfoService.isVIP(uid))
-			return UserLevelEnum.superVIP;
-		UserVIPPreInfo info = userVIPPreInfoService.getLatestProcessInfo(uid);
-		if (info != null)
-			for (UserLevelEnum level : UserLevelEnum.values())
-				if (level.getLevel() == info.getProcess())
-					return level;
-		return UserLevelEnum.daRen;
-	}
-
-	/**
-	 * 鑾峰彇褰撴椂鐨勭敤鎴风瓑绾�
-	 * @Title: getUserLevel
-	 * @Description: 
-	 * @param uid
-	 * @param date
-	 * @return 
-	 * UserLevelEnum 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public UserLevelEnum getUserLevel(Long uid, Date date) {
-		if (userVIPInfoService.isVIP(uid, date.getTime()))
-			return UserLevelEnum.superVIP;
-		UserVIPPreInfo info = userVIPPreInfoService.getProcessInfo(uid, date);
-		if (info != null)
-			for (UserLevelEnum level : UserLevelEnum.values())
-				if (level.getLevel() == info.getProcess())
-					return level;
-		return UserLevelEnum.daRen;
-	}
-
-}
+package com.yeshi.fanli.service.manger.user;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
+import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
+
+@Component
+public class UserLevelManager {
+	@Resource
+	private UserVIPInfoService userVIPInfoService;
+
+	@Resource
+	private UserVIPPreInfoService userVIPPreInfoService;
+
+	/**
+	 * 鑾峰彇鐢ㄦ埛绛夌骇
+	 * @Title: getUserLevel
+	 * @Description: 
+	 * @param uid
+	 * @return 
+	 * UserLevelEnum 杩斿洖绫诲瀷
+	 * @throws
+	 */
+	public UserLevelEnum getUserLevel(Long uid) {
+		UserVIPPreInfo info = userVIPPreInfoService.getLatestProcessInfo(uid);
+		if (info != null)
+			for (UserLevelEnum level : UserLevelEnum.values())
+				if (level.getLevel() == info.getProcess())
+					return level;
+		return UserLevelEnum.daRen;
+	}
+
+	/**
+	 * 鑾峰彇褰撴椂鐨勭敤鎴风瓑绾�
+	 * @Title: getUserLevel
+	 * @Description: 
+	 * @param uid
+	 * @param date
+	 * @return 
+	 * UserLevelEnum 杩斿洖绫诲瀷
+	 * @throws
+	 */
+	public UserLevelEnum getUserLevel(Long uid, Date date) {
+		UserVIPPreInfo info = userVIPPreInfoService.getProcessInfo(uid, date);
+		if (info != null)
+			for (UserLevelEnum level : UserLevelEnum.values())
+				if (level.getLevel() == info.getProcess())
+					return level;
+		return UserLevelEnum.daRen;
+	}
+
+	@Transactional
+	public void setUserLevel(Long uid, UserLevelEnum level, Date date) {
+
+		// 鍒犻櫎鍘熸湁绛夌骇
+
+		for (UserLevelEnum le : UserLevelEnum.values()) {
+			UserVIPPreInfo info = userVIPPreInfoService.getVipByProcess(uid, le.getLevel());
+			if (info != null)
+				userVIPPreInfoService.deleteByPrimaryKey(info.getId());
+		}
+
+		// 娣诲姞鏂扮殑绛夌骇
+		if (level == UserLevelEnum.daRen)
+			return;
+
+		UserVIPPreInfo info = new UserVIPPreInfo();
+		info.setCreateTime(date);
+		info.setProcess(level.getLevel());
+		info.setUid(uid);
+		//榛樿涓鸿鍗曞瀷
+		info.setSourceType(UserVIPPreInfo.SOURCE_TYPE_ORDER);
+		try {
+			userVIPPreInfoService.addUserVIPPreInfo(info);
+		} catch (UserVIPPreInfoException e) {
+			e.printStackTrace();
+		}
+
+	}
+
+}

--
Gitblit v1.8.0