|
|
@@ -780,6 +780,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+
|
|
|
public List<OrganizationContactBook> findCustomerContacts(String uid) {
|
|
|
List<OrganizationContactBook> list = userMapper.findCustomerContacts(uid, null);
|
|
|
for (OrganizationContactBook ob : list) {
|
|
|
@@ -791,9 +792,10 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+
|
|
|
@Transactional
|
|
|
- public int addFollow(FollowBusinessBo fbb,String ufid,Integer mainStatus) throws BusinessException {
|
|
|
+ @Override
|
|
|
+ public int addFollow(FollowBusinessBo fbb,String ufid,Integer mainStatus,Integer type) throws BusinessException {
|
|
|
// 更新跟进记录表
|
|
|
Date followTime=DateUtils.StringToDate(fbb.getFollowTime(),AFTConstants.YYYYMMDDHHMMSS);
|
|
|
UserFollow userFollow = new UserFollow();
|
|
|
@@ -812,27 +814,92 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
userFollow.setUid(fbb.getUid());
|
|
|
int followCount = userBusinessMapper.selectFollowCountByUAid(fbb.getUid(), null) + 1;
|
|
|
userFollow.setFollowCount(followCount);
|
|
|
- //处理中间表
|
|
|
- UserMid um =new UserMid();
|
|
|
- um.setUid(userFollow.getUid());
|
|
|
- //检查客户,修改小程序打卡,如果负责人和跟进人是同一个,则刷新最后跟进时间
|
|
|
- User user = userMapper.selectByPrimaryKey(fbb.getUid());
|
|
|
- if (aid.equals(user.getAid())){
|
|
|
- um.setLastFollowTime(userFollow.getCreateTime());
|
|
|
- }
|
|
|
- um.setFollowNumber(followCount);
|
|
|
- um.setFollowExplain(userFollow.getResult());
|
|
|
- um.setFollowDep(userFollow.getFollowDep());
|
|
|
- um.setLastFollowType(userFollow.getContactType());
|
|
|
- um.setFollowAname(a.getName());
|
|
|
- userMidMapper.updateByUid(um);
|
|
|
+ userFollow.setType(0);
|
|
|
+ //处理中间表
|
|
|
+ UserMid um =new UserMid();
|
|
|
+ um.setUid(userFollow.getUid());
|
|
|
+ //检查客户,修改小程序打卡,如果负责人和跟进人是同一个,则刷新最后跟进时间
|
|
|
+ User user = userMapper.selectByPrimaryKey(fbb.getUid());
|
|
|
+ if (aid.equals(user.getAid())){
|
|
|
+ um.setLastFollowTime(userFollow.getCreateTime());
|
|
|
+ }
|
|
|
+ um.setFollowNumber(followCount);
|
|
|
+ um.setFollowExplain(userFollow.getResult());
|
|
|
+ um.setFollowDep(userFollow.getFollowDep());
|
|
|
+ um.setLastFollowType(userFollow.getContactType());
|
|
|
+ um.setFollowAname(a.getName());
|
|
|
+ userMidMapper.updateByUid(um);
|
|
|
+ if (type==0){
|
|
|
+ addUserFllow( fbb, ufid, mainStatus,followTime,followId);
|
|
|
+ }else if (type==1){
|
|
|
+ addRestrictProject(fbb, ufid, mainStatus,followTime,followId);
|
|
|
+ }
|
|
|
userFollowMapper.insert(userFollow);
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addRestrictProject(FollowBusinessBo fbb, String ufid, Integer mainStatus, Date followTime, String followId) {
|
|
|
+ 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();
|
|
|
+ UserBusiness us = userBusinessMapper.selectByPrimaryKey(ub.getBusinessId());
|
|
|
+ if (StringUtils.isNotBlank(ub.getBusinessId())) {
|
|
|
+ // 更新业务表
|
|
|
+ userBusiness.setId(ub.getBusinessId());
|
|
|
+ if (us.getFollowSituation() == 5) {// 如果已签合同,则不允许变更
|
|
|
+ if (ub.getCustomerStatus() != us.getCustomerStatus() && ub.getFollowSituation() != 5) {
|
|
|
+ throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_LOCKED, ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
|
|
|
+ userBusiness.setCustomerStatus(ub.getCustomerStatus());
|
|
|
+ userBusiness.setFollowSituation(ub.getFollowSituation());
|
|
|
+ userBusiness.setRemarks(ub.getRemarks());
|
|
|
+ userBusiness.setUid(fbb.getUid());
|
|
|
+ userBusiness.setUpdateTime(followTime);
|
|
|
+ userBusiness.setAid(TokenManager.getAdminId());
|
|
|
+ userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
|
|
+ // 更新业务中间表
|
|
|
+ addUserFollowBusiness(userFollowBusiness, ub.getBusinessProjectId(), ub, ufbId, followId);
|
|
|
+ } else {
|
|
|
+ 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());
|
|
|
+ userBusiness.setCreateTime(followTime);
|
|
|
+ userBusiness.setUpdateTime(followTime);
|
|
|
+ userBusiness.setCustomerStatus(ub.getCustomerStatus());
|
|
|
+ userBusiness.setFollowSituation(ub.getFollowSituation());
|
|
|
+ userBusiness.setUid(fbb.getUid());
|
|
|
+ userBusiness.setAid(TokenManager.getAdminId());
|
|
|
+ userBusiness.setRemarks(ub.getRemarks());
|
|
|
+ userBusinessMapper.insert(userBusiness);
|
|
|
+ // 更新业务中间表
|
|
|
+ addUserFollowBusiness(userFollowBusiness, ubId, ub, ufbId, followId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addUserFllow(FollowBusinessBo fbb,String ufid,Integer mainStatus,Date followTime,String followId) {
|
|
|
+ boolean isUserOwner = false;
|
|
|
// 检查客户锁定情况
|
|
|
- if (fbb.getUserBusinessList()!=null&&fbb.getUserBusinessList().size() > 0) {
|
|
|
- boolean isUserOwner = false;
|
|
|
+ if (fbb.getUserBusinessList()!=null&& !fbb.getUserBusinessList().isEmpty()) {
|
|
|
List<LockingReleaseBo> userLockedList = userMapper.selectLockedProject(fbb.getUid(),
|
|
|
TokenManager.getAdminId(), null, 0, UserLockReleaseStatus.LOCKED.getCode());
|
|
|
- if (userLockedList.size() > 0) {
|
|
|
+ if (!userLockedList.isEmpty()) {
|
|
|
isUserOwner = true;
|
|
|
}
|
|
|
boolean isBusinessOwner = false;
|
|
|
@@ -871,6 +938,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
throw new BusinessException(
|
|
|
new Error(ErrorConstants.CUSTOMER_ALREADY_LOCKED, businessName, ""));
|
|
|
}
|
|
|
+
|
|
|
// if (us.getFollowSituation()!=5&&ub.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
|
|
|
// if (StringUtils.isNotBlank(fbb.getUid())) ub.setUid(fbb.getUid());
|
|
|
// lockProject(ub);//锁定客户业务
|
|
|
@@ -885,19 +953,12 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
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);
|
|
|
+ addUserFollowBusiness(userFollowBusiness, ub.getBusinessProjectId(), ub, ufbId, followId);
|
|
|
} else {
|
|
|
// 检查业务锁定情况
|
|
|
businessLockedList = userMapper.selectLockedProject(fbb.getUid(), null, ub.getBusinessProjectId(),
|
|
|
1, UserLockReleaseStatus.LOCKED.getCode());
|
|
|
- if (businessLockedList.size() > 0) {
|
|
|
+ if (!businessLockedList.isEmpty()) {
|
|
|
for (LockingReleaseBo bo : businessLockedList) {
|
|
|
if (bo.getAid().equals(TokenManager.getAdminId()))
|
|
|
isBusinessOwner = true;
|
|
|
@@ -932,23 +993,26 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
userBusiness.setRemarks(ub.getRemarks());
|
|
|
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);
|
|
|
+ addUserFollowBusiness(userFollowBusiness, ubId, ub, ufbId, followId);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (mainStatus==1){
|
|
|
- followProject(fbb.getUid());
|
|
|
+ followProject(fbb.getUid());
|
|
|
}
|
|
|
- updateADminUserCountFollow(aid,followTime);
|
|
|
- return 1;
|
|
|
+ updateADminUserCountFollow(TokenManager.getAdminId(),followTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addUserFollowBusiness(UserFollowBusiness userFollowBusiness, String ub, BusinessListBo ub1, String ufbId, String followId) {
|
|
|
+ userFollowBusiness.setBusinessId(ub);
|
|
|
+ userFollowBusiness.setCustomerStatus(ub1.getCustomerStatus());
|
|
|
+ userFollowBusiness.setFollowSituation(ub1.getFollowSituation());
|
|
|
+ userFollowBusiness.setId(ufbId);
|
|
|
+ userFollowBusiness.setFollowId(followId);
|
|
|
+ userFollowBusiness.setRemarks(ub1.getRemarks());
|
|
|
+ userFollowBusiness.setBusinessProjectId(ub1.getBusinessProjectId());
|
|
|
+ userFollowBusinessMapper.insert(userFollowBusiness);
|
|
|
}
|
|
|
|
|
|
private void updateADminUserCountFollow(String aid, Date transferTime) {
|