Browse Source

Merge remote-tracking branch 'origin/test' into patch

anderx 7 years ago
parent
commit
655011729a
1 changed files with 140 additions and 136 deletions
  1. 140 136
      src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

+ 140 - 136
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -361,7 +361,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	@Override
 	@Transactional
 	public int addFollow(FollowBusinessBo fbb) throws BusinessException{
-		if(fbb.getUserBusinessList().size()<1) throw new BusinessException(new Error(ErrorConstants.AT_LEAST_A_BUSINESS,"",""));
+		//if(fbb.getUserBusinessList().size()<1) throw new BusinessException(new Error(ErrorConstants.AT_LEAST_A_BUSINESS,"",""));
 		//更新跟进记录表
 		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
 		UserFollow userFollow = new UserFollow();
@@ -382,85 +382,87 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		userFollow.setFollowCount(followCount);
 		userFollowMapper.insert(userFollow);
 		//检查客户锁定情况
-		boolean isUserOwner = false;
-		List<LockingReleaseBo> userLockedList = userMapper.selectLockedProject(fbb.getUid(), TokenManager.getAdminId(),null, 0, UserLockReleaseStatus.LOCKED.getCode());
-		if(userLockedList.size() > 0){
-			isUserOwner = true;
-		}
-		boolean isBusinessOwner = false;
-		List<LockingReleaseBo> businessLockedList = null;
-		String businessName= "";
-		String ufbId = "";
-		UserBusiness userBusiness = null;
-		UserFollowBusiness userFollowBusiness = null;
-		for(BusinessListBo ub: fbb.getUserBusinessList()){
-			userBusiness = new UserBusiness();
-			userFollowBusiness = new UserFollowBusiness();
-			ufbId = UUID.randomUUID().toString();
-			businessName = businessProjectMapper.selectByPrimaryKey(ub.getBusinessProjectId()).getBname();
-			if(StringUtils.isNotBlank(ub.getBusinessId())){
-				//更新业务表
-				userBusiness.setId(ub.getBusinessId());
-				userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				userBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userBusiness.setFollowSituation(ub.getFollowSituation());
-				userBusiness.setUid(fbb.getUid());
-				try {
-					userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
-				} catch (ParseException e) {
-					e.printStackTrace();
-				}
-				userBusiness.setAid(TokenManager.getAdminId());
-				userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
-				//更新业务中间表
-				userFollowBusiness.setBusinessId(ub.getBusinessProjectId());
-				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
-				userFollowBusiness.setId(ufbId);
-				userFollowBusiness.setFollowId(followId);
-				userFollowBusiness.setRemarks(ub.getRemarks());
-				userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				userFollowBusinessMapper.insert(userFollowBusiness);
-			}else{
-				//检查业务锁定情况
-				businessLockedList = userMapper.selectLockedProject(fbb.getUid(), null, ub.getBusinessProjectId(), 1, UserLockReleaseStatus.LOCKED.getCode());
-				if(businessLockedList.size() > 0){
-					for(LockingReleaseBo bo : businessLockedList){
-						if(bo.getAid().equals(TokenManager.getAdminId())) isBusinessOwner = true;
+		if(fbb.getUserBusinessList().size()>0){
+			boolean isUserOwner = false;
+			List<LockingReleaseBo> userLockedList = userMapper.selectLockedProject(fbb.getUid(), TokenManager.getAdminId(),null, 0, UserLockReleaseStatus.LOCKED.getCode());
+			if(userLockedList.size() > 0){
+				isUserOwner = true;
+			}
+			boolean isBusinessOwner = false;
+			List<LockingReleaseBo> businessLockedList = null;
+			String businessName= "";
+			String ufbId = "";
+			UserBusiness userBusiness = null;
+			UserFollowBusiness userFollowBusiness = null;
+			for(BusinessListBo ub: fbb.getUserBusinessList()){
+				userBusiness = new UserBusiness();
+				userFollowBusiness = new UserFollowBusiness();
+				ufbId = UUID.randomUUID().toString();
+				businessName = businessProjectMapper.selectByPrimaryKey(ub.getBusinessProjectId()).getBname();
+				if(StringUtils.isNotBlank(ub.getBusinessId())){
+					//更新业务表
+					userBusiness.setId(ub.getBusinessId());
+					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					userBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userBusiness.setFollowSituation(ub.getFollowSituation());
+					userBusiness.setUid(fbb.getUid());
+					try {
+						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
+					} catch (ParseException e) {
+						e.printStackTrace();
 					}
-					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(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){
-					throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_EXIST,businessName,""));
-				}
-				String ubId = UUID.randomUUID().toString();
-				//更新业务表
-				userBusiness.setId(ubId);
-				userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				try {
-					userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
-					userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
-				} catch (ParseException e) {
-					e.printStackTrace();
+					userBusiness.setAid(TokenManager.getAdminId());
+					userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
+					//更新业务中间表
+					userFollowBusiness.setBusinessId(ub.getBusinessProjectId());
+					userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+					userFollowBusiness.setId(ufbId);
+					userFollowBusiness.setFollowId(followId);
+					userFollowBusiness.setRemarks(ub.getRemarks());
+					userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					userFollowBusinessMapper.insert(userFollowBusiness);
+				}else{
+					//检查业务锁定情况
+					businessLockedList = userMapper.selectLockedProject(fbb.getUid(), null, ub.getBusinessProjectId(), 1, UserLockReleaseStatus.LOCKED.getCode());
+					if(businessLockedList.size() > 0){
+						for(LockingReleaseBo bo : businessLockedList){
+							if(bo.getAid().equals(TokenManager.getAdminId())) isBusinessOwner = true;
+						}
+						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(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){
+						throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_EXIST,businessName,""));
+					}
+					String ubId = UUID.randomUUID().toString();
+					//更新业务表
+					userBusiness.setId(ubId);
+					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					try {
+						userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
+						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+					userBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userBusiness.setFollowSituation(ub.getFollowSituation());
+					userBusiness.setUid(fbb.getUid());
+					userBusiness.setAid(TokenManager.getAdminId());
+					userBusinessMapper.insert(userBusiness);	
+					//更新业务中间表
+					userFollowBusiness.setBusinessId(ubId);
+					userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+					userFollowBusiness.setId(ufbId);
+					userFollowBusiness.setFollowId(followId);
+					userFollowBusiness.setRemarks(ub.getRemarks());
+					userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					userFollowBusinessMapper.insert(userFollowBusiness);
 				}
-				userBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userBusiness.setFollowSituation(ub.getFollowSituation());
-				userBusiness.setUid(fbb.getUid());
-				userBusiness.setAid(TokenManager.getAdminId());
-				userBusinessMapper.insert(userBusiness);	
-				//更新业务中间表
-				userFollowBusiness.setBusinessId(ubId);
-				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
-				userFollowBusiness.setId(ufbId);
-				userFollowBusiness.setFollowId(followId);
-				userFollowBusiness.setRemarks(ub.getRemarks());
-				userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				userFollowBusinessMapper.insert(userFollowBusiness);
+				
 			}
-			
 		}
 		return 1;
 	}
@@ -486,66 +488,68 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		userFollow.setResult(fbb.getResult());
 		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
 		userFollowMapper.updateByPrimaryKeySelective(userFollow); //修改拜访记录表
-		//检查客户锁定情况
-		boolean isUserOwner = false;
-		List<LockingReleaseBo> userLockedList = userMapper.selectLockedProject(fbb.getUid(), TokenManager.getAdminId(),null, 0, UserLockReleaseStatus.LOCKED.getCode());
-		if(userLockedList.size() > 0){
-			isUserOwner = true;
-		}
-		boolean isBusinessOwner = false;	
-		List<LockingReleaseBo> businessLockedList = null;
-		String businessName= "";
-		UserFollowBusiness userFollowBusiness = null;
-		for(BusinessListBo ub: fbb.getUserBusinessList()){
-			userFollowBusiness = new UserFollowBusiness();
-			businessName = businessProjectMapper.selectByPrimaryKey(ub.getBusinessProjectId()).getBname();
-			if(StringUtils.isNotBlank(ub.getUfbId())){
-				userFollowBusiness.setId(ub.getUfbId());
-				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
-				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userFollowBusiness.setRemarks(ub.getRemarks());
-				userFollowBusinessMapper.updateByPrimaryKeySelective(userFollowBusiness); //修改拜访记录中间表
-			}else{
-				//检查业务锁定情况
-				businessLockedList = userMapper.selectLockedProject(fbb.getUid(), null,ub.getBusinessProjectId(), 1, UserLockReleaseStatus.LOCKED.getCode());
-				if(businessLockedList.size() > 0){
-					for(LockingReleaseBo bo : businessLockedList){
-						if(bo.getAid().equals(TokenManager.getAdminId())) isBusinessOwner = true;
-					}
-					if(!isBusinessOwner) throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_LOCKED,businessName,""));
+		if(fbb.getUserBusinessList().size()>0){
+			//检查客户锁定情况
+			boolean isUserOwner = false;
+			List<LockingReleaseBo> userLockedList = userMapper.selectLockedProject(fbb.getUid(), TokenManager.getAdminId(),null, 0, UserLockReleaseStatus.LOCKED.getCode());
+			if(userLockedList.size() > 0){
+				isUserOwner = true;
+			}
+			boolean isBusinessOwner = false;	
+			List<LockingReleaseBo> businessLockedList = null;
+			String businessName= "";
+			UserFollowBusiness userFollowBusiness = null;
+			for(BusinessListBo ub: fbb.getUserBusinessList()){
+				userFollowBusiness = new UserFollowBusiness();
+				businessName = businessProjectMapper.selectByPrimaryKey(ub.getBusinessProjectId()).getBname();
+				if(StringUtils.isNotBlank(ub.getUfbId())){
+					userFollowBusiness.setId(ub.getUfbId());
+					userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+					userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userFollowBusiness.setRemarks(ub.getRemarks());
+					userFollowBusinessMapper.updateByPrimaryKeySelective(userFollowBusiness); //修改拜访记录中间表
 				}else{
-					if(!isUserOwner) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_LOCKED,businessName,""));
-				}
-				if(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){
-					throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_EXIST,businessName,""));
-				}
-				String ubId = UUID.randomUUID().toString();		
-				UserBusiness userBusiness = new UserBusiness();
-				//更新业务表
-				userBusiness.setId(ubId);
-				userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				try {
-					userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
-					userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
-				} catch (ParseException e) {
-					e.printStackTrace();
-				}
-				userBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userBusiness.setFollowSituation(ub.getFollowSituation());
-				userBusiness.setUid(fbb.getUid());
-				userBusiness.setAid(TokenManager.getAdminId());
-				userBusinessMapper.insert(userBusiness);	
-				//更新业务中间表
-				String ufbId = UUID.randomUUID().toString();
-				userFollowBusiness.setId(ufbId);
-				userFollowBusiness.setFollowId(fbb.getFollowId());
-				userFollowBusiness.setBusinessId(ubId);
-				userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
-				userFollowBusiness.setFollowSituation(ub.getFollowSituation());
-				userFollowBusiness.setRemarks(ub.getRemarks());
-				userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-				userFollowBusinessMapper.insert(userFollowBusiness);
-			}		
+					//检查业务锁定情况
+					businessLockedList = userMapper.selectLockedProject(fbb.getUid(), null,ub.getBusinessProjectId(), 1, UserLockReleaseStatus.LOCKED.getCode());
+					if(businessLockedList.size() > 0){
+						for(LockingReleaseBo bo : businessLockedList){
+							if(bo.getAid().equals(TokenManager.getAdminId())) isBusinessOwner = true;
+						}
+						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(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){
+						throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_EXIST,businessName,""));
+					}
+					String ubId = UUID.randomUUID().toString();		
+					UserBusiness userBusiness = new UserBusiness();
+					//更新业务表
+					userBusiness.setId(ubId);
+					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					try {
+						userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
+						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
+					userBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userBusiness.setFollowSituation(ub.getFollowSituation());
+					userBusiness.setUid(fbb.getUid());
+					userBusiness.setAid(TokenManager.getAdminId());
+					userBusinessMapper.insert(userBusiness);	
+					//更新业务中间表
+					String ufbId = UUID.randomUUID().toString();
+					userFollowBusiness.setId(ufbId);
+					userFollowBusiness.setFollowId(fbb.getFollowId());
+					userFollowBusiness.setBusinessId(ubId);
+					userFollowBusiness.setCustomerStatus(ub.getCustomerStatus());
+					userFollowBusiness.setFollowSituation(ub.getFollowSituation());
+					userFollowBusiness.setRemarks(ub.getRemarks());
+					userFollowBusiness.setBusinessProjectId(ub.getBusinessProjectId());
+					userFollowBusinessMapper.insert(userFollowBusiness);
+				}		
+			}
 		}
 		return 1;
 	}