From f99d8098b0aee17c09be5dfee8b4f72a6f4071b1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期日, 26 四月 2020 11:57:39 +0800
Subject: [PATCH] 同步老用户等级数据

---
 fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java |   67 ++++++++++++---------------------
 1 files changed, 25 insertions(+), 42 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 3ad78c1..ba58d09 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
@@ -30,12 +30,10 @@
 import com.yeshi.fanli.entity.order.CommonOrder;
 import com.yeshi.fanli.entity.order.CommonOrderGoods;
 import com.yeshi.fanli.entity.order.HongBaoOrder;
-import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
 import com.yeshi.fanli.exception.order.CommonOrderException;
 import com.yeshi.fanli.exception.order.HongBaoException;
 import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
 import com.yeshi.fanli.exception.user.UserAccountException;
-import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
 import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
 import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
@@ -153,31 +151,7 @@
 				}
 			}
 
-			if (hasAdd) {
-				try {
-					inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
-				} catch (InviteOrderSubsidyException e) {
-					throw new HongBaoException(201, "娣诲姞琛ヨ创鍑洪敊");
-				} catch (CommonOrderException e) {
-					throw new HongBaoException(202, "娣诲姞琛ヨ创鍑洪敊");
-				}
-			}
-
 			int state = getOrderState(stateSet);
-
-			if (hasAdd || hasUpdate) {
-				// 琛ヨ创澶辨晥
-				if (state == CommonOrder.STATE_SX)
-					inviteOrderSubsidyService.invalidByOrderIdAndSourceType(orderId, orderType);
-				else
-					try {
-						inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
-					} catch (InviteOrderSubsidyException e) {
-						LogHelper.errorDetailInfo(e, "娣樺疂璁㈠崟琛ヨ创鏇存柊澶辫触", orderId);
-					} catch (CommonOrderException e) {
-						LogHelper.errorDetailInfo(e, "娣樺疂璁㈠崟琛ヨ创鏇存柊澶辫触", orderId);
-					}
-			}
 
 			/**
 			 * 閫氱煡鐢ㄦ埛鐨勮繑鍒╂儏鍐�
@@ -194,15 +168,6 @@
 					CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
 					Long uid = notify.getUserInfo().getId();
 
-					List<InviteOrderSubsidy> subsidyList = inviteOrderSubsidyService.listByOrderNoAndTypeAndUid(orderId,
-							orderType, uid);
-					BigDecimal subsidy = new BigDecimal(0);
-					if (subsidyList != null)
-						for (InviteOrderSubsidy s : subsidyList) {
-							if (s.getState() != InviteOrderSubsidy.STATE_INVALID)
-								subsidy = subsidy.add(s.getOriginalMoney());
-						}
-
 					BigDecimal money = notify.getMoney();
 					switch (t) {
 					case HongBaoV2.TYPE_ZIGOU:
@@ -218,27 +183,27 @@
 						break;
 					case HongBaoV2.TYPE_YIJI:
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-								commonOrder.getPayment(), money, subsidy, goodsCount, state,
+								commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
 								commonOrder.getThirdCreateTime());
 
 						break;
 					case HongBaoV2.TYPE_ERJI:
 
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-								commonOrder.getPayment(), money, subsidy, 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, subsidy, 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, subsidy, goodsCount, state,
+								commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
 								commonOrder.getThirdCreateTime());
 
 						break;
@@ -289,6 +254,24 @@
 				}
 		}
 
+		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;
 	}
 
@@ -368,7 +351,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)
@@ -415,7 +398,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,
@@ -474,7 +457,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