From 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 11 七月 2019 16:34:13 +0800
Subject: [PATCH] 订单bug,分享爆款自购修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java |  122 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 109 insertions(+), 13 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
index c085968..6f59edf 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -175,7 +175,6 @@
 			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();
@@ -184,8 +183,6 @@
 					BigDecimal money = notify.getMoney();
 					switch (t) {
 					case HongBaoV2.TYPE_ZIGOU:
-						userNotificationService.orderFanliStatisticed(uid, orderId, goodsCount, MsgOrderDetail.STATE_FK,
-								null, money);
 						userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, commonOrder.getPayment(),
 								money, goodsCount, state);
 						break;
@@ -206,6 +203,11 @@
 								MsgOrderDetail.STATE_FK, null, money);
 						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, commonOrder.getPayment(),
 								money, goodsCount, state);
+						break;
+
+					case HongBaoV2.TYPE_SHARE_YIJI:
+						userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,
+								commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
 						break;
 					}
 				}
@@ -239,6 +241,9 @@
 						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
 								money, state);
 						break;
+					case HongBaoV2.TYPE_SHARE_YIJI:
+						userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,
+								commonOrder.getPayment(), money, state);
 					}
 				}
 			}
@@ -548,17 +553,20 @@
 					childUpdate.setUpdateTime(new Date());
 					BigDecimal rate = null;
 					if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 涓�绾у垎浜禋
-						rate = hongBaoManageService.getFirstShareRate(child.getUrank(),
-								commonOrder.getCreateTime().getTime());
+						rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime());
 					} else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 浜岀骇鍒嗕韩璧�
-						rate = hongBaoManageService.getSecondShareRate(child.getUrank(),
-								commonOrder.getCreateTime().getTime());
+						rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime());
 					}
 
 					// 浠ュ疄闄呮敹鍏ヤ负鍑嗚绠楅浼版敹鐩�
 					if (CommonOrder.STATE_JS == commonOrder.getState()) {
 						childUpdate.setMoney(
 								MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
+						if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
+								"yyyy-MM-dd"))
+							childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
+									rate.divide(new BigDecimal(100))));
+
 						Calendar calendar = Calendar.getInstance();
 						calendar.setTime(commonOrder.getSettleTime());
 						calendar.add(Calendar.MONTH, 1);
@@ -566,13 +574,33 @@
 								calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
 								"yyyy-M-dd")));
 					} else if (CommonOrder.STATE_FK == commonOrder.getState()) {
-						if (commonOrder.getOrderNo().equalsIgnoreCase("314134177659155087"))
-							System.out.println("");
-
-						childUpdate.setMoney(
-								MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
+						if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
+								"yyyy-MM-dd"))
+							childUpdate.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
+									rate.divide(new BigDecimal(100))));
+						else
+							childUpdate.setMoney(
+									MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
 					}
 					hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
+					// 娣诲姞閫氱煡
+					if (notificationMap.get(child.getType()) == null) {
+						HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
+						tempHongBao.setUserInfo(child.getUserInfo());
+						tempHongBao.setMoney(childUpdate.getMoney());
+						CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+						tempCommonOrder.setPayment(commonOrder.getPayment());
+						notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao));
+					} else {
+						// 澧炲姞浠樻閲戦涓庤祫閲�
+						HongBaoOrder tempHongBaoOrder = notificationMap.get(child.getType());
+						tempHongBaoOrder.getCommonOrder().setPayment(
+								tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+						tempHongBaoOrder.getHongBaoV2()
+								.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(childUpdate.getMoney()));
+						notificationMap.put(child.getType(), tempHongBaoOrder);
+					}
+
 				}
 		} else
 			throw new HongBaoException(2, "type閿欒");
@@ -698,6 +726,10 @@
 					firstHongbao.setMoney(
 							MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
 				}
+				//杩斿埄涓�0鐨勪笉閫氱煡
+				if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
+					return;
+
 				hongBaoV2Mapper.insertSelective(firstHongbao);
 				// 鐢ㄦ埛閫氱煡
 				if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
@@ -745,6 +777,11 @@
 						secondHongbao.setMoney(
 								MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
 					}
+					
+					//杩斿埄涓�0鐨勪笉缁熻
+					if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
+						return;
+
 					hongBaoV2Mapper.insertSelective(secondHongbao);
 
 					// 鐢ㄦ埛閫氱煡
@@ -802,7 +839,6 @@
 						}
 					}
 				}
-
 			}
 
 			HongBaoV2 hongBao = new HongBaoV2();
@@ -849,6 +885,56 @@
 				tempHongBaoOrder.getHongBaoV2()
 						.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
 				notificationMap.put(type, tempHongBaoOrder);
+			}
+
+			// 4鏈�17鏃ュ悗鎵嶆湁涓�绾у垎浜禋
+			if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17", "yyyy-MM-dd")) {
+				UserInfo boss = threeSaleSerivce.getBoss(hongBao.getUserInfo().getId());
+				if (boss != null) {
+					BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
+							commonOrder.getThirdCreateTime().getTime());
+					HongBaoV2 child = new HongBaoV2();
+					child.setParent(hongBao);
+					child.setType(HongBaoV2.TYPE_SHARE_YIJI);
+					if (commonOrder.getState() == CommonOrder.STATE_FK) {
+						child.setState(HongBaoV2.STATE_BUKELINGQU);
+						child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
+								firstLevelRate.divide(new BigDecimal(100))));
+					} else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+						child.setState(HongBaoV2.STATE_KELINGQU);
+						child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
+								firstLevelRate.divide(new BigDecimal(100))));
+						Calendar calendar = Calendar.getInstance();
+						calendar.setTime(commonOrder.getSettleTime());
+						calendar.add(Calendar.MONTH, 1);
+						child.setPreGetTime(new Date(TimeUtil.convertToTimeTemp(
+								calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25",
+								"yyyy-M-dd")));
+					}
+					child.setUserInfo(boss);
+					child.setUrank(boss.getRank());
+					child.setVersion(2);
+					child.setCreateTime(new Date());
+					hongBaoV2Mapper.insertSelective(child);
+					// 娣诲姞閫氱煡
+					if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) {
+						HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
+						tempHongBao.setUserInfo(child.getUserInfo());
+						tempHongBao.setMoney(child.getMoney());
+						tempHongBao.setBeizhu(hongBao.getUserInfo().getNickName());
+						CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+						tempCommonOrder.setPayment(commonOrder.getPayment());
+						notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
+					} else {
+						// 澧炲姞浠樻閲戦涓庤祫閲�
+						HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI);
+						tempHongBaoOrder.getCommonOrder().setPayment(
+								tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+						tempHongBaoOrder.getHongBaoV2()
+								.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
+						notificationMap.put(HongBaoV2.TYPE_SHARE_YIJI, tempHongBaoOrder);
+					}
+				}
 			}
 
 			// 淇敼缁熻鏁版嵁
@@ -943,4 +1029,14 @@
 		else
 			return money;
 	}
+
+	@Override
+	public List<HongBaoV2> listChildrenById(Long id) {
+		return hongBaoV2Mapper.listChildrenById(id);
+	}
+	
+	@Override
+	public List<Long> getUidByNear30DayShareSucceed(){
+		return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
+	}
 }

--
Gitblit v1.8.0