From 8b25dae4f4481a72a1adbb09a6628f2e001f45b1 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 29 四月 2020 16:25:46 +0800
Subject: [PATCH] 动态自动删除过期

---
 fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java |   47 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java b/fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java
index bb92104..0825bf6 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java
@@ -25,7 +25,6 @@
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
 import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
 import com.yeshi.fanli.entity.order.CommonOrder;
 import com.yeshi.fanli.entity.order.CommonOrderGoods;
@@ -43,7 +42,6 @@
 import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
-import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
 import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
 import com.yeshi.fanli.service.manger.user.UserLevelManager;
 import com.yeshi.fanli.util.Constant;
@@ -97,9 +95,6 @@
 	@Resource
 	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
-	@Resource
-	private TeamUserLevelStatisticService teamUserLevelStatisticService;
-
 	/**
 	 * 娣诲姞绾㈠寘淇℃伅
 	 * 
@@ -151,7 +146,6 @@
 				}
 			}
 
-		
 			int state = getOrderState(stateSet);
 
 			/**
@@ -191,20 +185,20 @@
 					case HongBaoV2.TYPE_ERJI:
 
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-								commonOrder.getPayment(), money,  new BigDecimal(0), goodsCount, state,
+								commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
 								commonOrder.getThirdCreateTime());
 
 						break;
 
 					case HongBaoV2.TYPE_SHARE_YIJI:
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-								commonOrder.getPayment(), money,  new BigDecimal(0), goodsCount, state,
+								commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
 								commonOrder.getThirdCreateTime());
 						break;
 					case HongBaoV2.TYPE_SHARE_ERJI:
 
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-								commonOrder.getPayment(), money,  new BigDecimal(0), goodsCount, state,
+								commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
 								commonOrder.getThirdCreateTime());
 
 						break;
@@ -248,13 +242,32 @@
 			List<Long> uidList = new ArrayList<Long>();
 			for (ThreeSale ts : threeSales)
 				uidList.add(ts.getBoss().getId());
-			List<TeamUserLevelStatistic> levelList = teamUserLevelStatisticService.listByUids(uidList);
-			if (levelList != null)
-				for (TeamUserLevelStatistic s : levelList) {
-					resultList.add(new UserTeamLevel(s.getId(), s.getLevel()));
-				}
+
+			for (Long bossUid : uidList) {
+				UserLevelEnum level = userLevelManager.getUserLevel(bossUid);
+				resultList.add(new UserTeamLevel(bossUid, level));
+			}
+
 		}
 
+		return resultList;
+	}
+
+	private List<UserTeamLevel> getBossList(List<HongBaoV2> children) {
+		List<UserTeamLevel> resultList = new ArrayList<>();
+		for (HongBaoV2 v2 : children) {
+
+			UserLevelEnum level = UserLevelUtil.getByOrderRank(v2.getUrank());
+			if (level == null)
+				level = UserLevelEnum.daRen;
+			UserTeamLevel teamLevel = new UserTeamLevel(v2.getUserInfo().getId(), level);
+
+			if (v2.getType() == HongBaoV2.TYPE_YIJI || v2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
+				resultList.add(0, teamLevel);
+			} else {
+				resultList.add(teamLevel);
+			}
+		}
 		return resultList;
 	}
 
@@ -334,7 +347,7 @@
 			// 鑾峰彇瀛愮孩鍖�
 			List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
 			if (children != null && children.size() > 0) {
-				List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
+				List<UserTeamLevel> bossList = getBossList(children);
 
 				for (HongBaoV2 child : children) {
 					if (child.getState() == HongBaoV2.STATE_YILINGQU)
@@ -381,7 +394,7 @@
 						}
 
 						if (boss != null) {
-							List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
+							List<UserTeamLevel> bossList = getBossList(oldHongBao.getUserInfo().getId(), 2);
 
 							// 鎻掑叆涓�绾у瓙绾㈠寘
 							money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
@@ -440,7 +453,7 @@
 			// 鑾峰彇瀛愮孩鍖�
 			List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
 			if (children != null && children.size() > 0) {
-				List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
+				List<UserTeamLevel> bossList = getBossList(children);
 				for (HongBaoV2 child : children) {
 					if (child.getState() == HongBaoV2.STATE_YILINGQU)
 						continue;

--
Gitblit v1.8.0