From 8222e8b237c5dfb0affcdc03335bfadc06403bf8 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 19 七月 2019 15:49:39 +0800
Subject: [PATCH] 奖励券使用优化类型

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java |  105 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 102 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 93cef48..ddbfe9d 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
@@ -8,6 +8,8 @@
 
 import javax.annotation.Resource;
 
+import org.apache.ibatis.annotations.Param;
+import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -15,15 +17,20 @@
 import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
 import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
+import com.yeshi.fanli.entity.bus.user.UserActiveLog;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.exception.ThreeSaleException;
+import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
 import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
 import com.yeshi.fanli.service.inter.msg.UserInviteMsgNotificationService;
+import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
+import com.yeshi.fanli.service.inter.user.UserActiveLogService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.VersionUtil;
 import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
 
 import net.sf.json.JSONArray;
@@ -49,6 +56,17 @@
 
 	@Resource
 	private MsgInviteDetailService msgInviteDetailService;
+	
+	@Resource
+	private UserTaoLiJinOriginService userTaoLiJinOriginService;
+	
+	@Resource
+	private UserActiveLogService userActiveLogService;
+	
+	@Resource(name = "taskExecutor")
+	private TaskExecutor executor;
+	
+	
 
 	public UserInfo getBoss(final long uid) {
 		return threeSaleMapper.selectBoss(uid);
@@ -476,7 +494,7 @@
 
 	@Override
 	@Transactional
-	public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
+	public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter, String platform, String version) throws ThreeSaleException {
 
 		if (invitee == null || inviter == null) 
 			throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖");
@@ -519,11 +537,49 @@
 
 		// 閭�璇锋秷鎭�
 		userInviteMsgNotificationService.inviteSuccess(inviter.getId(), threeSale);
+		
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					UserActiveLog activeLog  = userActiveLogService.getUserLatestActiveInfo(inviter.getId());
+					if (activeLog != null  && !StringUtil.isNullOrEmpty(activeLog.getVersionCode()) ) {
+						String versionCode = activeLog.getVersionCode();
+						String channel = activeLog.getChannel();
+						
+						boolean result = false;
+						// 娓犻亾鏄痑ppstore 鍒ゆ柇涓篒OS
+						if (!StringUtil.isNullOrEmpty(channel) && "appstore".equalsIgnoreCase(channel)) {
+							result = VersionUtil.greaterThan_1_5_60("ios", versionCode);
+						} else {
+							result = VersionUtil.greaterThan_1_5_60("android", versionCode);
+						}
+						
+						if (result) {
+							// 琚個璇峰悕绉�
+							String inviteName= invitee.getNickName();
+							if (StringUtil.isNullOrEmpty(inviteName)) {
+								UserInfo userInfo = userInfoService.selectByPKey(invitee.getId());
+								if (userInfo != null) {
+									inviteName= userInfo.getNickName();
+								}
+							}
+							// 濂栧姳閭�璇风孩鍖咃紙娣樼ぜ閲戯級
+							userTaoLiJinOriginService.addInviteWinMoney(inviter.getId(), inviteName);
+						}
+					}
+				} catch (Exception e) {
+					LogHelper.errorDetailInfo(e);
+				}
+			}
+		});
+		
+		
 	}
 
 	@Override
 	@Transactional
-	public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) throws ThreeSaleException {
+	public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld, String platform, String version) throws ThreeSaleException {
 
 		if (invitee == null || (inviterId == null && threeSaleOld == null))
 			throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖");
@@ -567,11 +623,48 @@
 		UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
 		threeSale.setBoss(boss);
 		
-		
 		// 娣诲姞鍒伴槦鍒�
 		ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
+	
 		// 閭�璇锋秷鎭�
 		userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
+		
+		
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					UserActiveLog activeLog  = userActiveLogService.getUserLatestActiveInfo(inviterId);
+					if (activeLog != null  && !StringUtil.isNullOrEmpty(activeLog.getVersionCode()) ) {
+						boolean result = false;
+						String versionCode = activeLog.getVersionCode();
+						String channel = activeLog.getChannel();
+						
+						// 娓犻亾鏄痑ppstore 鍒ゆ柇涓篒OS
+						if (!StringUtil.isNullOrEmpty(channel) && "appstore".equalsIgnoreCase(channel)) {
+							result = VersionUtil.greaterThan_1_5_60("ios", versionCode);
+						} else {
+							result = VersionUtil.greaterThan_1_5_60("android", versionCode);
+						}
+						
+						if (result) {
+							// 琚個璇峰悕绉�
+							String inviteName= invitee.getNickName();
+							if (StringUtil.isNullOrEmpty(inviteName)) {
+								UserInfo userInfo = userInfoService.selectByPKey(invitee.getId());
+								if (userInfo != null) {
+									inviteName= userInfo.getNickName();
+								}
+							}
+							// 濂栧姳閭�璇风孩鍖咃紙娣樼ぜ閲戯級
+							userTaoLiJinOriginService.addInviteWinMoney(inviterId, inviteName);
+						}
+					}
+				} catch (Exception e) {
+					LogHelper.errorDetailInfo(e);
+				}
+			}
+		});
 	}
 	
 	/**
@@ -595,5 +688,11 @@
 	public ThreeSale selectByWorkerId(Long workerId) {
 		return threeSaleMapper.selectSuccessByWorkerId(workerId);
 	}
+	
+	
+	@Override
+	public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime){
+		return threeSaleMapper.getSuccessByDate(bossId, minTime, maxTime);
+	}
 
 }

--
Gitblit v1.8.0