From 1da17d215d48e3e3aa9e8d7a3ef526904764f408 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 08 四月 2019 14:06:12 +0800
Subject: [PATCH] 1.5.3部分需求 提交

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java |   82 +++++++++++++++++++++++++++++++++-------
 1 files changed, 67 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
index 484b790..7a0ba10 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -297,20 +297,12 @@
 		return threeSaleMapper.countSuperiorQuery(state, uid);
 	}
 
-	@Override
-	public List<ThreeSale> listFirstTeam(long start, int count, Long uid) {
-		return threeSaleMapper.listFirstTeam(start, count, uid);
-	}
 
 	@Override
 	public long countFirstTeam(Long uid, Integer state) {
 		return threeSaleMapper.countFirstTeam(uid, state);
 	}
 
-	@Override
-	public List<ThreeSale> listSecondTeam(long start, int count, Long uid) {
-		return threeSaleMapper.listSecondTeam(start, count, uid);
-	}
 
 	@Override
 	public long countSecondTeam(Long uid, Integer state) {
@@ -333,9 +325,9 @@
 	}
 
 	@Override
-	public JSONObject getMyFirstTeam(long start, int count, Long uid) {
+	public JSONObject getMyFirstTeam(long start, int count, Long uid, Integer state) {
 
-		List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid);
+		List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, state);
 		if (list == null) {
 			list = new ArrayList<ThreeSale>();
 		}
@@ -346,8 +338,8 @@
 	}
 
 	@Override
-	public JSONObject getMySecondTeam(long start, int count, Long uid) {
-		List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid);
+	public JSONObject getMySecondTeam(long start, int count, Long uid, Integer state) {
+		List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, state);
 		if (list == null) {
 			list = new ArrayList<ThreeSale>();
 		}
@@ -486,9 +478,9 @@
 	@Transactional
 	public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
 
-		if (invitee == null || inviter == null)
+		if (invitee == null || inviter == null) 
 			throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖");
-
+		
 		// 鑾峰彇鏈夋晥鐨勯個璇峰叧绯�
 		ThreeSale threeSale = threeSaleMapper.getRelationshipByBossIdAndWorkerId(inviter.getId(), invitee.getId());
 
@@ -510,7 +502,6 @@
 			threeSale.setCreateTime(java.lang.System.currentTimeMillis());
 			threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
 			threeSaleMapper.insertSelective(threeSale);
-
 		}
 
 		List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), invitee.getId());
@@ -531,6 +522,67 @@
 	}
 
 	@Override
+	@Transactional
+	public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) throws ThreeSaleException {
+
+		if (invitee == null || (inviterId == null && threeSaleOld == null))
+			throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖");
+		
+		ThreeSale threeSale = null;
+		if (inviterId != null ) {
+			// 鏂板缓绔嬬‘瀹氬叧绯�
+			threeSale  = new ThreeSale();
+			threeSale.setBoss(new UserInfo(inviterId));
+			threeSale.setWorker(invitee);
+			threeSale.setState(true);
+			threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
+			threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
+			threeSale.setCreateTime(java.lang.System.currentTimeMillis());
+			threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
+			threeSaleMapper.insertSelective(threeSale);
+			
+			// 閭�璇峰叧绯诲け鏁�  1.5.3 涔嬪墠澶辨晥
+			if (threeSaleOld != null) {
+				ThreeSale three  = new ThreeSale();
+				three.setId(threeSaleOld.getId());
+				three.setExpire(ThreeSale.EXPIRE_OUTOFDATE);
+				three.setUpdateTime(java.lang.System.currentTimeMillis());
+				threeSaleMapper.updateByPrimaryKeySelective(three);
+			}
+		} else if (threeSaleOld != null && inviterId == null) {
+			// 1.5.3 涔嬪墠鐢熸晥
+			threeSaleOld.setState(true);
+			threeSaleOld.setExpire(ThreeSale.EXPIRE_NORMAL);
+			threeSaleOld.setSucceedTime(java.lang.System.currentTimeMillis());
+			threeSaleOld.setUpdateTime(java.lang.System.currentTimeMillis());
+			threeSaleMapper.updateByPrimaryKeySelective(threeSaleOld);
+			
+			threeSale = threeSaleOld;
+		}
+
+		if (threeSale == null) {
+			throw new ThreeSaleException(1, "鍏崇郴缁戝畾澶辫触");
+		}
+		
+		// 娣诲姞鍒伴槦鍒�
+		ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
+		// 閭�璇锋秷鎭�
+		userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
+	}
+	
+	/**
+	 * 鏍规嵁閭�璇疯�呮煡璇㈠叧绯�
+	 * 
+	 * @param workerId
+	 * @return
+	 */
+	@Override
+	public ThreeSale getByWorkerId(Long workerId) {
+		return threeSaleMapper.getByWorkerId(workerId);
+	}
+	
+	
+	@Override
 	public long countSuccessFirstTeam(Long uid) {
 		return threeSaleMapper.countFirstTeam(uid, 1);
 	}

--
Gitblit v1.8.0