From 8ce7c720e4e7a604b0ff770349b5556f39d37759 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 13 九月 2021 11:44:38 +0800 Subject: [PATCH] 好省呗应用兼容 --- fanli/src/main/java/com/yeshi/fanli/service/manger/user/UserLevelManager.java | 180 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 90 insertions(+), 90 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 b4e0bd4..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,90 +1,90 @@ -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(); - } - - } - -} +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