From 2bd2200f209ddb7bcc59b636d9de6f8b3f762958 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 23 四月 2020 10:00:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/manger/order/HongBaoV2AddManager.java |  123 +++++++++++++++++++++-------------------
 1 files changed, 65 insertions(+), 58 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 2527f19..d1528e1 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
@@ -26,6 +26,7 @@
 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;
@@ -171,59 +172,69 @@
 			 * 閫氱煡鐢ㄦ埛鐨勮繑鍒╂儏鍐�
 			 */
 
-			if (!Constant.IS_TEST) {
-				if (hasAdd) {
-					Iterator<Integer> its = notificationMap.keySet().iterator();
-					while (its.hasNext()) {
-						Integer t = its.next();
-						HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
-						CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
-						Long uid = notify.getUserInfo().getId();
-						BigDecimal money = notify.getMoney();
-						switch (t) {
-						case HongBaoV2.TYPE_ZIGOU:
-							userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
+			// if (!Constant.IS_TEST) {
+			if (hasAdd) {
+				// 鑾峰彇璁㈠崟琛ヨ创
 
-							break;
-						case HongBaoV2.TYPE_SHARE_GOODS:
+				Iterator<Integer> its = notificationMap.keySet().iterator();
+				while (its.hasNext()) {
+					Integer t = its.next();
+					HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
+					CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
+					Long uid = notify.getUserInfo().getId();
 
-							userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
-
-							break;
-						case HongBaoV2.TYPE_YIJI:
-							userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
-
-							break;
-						case HongBaoV2.TYPE_ERJI:
-
-							userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
-
-							break;
-
-						case HongBaoV2.TYPE_SHARE_YIJI:
-							userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
-							break;
-						case HongBaoV2.TYPE_SHARE_ERJI:
-
-							userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
-									commonOrder.getPayment(), money, goodsCount, state,
-									commonOrder.getThirdCreateTime());
-
-							break;
-
+					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:
+						userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, goodsCount, state, commonOrder.getThirdCreateTime());
+
+						break;
+					case HongBaoV2.TYPE_SHARE_GOODS:
+
+						userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, goodsCount, state, commonOrder.getThirdCreateTime());
+
+						break;
+					case HongBaoV2.TYPE_YIJI:
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, subsidy, goodsCount, state,
+								commonOrder.getThirdCreateTime());
+
+						break;
+					case HongBaoV2.TYPE_ERJI:
+
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, subsidy, goodsCount, state,
+								commonOrder.getThirdCreateTime());
+
+						break;
+
+					case HongBaoV2.TYPE_SHARE_YIJI:
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, subsidy, goodsCount, state,
+								commonOrder.getThirdCreateTime());
+						break;
+					case HongBaoV2.TYPE_SHARE_ERJI:
+
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+								commonOrder.getPayment(), money, subsidy, goodsCount, state,
+								commonOrder.getThirdCreateTime());
+
+						break;
+
 					}
 				}
+				// }
 			}
 
 			int resultCode = 0;
@@ -252,7 +263,6 @@
 		return CommonOrder.STATE_SX;
 	}
 
-	@Transactional(rollbackFor = Exception.class)
 	private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
 			Map<Integer, HongBaoOrder> notificationMap, Date placeOrderTime)
 			throws HongBaoException, UserAccountException {
@@ -688,13 +698,11 @@
 		}
 
 		child.setUserInfo(user);
-		child.setUrank(user.getRank());
+		child.setUrank(userLevel.getOrderRank());
 		child.setVersion(2);
 		child.setCreateTime(new Date());
 		child.setOrderType(commonOrder.getSourceType());
 		if (child.getMoney() == null)
-			return null;
-		if (child.getMoney().compareTo(new BigDecimal(0)) <= 0 && userLevel == UserLevelEnum.daRen)
 			return null;
 		return child;
 	}
@@ -748,19 +756,19 @@
 		return hongBao;
 	}
 
-	private HongBaoV2 createFanLiUpdateHongBao(CommonOrder commonOrder, BigDecimal fanliRate, Long hongBaoId,
+	private HongBaoV2 createFanLiUpdateHongBao(CommonOrder commonOrder, BigDecimal money, Long hongBaoId,
 			boolean mianDan) throws HongBaoException, UserAccountException {
 		HongBaoV2 hongBao = new HongBaoV2(hongBaoId);
 		hongBao.setUpdateTime(new Date());
+		hongBao.setMoney(money);
 		// 鏇存敼鐘舵�佷笌璧勯噾
 		if (commonOrder.getState() == CommonOrder.STATE_FK) {
 			hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
-			hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
+
 			if (mianDan)
 				hongBao.setMoney(commonOrder.getPayment());
 		} else if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_WQ) {
 			hongBao.setState(HongBaoV2.STATE_KELINGQU);
-			hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
 			if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 鎷煎澶�15澶╄繃1涓皬鏃跺埌璐�
 				hongBao.setPreGetTime(new Date(
 						commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 1L));
@@ -787,17 +795,16 @@
 	 * @throws HongBaoException
 	 * @throws UserAccountException
 	 */
-	private HongBaoV2 createShareUpdateHongBao(CommonOrder commonOrder, BigDecimal fanliRate, Long hongBaoId)
+	private HongBaoV2 createShareUpdateHongBao(CommonOrder commonOrder, BigDecimal money, Long hongBaoId)
 			throws HongBaoException, UserAccountException {
 		HongBaoV2 hongBao = new HongBaoV2(hongBaoId);
 		hongBao.setUpdateTime(new Date());
+		hongBao.setMoney(money);
 		// 鏇存敼鐘舵�佷笌璧勯噾
 		if (commonOrder.getState() == CommonOrder.STATE_FK) {
 			hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
-			hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
 		} else if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_WQ) {
 			hongBao.setState(HongBaoV2.STATE_KELINGQU);
-			hongBao.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
 			Calendar calendar = Calendar.getInstance();
 			calendar.setTime(commonOrder.getSettleTime());
 			calendar.add(Calendar.MONTH, 1);

--
Gitblit v1.8.0