Browse Source

修改客户跟进列表

anderx 4 years ago
parent
commit
7a68626dbb

+ 37 - 32
src/main/java/com/goafanti/common/mapper/UserFollowMapper.xml

@@ -59,13 +59,13 @@
       create_time, ocb_id, contact_type, 
       effective, time_stamp, follow_count, 
       guidance, guidance_time, guidance_aid, 
-      guidance_name)
+      guidance_name,follow_name,follow_dep)
     values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, 
       #{paid,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{attachmentUrl,jdbcType=VARCHAR}, 
       #{createTime,jdbcType=TIMESTAMP}, #{ocbId,jdbcType=VARCHAR}, #{contactType,jdbcType=INTEGER}, 
       #{effective,jdbcType=INTEGER}, #{timeStamp,jdbcType=TIMESTAMP}, #{followCount,jdbcType=INTEGER}, 
       #{guidance,jdbcType=VARCHAR}, #{guidanceTime,jdbcType=TIMESTAMP}, #{guidanceAid,jdbcType=VARCHAR}, 
-      #{guidanceName,jdbcType=VARCHAR})
+      #{guidanceName,jdbcType=VARCHAR},#{followName},#{followDep})
   </insert>
   <insert id="insertSelective" parameterType="com.goafanti.common.model.UserFollow">
     <!--
@@ -268,20 +268,23 @@
 
 
 	<select id="userFollowList" resultType="com.goafanti.user.bo.outUserFollowList">
-        select b.nickname,b.share_type shareType ,b.channel,b.id,date_format(b.transfer_time,'%Y-%m-%d %H:%i:%s')startTimes,
-        a.contact_type contactType,c.name followName ,d.name followDep,a.`result` ,a.follow_count followCount,
-        date_format(a.create_time ,'%Y-%m-%d %H:%i:%s')followTimes,a.guidance_name guidanceName,
-        a.guidance ,date_format(a.guidance_time,'%Y-%m-%d %H:%i:%s') guidanceTimes
-      from user_follow a left join `user`b on a.uid =b.id left join admin c on a.aid =c.id
-      left join department d on c.department_id =d.id where 1=1
+      select b.nickname,b.share_type shareType ,b.channel,b.id,date_format(b.transfer_time,'%Y-%m-%d %H:%i:%s')startTimes,
+      a.contact_type contactType,a.follow_name followName ,a.follow_dep followDep,a.`result` ,a.follow_count followCount,
+      date_format(a.create_time ,'%Y-%m-%d %H:%i:%s')followTimes,a.guidance_name guidanceName, a.guidance ,
+      date_format(a.guidance_time,'%Y-%m-%d %H:%i:%s') guidanceTimes
+      from user_follow a left join `user`b on a.uid =b.id
+      where 1=1
       <if test="shiroType == 0">
       and a.aid= #{aid}
       </if>
       <if test="shiroType == 1">
-        and (c.superior_id= #{aid} or  a.aid= #{aid})
+        and aid in
+        <foreach close=")" collection="aids" item="listItem" open="(" separator=",">
+          #{listItem}
+        </foreach>
       </if>
       <if test="followName != null">
-        and c.name  like concat('%',#{followName},'%')
+        and a.follow_name  like concat('%',#{followName},'%')
       </if>
       <if test="userName != null">
 		  and b.nickname like concat('%',#{userName},'%')
@@ -311,7 +314,7 @@
 		and a.guidance_time between #{guidanceStartTime} and #{guidanceEndTime}
 		</if>
         <if test="depId != null">
-            and  c.department_id = #{depId}
+            and a.follow_dep = #{depId}
         </if>
 		order by  a.create_time desc
 		<if test="page_sql != null">
@@ -320,20 +323,22 @@
 	</select>
 	<select id="userFollowCount" resultType="java.lang.Integer">
 		select count(*)
-      from user_follow a left join `user`b on a.uid =b.id left join admin c on a.aid =c.id
-      left join department d on c.department_id =d.id where 1=1
+      from user_follow a left join `user`b on a.uid =b.id where 1=1
       <if test="shiroType == 0">
         and a.aid= #{aid}
       </if>
       <if test="shiroType == 1">
-        and (c.superior_id= #{aid} or  a.aid= #{aid})
+        and aid in
+        <foreach close=")" collection="aids" item="listItem" open="(" separator=",">
+          #{listItem}
+        </foreach>
       </if>
       <if test="followName != null">
-        and c.name  like concat('%',#{followName},'%')
+        and a.follow_name  like concat('%',#{followName},'%')
       </if>
       <if test="userName != null">
-            and b.nickname like concat('%',#{userName},'%')
-        </if>
+        and b.nickname like concat('%',#{userName},'%')
+      </if>
       <if test="userType == 1">
         and b.share_type =0
       </if>
@@ -346,20 +351,20 @@
       <if test="userType == 4">
         and b.share_type =3
       </if>
-        <if test="contactType != null">
-            and a.contact_type = #{contactType}
-        </if>
-        <if test="followStartTime !=null and followEndTime !=null">
-            and a.create_time between #{followStartTime} and #{followEndTime}
-        </if>
-        <if test="createStartTime !=null and createEndTime !=null">
-            and b.transfer_time between #{createStartTime} and #{createEndTime}
-        </if>
-        <if test="guidanceStartTime !=null and guidanceEndTime !=null">
-            and a.guidance_time between #{guidanceStartTime} and #{guidanceEndTime}
-        </if>
-        <if test="depId != null">
-            and  c.department_id = #{depId}
-        </if>
+      <if test="contactType != null">
+        and a.contact_type = #{contactType}
+      </if>
+      <if test="followStartTime !=null and followEndTime !=null">
+        and a.create_time between #{followStartTime} and #{followEndTime}
+      </if>
+      <if test="createStartTime !=null and createEndTime !=null">
+        and b.transfer_time between #{createStartTime} and #{createEndTime}
+      </if>
+      <if test="guidanceStartTime !=null and guidanceEndTime !=null">
+        and a.guidance_time between #{guidanceStartTime} and #{guidanceEndTime}
+      </if>
+      <if test="depId != null">
+        and a.follow_dep = #{depId}
+      </if>
 	</select>
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/common/model/AftUser.java

@@ -12,7 +12,7 @@ public interface AftUser {
 	String getAid();
 
 	String getMobile();
-	
+
 	Integer getType();
 
 }

+ 20 - 0
src/main/java/com/goafanti/common/model/UserFollow.java

@@ -183,6 +183,26 @@ public class UserFollow implements Serializable {
      */
     private String guidanceName;
 
+
+    private String followName;
+    private String followDep;
+
+    public String getFollowName() {
+        return followName;
+    }
+
+    public void setFollowName(String followName) {
+        this.followName = followName;
+    }
+
+    public String getFollowDep() {
+        return followDep;
+    }
+
+    public void setFollowDep(String followDep) {
+        this.followDep = followDep;
+    }
+
     /**
      * This field was generated by MyBatis Generator.
      * This field corresponds to the database table user_follow

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

@@ -15,6 +15,7 @@ import java.util.UUID;
 
 import javax.annotation.Resource;
 
+import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.customer.bo.*;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.beanutils.PropertyUtils;
@@ -631,7 +632,11 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		UserFollow userFollow = new UserFollow();
 		String followId = ufid==null?UUID.randomUUID().toString():ufid;
 		userFollow.setId(followId);
-		userFollow.setAid(TokenManager.getAdminId());
+		String aid=TokenManager.getAdminId();
+		userFollow.setAid(aid);
+		AdminListBo a=adminMapper.getDeptNameByAid(aid);
+		userFollow.setFollowName(a.getName());
+		userFollow.setFollowDep(a.getDepartmentName());
 		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
 		userFollow.setEffective(DeleteStatus.UNDELETE.getCode());
 		try {
@@ -1636,8 +1641,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 				// 如果最近跟进为空直接取转换时间
 				if (StringUtils.isNotBlank(clo.getLastFollowTime())) {
 					// 如果最近跟进小于转换取转换时间
-					if (DateUtils.parseDate(clo.getLastFollowTime(), AFTConstants.YYYYMMDDHHMMSS).getTime() > DateUtils
-							.parseDate(clo.getTransferTime(), AFTConstants.YYYYMMDDHHMMSS).getTime()) {
+					if (StringUtils.isNotBlank(clo.getTransferTime())&&(DateUtils.parseDate(clo.getLastFollowTime(), AFTConstants.YYYYMMDDHHMMSS).getTime() > DateUtils
+							.parseDate(clo.getTransferTime(), AFTConstants.YYYYMMDDHHMMSS).getTime())
+							) {
 						s1 = clo.getLastFollowTime();
 					} else {
 						s1 = clo.getTransferTime();

+ 14 - 1
src/main/java/com/goafanti/user/service/impl/UserFollowServiceImpl.java

@@ -1,5 +1,6 @@
 package com.goafanti.user.service.impl;
 
+import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.UserFollowMapper;
 import com.goafanti.common.utils.excel.NewExcelUtil;
 import com.goafanti.core.mybatis.BaseMybatisDao;
@@ -9,10 +10,12 @@ import com.goafanti.user.bo.InputUserFollowList;
 import com.goafanti.user.bo.outUserFollowList;
 import com.goafanti.user.service.UserFollowService;
 import jdk.nashorn.internal.parser.Token;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.terracotta.offheapstore.HashingMap;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -20,6 +23,8 @@ import java.util.Map;
 @Service
 public class UserFollowServiceImpl extends BaseMybatisDao<UserFollowMapper>  implements UserFollowService {
 
+    @Autowired
+    private AdminMapper adminMapper;
 
 
     @Override
@@ -43,8 +48,16 @@ public class UserFollowServiceImpl extends BaseMybatisDao<UserFollowMapper>  imp
         if (in.getDepId() != null) map.put("depId",in.getDepId());
         if (in.getShiroType()!=null)map.put("shiroType",in.getShiroType());
         else map.put("shiroType",0);
-        if (in.getFollowName() != null )map.put("followName",in.getFollowName());
+        if(in.getShiroType()==0){
         map.put("aid", TokenManager.getAdminId());
+        }else if(in.getShiroType()==1){
+            String aid=TokenManager.getAdminId();
+            List<String> aids=new ArrayList<>();
+            aids=adminMapper.selectBySuperId(aid);
+            aids.add(aid);
+            map.put("aids",aids);
+        }
+        if (in.getFollowName() != null )map.put("followName",in.getFollowName());
         return map;
     }