Explorar o código

修复客户跟进

anderx %!s(int64=6) %!d(string=hai) anos
pai
achega
6a48c7fab2

+ 7 - 0
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -3,10 +3,13 @@ package com.goafanti.admin.service;
 import java.util.List;
 import java.util.Map;
 
+import com.goafanti.admin.bo.AdminCustomerBo;
+import com.goafanti.admin.bo.AdminCustomerDetailBo;
 import com.goafanti.admin.bo.AdminDetail;
 import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.common.model.Admin;
 import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.customer.controller.AdminCustomerApiController;
 
 public interface AdminService {
 
@@ -76,4 +79,8 @@ public interface AdminService {
 	Pagination<AdminListBo>  frequentContactsList(String depId, String name, String roleName, Integer pageSize, Integer pageNo);
 
 	int deleteFrequentContacts(String id);
+
+	Pagination<AdminCustomerBo> selectAdminCustomerStatistics(String depId, String startTime, String endTime, Integer pageSize, Integer pageNo);
+
+	Pagination<AdminCustomerDetailBo> selectAdminCustomerList(String aid, String startTime, String endTime, Integer pageSize, Integer pageNo);
 }

+ 27 - 0
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.admin.bo.AdminContacts;
+import com.goafanti.admin.bo.AdminCustomerBo;
+import com.goafanti.admin.bo.AdminCustomerDetailBo;
 import com.goafanti.admin.bo.AdminDetail;
 import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.admin.service.AdminService;
@@ -356,4 +358,29 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		return adminMapper.deleteFrequentContacts(id);
 	}
 
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<AdminCustomerBo> selectAdminCustomerStatistics(String depId, String startTime, String endTime, Integer pageSize, Integer pageNo) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		if(pageSize==null||pageSize<0)pageSize=10;
+		if(pageNo==null||pageNo<0)pageNo=1;
+		if (StringUtils.isNotBlank(depId)) params.put("depId", depId);
+		if (StringUtils.isNotBlank(startTime)) params.put("startTime", startTime);
+		if (StringUtils.isNotBlank(endTime)) params.put("endTime", endTime+" 23:59:59");
+		return (Pagination<AdminCustomerBo>)findPage("selectAdminCustomerList", "selectAdminCustomerCount", params, pageNo, pageSize); 
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<AdminCustomerDetailBo> selectAdminCustomerList(String aid, String startTime, String endTime,
+			Integer pageSize, Integer pageNo) {
+		Map<String, Object> params = new HashMap<String, Object>();
+		if(pageSize==null||pageSize<0)pageSize=10;
+		if(pageNo==null||pageNo<0)pageNo=1;
+		if (StringUtils.isNotBlank(aid)) params.put("aid", aid);
+		if (StringUtils.isNotBlank(startTime)) params.put("startTime", startTime);
+		if (StringUtils.isNotBlank(endTime)) params.put("endTime", endTime+" 23:59:59");
+		return (Pagination<AdminCustomerDetailBo>)findPage("selectAdminCustomerDetailList", "selectAdminCustomerDetailCount", params, pageNo, pageSize);
+	}
+
 }

+ 74 - 0
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -1049,4 +1049,78 @@
   select b.id from admin_contacts a left join admin b on a.contacts_id = b.id 
      where b.status = '正常' and a.aid= #{id,jdbcType=VARCHAR}
   </select>
+  
+  
+   <select id="selectAdminCustomerList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminCustomerBo">
+  	select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.timeCount,0) as timeCount from admin a 
+	left join (select aid,count(aid) as userCount from user where aid is not null  
+	and  share_type=0 and source !=0
+	group by aid) b on a.id=b.aid
+	left join (select aid,count(aid) as timeCount from user where aid is not null  
+	and  share_type=0 and source=1
+	 <if test="startTime != null and endTime != null"> 
+    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+    </if>
+	group by aid) c on a.id=c.aid
+	left join department d on a.department_id=d.id
+	where a.status='正常'
+	and b.userCount !=0
+	<if test="depId != null"> 
+    and a.department_id =  #{depId,jdbcType=VARCHAR}
+    </if>
+   <if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  
+  <select id="selectAdminCustomerCount" parameterType="java.lang.String" resultType="java.lang.Integer">
+  select count(*) from admin a 
+	left join (select aid,count(aid) as userCount from user where aid is not null  
+	and  share_type=0 and source !=0
+	group by aid) b on a.id=b.aid
+	left join (select aid,count(aid) as timeCount from user where aid is not null  
+	and  share_type=0 and source=1
+	 <if test="startTime != null and endTime != null"> 
+    and  create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+    </if>
+	group by aid) c on a.id=c.aid
+	where a.status='正常'
+	and b.userCount !=0
+	<if test="depId != null"> 
+    and a.department_id =  #{depId,jdbcType=VARCHAR}
+    </if>
+  </select>
+  
+   <select id="selectAdminCustomerDetailList" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
+  	select a.id,a.nickname as name,c.contacts,c.contact_mobile as contactMobile,
+	a.create_time as createTime,b.time_stamp as followTime
+	from user a 
+	left join (select uid,max(time_stamp) as time_stamp from user_follow group by uid) b  on a.id=b.uid
+	left join organization_identity c on a.id=c.uid
+	where a.aid is not null
+	<if test="aid != null"> 
+	and a.aid=  #{aid,jdbcType=VARCHAR}
+    </if>
+	and  a.share_type=0 and a.source=1
+	<if test="startTime != null and endTime != null">
+	 and  a.create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR} 
+    </if>
+   <if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  
+  <select id="selectAdminCustomerDetailCount" parameterType="java.lang.String" resultType="java.lang.Integer">
+  	select count(*) from user a 
+	left join (select uid,max(time_stamp) as time_stamp from user_follow group by uid) b  on a.id=b.uid
+	left join organization_identity c on a.id=c.uid
+	where a.aid is not null
+	<if test="aid != null"> 
+	and a.aid=  #{aid,jdbcType=VARCHAR}
+    </if>
+	and  a.share_type=0 and a.source=1
+	<if test="startTime != null and endTime != null">
+	 and  a.create_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR} 
+    </if>
+  </select>
 </mapper>

+ 30 - 0
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -1073,6 +1073,36 @@ public class AdminCustomerApiController extends BaseApiController{
 		}
 		return res;
 	}
+	/**
+	 * 查看营销员客户统计
+	 * @param depId
+	 * @param startTime
+	 * @param endTime
+	 * @param pageSize
+	 * @param pageNo
+	 * @return
+	 */
+	@RequestMapping(value = "/selectAdminCustomerStatistics", method = RequestMethod.GET)
+	public Result selectAdminCustomerstatistics(String depId, String startTime,String endTime, Integer pageSize, Integer pageNo) {
+		Result res = new Result();
+		res.data(adminService.selectAdminCustomerStatistics( depId,  startTime, endTime,  pageSize,  pageNo));
+		return res;
+	}
+	/**
+	 * 查看客户日期内新增客户
+	 * @param depId
+	 * @param startTime
+	 * @param endTime
+	 * @param pageSize
+	 * @param pageNo
+	 * @return
+	 */
+	@RequestMapping(value = "/selectAdminCustomerList", method = RequestMethod.GET)
+	public Result selectAdminCustomerList(String aid, String startTime,String endTime, Integer pageSize, Integer pageNo) {
+		Result res = new Result();
+		res.data(adminService.selectAdminCustomerList( aid,  startTime, endTime,  pageSize,  pageNo));
+		return res;
+	}
 	
 }
 

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

@@ -493,6 +493,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 				ufbId = UUID.randomUUID().toString();
 				businessName = businessProjectMapper.selectByPrimaryKey(ub.getBusinessProjectId()).getBname();
 				UserBusiness us=userBusinessMapper.selectByPrimaryKey(ub.getBusinessId());
+				//sas
 				if(StringUtils.isNotBlank(ub.getBusinessId())){
 					//更新业务表
 					userBusiness.setId(ub.getBusinessId());
@@ -551,7 +552,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 						}
 						if(!isBusinessOwner) throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_LOCKED,businessName,""));
 					}else{ 
-						if(!isUserOwner) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_LOCKED,businessName,""));
+						if(isUserOwner) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_LOCKED,businessName,""));
 					}
 					
 					if(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){