From f4548a3ee46afe45da4ee2a42dc169c575deee9f Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 31 七月 2019 11:57:36 +0800
Subject: [PATCH] 动态v2兼容

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java |   52 ++++++++++++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 24 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 9a07365..ca70561 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
@@ -25,7 +25,6 @@
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
 import com.yeshi.fanli.dto.HongBao;
 import com.yeshi.fanli.dto.HongBaoDTO;
-import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -48,7 +47,6 @@
 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.service.inter.user.UserSystemCouponRecordService;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
@@ -95,9 +93,6 @@
 
 	@Resource
 	private ThreeSaleSerivce threeSaleSerivce;
-
-	@Resource
-	private UserNotificationService userNotificationService;
 
 	@Resource
 	private UserOrderMsgNotificationService userOrderMsgNotificationService;
@@ -152,6 +147,8 @@
 	public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
 		Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et
 		if (commonOrderList != null && commonOrderList.size() > 0) {
+			int orderType = commonOrderList.get(0).getSourceType();
+
 			Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
 			int goodsCount = 0;
 			boolean hasAdd = false;
@@ -183,30 +180,27 @@
 					BigDecimal money = notify.getMoney();
 					switch (t) {
 					case HongBaoV2.TYPE_ZIGOU:
-						userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, commonOrder.getPayment(),
+						userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,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(),
+					
+						userOrderMsgNotificationService.orderShareStatistic(uid, orderId,orderType, 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(),
+					
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, 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(),
+					
+						userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, commonOrder.getPayment(),
 								money, goodsCount, state);
 						break;
 
 					case HongBaoV2.TYPE_SHARE_YIJI:
-						userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,
+						userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,orderType,
 								commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
 						break;
 					}
@@ -226,23 +220,23 @@
 					BigDecimal money = notify.getMoney();
 					switch (t) {
 					case HongBaoV2.TYPE_ZIGOU:
-						userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, commonOrder.getPayment(),
+						userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
 								money, state);
 						break;
 					case HongBaoV2.TYPE_SHARE_GOODS:
-						userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, commonOrder.getPayment(),
+						userOrderMsgNotificationService.orderShareStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
 								money, state);
 						break;
 					case HongBaoV2.TYPE_YIJI:
-						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
+						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
 								money, state);
 						break;
 					case HongBaoV2.TYPE_ERJI:
-						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
+						userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
 								money, state);
 						break;
 					case HongBaoV2.TYPE_SHARE_YIJI:
-						userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,
+						userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,orderType,
 								commonOrder.getPayment(), money, state);
 					}
 				}
@@ -272,7 +266,7 @@
 		HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
 		if (oldHongBao == null)
 			throw new HongBaoException(10, "绾㈠寘瀵硅薄涓嶅瓨鍦�");
-		// 宸茬粡澶辨晥鎴栬�呭凡缁忛鍙栫殑绾㈠寘涓嶅仛澶勭悊
+		// 宸茬粡澶辨晥锛屽凡缁忛鍙栵紝鏂拌�佺姸鎬佷竴鑷寸殑绾㈠寘涓嶅仛澶勭悊
 		if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
 			return;
 
@@ -288,7 +282,8 @@
 					payMent = commonOrder.getSettlement();
 
 				if (payMent.compareTo(new BigDecimal(10)) < 0) {
-					mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo());
+					mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getSourceType(),
+							commonOrder.getOrderNo());
 				}
 			}
 
@@ -312,6 +307,14 @@
 			} else if (commonOrder.getState() == CommonOrder.STATE_SX) {
 				hongBao.setState(HongBaoV2.STATE_SHIXIAO);
 				hongBao.setMoney(new BigDecimal(0));
+
+			}
+
+			// 鏂拌�佺孩鍖呯姸鎬佷竴鑷翠笉澶勭悊
+			if (oldHongBao.getState().intValue() == hongBao.getState())
+				return;
+
+			if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
 				if (mianDan) {
 					try {
 						userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
@@ -321,6 +324,7 @@
 					}
 				}
 			}
+
 			hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
 
 			// 鍔犲叆閫氱煡
@@ -952,7 +956,7 @@
 			hb.setMoney(hongBao.getMoney());
 
 			try {
-				userShareGoodsGroupService.updateOrderRecord(hb);
+				userShareGoodsGroupService.updateOrderRecord(hb,commonOrder.getSourceType());
 			} catch (UserShareGoodsRecordException e) {
 				try {
 					LogHelper.errorDetailInfo(e);

--
Gitblit v1.8.0