Explorar o código

客户系统接口调整

wanghui %!s(int64=8) %!d(string=hai) anos
pai
achega
b90f0e2ef1

+ 2 - 2
src/main/java/com/goafanti/customer/bo/CustomerOut.java

@@ -2,7 +2,7 @@ package com.goafanti.customer.bo;
 
 public class CustomerOut {
 	/**
-	 * 客户类型(1-个人用户,2-公司用户)
+	 * 客户类型(1-个人客户,2-机构单位,3-团体单位)
 	 */
 	private Integer customerType;
 	
@@ -21,7 +21,7 @@ public class CustomerOut {
 	 */
 	private String cid;
 	/**
-	 * 分享类型(1-个人用户,2-公共用户)
+	 * 分享类型(1-私有客户,2-公共客户)
 	 */
 	private Integer shareType;
 	

+ 33 - 32
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -64,43 +64,44 @@ public class AdminCustomerApiController extends BaseApiController {
 	public Result addCustomer(CustomerIn cusIn,CustomerOrganizationInfo coi,CustomerUserInfo cui,FollowUpRecord fur) throws ParseException, IllegalAccessException, InvocationTargetException {
 		Result res=new Result();
 		//查询客户是否已经存在
+		if(StringUtils.isEmpty(cusIn.getCompanyName())) res.getError().add(new Error("公司名字不能为空"));
+		if(StringUtils.isEmpty(cusIn.getCompanyIntention())) res.getError().add(new Error("意向服务不能为空"));
+		if(StringUtils.isEmpty(cusIn.getFollowSituation())) res.getError().add(new Error("跟进进度不能为空"));
+		if(StringUtils.isEmpty(cusIn.getCustomerStatus())) res.getError().add(new Error("客户状态不能为空"));
+		if(StringUtils.isEmpty(cusIn.getContactName())) res.getError().add(new Error("联系人姓名不能"));
+		if(StringUtils.isEmpty(cui.getMobile())&&StringUtils.isEmpty(cui.getTelNum())) res.getError().add(new Error("手机号码和座机不能同时为空"));
 		if(customerOrganizationService.findCustomerOrganizationByName(cusIn.getCompanyName())>0){
 			res.getError().add(buildError(ErrorConstants.CUSTOMER_ALREADY_EXIST));
 			return res;
 		}
 		//添加 customer
 		String customerId = UUID.randomUUID().toString();//客户记录ID
-		String  customerUsrId= UUID.randomUUID().toString();//客户联系人ID
+		String customerUserId= UUID.randomUUID().toString();//客户联系人ID
 		String followId=UUID.randomUUID().toString();//跟进记录ID
-		Customer c = new Customer();
-		cusIn.setFollowId(followId);
-		cusIn.setId(customerId);		
-		cui.setId(customerUsrId);
-		cui.setCid(customerId);//客户联系人表中的cid
-		
+		//客户信息表
+		Customer cus = new Customer();
+		BeanUtils.copyProperties(cus, cusIn);
+		cus.setId(customerId);
+		cus.setFollowId(followId);
+		cus.setShareType(Integer.parseInt(cusIn.getShareType()));
+		cus.setCustomerType(Integer.parseInt(cusIn.getCustomerType()));
+		cus.setId(customerId);
+		cus.setCreateTime(new Date());
+		//公司信息和联系人信息表
+		cui.setId(customerUserId);
+		cui.setCid(customerId);//客户联系人表中的cid		
 		coi.setId(UUID.randomUUID().toString());//客户公司ID
 		coi.setCid(customerId);//客户公司表中的cid
-		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDD);
+		//跟进信息表
+		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
 		fur.setFollowDate(format.parse(cusIn.getFollowDates()));
 		fur.setId(followId);//跟进记录的ID
 		fur.setCid(customerId);//跟进记录表中的cid
-		fur.setCuid(customerUsrId);//跟进记录表中的联系人id		
-		/*if(StringUtils.isNotBlank(cusIn.getAid())) fur.setAid(cusIn.getAid());*//*暂时注释*/
-		
-		BeanUtils.copyProperties(c, cusIn);
-		c.setShareType(Integer.parseInt(cusIn.getShareType()));
-		c.setCustomerType(Integer.parseInt(cusIn.getCustomerType()));
-		c.setId(customerId);
-		
-		customerService.addCustomer(c);
-		//插入 customerUserInfo
-		customerUserService.addCustomerUserInfo(cui);
-		//插入 customerOrganizationInfo
-		customerOrganizationService.addCustomerOrganizationInfo(coi);
-		//插入跟进表
-		followUpService.addFollowUp(fur);
+		fur.setCuid(customerUserId);//跟进记录表中的联系人id	
+		customerService.addCustomer(cus,cui,coi,fur);
 		//添加日志
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_CREATE,customerId);
+		cusIn.setId(customerId);
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_CREATE);
 		return res;
 	}
 	
@@ -111,11 +112,11 @@ public class AdminCustomerApiController extends BaseApiController {
 	 * @return
 	 * @throws ParseException
 	 */
-	@RequestMapping(value = "/deleteCustomer", method = RequestMethod.POST)
+	@RequestMapping(value = "/deleteCustomer", method = RequestMethod.GET)
 	public Result deleteCustomer(CustomerIn cusIn) throws ParseException {
 		Result res=new Result();
 		customerService.deleteCustomer(cusIn.getId());
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_DELETE,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_DELETE);
 		return res;
 	}
 	
@@ -230,12 +231,12 @@ public class AdminCustomerApiController extends BaseApiController {
 		BeanUtils.copyProperties(c, cusIn);
 		c.setCustomerType(Integer.parseInt(cusIn.getCustomerType()));
 		coi.setCid(cusIn.getId());
-		//更新主表
+		//更新客户信息和客户公司信息
 		customerService.updateCustomer(c);
 		//更新公司表
 		customerOrganizationService.updateCustomerOrganizationInfo(coi);
 		//插入日志表
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_MODIFY,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_MODIFY);
 	    return res;
 	}
 	
@@ -255,7 +256,7 @@ public class AdminCustomerApiController extends BaseApiController {
 		//更新主表
 		customerService.updateCustomer(c);
 		//插入日志表
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_TRANSFER,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_TRANSFER);
 	    return res;
 	}
 	
@@ -315,7 +316,7 @@ public class AdminCustomerApiController extends BaseApiController {
 			e.printStackTrace();
 		}	
 		customerService.updateCustomer(cus);
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_FOLLOW,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_FOLLOW);
 		return res;
 	}
 	
@@ -428,7 +429,7 @@ public class AdminCustomerApiController extends BaseApiController {
 		//更新主表
 		customerService.updateCustomer(c);
 		//插入日志表
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_RECEIVE,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_RECEIVE);
 	    return res;
 	}
 	
@@ -462,7 +463,7 @@ public class AdminCustomerApiController extends BaseApiController {
 		//更新主表
 		customerService.updateCustomer(c);
 		//插入日志表
-		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_TO_PUBLIC,cusIn.getId());
+		customerService.saveCustomerLog(cusIn, AFTConstants.CUSTOMER_TO_PUBLIC);
 	    return res;
 	}
 	

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

@@ -4,6 +4,9 @@ import java.util.List;
 
 import com.goafanti.common.model.Customer;
 import com.goafanti.common.model.CustomerLog;
+import com.goafanti.common.model.CustomerOrganizationInfo;
+import com.goafanti.common.model.CustomerUserInfo;
+import com.goafanti.common.model.FollowUpRecord;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.customer.bo.CustomerIn;
 import com.goafanti.customer.bo.CustomerOut;
@@ -15,7 +18,7 @@ public interface CustomerService {
 	 * @param cus
 	 * @return
 	 */
-	int addCustomer(Customer cus);
+	int addCustomer(Customer cus,CustomerUserInfo cui,CustomerOrganizationInfo coi,FollowUpRecord fur);
 	
 	/**
 	 * 删除客户信息
@@ -64,7 +67,7 @@ public interface CustomerService {
 	 * 
 	 * @param cus 添加日志
 	 */
-	public void saveCustomerLog(CustomerIn cus,String operatorType,String cid);
+	public void saveCustomerLog(CustomerIn cus,String operatorType);
 	
 	/**
 	 * 

+ 44 - 22
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -23,12 +23,18 @@ import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.CustomerLogMapper;
 import com.goafanti.common.dao.CustomerMapper;
+import com.goafanti.common.dao.CustomerOrganizationInfoMapper;
+import com.goafanti.common.dao.CustomerUserInfoMapper;
+import com.goafanti.common.dao.FollowUpRecordMapper;
 import com.goafanti.common.enums.CustomerFollowFiled;
 import com.goafanti.common.enums.CustomerIntentionFiled;
 import com.goafanti.common.enums.CustomerStatusFiled;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.Customer;
 import com.goafanti.common.model.CustomerLog;
+import com.goafanti.common.model.CustomerOrganizationInfo;
+import com.goafanti.common.model.CustomerUserInfo;
+import com.goafanti.common.model.FollowUpRecord;
 import com.goafanti.common.utils.StringUtils;
 @Service
 public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implements CustomerService {
@@ -38,11 +44,22 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
 	private AdminMapper adminMapper;
 	@Autowired
 	private CustomerLogMapper customerLogMapper;
+	@Autowired
+	private CustomerUserInfoMapper customerUserInfoMapper;
+	@Autowired
+	private CustomerOrganizationInfoMapper customerOrganizationInfoMapper;
+	@Autowired
+	private FollowUpRecordMapper followUpRecordMapper;
 	@Override
-	public int addCustomer(Customer cus) {
-		Date data =new Date();
+	public int addCustomer(Customer cus,CustomerUserInfo cui,CustomerOrganizationInfo coi,FollowUpRecord fur) {
+		//插入 customerUserInfo
+		customerUserInfoMapper.insert(cui);
+		//插入 customerOrganizationInfo
+		customerOrganizationInfoMapper.insert(coi);
+		//插入跟进表
+		followUpRecordMapper.insert(fur);
 		String paid = findLadderIds(TokenManager.getAdminId());//查询上级管理员ID集合
-		cus.setCreateTime(data);
+		if(StringUtils.isNotBlank(paid)) paid = paid.substring(0, paid.length()-1);	
 		cus.setAid(TokenManager.getAdminId());
 		cus.setPaid(paid);
 		int res = customerMapper.insert(cus);
@@ -72,7 +89,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
 			String newPaid = "";
 			for(Customer c:customers){
 				newPaid = findLadderIds(c.getAid());
-				if(!newPaid.equals("")) newPaid = newPaid.substring(0, newPaid.length()-1);
+				if(StringUtils.isNotBlank(newPaid)) newPaid = newPaid.substring(0, newPaid.length()-1);
 				c.setPaid(newPaid);
 				customerMapper.updateByPrimaryKeySelective(c);
 			}
@@ -232,31 +249,34 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
 	}
 	
 	@Override
-	public void saveCustomerLog(CustomerIn cus,String operatorType,String cid){
+	public void saveCustomerLog(CustomerIn cus,String operatorType){
 		/* 记录日志 */
+		String cid =cus.getId();
 		CustomerLog log = new CustomerLog();
 		log.setId(UUID.randomUUID().toString());
 		log.setCid(cid);
 		log.setOperatorTime(new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS).format(new Date()));
 		log.setOperatorName(TokenManager.getAdminToken().getName());
 		Customer c =  customerMapper.selectByPrimaryKey(cid) ;
+		String beforeAdminName = adminMapper.selectByPrimaryKey(c.getAid()).getName();
 		if(operatorType.equals(AFTConstants.CUSTOMER_CREATE)){//创建用户
 			log.setAfterFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getFollowSituation())).getDesc()); //跟进状态
 			log.setAfterCustomerIntention(getCompanyIntention(cus.getCompanyIntention())); //跟进意向
 			log.setAfterCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getCustomerStatus())).getDesc()); //客户状态
 			log.setAfterAdminName(TokenManager.getAdminToken().getName());
 			log.setOperatorType(AFTConstants.CUSTOMER_CREATE);
-		}else if(operatorType.equals(AFTConstants.CUSTOMER_MODIFY)){ //修改
-			log.setBeforeAdminName(cus.getBeforeAdminName());//修改前操作人
+		}else if(operatorType.equals(AFTConstants.CUSTOMER_MODIFY)){ //修改
+			log.setBeforeAdminName(beforeAdminName);//修改前操作人
 			log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
 			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
 			log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
+			log.setAfterAdminName(TokenManager.getAdminToken().getName());
 			log.setAfterFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getFollowSituation())).getDesc()); //修改后跟进状态
 			log.setAfterCustomerIntention(getCompanyIntention(cus.getCompanyIntention())); //修改后跟进意向
 			log.setAfterCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getCustomerStatus())).getDesc()); //修改后客户状态
 			log.setOperatorType(AFTConstants.CUSTOMER_MODIFY);
-		}else if(operatorType.equals(AFTConstants.CUSTOMER_DELETE)){ //删除
-			log.setBeforeAdminName(cus.getBeforeAdminName());
+		}else if(operatorType.equals(AFTConstants.CUSTOMER_DELETE)){ //删除
+			log.setBeforeAdminName(beforeAdminName); //删除前跟进人
 			log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //跟进意向
 			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //跟进状态
 			log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//跟进进度
@@ -264,25 +284,25 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
 		}else if(operatorType.equals(AFTConstants.CUSTOMER_TRANSFER)){ //转交客户
 			log.setBeforeAdminName(cus.getBeforeAdminName());//转交前的人
 			log.setAfterAdminName(cus.getAdminName());//转交后的人
-			log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //修改前跟进意向
-			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //修改前跟进状态
-			log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//修改前跟进进度
+			log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
+			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
+			log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
 			log.setOperatorType(AFTConstants.CUSTOMER_TRANSFER);
-		}else if(operatorType.equals(AFTConstants.CUSTOMER_RECEIVE)){ //领取
-			log.setBeforeAdminName(cus.getBeforeAdminName());//领取前的人
+		}else if(operatorType.equals(AFTConstants.CUSTOMER_RECEIVE)){ //领取客户
+			log.setBeforeAdminName(beforeAdminName);//领取前的人
 			log.setAfterAdminName(TokenManager.getAdminToken().getName());//领取后跟进人
-			log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //领取前跟进意向
-			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //领取前跟进状态
-			log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//领取前跟进进度
+			log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //领取前跟进意向
+			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //领取前跟进状态
+			log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//领取前跟进进度
 			log.setOperatorType(AFTConstants.CUSTOMER_RECEIVE);
 		}else if(operatorType.equals(AFTConstants.CUSTOMER_TO_PUBLIC)){ //转为公共客户
-			log.setBeforeAdminName(cus.getBeforeAdminName());//转为公共客户前跟进人
-			log.setBeforeCustomerIntention(getCompanyIntention(cus.getBeforeCompanyIntention())); //修改前跟进意向
-			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(Integer.parseInt(cus.getBeforeCustomerStatus())).getDesc()); //修改前跟进状态
-			log.setBeforeFollowSituation(CustomerFollowFiled.getField(Integer.parseInt(cus.getBeforeFollowSituation())).getDesc());//修改前跟进进度
+			log.setBeforeAdminName(beforeAdminName);//转为公共客户前跟进人
+			log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //转换前跟进意向
+			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //转换前跟进状态
+			log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//转换前跟进进度
 			log.setOperatorType(AFTConstants.CUSTOMER_TO_PUBLIC);
 		}else if(operatorType.equals(AFTConstants.CUSTOMER_FOLLOW)){ //跟进客户
-			log.setBeforeAdminName(TokenManager.getAdminToken().getName());//跟进前操作人
+			log.setBeforeAdminName(beforeAdminName);//跟进前操作人
 			log.setBeforeCustomerIntention(getCompanyIntention(c.getCompanyIntention())); //修改前跟进意向
 			log.setBeforeCustomerStatus(CustomerStatusFiled.getField(c.getCustomerStatus()).getDesc()); //修改前跟进状态
 			log.setBeforeFollowSituation(CustomerFollowFiled.getField(c.getFollowSituation()).getDesc());//修改前跟进进度
@@ -314,7 +334,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<CustomerMapper> implemen
 	 */
 	@Override
 	public int updateCustomer(Customer c) {
+		//修改主表
 		 return customerMapper.updateByPrimaryKeySelective(c);
+		
 	}
 	
 	/**