wanghui hace 8 años
padre
commit
0d29fdc89c

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

@@ -3,6 +3,7 @@ package com.goafanti.common.dao;
 import com.goafanti.common.model.UserBusiness;
 import com.goafanti.common.model.UserBusinessExample;
 import com.goafanti.customer.bo.BusinessListBo;
+import com.goafanti.customer.bo.BussinessFollowBo;
 
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
@@ -79,5 +80,7 @@ public interface UserBusinessMapper {
 
 	int judgeBusiness(@Param("uid")String uid,@Param("businessGlossoryId")Integer businessGlossoryId,@Param("aid")String aid);
 
-	List<UserBusiness> findBusinessByUAid(String uid, String aid);
+	List<UserBusiness> findBusinessByUAid(@Param("uid")String uid, @Param("aid")String aid);
+
+	BussinessFollowBo findBusinessDetail(@Param("businessId")String businessId);
 }

+ 0 - 1
src/main/java/com/goafanti/common/enums/MarketingPage.java

@@ -4,7 +4,6 @@ public enum MarketingPage {
 	mainAchievement("/index",1,5), //首页成果
 	mainDemand("/index",2,5),	// 首页需求
 	mainPolicy("/index",6,3); //首页政策
-	
 	MarketingPage(String pageUrl,Integer boothType,Integer boothSize){
 		this.boothSize = boothSize;
 		this.pageUrl = pageUrl;

+ 1 - 1
src/main/java/com/goafanti/common/mapper/ContractMapper.xml

@@ -379,7 +379,7 @@
    <if test="type !=null">
     and c.type = #{type,jdbcType=INTEGER}
   </if>
-   <if test="uid !=null">ContractDetail
+   <if test="uid !=null">
     and c.uid = #{uid,jdbcType=INTEGER}
   </if>
    <if test="status !=null">

+ 29 - 12
src/main/java/com/goafanti/common/mapper/UserBusinessMapper.xml

@@ -362,27 +362,27 @@
 		a.uid = b.id left join business_glossory c on
 		a.business_glossory_id = c.id left join admin d on
 		a.uid = d.id
-	where a.aid = #{adminId,jdbcType=VARCHAR}
+	where a.aid = #{aid,jdbcType=VARCHAR}
 	<if test="businessId !=null and businessId != ''">
 		and c.id = #{businessId,jdbcType=VARCHAR}
 	</if>
 	<if test="identifyName != null and identifyName != ''">
-		b.identify_name = #{identifyName,jdbcType=VARCHAR}
+		and b.identify_name = #{identifyName,jdbcType=VARCHAR}
 	</if>
 	<if test="followSituation != null">
-		a.follow_situation = #{followSituation,jdbcType=INTEGER}
+		and a.follow_situation = #{followSituation,jdbcType=INTEGER}
 	</if>
 	<if test="customerStatus != null">
-		a.customer_status = #{customerStatus,jdbcType=INTEGER}
+		and a.customer_status = #{customerStatus,jdbcType=INTEGER}
 	</if>
 	<if test="adminName != null and adminName != ''">
-		d.name = #{adminName,jdbcType=VARCHAR}
+		and d.name = #{adminName,jdbcType=VARCHAR}
 	</if>
 	<if test="startDate != null and startDate != ''">
-		and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
+		and and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
 	</if>
 	<if test="endDate != null and endDate != ''">
-		and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
+		and and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
 	</if>
 	<if test="page_sql != null">
     	${page_sql}
@@ -396,21 +396,21 @@
 		a.uid = b.id left join business_glossory c on
 		a.business_glossory_id = c.id left join admin d on
 		a.uid = d.id
-	where a.aid = #{adminId,jdbcType=VARCHAR}
+	where a.aid = #{aid,jdbcType=VARCHAR}
 	<if test="businessId !=null and businessId != ''">
 		and c.id = #{businessId,jdbcType=VARCHAR}
 	</if>
 	<if test="identifyName != null and identifyName != ''">
-		b.identify_name = #{identifyName,jdbcType=VARCHAR}
+		and b.identify_name = #{identifyName,jdbcType=VARCHAR}
 	</if>
 	<if test="followSituation != null">
-		a.follow_situation = #{followSituation,jdbcType=INTEGER}
+		and a.follow_situation = #{followSituation,jdbcType=INTEGER}
 	</if>
 	<if test="customerStatus != null">
-		a.customer_status = #{customerStatus,jdbcType=INTEGER}
+		and a.customer_status = #{customerStatus,jdbcType=INTEGER}
 	</if>
 	<if test="adminName != null and adminName != ''">
-		d.name = #{adminName,jdbcType=VARCHAR}
+		and d.name = #{adminName,jdbcType=VARCHAR}
 	</if>
 	<if test="startDate != null and startDate != ''">
 		and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
@@ -439,4 +439,21 @@
   	select select id,uid,business_glossory_id,follow_situation,customer_status,remarks from user_business
   	where  uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
   </select>
+  
+  <select id="findBusinessDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BussinessFollowBo">
+	select
+		a.id as businessId,
+		a.business_glossory_id as businessGlossoryId,
+		a.create_time as createTime,
+		a.follow_situation as followSituation,
+		a.customer_status as customerStatus,
+		a.remarks,
+		b.identify_name as identifyName,
+		c.name as adminName
+	from
+		user_business a left join user b on
+		a.uid = b.id left join admin c on
+		a.aid = c.id
+	where a.id = #{businessId,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 3 - 1
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -368,13 +368,14 @@
 	</select>
 	
 	<select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
-		select id as ocbId,name from organization_contact_book 
+		select id as ocbId,name,mobile from organization_contact_book 
 		where uid = #{uid,jdbcType=VARCHAR} and aid = #{aid,jdbcType=VARCHAR}
 	</select>
 	
 	<select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
 		select
 			a.id as followId,
+			a.uid,
 			a.ocb_id as ocbId,
 			a.contact_type as contactType,
 			a.result,
@@ -401,4 +402,5 @@
 		user_follow_business a
 		where a.id = #{followId,jdbcType=VARCHAR}
 	</select>
+	
 </mapper>

+ 17 - 0
src/main/java/com/goafanti/customer/bo/BusinessListBo.java

@@ -13,12 +13,17 @@ public class BusinessListBo {
 	private String followSituation;
 	/** 客户状态 **/
 	private String customerStatus;
+	/** 营销员ID **/
+	private String aid;
 	/** 营销员名字 **/
 	private String adminName;
 	/** 开始时间 **/
 	private String startDate;
 	/** 结束时间 **/
 	private String endDate;
+	/** 业务创建时间 **/
+	private String createTime;
+	
 	public String getId() {
 		return id;
 	}
@@ -49,6 +54,12 @@ public class BusinessListBo {
 	public void setFollowSituation(String followSituation) {
 		this.followSituation = followSituation;
 	}
+	public String getAid() {
+		return aid;
+	}
+	public void setAid(String aid) {
+		this.aid = aid;
+	}
 	public String getCustomerStatus() {
 		return customerStatus;
 	}
@@ -73,4 +84,10 @@ public class BusinessListBo {
 	public void setEndDate(String endDate) {
 		this.endDate = endDate;
 	}
+	public String getCreateTime() {
+		return createTime;
+	}
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
 }

+ 9 - 0
src/main/java/com/goafanti/customer/bo/FollowBusinessBo.java

@@ -10,6 +10,8 @@ import com.goafanti.common.model.UserBusiness;
  *
  */
 public class FollowBusinessBo {
+	/** 拜访记录ID **/
+	private String followId;
 	/** 客户ID **/
 	private String uid;
 	/** 客户名 **/
@@ -28,6 +30,13 @@ public class FollowBusinessBo {
 	private String adminName;
 	/** 业务意向列表 **/
 	private List<UserBusiness> userBusinessList;
+	
+	public String getFollowId() {
+		return followId;
+	}
+	public void setFollowId(String followId) {
+		this.followId = followId;
+	}
 	public String getUid() {
 		return uid;
 	}

+ 16 - 1
src/main/java/com/goafanti/customer/controller/BusinessApiController.java

@@ -75,5 +75,20 @@ public class BusinessApiController extends BaseController{
 		res.setData(bo);
 		return res;
 	}
-
+	
+	/** 进入修改业务意向 **/
+	@RequestMapping(value = "/toUpdateBusiness", method = RequestMethod.GET)
+	public Result toUpdateBusiness(String businessId){
+		Result res = new Result();
+		res.setData(businessService.findBusinessDetail(businessId));
+		return res;
+	}
+	
+	/** 修改业务意向 **/
+	@RequestMapping(value = "/updateBusiness", method = RequestMethod.POST)
+	public Result updateBusiness(BussinessFollowBo bfb){
+		Result res = new Result();
+		businessService.updateBusiness(bfb);
+		return res;
+	}
 }

+ 7 - 1
src/main/java/com/goafanti/customer/controller/CustomerApiController.java

@@ -209,9 +209,15 @@ public class CustomerApiController extends BaseController{
 	 * @param fbb
 	 * @return
 	 */
+	@RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
 	public Result updateFollow(FollowBusinessBo fbb){
 		Result res = new Result();
-		customerService.updateFollow(fbb);
+		try {
+			customerService.updateFollow(fbb);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
 		return res;
 	}
+	
 }

+ 14 - 0
src/main/java/com/goafanti/customer/service/BusinessService.java

@@ -43,4 +43,18 @@ public interface BusinessService {
 	 * @return
 	 */
 	List<UserBusiness> findBusinessByUAid(String uid,String aid);
+
+	/**
+	 * 查看业务意向详情
+	 * @param businessId
+	 * @return
+	 */
+	BussinessFollowBo findBusinessDetail(String businessId);
+
+	/**
+	 * 修改业务意向
+	 * @param bfb
+	 * @return
+	 */
+	int updateBusiness(BussinessFollowBo bfb);
 }

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

@@ -171,5 +171,5 @@ public interface CustomerService {
 	 * 修改拜访记录
 	 * @param fbb
 	 */
-	int updateFollow(FollowBusinessBo fbb);
+	int updateFollow(FollowBusinessBo fbb)  throws ParseException ;
 }

+ 22 - 0
src/main/java/com/goafanti/customer/service/impl/BusinessServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.customer.service.impl;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,11 +38,13 @@ public class BusinessServiceImpl extends BaseMybatisDao<UserBusinessMapper> impl
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<BusinessListBo> listBusiness(BusinessListBo blo,Integer pageNo,Integer pageSize) {
+		blo.setAid(TokenManager.getAdminId());
 		return (Pagination<BusinessListBo>) findPage("selectBusinessList", "selectBusinessCount", disposeParams(blo), pageNo, pageSize);
 	}
 	
 	private Map<String,Object> disposeParams(BusinessListBo blo){
 		Map<String, Object> params = new HashMap<String, Object>();
+		if(StringUtils.isNotBlank(blo.getAid())) params.put("aid", blo.getAid());
 		if(StringUtils.isNotBlank(blo.getAdminName())) params.put("adminName", blo.getAdminName());
 		if(StringUtils.isNotBlank(blo.getBusinessId())) params.put("businessId", blo.getBusinessId());
 		if(StringUtils.isNotBlank(blo.getStartDate())) params.put("startDate", blo.getStartDate()+" 00:00:00");
@@ -75,6 +78,7 @@ public class BusinessServiceImpl extends BaseMybatisDao<UserBusinessMapper> impl
 		ub.setUid(bfb.getUid());
 		ub.setAid(TokenManager.getAdminId());
 		ub.setRemarks(bfb.getRemarks());
+		ub.setBusinessGlossoryId(Integer.parseInt(bfb.getBusinessGlossoryId()));
 		ub.setUpdateTime(format.parse(bfb.getCreateTime()));
 		ub.setCreateTime(format.parse(bfb.getCreateTime()));
 		userBusinessMapper.insert(ub);
@@ -108,4 +112,22 @@ public class BusinessServiceImpl extends BaseMybatisDao<UserBusinessMapper> impl
 		return userBusinessMapper.findBusinessByUAid(uid,aid);
 	}
 
+	@Override
+	public BussinessFollowBo findBusinessDetail(String businessId) {
+		
+		return userBusinessMapper.findBusinessDetail(businessId);
+	}
+
+	@Override
+	public int updateBusiness(BussinessFollowBo bfb) {
+		UserBusiness userBusiness = new UserBusiness();
+		userBusiness.setId(bfb.getBusinessId());
+		userBusiness.setCustomerStatus(Integer.parseInt(bfb.getCustomerStatus()));
+		userBusiness.setFollowSituation(Integer.parseInt(bfb.getFollowSituation()));
+		userBusiness.setRemarks(bfb.getRemarks());
+		userBusiness.setUpdateTime(new Date());
+		userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
+		return 1;
+	}
+
 }

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

@@ -320,14 +320,13 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 				//更新业务表
 				userBusiness.setId(ub.getId());
 				userBusiness.setBusinessGlossoryId(ub.getBusinessGlossoryId());
-				userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
 				userBusiness.setCustomerStatus(ub.getCustomerStatus());
 				userBusiness.setFollowSituation(ub.getFollowSituation());
 				userBusiness.setUid(fbb.getUid());
 				userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
 				userBusiness.setAid(TokenManager.getAdminId());
 				userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
-				//更新拜访和业务中间表
+				//更新业务中间表
 				userFollowBusiness.setBusinessId(ub.getId());
 				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
 				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
@@ -353,7 +352,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 				userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
 				userBusiness.setAid(TokenManager.getAdminId());
 				userBusinessMapper.insert(userBusiness);	
-				//更新拜访和业务中间表
+				//更新业务中间表
 				userFollowBusiness.setBusinessId(ubId);
 				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
 				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
@@ -381,8 +380,53 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 
 	@Override
 	@Transactional
-	public int updateFollow(FollowBusinessBo fbb) {
-		 	 	 	
+	public int updateFollow(FollowBusinessBo fbb) throws ParseException {
+		 UserFollow userFollow  = new UserFollow();
+		 SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
+		 userFollow.setCreateTime(format.parse(fbb.getFollowTime()));
+		if(StringUtils.isNotBlank(fbb.getOcbId())) userFollow.setOcbId(fbb.getOcbId());
+		userFollow.setResult(fbb.getResult());
+		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
+		userFollowMapper.updateByPrimaryKeySelective(userFollow); //修改拜访记录表
+		UserFollowBusiness userFollowBusiness = null;
+		for(UserBusiness ub: fbb.getUserBusinessList()){
+			userFollowBusiness = new UserFollowBusiness();
+			if(StringUtils.isNotBlank(ub.getId())){
+				userFollowBusiness.setId(ub.getId());
+				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+				userFollowBusiness.setRemarks(ub.getRemarks());
+				userFollowBusinessMapper.updateByPrimaryKeySelective(userFollowBusiness); //修改拜访记录中间表
+			}else{
+				//检测是否可以创建业务	
+				if(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessGlossoryId(), "")>0){
+					String businessName = businessGlossoryMapper.selectByPrimaryKey(ub.getBusinessGlossoryId()).getName();
+					throw new BusinessException(new Error(businessName+" 已经被跟进"));
+				}
+				String ubId = UUID.randomUUID().toString();		
+				UserBusiness userBusiness = new UserBusiness();
+				//更新业务表
+				userBusiness.setId(ubId);
+				userBusiness.setBusinessGlossoryId(ub.getBusinessGlossoryId());
+				userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
+				userBusiness.setCustomerStatus(ub.getCustomerStatus());
+				userBusiness.setFollowSituation(ub.getFollowSituation());
+				userBusiness.setUid(fbb.getUid());
+				userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
+				userBusiness.setAid(TokenManager.getAdminId());
+				userBusinessMapper.insert(userBusiness);	
+				//更新业务中间表
+				String ufbId = UUID.randomUUID().toString();
+				userFollowBusiness.setBusinessId(ubId);
+				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+				userFollowBusiness.setId(ufbId);
+				userFollowBusiness.setFollowId(fbb.getFollowId());
+				userFollowBusiness.setRemarks(ub.getRemarks());
+				userFollowBusiness.setBusinessGlossoryId(ub.getBusinessGlossoryId());
+				userFollowBusinessMapper.insert(userFollowBusiness);
+			}		
+		}
 		return 1;
 	}