Browse Source

客户锁定、释放的规则变更

anderx 7 years ago
parent
commit
d4d8f384d5

+ 2 - 6
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -379,17 +379,13 @@
 		t0.uid,
 		t0.aid,
 		t0.lock_time,
-		t1.last_follow_time,
-		t2.last_sign_time
+		t1.last_follow_time
 	from
 		(select id,uid,aid,lock_time from user_lock_release t0 where aid = #{aid} and type = 1 and status = 0)t0
 	left join 
 		(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
 	on t0.uid = t1.uid 
-	left join
-		(select buyer_id,salesman_id,max(sign_time) as last_sign_time from t_order where salesman_id = #{aid} group by buyer_id)t2
-	on t0.uid = t2.buyer_id
-	where datediff(t1.last_follow_time,lock_time)>360 or datediff(t2.last_sign_time,t0.lock_time)>900
+	where datediff(t1.last_follow_time,lock_time)>360 or datediff(now(),t0.lock_time)>900
   </select>
   
   <update id="updateReleaseLock" parameterType="java.lang.String">

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

@@ -295,8 +295,9 @@
 			<!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
 		inner join
 			(select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
-		on t0.buyer_id = t2.id
-		left join user_identity b on t0.buyer_id = b.uid where 1 = 1
+		on t0.uid = t2.id
+		left join user_identity b on t0.uid = b.uid
+		 where 1 = 1
 		<if test="name != null and name != ''">
 			and t2.identify_name like concat('%',#{name},'%')
 		</if>

+ 1 - 1
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -38,7 +38,7 @@ public class ReleaseUserTask {
 		for(User u : userList){
 			userTmpList = customerServiceImpl.selectWaitReleaseCustomer(u.getId());
 			lockUserList.addAll(userTmpList);
-			businessTmpList = customerServiceImpl.selectLockedProject(u.getId());
+			businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
 			lockBusinessList.addAll(businessTmpList);
 		}
 		if(lockUserList.size()>0) customerServiceImpl.updateReleaseLock(lockUserList,releaseTime);

+ 15 - 9
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -403,7 +403,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 					//更新业务表
 					userBusiness.setId(ub.getBusinessId());
 					UserBusiness us=userBusinessMapper.selectByPrimaryKey(ub.getBusinessId());
-					if (us.getFollowSituation()==5&& userBusiness.getFollowSituation()!=5) {//如果已签合同,则不允许变更
+					if (us.getFollowSituation()==5&& ub.getFollowSituation()!=5) {//如果已签合同,则不允许变更
 						throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_LOCKED,""));
 					}
 					//检查业务锁定情况
@@ -416,13 +416,14 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 					}else{ 
 						if(!isUserOwner) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_LOCKED,businessName,""));
 					}
-					if (userBusiness.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
+					if (ub.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
 						if(isBusinessOwner) releaseProject(businessLockedList);
-						lockProject(fbb.getUserBusinessList());//锁定客户业务
+						lockProject(fbb);//锁定客户业务
 					}		
 					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
 					userBusiness.setCustomerStatus(ub.getCustomerStatus());
 					userBusiness.setFollowSituation(ub.getFollowSituation());
+					userBusiness.setRemarks(ub.getRemarks());
 					userBusiness.setUid(fbb.getUid());
 					try {
 						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
@@ -455,10 +456,9 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 					if(userBusinessMapper.judgeBusiness(fbb.getUid(), ub.getBusinessProjectId(), "")>0){
 						throw new BusinessException(new Error(ErrorConstants.BUSINESS_ALREADY_EXIST,businessName,""));
 					}
-					if (userBusiness.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
-						
+					if (ub.getFollowSituation()==5) {//如果改成已签合同,则锁定业务
 						if(isBusinessOwner) releaseProject(businessLockedList);
-						lockProject(fbb.getUserBusinessList());//锁定客户业务
+						lockProject(fbb);//锁定客户业务
 					}
 					String ubId = UUID.randomUUID().toString();
 					//更新业务表
@@ -474,6 +474,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 					userBusiness.setFollowSituation(ub.getFollowSituation());
 					userBusiness.setUid(fbb.getUid());
 					userBusiness.setAid(TokenManager.getAdminId());
+					userBusiness.setRemarks(ub.getRemarks());
 					userBusinessMapper.insert(userBusiness);	
 					//更新业务中间表
 					userFollowBusiness.setBusinessId(ubId);
@@ -491,7 +492,8 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		return 1;
 	}
 
-	private void lockProject(List<BusinessListBo> userBusinessList) {
+	private void lockProject(FollowBusinessBo fb) {
+		List<BusinessListBo> userBusinessList=fb.getUserBusinessList();
 		UserLockRelease ulr = null;
 		for(BusinessListBo b : userBusinessList){
 			//新增锁定数据
@@ -502,12 +504,16 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 			ulr.setBusinessProjectId(b.getBusinessProjectId());
 			SimpleDateFormat sdf =   new SimpleDateFormat( " yyyy-MM-dd HH:mm:ss " ); 
 			try {
-				ulr.setLockTime(sdf.parse(b.getCreateTime()));
+				if (null==b.getCreateTime()) {
+					ulr.setLockTime(new Date());
+				}else {
+					ulr.setLockTime(sdf.parse(b.getCreateTime()));
+				}
 			} catch (ParseException e) {
 				e.printStackTrace();
 			}
 			ulr.setStatus(UserLockReleaseStatus.LOCKED.getCode());
-			ulr.setUid(b.getUid());
+			ulr.setUid(fb.getUid());
 			userLockReleaseMapper.insert(ulr);
 		}
 	}