From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java |  205 +++++++++++++++++----------------------------------
 1 files changed, 69 insertions(+), 136 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
index 4cc82b2..f0380c1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/msg/UserOrderMsgNotificationServiceImpl.java
@@ -6,6 +6,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.yeshi.fanli.dto.push.PushContentDTO;
 import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
@@ -15,6 +16,7 @@
 import com.yeshi.fanli.service.inter.order.msg.MsgOrderDetailService;
 import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
 import com.yeshi.fanli.service.inter.push.PushService;
+import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.factory.msg.MsgOrderDetailFactory;
 
 @Service
@@ -25,20 +27,17 @@
 
 	@Resource
 	private PushService pushService;
+	
 
 	@Override
 	public void orderFanLiStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int goodsCount, int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createFanLiOrder(uid, orderId, orderType, goodsCount, orderState,
-				payMoney, money, null);
-		try {
-			msgOrderDetailService.addMsgOrderDetail(detail,
-					(payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
-		}
-
-		if (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) {
+			int goodsCount, int orderState, Date downTime) {
+		// 鏄惁閫氱煡
+		boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
+		// 淇濆瓨娑堟伅鏄庣粏娑堟伅
+		addOrderStatistics(uid, orderId, orderType, Constant.TYPE_REBATE, goodsCount, payMoney, money, downTime, null, needNotify);
+		
+		if (needNotify) {
 			PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money);
 			try {
 				pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
@@ -50,33 +49,17 @@
 		}
 	}
 
-	@Override
-	public void orderFanLiStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createFanLiOrder(uid, orderId, orderType, 0, orderState, payMoney,
-				money, null);
-		// 鏆傛椂涓嶆帹閫�
-		try {
-			msgOrderDetailService.updateMsgOrderDetail(detail, false);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
-		}
-
-	}
 
 	@Override
 	public void orderShareStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int goodsCount, int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createShareOrder(uid, orderId, orderType, goodsCount, orderState,
-				payMoney, money, null);
-		try {
-			msgOrderDetailService.addMsgOrderDetail(detail,
-					(payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
-		}
+			int goodsCount, int orderState, Date downTime) {
+		// 鏄惁閫氱煡
+		boolean needNotify = (payMoney != null && payMoney.compareTo(new BigDecimal(0)) > 0) ? true : false;
+		// 淇濆瓨娑堟伅鏄庣粏娑堟伅
+		addOrderStatistics(uid, orderId, orderType, Constant.TYPE_SHAER, goodsCount, payMoney, money, downTime, null, needNotify);
+		
 
-		PushContentDTO dto = PushMsgFactory.createFanLiOrderStatisticed(orderType, orderId, money);
+		PushContentDTO dto = PushMsgFactory.createShareOrderStatisticed(orderType, orderId, money);
 		try {
 			pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
 		} catch (NumberFormatException e) {
@@ -87,31 +70,24 @@
 
 	}
 
-	@Override
-	public void orderShareStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createShareOrder(uid, orderId, orderType, 0, orderState, payMoney,
-				money, null);
-		// 鏆傛椂涓嶆帹閫�
-		// try {
-		// msgOrderDetailService.updateMsgOrderDetail(detail, false);
-		// } catch (MsgOrderDetailException e) {
-		// e.printStackTrace();
-		// }
-
-	}
 
 	@Override
 	public void orderInviteStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int goodsCount, int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, goodsCount, orderState,
-				payMoney, money, null);
-		try {
-			msgOrderDetailService.addMsgOrderDetail(detail,
-					(money == null || money.compareTo(new BigDecimal(0)) <= 0) ? false : true);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
+			BigDecimal subsidy, int goodsCount, int orderState, Date downTime) {
+		BigDecimal totalMoney = new BigDecimal(0);
+		if (money != null) {
+			totalMoney = totalMoney.add(money);
+		} 
+		if (subsidy != null) {
+			totalMoney = totalMoney.add(subsidy);	
 		}
+		
+		if (totalMoney.compareTo(new BigDecimal(0)) <= 0) {
+			return;
+		}
+		
+		// 淇濆瓨娑堟伅鏄庣粏娑堟伅
+		addOrderStatistics(uid, orderId, orderType, Constant.TYPE_INVITE, goodsCount, payMoney, totalMoney, downTime, null, true);
 
 		PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
 		try {
@@ -122,110 +98,67 @@
 			e.printStackTrace();
 		}
 	}
-
-	@Override
-	public void orderInviteStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, 0, orderState,
-				payMoney, money, null);
-		// 鏆傛椂涓嶆帹閫�
-		// try {
-		// msgOrderDetailService.updateMsgOrderDetail(detail, false);
-		// } catch (MsgOrderDetailException e) {
-		// e.printStackTrace();
-		// }
-
-	}
-
-	private String getShortName(String name) {
-		if (name != null && name.length() > 2) {
-			return name.charAt(0) + "**" + name.charAt(name.length() - 1);
-		}
-		return name;
-	}
-
-	@Override
-	public void orderShareFirstLevelStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney,
-			BigDecimal money, int goodsCount, int orderState, String sourceUserName) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, goodsCount, orderState,
-				payMoney, money, String.format("鐢变竴绾ч槦鍛樸��%s銆戝垎浜�", getShortName(sourceUserName)));
+	
+	/**
+	 * 鍒涘缓璁㈠崟琚粺璁℃秷鎭�
+	 * @param uid
+	 * @param orderId 璁㈠崟鍙�
+	 * @param source  璁㈠崟鏉ユ簮锛氭窐瀹濄�佷含涓溿�佸ぉ鐚�
+	 * @param type    璁㈠崟绫诲瀷锛氳嚜璐�佸垎浜�佸洟闃�
+	 * @param goodsCount 鍟嗗搧鏁伴噺
+	 * @param payMoney  浠樻閲戦
+	 * @param money     杩斿埄閲戦
+	 * @param downTime  涓嬪崟鏃堕棿
+	 * @param beiZhu 澶囨敞淇℃伅 - 闈炲繀濉�
+	 * @return
+	 */
+	@Transactional(rollbackFor = Exception.class)
+	private void addOrderStatistics(Long uid, String orderId, int source, int type, int goodsCount,
+		BigDecimal payMoney, BigDecimal money, Date downTime, String beiZhu, boolean needNotify) {
 		try {
-			msgOrderDetailService.addMsgOrderDetail(detail,
-					(money == null || money.compareTo(new BigDecimal(0)) <= 0) ? false : true);
+			MsgOrderDetail detail = MsgOrderDetailFactory.createOrderStatistics(uid, orderId, source, type, goodsCount, payMoney, money, downTime, beiZhu);
+			// 娑堟伅
+			msgOrderDetailService.addMsgOrderDetail(detail, needNotify);
 		} catch (MsgOrderDetailException e) {
 			e.printStackTrace();
 		}
+	}
 
-		PushContentDTO dto = PushMsgFactory.createInviteOrderStatisticed(orderType, orderId, money);
+
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void orderFoundSuccess(Long uid, String orderId, int orderSource, int type, BigDecimal payMoney, BigDecimal money, int goodsCount, Date submitTime) {
 		try {
-			pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
-		} catch (NumberFormatException e) {
-			e.printStackTrace();
-		} catch (PushException e) {
+			MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundSuccess(uid, orderId, orderSource, type, goodsCount, payMoney, money, submitTime, "");
+			// 娑堟伅
+			msgOrderDetailService.addMsgOrderDetail(detail, true);
+		} catch (MsgOrderDetailException e) {
 			e.printStackTrace();
 		}
-
+	
 	}
 
 	@Override
-	public void orderShareFirstLevelStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney,
-			BigDecimal money, int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createInviteOrder(uid, orderId, orderType, 0, orderState,
-				payMoney, money, null);
-		// 鏆傛椂涓嶆帹閫�
-		// try {
-		// msgOrderDetailService.updateMsgOrderDetail(detail, false);
-		// } catch (MsgOrderDetailException e) {
-		// e.printStackTrace();
-		// }
-	}
-
-	@Override
-	public void orderFoundSuccess(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createFoundOrder(uid, orderId, true, payMoney, orderType,
-				happendDate, "濡傛湁鐤戦棶璇疯仈绯讳汉宸ュ鏈�");
+	public void orderFoundFail(Long uid, String orderId) {
 		try {
+			MsgOrderDetail detail = MsgOrderDetailFactory.createOrderFoundFail(uid, orderId, "");
+			// 娑堟伅
 			msgOrderDetailService.addMsgOrderDetail(detail, true);
 		} catch (MsgOrderDetailException e) {
 			e.printStackTrace();
 		}
 	}
 
+	
 	@Override
-	public void orderFoundFail(Long uid, String orderId, BigDecimal payMoney, int orderType, Date happendDate) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createFoundOrder(uid, orderId, false, payMoney, orderType,
-				happendDate, "濡傛湁鐤戦棶璇疯仈绯讳汉宸ュ鏈�");
+	public void orderInvalidToBusinessRunning(Long uid, String orderId, int orderSource, int type) {
 		try {
+			MsgOrderDetail detail = MsgOrderDetailFactory.orderInvalidToBusinessRunning(uid, orderId, orderSource, type);
+			// 娑堟伅
 			msgOrderDetailService.addMsgOrderDetail(detail, true);
 		} catch (MsgOrderDetailException e) {
 			e.printStackTrace();
 		}
 	}
-
-	@Override
-	public void orderElmeStatistic(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
-				money, null);
-		try {
-			msgOrderDetailService.addMsgOrderDetail(detail,
-					(payMoney == null || payMoney.compareTo(new BigDecimal(0)) <= 0) ? false : true);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public void orderElmeStateChanged(Long uid, String orderId, int orderType, BigDecimal payMoney, BigDecimal money,
-			int orderState) {
-		MsgOrderDetail detail = MsgOrderDetailFactory.createElmeOrder(uid, orderId, orderType, orderState, payMoney,
-				money, null);
-		// 鏆傛椂涓嶆帹閫�
-		try {
-			msgOrderDetailService.updateMsgOrderDetail(detail, false);
-		} catch (MsgOrderDetailException e) {
-			e.printStackTrace();
-		}
-	}
-
 }

--
Gitblit v1.8.0