From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 22 一月 2019 15:58:24 +0800
Subject: [PATCH] 邀请码添加返回状态

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 3 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 a5a7035..bd3ac09 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
@@ -32,6 +32,7 @@
 import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.msg.UserInviteMsgNotificationService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
@@ -56,6 +57,9 @@
 
 	@Resource
 	private ThreeSaleMapper threeSaleMapper;
+	
+	@Resource
+	private UserInviteMsgNotificationService userInviteMsgNotificationService;
 
 	public UserInfo getBoss(final long uid) {
 		return (UserInfo) dao.excute(new HibernateCallback<UserInfo>() {
@@ -108,6 +112,11 @@
 			threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
 			threeSale.setWorker(inviteeUser);
 			threeSaleMapper.insertSelective(threeSale);
+			
+			//鍒涘缓閫氱煡
+			userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
+			
+			
 		} else {// 鏄凡缁忓瓨鍦ㄧ殑鐢ㄦ埛
 
 			// 鐢ㄦ埛宸茬粡瀛樺湪鎴戜滑鐨勭敤鎴峰簱涓�
@@ -133,7 +142,7 @@
 						threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
 						threeSale.setWorker(invitee);
 						threeSaleMapper.insertSelective(threeSale);
-
+						userInviteMsgNotificationService.inviteScan(inviter.getId(), threeSale);
 						// threeSaleSerivce.bind(invitee, inviter);
 
 					} else {
@@ -160,6 +169,8 @@
 			dao.update(threeSale);
 			if (inviter != null)
 				reComputeUserRank(inviter.getId());
+			//閫氱煡
+			userInviteMsgNotificationService.inviteSuccess(inviter.getId(), threeSale);
 			// }
 			// });
 		}
@@ -517,10 +528,10 @@
 
 				if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
 					// 鏈勾
-					contentJson.put("content", "鏈�杩戠櫥闄� " + sdf.format(lastLoginTime));
+					contentJson.put("content", "鏈�杩戠櫥褰� " + sdf.format(lastLoginTime));
 				} else {
 					// 寰�骞�
-					contentJson.put("content", "鏈�杩戠櫥闄� " + format.format(lastLoginTime));
+					contentJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime));
 				}
 
 				array.add(contentJson);
@@ -577,5 +588,44 @@
 	public List<ThreeSale> listByWorkerId(Long workerId) {
 		return threeSaleMapper.listByWorkerId(workerId);
 	}
+	
+	
+	@Override
+	public int getSuccessRelationshipNum(Long uid) {
+		return threeSaleMapper.getSuccessRelationshipNum(uid);
+	}
 
+	@Override
+	@Transactional
+	public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
+		
+		if (invitee == null || inviter == null)
+			throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖");
+		
+		// 鑾峰彇鏈夋晥鐨勯個璇峰叧绯�
+		ThreeSale threeSale = 
+				threeSaleMapper.getRelationshipByBossIdAndWorkerId(inviter.getId(), invitee.getId());
+		
+		if (threeSale != null) {
+			// 鏈夋晥鍏崇郴--鐢熸晥
+			threeSale.setState(true);
+			threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
+			threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
+			threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
+			threeSaleMapper.updateByPrimaryKeySelective(threeSale);
+		} else {
+			// 鏂板缓绔嬬‘瀹氬叧绯�
+			threeSale = new ThreeSale();
+			threeSale.setBoss(inviter);
+			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);
+		}
+
+	}
+	
 }

--
Gitblit v1.8.0