Browse Source

修改签单客户查询

wanghui 7 years ago
parent
commit
6bda96bf3c

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

@@ -76,11 +76,13 @@ public interface UserBusinessMapper {
 	 */
 	int updateByPrimaryKey(UserBusiness record);
 
-	List<BusinessListBo> findBusinessGlossory();
+	List<BusinessListBo> selectBusinessGlossory();
 
 	int judgeBusiness(@Param("uid")String uid,@Param("businessProjectId")String businessProjectId,@Param("aid")String aid);
 
-	List<BusinessListBo> findBusinessByUAid(@Param("uid")String uid, @Param("aid")String aid);
+	List<BusinessListBo> selectBusinessByUAid(@Param("uid")String uid, @Param("aid")String aid);
+	
+	List<BusinessListBo> selectLockedBusinessByUAid(@Param("uid")String uid, @Param("aid")String aid);
 
 	BussinessFollowBo findBusinessDetail(@Param("businessId")String businessId);
 

+ 23 - 3
src/main/java/com/goafanti/common/mapper/UserBusinessMapper.xml

@@ -349,7 +349,7 @@
     where id = #{id,jdbcType=VARCHAR}
   </update>
   
-  <select id="findBusinessGlossory" resultType="com.goafanti.customer.bo.BusinessListBo">
+  <select id="selectBusinessGlossory" resultType="com.goafanti.customer.bo.BusinessListBo">
   	select id as businessGlossoryId,name as businessName from business_glossory
   </select>
   
@@ -364,7 +364,7 @@
   	 </if>
   </select>
  
-  <select id="findBusinessByUAid" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
+  <select id="selectBusinessByUAid" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
 	select 
 		a.id as businessId,
 		a.uid,
@@ -377,7 +377,27 @@
 	from user_business a
 	left join business_project b on a.business_project_id = b.id
 	left join business_varieties c on b.cid = c.id
-	where  uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR} and  customer_status != 6
+	where  a.uid = #{uid,jdbcType=VARCHAR} and a.aid = #{aid,jdbcType=VARCHAR} and  a.customer_status != 6
+  </select>
+  
+  <select id="selectLockedBusinessByUAid" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
+	select x.* from(
+		select 
+			a.id as businessId,
+			a.uid,
+			a.business_project_id as businessProjectId,
+			a.follow_situation as followSituation,
+			a.customer_status as customerStatus,
+			a.remarks,
+			b.bname as businessProjectName,
+			c.cname as businessvarietiesName
+		from user_business a
+		left join business_project b on a.business_project_id = b.id
+		left join business_varieties c on b.cid = c.id
+		where  a.uid = '1' and a.aid = '1' and  a.customer_status != 6
+	)x right join(
+		select business_project_id from user_lock_release where uid = '1' and aid = '1' and type = 1 and status = 0
+	)y on x.businessProjectId = y.business_project_id
   </select>
   
   <select id="selectFollowCountByUAid" parameterType="java.lang.String" resultType="java.lang.Integer">

+ 7 - 25
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -103,9 +103,6 @@
 		left join district_glossory dg3 on b.area = dg3.id
 		left join industry_category c on b.industry = c.id
 		left join admin d on t0.aid = d.id where 1=1
-		<if test="aid != null and aid !=''">
-			and t0.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t0.identify_name like concat('%',#{name},'%')
 		</if>
@@ -134,9 +131,6 @@
 		from 
 			(select id,aid,type,share_type,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
 		left join user_identity b on t0.id = b.uid where 1=1
-		<if test="aid != null and aid !=''">
-			and t0.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t0.identify_name like concat('%',#{name},'%')
 		</if>	
@@ -249,7 +243,7 @@
 			c.name as industry,
 			d.name as adminName
 		from
-			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and delete_sign != 1 group by buyer_id)t0
+			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and order_status = 3 and delete_sign != 1 group by buyer_id)t0
 			<!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
 		left join 
 			(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
@@ -263,9 +257,6 @@
 		left join district_glossory dg3 on b.area = dg3.id
 		left join industry_category c on b.industry = c.id
 		left join admin d on t2.aid = d.id
-		<if test="aid != null and aid !=''">
-			and t2.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t2.identify_name like concat('%',#{name},'%')
 		</if>
@@ -295,15 +286,12 @@
 		select 
 			count(0)
 		from
-			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and delete_sign != 1 group by buyer_id)t0
+			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and order_status = 3 and delete_sign != 1 group by buyer_id)t0
 			<!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
 		inner join
 			(select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
 		on t0.buyer_id = t2.id
 		left join user_identity b on t0.buyer_id = b.uid
-		<if test="aid != null and aid !=''">
-			and t2.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t2.identify_name like concat('%',#{name},'%')
 		</if>
@@ -581,7 +569,7 @@
 			c.name as industry,
 			d.name as adminName
 		from
-			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and delete_sign != 1 group by buyer_id)t0
+			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and order_status = 3 and delete_sign != 1 group by buyer_id)t0
 		left join 
 			(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
 		on t0.buyer_id = t1.uid
@@ -594,9 +582,6 @@
 		left join district_glossory dg3 on b.location_area = dg3.id
 		left join industry_category c on b.industry = c.id
 		left join admin d on t2.aid = d.id where 1=1
-		<if test="aid != null and aid !=''">
-			and t2.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t2.identify_name like concat('%',#{name},'%')
 		</if>
@@ -628,14 +613,11 @@
 		select 
 			count(0)
 		from
-			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and delete_sign != 1 group by buyer_id)t0
+			(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} and order_status = 3 and delete_sign != 1 group by buyer_id)t0
 		inner join
 			(select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
 		on t0.buyer_id = t2.id
 		left join organization_identity b on t0.buyer_id = b.uid where 1=1
-		<if test="aid != null and aid !=''">
-			and t2.aid = #{aid,jdbcType=VARCHAR}
-		</if>
 		<if test="name != null and name != ''">
 			and t2.identify_name like concat('%',#{name},'%')
 		</if>
@@ -1063,7 +1045,7 @@
 	from
 		user_business a inner join user b on
 		a.uid = b.id left join business_glossory c on
-		a.business_glossory_id = c.id left join admin d on
+		a.business_project_id = c.id left join admin d on
 		a.aid = d.id
 	where 1 = 1
 	<if test="aid != null and aid != ''">
@@ -1072,8 +1054,8 @@
 	<if test="uid != null and uid !=''">
 		and a.uid = #{uid,jdbcType=VARCHAR}
 	</if>
-	<if test="businessGlossoryId !=null and businessGlossoryId != ''">
-		and a.business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
+	<if test="businessProjectId !=null and businessProjectId != ''">
+		and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
 	</if>
 	<if test="identifyName != null and identifyName != ''">
 		and b.identify_name like concat('%', #{identifyName},'%')

+ 22 - 6
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -131,7 +131,6 @@ public class AdminCustomerApiController extends BaseApiController{
 	@RequestMapping(value = "/listAllManageOrganizationCustomer" , method = RequestMethod.POST)
 	public Result listAllManageOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
 		Result res = new Result();
-		cli.setAid(TokenManager.getAdminId());
 		res.setData(customerService.listAllManageOrganizationCustomer(cli, pageNo, pageSize));
 		return res;
 	}
@@ -140,7 +139,6 @@ public class AdminCustomerApiController extends BaseApiController{
 	@RequestMapping(value = "/listSignOrganizationCustomer", method = RequestMethod.POST)
 	public Result listSignOrganizationCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
 		Result res = new Result();
-		cli.setAid(TokenManager.getAdminId());
 		res.setData(customerService.listSignOrganizationCustomer(cli, pageNo, pageSize));
 		return res;
 	}
@@ -149,7 +147,6 @@ public class AdminCustomerApiController extends BaseApiController{
 	@RequestMapping(value = "/listSignPersonalCustomer", method = RequestMethod.POST)
 	public Result listSignPersonalCustomer(CustomerListIn cli,Integer pageNo, Integer pageSize){
 		Result res = new Result();
-		cli.setAid(TokenManager.getAdminId());
 		res.setData(customerService.listSignPersonalCustomer(cli, pageNo, pageSize));
 		return res;
 	}
@@ -272,9 +269,9 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 	
-	/** 进入添加拜访记录 **/
-	@RequestMapping(value = "/toAddFollow", method = RequestMethod.GET)
-	public Result toAddFollow(String uid){
+	/** 针对已作拜访的业务作跟进 **/
+	@RequestMapping(value = "/toAddFollowOnHistory", method = RequestMethod.GET)
+	public Result toAddFollowOnHistory(String uid){
 		Result res =  new Result();
 		if(StringUtils.isBlank(uid)){
 			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
@@ -291,6 +288,25 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 	
+	/** 针对已锁定的业务作跟进 **/
+	@RequestMapping(value = "/toAddFollowOnLock", method = RequestMethod.GET)
+	public Result toAddFollowOnLock(String uid){
+		Result res =  new Result();
+		if(StringUtils.isBlank(uid)){
+			 res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,""));
+			 return res;
+		}
+		User user = customerService.findUserAccountDetail(uid);
+		FollowBusinessBo fbb = new FollowBusinessBo();
+		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
+		fbb.setFollowTime(format.format(new Date()));
+		fbb.setIdentifyName(user.getIdentifyName());
+		fbb.setUid(uid);
+		fbb.setUserBusinessList(customerService.findLockedBusinessByUAid(uid, TokenManager.getAdminId()));
+		res.setData(fbb);
+		return res;
+	}
+	
 	/** 添加拜访记录 
 	 * @throws ParseException 
 	 * @throws Exception **/

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

@@ -336,6 +336,14 @@ public interface CustomerService {
 	 * @return
 	 */
 	List<BusinessListBo> findBusinessByUAid(String uid,String aid);
+	
+	/**
+	 * 查询锁定的业务列表
+	 * @param uid
+	 * @param aid
+	 * @return
+	 */
+	List<BusinessListBo> findLockedBusinessByUAid(String uid,String aid);
 
 	/**
 	 * 查看业务意向详情

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

@@ -170,6 +170,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	public Pagination<CustomerListOut> listAllManageOrganizationCustomer(CustomerListIn cli, Integer pageNo,Integer pageSize) {
 		cli.setType(AFTConstants.USER_TYPE_ORGANIZATION);
 		cli.setShareType(String.valueOf(AFTConstants.USER_SHARE_PRIVATE));
+		cli.setAid(TokenManager.getAdminId());
 		Map<String,Object> params = disposeParams(cli);
 		@SuppressWarnings("unchecked")
 		Pagination<CustomerListOut> list = (Pagination<CustomerListOut>) findPage("selectManageOrganizationCustomerList","selectManageOrganizationCustomerCount",params,pageNo,pageSize);
@@ -819,7 +820,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 
 	@Override
 	public List<BusinessListBo> findBusinessGlossory() {
-		return userBusinessMapper.findBusinessGlossory();
+		return userBusinessMapper.selectBusinessGlossory();
 	}
 
 	@Override
@@ -870,8 +871,12 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 
 	@Override
 	public List<BusinessListBo> findBusinessByUAid(String uid, String aid) {
-		
-		return userBusinessMapper.findBusinessByUAid(uid,aid);
+		return userBusinessMapper.selectBusinessByUAid(uid,aid);
+	}
+
+	@Override
+	public List<BusinessListBo> findLockedBusinessByUAid(String uid, String aid) {
+		return userBusinessMapper.selectLockedBusinessByUAid(uid,aid);
 	}
 
 	@Override
@@ -1084,6 +1089,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	public Pagination<CustomerListOut> listSignOrganizationCustomer(CustomerListIn cli, Integer pageNo,
 			Integer pageSize) {
 		Map<String,Object> params = disposeParams(cli);
+		cli.setAid(TokenManager.getAdminId());
 		Pagination<CustomerListOut> list = (Pagination<CustomerListOut>) findPage("selectSignOrganizationCustomerList","selectSignOrganizationCustomerCount",params,pageNo,pageSize);
 		return list;
 	}
@@ -1093,6 +1099,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	public Pagination<CustomerListOut> listSignPersonalCustomer(CustomerListIn cli, Integer pageNo,
 			Integer pageSize) {
 		Map<String,Object> params = disposeParams(cli);
+		cli.setAid(TokenManager.getAdminId());
 		Pagination<CustomerListOut> list = (Pagination<CustomerListOut>) findPage("selectSignPersonalCustomerList","selectSignPersonalCustomerCount",params,pageNo,pageSize);
 		return list;
 	}