anderx лет назад: 4
Родитель
Сommit
b0a53e8119

+ 2 - 2
src/main/java/com/goafanti/common/dao/UserLockReleaseMapper.java

@@ -137,7 +137,7 @@ public interface UserLockReleaseMapper {
 
 	void updateByAidAndUid(@Param("aid")String aid, @Param("uid")String uid);
 
-	List<userDaysBo> selectChannelUserDays(Integer z);
+	List<userDaysBo> selectChannelUserDays(@Param("days")Integer days, @Param("aid")String aid);
 
 	List<String> selectByids(List<String> uids);
 
@@ -145,7 +145,7 @@ public interface UserLockReleaseMapper {
 
 	void updateChannelList(@Param("list")List<String> list);
 
-	List<userDaysBo> selectChannelNotFollow(Integer days);
+	List<userDaysBo> selectChannelNotFollow(@Param("days")Integer days, @Param("aid")String aid);
 
 
 }

+ 9 - 8
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -465,21 +465,22 @@
   
     <select id="selectChannelUserDays" resultType="com.goafanti.common.bo.userDaysBo">
 	select  t0.uid, t0.aid, u.nickname name,c.recovery 
-	from `user` u
-	inner join (select id,uid,aid,lock_time from user_lock_release where type = 0 and status = 0 group by aid,uid)t0 on t0.uid=u.id
+	from (select id,uid,aid,lock_time from user_lock_release where type = 0 and status = 0  and aid='1' )t0
+	left join user  u on t0.uid=u.id
 	left join user_channel c on u.id=c.uid
 	where u.channel =1 and c.status &lt; 3
 	and datediff(now(),t0.lock_time) &gt; #{days}
   </select>
   
   <select id="selectChannelNotFollow" resultType="com.goafanti.common.bo.userDaysBo">
-  	 select  t0.uid, t0.aid, u.nickname name ,u.channel
-	from `user` u
-	inner join (select id,uid,aid,lock_time from user_lock_release where type = 0 and status = 0 group by aid,uid)t0 on t0.uid=u.id
+  	   select  t0.uid, t0.aid, u.nickname name ,u.channel 
+	from
+		(select id,uid,aid,lock_time from user_lock_release where aid = #{aid} and type = 0 and status = 0)t0
 	left join 
-		(select uid,aid,max(create_time) as last_follow_time from user_follow  group by aid,uid)t1
-	on t0.uid = t1.uid  and t0.aid=t1.aid
-	where 1=1 
+		(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
+	on t0.uid = t1.uid 
+	left join user u on t0.uid=u.id
+	where 1=1
 	and datediff(now(),if(t0.lock_time &lt; t1.last_follow_time,t1.last_follow_time,t1.t0.lock_time)) &gt; #{days} 
   </select>
   

+ 42 - 32
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -16,7 +16,6 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import com.goafanti.admin.bo.NoticeBo;
 import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.bo.userDaysBo;
 import com.goafanti.common.constant.AFTConstants;
@@ -65,37 +64,39 @@ public class ReleaseUserTask {
 	private void pushUserDays() throws InterruptedException {
 		LoggerUtils.debug(getClass(), "==============客户提醒开始============");
 		List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
-		List<userDaysBo> count = new ArrayList<>();
 		List<userDaysBo> userTmpList = null;
+		List<Notice> ln = new ArrayList<>();
 		for (User u : userList) {
 			if (StringUtils.isNotBlank(u.getId())) {
-				userTmpList = customerService.selectUserDays(u.getId());
+				userTmpList = customerService.selectReleaseUserDays(u.getId());
 			}
-			if (!userTmpList.isEmpty())
-				count.addAll(userTmpList);
-		}
-		List<Notice> ln = new ArrayList<>();
-		for (userDaysBo ub : count) {
-			String str=null;  
-			if (ub.getChannel() == 0) {
-				str = String.format("您的%s客户【%s】剩余天数不足十五天,请及时跟进或者限时签单!", "私有", ub.getName());
-			}else {
-				str = String.format("您的%s客户【%s】剩余天数不足十五天,请及时跟进或者限时签单!", "渠道", ub.getName());
+			for (userDaysBo ub : userTmpList) {
+				String str=null;  
+				if (ub.getChannel() == 0) {
+					str = String.format("您的%s客户【%s】剩余天数不足十五天,请及时跟进或者限时签单!", "私有", ub.getName());
+				}else {
+					str = String.format("您的%s客户【%s】剩余天数不足十五天,请及时跟进或者限时签单!", "渠道", ub.getName());
+				}
+				ln.add(new Notice(UUID.randomUUID().toString(), new Date(), 0, ub.getAid(),
+						NoticeStatus.CUSTOMER_LOSE_REMINDER.getCode(), str,ub.getUid()));
 			}
-			ln.add(new Notice(UUID.randomUUID().toString(), new Date(), 0, ub.getAid(),
-					NoticeStatus.CUSTOMER_LOSE_REMINDER.getCode(), str,ub.getUid()));
 		}
 		//查询15天未跟进
-		List<userDaysBo> userChannelList = customerService.selectChannelNotFollow();
-		for (userDaysBo ub : userChannelList) {
-			String str=null;  
-			if (ub.getChannel() == 0) {
-				str = String.format("您的%s客户【%s】已经十五天未跟进,请及时跟进或者限时签单!", "私有", ub.getName());
-			}else {
-				str = String.format("您的%s客户【%s】已经十五天未跟进,请及时跟进或者限时签单!", "渠道", ub.getName());
+		List<userDaysBo> userChannelList = new ArrayList<userDaysBo>();
+		for (User u : userList) {
+			if (StringUtils.isNotBlank(u.getId())) {
+				userChannelList = customerService.selectChannelNotFollow(u.getId());
+			}
+			for (userDaysBo ub : userChannelList) {
+				String str=null;  
+				if (ub.getChannel() == 0) {
+					str = String.format("您的%s客户【%s】已经十五天未跟进,请及时跟进或者限时签单!", "私有", ub.getName());
+				}else {
+					str = String.format("您的%s客户【%s】已经十五天未跟进,请及时跟进或者限时签单!", "渠道", ub.getName());
+				}
+				ln.add(new Notice(UUID.randomUUID().toString(), new Date(), 0, ub.getAid(),
+						NoticeStatus.CUSTOMER_PRIVATE_REMINDER.getCode(), str,ub.getUid()));
 			}
-			ln.add(new Notice(UUID.randomUUID().toString(), new Date(), 0, ub.getAid(),
-					NoticeStatus.CUSTOMER_PRIVATE_REMINDER.getCode(), str,ub.getUid()));
 		}
 		List<Notice> newList = new ArrayList<>();
 		if (ln != null && ln.size() > 0) {
@@ -124,7 +125,6 @@ public class ReleaseUserTask {
 			List<LockingReleaseBo> lockUserList = new ArrayList<LockingReleaseBo>();
 			List<LockingReleaseBo> userTmpList = null;
 			List<LockingReleaseBo> userTmpList2 = null;
-			List<Notice> ln = new ArrayList<>();
 			if (userList != null && !userList.isEmpty()) {
 				for (User u : userList) {
 					if (StringUtils.isNotBlank(u.getId())) {
@@ -132,6 +132,7 @@ public class ReleaseUserTask {
 						userTmpList = customerService.selectWaitReleaseCustomer(u.getId(), 0);
 						// 获取270天释放
 						userTmpList2 = customerService.selectWaitReleaseCustomer(u.getId(), 1);
+						//
 						customerService.pushReleaseLog(userTmpList, 0);
 						customerService.pushReleaseLog(userTmpList2, 1);
 						if (userTmpList != null && !userTmpList.isEmpty())
@@ -155,18 +156,27 @@ public class ReleaseUserTask {
 				}
 			}
 			// 获取超过90天客户,判断是否回收过,未回收则回收,已回收则释放为公共客户
-			List<userDaysBo> userChannelList = customerService.selectChannelUserDays();
+			List<userDaysBo> userChannelList =null;
+			List<userDaysBo> count =new ArrayList<userDaysBo>();
+			if (userList != null && !userList.isEmpty()) {
+				for (User u : userList) {
+					userChannelList=customerService.selectChannelUserDays(u.getId());
+					if (userChannelList!=null) {
+						count.addAll(userChannelList);
+					}
+				}
+			}
 			List<userDaysBo> hsList=new ArrayList<>();
 			List<userDaysBo> sfList=new ArrayList<>();
-			if (userChannelList != null && userChannelList.size() > 0) {
-				for (int i = 0; i < userChannelList.size(); i++) {
+			if (count != null && count.size() > 0) {
+				for (int i = 0; i < count.size(); i++) {
 					//回收
-					if (userChannelList.get(i).getRecovery()==0) {
-						hsList.add(userChannelList.get(i));
+					if (count.get(i).getRecovery()==0) {
+						hsList.add(count.get(i));
 					}else {
-						sfList.add(userChannelList.get(i));
+						sfList.add(count.get(i));
 					}
-					if (pointsDataLimit == (hsList.size()+sfList.size()) || i == userChannelList.size() - 1) {
+					if (pointsDataLimit == (hsList.size()+sfList.size()) || i == count.size() - 1) {
 						if(!hsList.isEmpty())userService.pushReleaseUserChannel(hsList,0);
 						if(!sfList.isEmpty())userService.pushReleaseUserChannel(sfList,1);
 						addChannelNotice(hsList,sfList);

+ 8 - 3
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -515,9 +515,14 @@ public interface CustomerService {
 	List<transferListBo> transferList(String uid);
 	int updatePrivateBusinessTransfer(String inputId, String uid, String pid);
 	int pushReleaseUser(String id);
-	List<userDaysBo> selectUserDays(String id);
+	/**
+	 * 
+	 * @param id
+	 * @return
+	 */
+	List<userDaysBo> selectReleaseUserDays(String id);
 
-	List<userDaysBo> selectChannelUserDays();
+	List<userDaysBo> selectChannelUserDays(String id);
 	
 	int addGuidance(String followId, String guidance);
 	/**
@@ -551,6 +556,6 @@ public interface CustomerService {
 	boolean checkChannel(List<String> uids);
 	boolean checkBeforeChannel(String uid);
 	boolean checkRecovery(List<String> uids);
-	List<userDaysBo> selectChannelNotFollow();
+	List<userDaysBo> selectChannelNotFollow(String string);
 	Object listChannelCounts(InputChannelCounts in);
 }

+ 5 - 5
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -1988,7 +1988,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public List<userDaysBo> selectUserDays(String id) {
+	public List<userDaysBo> selectReleaseUserDays(String id) {
 		Integer x = 30, y = 270;
 		x = x - USER_REMIND_DAYS;
 		y = y - USER_REMIND_DAYS;
@@ -1997,9 +1997,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public List<userDaysBo> selectChannelUserDays() {
+	public List<userDaysBo> selectChannelUserDays(String id) {
 		Integer days = 90;
-		return userLockReleaseMapper.selectChannelUserDays(days);
+		return userLockReleaseMapper.selectChannelUserDays(days,id);
 	}
 
 	@Override
@@ -2184,9 +2184,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public List<userDaysBo> selectChannelNotFollow() {
+	public List<userDaysBo> selectChannelNotFollow(String aid) {
 		Integer days = 15;
-		return userLockReleaseMapper.selectChannelNotFollow(days);
+		return userLockReleaseMapper.selectChannelNotFollow(days,aid);
 	}
 
 	@Override