|
|
@@ -402,6 +402,24 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements
|
|
|
if(StringUtils.isNotBlank(ub.getBusinessId())){
|
|
|
//更新业务表
|
|
|
userBusiness.setId(ub.getBusinessId());
|
|
|
+ UserBusiness us=userBusinessMapper.selectByPrimaryKey(ub.getBusinessId());
|
|
|
+ if (us.getFollowSituation()==5&& userBusiness.getFollowSituation()!=5) {//如果已签合同,则不允许变更
|
|
|
+ throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_LOCKED,""));
|
|
|
+ }
|
|
|
+ //检查业务锁定情况
|
|
|
+ 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 (userBusiness.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
|
|
|
+ if(isBusinessOwner) releaseProject(businessLockedList);
|
|
|
+ lockProject(fbb.getUserBusinessList());//锁定客户业务
|
|
|
+ }
|
|
|
userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
|
|
|
userBusiness.setCustomerStatus(ub.getCustomerStatus());
|
|
|
userBusiness.setFollowSituation(ub.getFollowSituation());
|
|
|
@@ -433,9 +451,15 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements
|
|
|
}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,""));
|
|
|
}
|
|
|
+ if (userBusiness.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
|
|
|
+
|
|
|
+ if(isBusinessOwner) releaseProject(businessLockedList);
|
|
|
+ lockProject(fbb.getUserBusinessList());//锁定客户业务
|
|
|
+ }
|
|
|
String ubId = UUID.randomUUID().toString();
|
|
|
//更新业务表
|
|
|
userBusiness.setId(ubId);
|
|
|
@@ -467,6 +491,42 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void lockProject(List<BusinessListBo> userBusinessList) {
|
|
|
+ UserLockRelease ulr = null;
|
|
|
+ for(BusinessListBo b : userBusinessList){
|
|
|
+ //新增锁定数据
|
|
|
+ ulr = new UserLockRelease();
|
|
|
+ ulr.setId(UUID.randomUUID().toString());
|
|
|
+ ulr.setType(1);
|
|
|
+ ulr.setAid(TokenManager.getAdminId());
|
|
|
+ ulr.setBusinessProjectId(b.getBusinessProjectId());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " );
|
|
|
+ try {
|
|
|
+ ulr.setLockTime(sdf.parse(b.getCreateTime()));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ ulr.setStatus(UserLockReleaseStatus.LOCKED.getCode());
|
|
|
+ ulr.setUid(b.getUid());
|
|
|
+ userLockReleaseMapper.insert(ulr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void releaseProject(List<LockingReleaseBo> businessLockedList) {
|
|
|
+ if(businessLockedList != null && businessLockedList.size()>0){
|
|
|
+ UserLockRelease ulr = null;
|
|
|
+ for(LockingReleaseBo bo : businessLockedList){
|
|
|
+ ulr = new UserLockRelease();
|
|
|
+ ulr.setId(bo.getId());
|
|
|
+ ulr.setStatus(UserLockReleaseStatus.RELEASE.getCode());
|
|
|
+ userLockReleaseMapper.updateByPrimaryKeySelective(ulr);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public FollowBusinessBo findFollowById(String followId) {
|
|
|
|