Browse Source

客户管理

wanghui 8 years ago
parent
commit
6c92cfff81

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

@@ -267,7 +267,7 @@
 	
 	<select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
 		select id,identify_name as name from user where identify_name like
-		concat(#{identifyName},'%')
+		concat('%',#{identifyName},'%')
 	</select>
 	
 	<select id="judgeCustomerByName" parameterType="java.lang.String" resultType="java.lang.Integer">
@@ -315,8 +315,8 @@
 			a.contact_type as contactType,
 			a.result, 
 			b.identify_name as identityName,
-			c.name,
-			c.mobile,
+			c.name as contacts,
+			c.mobile as contactMobile,
 			d.name as adminName
 		<if test="businessGlossoryId != null and businessGlossoryId != ''"><!--  客户甲项目A所有的跟进记录 -->
 			,e.id as ufbId
@@ -393,7 +393,6 @@
 	<select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
 		select id,name,mobile from organization_contact_book 
 		where uid = #{uid,jdbcType=VARCHAR}
-		group by name
 	</select>
 	
 	<select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">

+ 13 - 0
src/main/java/com/goafanti/common/model/OrganizationContactBook.java

@@ -301,4 +301,17 @@ public class OrganizationContactBook {
 	public void setAid(String aid) {
 		this.aid = aid;
 	}
+	
+
+    @Override  
+    public boolean equals(Object arg0) {  
+    	OrganizationContactBook p = (OrganizationContactBook) arg0;  
+        return name.equals(p.name) && name.equals(p.name);  
+    }  
+      
+    @Override  
+    public int hashCode() {  
+        String str = name + mobile;  
+        return str.hashCode();  
+    }  
 }

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

@@ -22,6 +22,9 @@ public class FollowListBo {
 	/** 拜访人姓名 **/
 	private String adminName;
 	
+	/** 拜访方式 **/
+	private String contactType;
+	
 	/** user_follow_business ID **/ 
 	private String ufbId;
 	
@@ -67,6 +70,12 @@ public class FollowListBo {
 	public void setAdminName(String adminName) {
 		this.adminName = adminName;
 	}
+	public String getContactType() {
+		return contactType;
+	}
+	public void setContactType(String contactType) {
+		this.contactType = contactType;
+	}
 	public String getUfbId() {
 		return ufbId;
 	}

+ 41 - 3
src/main/java/com/goafanti/customer/controller/CustomerApiController.java

@@ -3,7 +3,9 @@ package com.goafanti.customer.controller;
 import java.lang.reflect.InvocationTargetException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 
 import javax.annotation.Resource;
 
@@ -11,11 +13,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseController;
 import com.goafanti.common.model.User;
+import com.goafanti.common.model.UserBusiness;
 import com.goafanti.common.utils.BeanUtilsExt;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -184,8 +189,25 @@ public class CustomerApiController extends BaseController{
 	
 	/** 添加拜访记录 **/
 	@RequestMapping(value = "/addFollow", method = RequestMethod.POST)
-	public Result addFollow(FollowBusinessBo fbb){
-		Result res =  new Result();
+	public Result addFollow(String userBusinessList,String uid,String ocbId,String contactType,String result,String followTime){
+		Result res = new Result();
+		if(StringUtils.isBlank(uid) || StringUtils.isBlank(ocbId)){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
+		}
+		JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
+		List<UserBusiness> list = new ArrayList<UserBusiness>();
+		if (ja != null && !ja.isEmpty()) {
+			for (int idx = 0; idx < ja.size(); idx++) {
+				list.add(ja.getJSONObject(idx).toJavaObject(UserBusiness.class));
+			}
+		}
+		FollowBusinessBo fbb = new FollowBusinessBo();
+		fbb.setOcbId(ocbId);
+		fbb.setUid(uid);
+		fbb.setContactType(contactType);
+		fbb.setResult(result);
+		fbb.setFollowTime(followTime);
+		fbb.setUserBusinessList(list);	
 		try {
 			customerService.addFollow(fbb);
 		} catch (ParseException e) {
@@ -206,8 +228,24 @@ public class CustomerApiController extends BaseController{
 	
 	/** 修改拜访记录 **/ 
 	@RequestMapping(value = "/updateFollow", method = RequestMethod.POST)
-	public Result updateFollow(FollowBusinessBo fbb){
+	public Result updateFollow(String userBusinessList,String followId,String followTime,String uid,String contactType,String result){
 		Result res = new Result();
+		if(StringUtils.isBlank(uid) || StringUtils.isBlank(followId)){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
+		}
+		JSONArray ja = (JSONArray) JSON.parse(userBusinessList);
+		List<UserBusiness> list = new ArrayList<UserBusiness>();
+		if (ja != null && !ja.isEmpty()) {
+			for (int idx = 0; idx < ja.size(); idx++) {
+				list.add(ja.getJSONObject(idx).toJavaObject(UserBusiness.class));
+			}
+		}
+		FollowBusinessBo fbb = new FollowBusinessBo();
+		fbb.setFollowTime(followTime);
+		fbb.setUid(uid);
+		fbb.setContactType(contactType);
+		fbb.setResult(result);
+		fbb.setUserBusinessList(list);	
 		try {
 			customerService.updateFollow(fbb);
 		} catch (ParseException e) {

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

@@ -2,6 +2,7 @@ package com.goafanti.customer.service;
 
 import java.text.ParseException;
 import java.util.List;
+import java.util.Set;
 
 import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.User;
@@ -178,5 +179,5 @@ public interface CustomerService {
 	 * @param uid
 	 * @return
 	 */
-	List<OrganizationContactBook> findAllContacts(String uid);
+	Set<OrganizationContactBook> findAllContacts(String uid);
 }

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

@@ -5,8 +5,10 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 
 import javax.annotation.Resource;
@@ -383,9 +385,8 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	@Override
 	@Transactional
 	public int updateFollow(FollowBusinessBo fbb) throws ParseException {
-		 UserFollow userFollow  = new UserFollow();
-		 SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
-		 userFollow.setCreateTime(format.parse(fbb.getFollowTime()));
+		UserFollow userFollow  = new UserFollow();
+		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
 		if(StringUtils.isNotBlank(fbb.getOcbId())) userFollow.setOcbId(fbb.getOcbId());
 		userFollow.setResult(fbb.getResult());
 		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
@@ -433,8 +434,10 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	}
 
 	@Override
-	public List<OrganizationContactBook> findAllContacts(String uid) {
-		return userMapper.findAllContacts(uid);
+	public Set<OrganizationContactBook> findAllContacts(String uid) {
+		Set<OrganizationContactBook> result = new HashSet<OrganizationContactBook>();
+		result.addAll(userMapper.findAllContacts(uid));
+		return result;
 	}
 	
 }