From 01407e36f8a1d46e065cdcfe14629540dbd6b921 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 04 十一月 2019 09:41:37 +0800
Subject: [PATCH] 红包

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java |   48 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
index c17cb30..31d1d4a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -31,6 +31,8 @@
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
+import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
 import com.yeshi.fanli.util.factory.RedPackDetailFactory;
 import com.yeshi.fanli.vo.order.CommonOrderVO;
 
@@ -76,8 +78,10 @@
 		return redPackWinInviteMapper.countRewardRecord(uid);
 	}
 	
-	@Override
+	@RedPackGetVersionLimit(uid = "#uid")
+	@RequestSerializableByKeyService(key = "#uid")
 	@Transactional(rollbackFor = Exception.class)
+	@Override
 	public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
 		if (uid == null || source == null || orderNo == null)
 			return;
@@ -86,10 +90,26 @@
 		UserInfo boss = threeSaleSerivce.getBoss(uid);
 		if(boss != null) {
 			firstReward(uid, source, orderNo);
-			firstSharedOrderRewardToBoss(boss.getId(), uid, source, orderNo);
-			firstSharedOrderRewardTheMonthToBoss(boss.getId(), uid, source, orderNo);
+			bossReward(boss.getId(), uid, source, orderNo);
 		}
 	}
+	
+	
+	/**
+	 * 涓婄骇濂栧姳
+	 * @param uid
+	 * @param teamUid
+	 * @param source
+	 * @param orderNo
+	 * @throws Exception
+	 */
+	@RedPackGetVersionLimit(uid = "#uid")
+	@Transactional
+	private void  bossReward(Long uid, Long teamUid, Integer source, String orderNo)  throws Exception {
+		firstSharedOrderRewardToBoss(uid, teamUid, source, orderNo);
+		firstSharedOrderRewardTheMonthToBoss(uid, teamUid, source, orderNo);
+	}
+	
 	
 	/**
 	 * 琚個璇蜂汉涓嬮鍗曡繑鍒╋紙涓嬪崟灏辩粰锛夛細
@@ -103,12 +123,12 @@
 	private void firstReward(Long uid, Integer source, String orderNo) throws Exception{
 		// 濂栧姳涓�娆�
 		long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.newUserReward.name());
-		if (total > 1)
+		if (total > 0)
 			return;
 		
 		// 1銆佸垽鏂槸鍚︾敤鎴烽涓鍗�
 		CommonOrderVO order = commonOrderService.firstValidOrderByUid(uid);
-		if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo())) 
+		if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo())) 
 			return;
 		
 		// 閲戦
@@ -149,16 +169,17 @@
 	private void firstSharedOrderRewardToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
 		// 鍚屼竴闃熷憳濂栧姳涓�娆�
 		long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(uid, inviteeUid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
-		if (totalReward > 1)
+		if (totalReward > 0)
 			return;
 		
 		// 1銆佸垽鏂槸鍚︽槸鏀圭敤鎴烽涓垎浜鍗�
 		CommonOrderVO order = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
-		if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo())) 
+		if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo())) 
 			return;
 		
 		// 2銆佸垽鏂槸绗嚑涓汉
 		long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
+		
 		
 		// 璁$畻搴斿鍔犵孩鍖呴噾棰�
 		BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("first_shared_order"));
@@ -201,9 +222,9 @@
 	 */
 	@Transactional
 	private void firstSharedOrderRewardTheMonthToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
-		// 1銆佸垽鏂槸鍚︽槸鏈湀棣栧崟
-		CommonOrderVO order = commonOrderService.firstValidOrderTheMonthByUidAndType(inviteeUid, 2);
-		if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()) ||
+		// 1銆佸垽鏂槸鍚︽槸涓婁釜鏈堥鍗�
+		CommonOrderVO order = commonOrderService.firstValidOrderLastMonthByUidAndType(inviteeUid, 2);
+		if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo()) ||
 				order.getAccountTime() == null) 
 			return;
 		
@@ -251,9 +272,10 @@
 	}
 	
 	
-
+	@RequestSerializableByKeyService(key = "#uid")
+	@Override
 	@Transactional
-	private void inviteSucceedReward(Long uid) throws Exception{
+	public void inviteSucceedReward(Long uid) throws Exception{
 		// 楠岃瘉鏄惁瀛樺湪涓婄骇
 		UserInfo boss = threeSaleSerivce.getBoss(uid);
 		if(boss == null) 
@@ -261,7 +283,7 @@
 		
 		// 鍚屼竴闃熷憳濂栧姳涓�娆�
 		long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
-		if (totalReward > 1)
+		if (totalReward > 0)
 			return;
 		
 		// 1銆佺粦瀹氱數璇濆彿鐮�

--
Gitblit v1.8.0