From 033a7cd02b9799a0acf42290fdc84d74bdcee79c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 29 一月 2019 15:33:12 +0800
Subject: [PATCH] 热门搜素更改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java |  348 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 295 insertions(+), 53 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 86cfabc..b6e6e90 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
@@ -6,9 +6,11 @@
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.annotation.Resource;
 
@@ -26,27 +28,37 @@
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
 import com.yeshi.fanli.dto.HongBaoDTO;
+import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
 import com.yeshi.fanli.entity.bus.user.HongBao;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.entity.bus.user.Order;
+import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 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.ShareGoodsActivityOrder;
 import com.yeshi.fanli.entity.taobao.PidOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
 import com.yeshi.fanli.exception.HongBaoException;
+import com.yeshi.fanli.exception.order.ShareGoodsActivityOrderException;
 import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
 import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.msg.UserOrderMsgNotificationService;
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
+import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
+import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.service.inter.user.UserNotificationService;
 import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
 
@@ -91,6 +103,27 @@
 
 	@Resource
 	private PidOrderMapper pidOrderMapper;
+
+	@Resource
+	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private ThreeSaleSerivce threeSaleSerivce;
+
+	@Resource
+	private UserNotificationService userNotificationService;
+
+	@Resource
+	private UserOrderMsgNotificationService userOrderMsgNotificationService;
+
+	@Resource
+	private ConfigService configService;
+
+	@Resource
+	private ShareGoodsActivityOrderService shareGoodsActivityOrderService;
+
+	@Resource
+	private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
 
 	@Override
 	public int insert(HongBaoV2 record) {
@@ -346,61 +379,122 @@
 
 	}
 
-	@Resource
-	private HongBaoManageService hongBaoManageService;
-
-	@Resource
-	private ThreeSaleSerivce threeSaleSerivce;
-
-	@Resource
-	private UserNotificationService userNotificationService;
-
 	@Transactional
 	@Override
 	public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
-
+		Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et
 		if (commonOrderList != null && commonOrderList.size() > 0) {
-			Map<Integer, HongBaoV2> notificationMap = new HashMap<>();
+			Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
+			int goodsCount = 0;
+			boolean hasAdd = false;
 			for (CommonOrder commonOrder : commonOrderList) {
+				stateSet.add(commonOrder.getState());
+				goodsCount += commonOrder.getCount();
 				if (commonOrder == null || commonOrder.getId() == null || commonOrder.getUserInfo() == null)
 					throw new HongBaoException(1, "璁㈠崟淇℃伅涓嶅畬鏁�");
 				HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
 				if (hongBaoOrder == null) {
 					saveHongBao(commonOrder, type, notificationMap);
+					hasAdd = true;
 				} else {
-					updateHongBao(hongBaoOrder, commonOrder, type);
+					updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
 				}
 			}
 			/**
 			 * 閫氱煡鐢ㄦ埛鐨勮繑鍒╂儏鍐�
 			 */
-			Iterator<Integer> its = notificationMap.keySet().iterator();
-			while (its.hasNext()) {
-				Integer t = its.next();
-				HongBaoV2 notify = notificationMap.get(t);
-				String orderId = commonOrderList.get(0).getOrderNo();
-				Long uid = notify.getUserInfo().getId();
-				BigDecimal money = notify.getMoney();
-				switch (t) {
-				case HongBaoV2.TYPE_ZIGOU:
-					userNotificationService.orderFanliStatisticed(uid, orderId);
-					break;
-				case HongBaoV2.TYPE_SHARE_GOODS:
-					userNotificationService.orderShareStatisticed(uid, orderId, money);
-					break;
-				case HongBaoV2.TYPE_YIJI:
-					userNotificationService.orderInviteStatisticed(uid, orderId, money);
-					break;
-				case HongBaoV2.TYPE_ERJI:
-					userNotificationService.orderInviteStatisticed(uid, orderId, money);
-					break;
+			int state = getOrderState(stateSet);
+			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();
+					String orderId = commonOrderList.get(0).getOrderNo();
+					Long uid = notify.getUserInfo().getId();
+					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;
+					case HongBaoV2.TYPE_SHARE_GOODS:
+						userNotificationService.orderShareStatisticed(uid, orderId, goodsCount, MsgOrderDetail.STATE_FK,
+								null, money);
+						userOrderMsgNotificationService.orderShareStatistic(uid, orderId, commonOrder.getPayment(),
+								money, goodsCount, state);
+						break;
+					case HongBaoV2.TYPE_YIJI:
+						userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
+								MsgOrderDetail.STATE_FK, null, money);
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, commonOrder.getPayment(),
+								money, goodsCount, state);
+						break;
+					case HongBaoV2.TYPE_ERJI:
+						userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
+								MsgOrderDetail.STATE_FK, null, money);
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, commonOrder.getPayment(),
+								money, goodsCount, state);
+						break;
+					}
+				}
+			}
+
+			// 娣诲姞鏂扮増鏈�氱煡
+
+			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();
+					String orderId = commonOrderList.get(0).getOrderNo();
+					Long uid = notify.getUserInfo().getId();
+					BigDecimal money = notify.getMoney();
+					switch (t) {
+					case HongBaoV2.TYPE_ZIGOU:
+						userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, commonOrder.getPayment(),
+								money, state);
+						break;
+					case HongBaoV2.TYPE_SHARE_GOODS:
+						userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, commonOrder.getPayment(),
+								money, state);
+						break;
+					case HongBaoV2.TYPE_YIJI:
+						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
+								money, state);
+						break;
+					case HongBaoV2.TYPE_ERJI:
+						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
+								money, state);
+						break;
+					}
 				}
 			}
 		}
+
+	}
+
+	private int getOrderState(Set<Integer> states) {
+		if (states.size() == 1)
+			return states.iterator().next();
+		Iterator<Integer> its = states.iterator();
+		while (its.hasNext()) {
+			int tempState = its.next();
+			if (tempState == CommonOrder.STATE_FK)
+				return CommonOrder.STATE_FK;
+			else if (tempState == CommonOrder.STATE_JS)
+				return CommonOrder.STATE_JS;
+		}
+		return CommonOrder.STATE_SX;
 	}
 
 	@Transactional
-	private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type) throws HongBaoException {
+	private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
+			Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException {
 		System.out.println(commonOrder.getOrderNo());
 		HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
 		if (oldHongBao == null)
@@ -428,6 +522,24 @@
 				hongBao.setMoney(new BigDecimal(0));
 			}
 			hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
+
+			// 鍔犲叆閫氱煡
+			if (notificationMap.get(type) == null) {
+				HongBaoV2 tempHongBao = new HongBaoV2(oldHongBao.getId());
+				tempHongBao.setUserInfo(oldHongBao.getUserInfo());
+				tempHongBao.setMoney(hongBao.getMoney());
+				CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+				tempCommonOrder.setPayment(commonOrder.getPayment());
+				notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
+			} else {
+				// 澧炲姞浠樻閲戦涓庤祫閲�
+				HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
+				tempHongBaoOrder.getCommonOrder()
+						.setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+				tempHongBaoOrder.getHongBaoV2()
+						.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
+				notificationMap.put(type, tempHongBaoOrder);
+			}
 
 			// 鑾峰彇瀛愮孩鍖�
 			List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
@@ -460,10 +572,38 @@
 								MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
 					}
 					hongBaoV2Mapper.updateByPrimaryKeySelective(childUpdate);
+
+					// 鍔犲叆閫氱煡
+					if (notificationMap.get(type) == null) {
+						HongBaoV2 tempHongBao = new HongBaoV2(child.getId());
+						tempHongBao.setUserInfo(child.getUserInfo());
+						tempHongBao.setMoney(child.getMoney());
+						CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+						tempCommonOrder.setPayment(commonOrder.getPayment());
+						notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
+					} else {
+						// 澧炲姞浠樻閲戦涓庤祫閲�
+						HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
+						tempHongBaoOrder.getCommonOrder().setPayment(
+								tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+						tempHongBaoOrder.getHongBaoV2()
+								.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(child.getMoney()));
+						notificationMap.put(type, tempHongBaoOrder);
+					}
+
 				}
 
 		} else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
-			BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
+			BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
+			Order order = orderMapper.selectOrderByOrderId(commonOrder.getOrderNo());
+			if (order != null) {
+				List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
+						.listByOrderIdAndUid(commonOrder.getUserInfo().getId(), order.getId());
+				if (list != null && list.size() > 0) {
+					fanliRate = list.get(0).getShareRate();
+				}
+			}
+
 			HongBaoV2 hongBao = new HongBaoV2(hongBaoOrder.getHongBaoV2().getId());
 			hongBao.setUpdateTime(new Date());
 			// 鏇存敼鐘舵�佷笌璧勯噾
@@ -485,6 +625,23 @@
 				hongBao.setMoney(new BigDecimal(0));
 			}
 			hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
+			// 閫氱煡
+			if (notificationMap.get(type) == null) {
+				HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
+				tempHongBao.setUserInfo(hongBao.getUserInfo());
+				tempHongBao.setMoney(hongBao.getMoney());
+				CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+				tempCommonOrder.setPayment(commonOrder.getPayment());
+				notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
+			} else {
+				// 澧炲姞浠樻閲戦涓庤祫閲�
+				HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
+				tempHongBaoOrder.getCommonOrder()
+						.setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+				tempHongBaoOrder.getHongBaoV2()
+						.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
+				notificationMap.put(type, tempHongBaoOrder);
+			}
 
 			// 鑾峰彇瀛愮孩鍖�
 			List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
@@ -527,7 +684,7 @@
 	}
 
 	@Transactional
-	private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoV2> notificationMap)
+	private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
 			throws HongBaoException {
 		if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚�
 			BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
@@ -561,10 +718,21 @@
 			hongBaoOrder.setHongBaoV2(hongBao);
 			hongBaoOrderMapper.insertSelective(hongBaoOrder);
 			// 鍔犲叆閫氱煡
-			if (notificationMap.get(type) == null)
-				notificationMap.put(type, hongBao);
-			else {
-				notificationMap.get(type).setMoney(notificationMap.get(type).getMoney().add(hongBao.getMoney()));
+			if (notificationMap.get(type) == null) {
+				HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
+				tempHongBao.setUserInfo(hongBao.getUserInfo());
+				tempHongBao.setMoney(hongBao.getMoney());
+				CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+				tempCommonOrder.setPayment(commonOrder.getPayment());
+				notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
+			} else {
+				// 澧炲姞浠樻閲戦涓庤祫閲�
+				HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
+				tempHongBaoOrder.getCommonOrder()
+						.setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+				tempHongBaoOrder.getHongBaoV2()
+						.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
+				notificationMap.put(type, tempHongBaoOrder);
 			}
 
 			UserInfo boss = threeSaleSerivce.getBoss(user.getId());
@@ -599,11 +767,21 @@
 				}
 				hongBaoV2Mapper.insertSelective(firstHongbao);
 				// 鐢ㄦ埛閫氱煡
-				if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null)
-					notificationMap.put(HongBaoV2.TYPE_YIJI, firstHongbao);
-				else {
-					notificationMap.get(HongBaoV2.TYPE_YIJI)
-							.setMoney(notificationMap.get(HongBaoV2.TYPE_YIJI).getMoney().add(firstHongbao.getMoney()));
+				if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
+					HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
+					tempHongBao.setUserInfo(firstHongbao.getUserInfo());
+					tempHongBao.setMoney(firstHongbao.getMoney());
+					CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+					tempCommonOrder.setPayment(commonOrder.getPayment());
+					notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
+				} else {
+					// 澧炲姞浠樻閲戦涓庤祫閲�
+					HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
+					tempHongBaoOrder.getCommonOrder()
+							.setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+					tempHongBaoOrder.getHongBaoV2()
+							.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
+					notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
 				}
 
 				// 鎻掑叆浜岀骇瀛愮孩鍖�
@@ -637,11 +815,21 @@
 					hongBaoV2Mapper.insertSelective(secondHongbao);
 
 					// 鐢ㄦ埛閫氱煡
-					if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null)
-						notificationMap.put(HongBaoV2.TYPE_ERJI, secondHongbao);
-					else {
-						notificationMap.get(HongBaoV2.TYPE_ERJI).setMoney(
-								notificationMap.get(HongBaoV2.TYPE_ERJI).getMoney().add(secondHongbao.getMoney()));
+					if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
+						HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
+						tempHongBao.setUserInfo(secondHongbao.getUserInfo());
+						tempHongBao.setMoney(secondHongbao.getMoney());
+						CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+						tempCommonOrder.setPayment(commonOrder.getPayment());
+						notificationMap.put(HongBaoV2.TYPE_ERJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
+					} else {
+						// 澧炲姞浠樻閲戦涓庤祫閲�
+						HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
+						tempHongBaoOrder.getCommonOrder().setPayment(
+								tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+						tempHongBaoOrder.getHongBaoV2()
+								.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
+						notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
 					}
 				}
 
@@ -653,6 +841,40 @@
 				return;
 			// 鍒嗕韩璧�
 			BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
+
+			// 鍒ゆ柇璁㈠崟鍒嗕韩娲诲姩鏄惁寮�鍚�
+			if ("1".equalsIgnoreCase(configService.get("share_goods_activity_open"))) {
+				// 娌℃湁璁㈠崟锛屽苟涓旀槸娓犻亾ID鏉ョ殑锛屽苟涓�
+				UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService
+						.getByUid(commonOrder.getUserInfo().getId());
+				if (taoBaoExtraInfo != null && ((!StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num())
+						&& !commonOrder.getOrderNo().endsWith(taoBaoExtraInfo.getTaoBaoOrderEnd6Num().trim()))
+						|| StringUtil.isNullOrEmpty(taoBaoExtraInfo.getTaoBaoOrderEnd6Num()))) {
+					List<TaoBaoOrder> taoBaoOrderList = taoBaoOrderMapper
+							.selectTaoBaoOrderByOrderId(commonOrder.getOrderNo());
+					if (taoBaoOrderList != null && taoBaoOrderList.size() > 0
+							&& !StringUtil.isNullOrEmpty(taoBaoOrderList.get(0).getRelationId())) {
+						if (shareGoodsActivityOrderService.listByUid(commonOrder.getUserInfo().getId()).size() < 1) {
+							Order order = orderMapper.selectOrderByOrderId(commonOrder.getOrderNo());
+							if (order != null) {
+								shareRate = new BigDecimal(hongBaoManageService.get("share_activity_proportion"));
+								try {
+									shareGoodsActivityOrderService.addShareGoodsActivityOrder(
+											commonOrder.getUserInfo().getId(), shareRate, order);
+								} catch (ShareGoodsActivityOrderException e) {
+									try {
+										LogHelper.errorDetailInfo(e);
+									} catch (Exception e1) {
+										e1.printStackTrace();
+									}
+								}
+							}
+						}
+					}
+				}
+
+			}
+
 			HongBaoV2 hongBao = new HongBaoV2();
 			hongBao.setCreateTime(new Date());
 			hongBao.setType(HongBaoV2.TYPE_SHARE_GOODS);
@@ -682,10 +904,21 @@
 			hongBaoOrder.setHongBaoV2(hongBao);
 			hongBaoOrderMapper.insertSelective(hongBaoOrder);
 
-			if (notificationMap.get(type) == null)
-				notificationMap.put(type, hongBao);
-			else {
-				notificationMap.get(type).setMoney(notificationMap.get(type).getMoney().add(hongBao.getMoney()));
+			if (notificationMap.get(type) == null) {
+				HongBaoV2 tempHongBao = new HongBaoV2(hongBao.getId());
+				tempHongBao.setUserInfo(hongBao.getUserInfo());
+				tempHongBao.setMoney(hongBao.getMoney());
+				CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+				tempCommonOrder.setPayment(commonOrder.getPayment());
+				notificationMap.put(type, new HongBaoOrder(tempCommonOrder, tempHongBao));
+			} else {
+				// 澧炲姞浠樻閲戦涓庤祫閲�
+				HongBaoOrder tempHongBaoOrder = notificationMap.get(type);
+				tempHongBaoOrder.getCommonOrder()
+						.setPayment(tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+				tempHongBaoOrder.getHongBaoV2()
+						.setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(hongBao.getMoney()));
+				notificationMap.put(type, tempHongBaoOrder);
 			}
 
 			// 淇敼缁熻鏁版嵁
@@ -760,4 +993,13 @@
 		else
 			return money;
 	}
+
+	@Override
+	public BigDecimal getUnRecievedMoneyWithPreGetTime(Long uid, Date minDate, Date maxDate) {
+		BigDecimal money = hongBaoV2Mapper.getUnRecievedMoneyWithPreGetTime(uid, minDate, maxDate);
+		if (money == null)
+			return new BigDecimal(0);
+		else
+			return money;
+	}
 }

--
Gitblit v1.8.0