|
|
@@ -106,7 +106,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
private PublicReleaseMapper publicReleaseMapper;
|
|
|
@Autowired
|
|
|
private SystemWebSocketHandler systemWebSocketHandler;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private AdminUserCountMapper adminUserCountMapper;
|
|
|
@Autowired
|
|
|
private AsyncUtils asyncUtils;
|
|
|
|
|
|
@@ -450,9 +451,44 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
}
|
|
|
addUserLock(uid, TokenManager.getAdminId(), now, uList);
|
|
|
addUserTransferLog(uid, TokenManager.getAdminId(), null,0, null, now, uList);
|
|
|
+
|
|
|
+ updateAdminUserCount(user.getAid(),user.getTransferTime());
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param aid 管理员编号
|
|
|
+ * @param transferTime 客户转换时间
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateAdminUserCount(String aid ,Date transferTime) {
|
|
|
+ String startTime=DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
|
|
|
+ String endTime=startTime+" 23:59:59";
|
|
|
+ AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);
|
|
|
+ if (adminUserCount==null){
|
|
|
+ AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
|
|
|
+ if(selectAUC!=null) adminUserCountMapper.insertSelective(selectAUC);
|
|
|
+ }else {
|
|
|
+ AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
|
|
|
+ AdminUserCount newAUC=new AdminUserCount();
|
|
|
+ newAUC.setId(adminUserCount.getId());
|
|
|
+ if (selectAUC==null){
|
|
|
+ newAUC.setPrivateCount(0);
|
|
|
+ newAUC.setChannelCount(0);
|
|
|
+ newAUC.setSignCount(0);
|
|
|
+ }else {
|
|
|
+ if (selectAUC.getPrivateCount()==null)selectAUC.setPrivateCount(0);
|
|
|
+ if (selectAUC.getChannelCount()==null)selectAUC.setChannelCount(0);
|
|
|
+ if (selectAUC.getSignCount()==null)selectAUC.setSignCount(0);
|
|
|
+ newAUC.setPrivateCount(selectAUC.getPrivateCount());
|
|
|
+ newAUC.setChannelCount(selectAUC.getChannelCount());
|
|
|
+ newAUC.setSignCount(selectAUC.getSignCount());
|
|
|
+ }
|
|
|
+ adminUserCountMapper.updateByPrimaryKeySelective(newAUC);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void checkUserName(InputAddCustomer in) {
|
|
|
if (userMapper.checkUser("", in.getName(), "", in.getType(), null, null).size() > 0)
|
|
|
throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_EXIST, in.getName(), ""));
|
|
|
@@ -711,7 +747,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
@Transactional
|
|
|
public int addFollow(FollowBusinessBo fbb,String ufid,Integer mainStatus) throws BusinessException {
|
|
|
// 更新跟进记录表
|
|
|
- SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
|
|
|
+ Date followTime=DateUtils.StringToDate(fbb.getFollowTime(),AFTConstants.YYYYMMDDHHMMSS);
|
|
|
UserFollow userFollow = new UserFollow();
|
|
|
String followId = ufid==null?UUID.randomUUID().toString():ufid;
|
|
|
userFollow.setId(followId);
|
|
|
@@ -722,11 +758,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
userFollow.setFollowDep(a.getDepartmentName());
|
|
|
userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
|
|
|
userFollow.setEffective(DeleteStatus.UNDELETE.getCode());
|
|
|
- try {
|
|
|
- userFollow.setCreateTime(format.parse(fbb.getFollowTime()));
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ userFollow.setCreateTime(followTime);
|
|
|
userFollow.setOcbId(fbb.getOcbId());
|
|
|
userFollow.setResult(fbb.getResult());
|
|
|
userFollow.setUid(fbb.getUid());
|
|
|
@@ -801,11 +833,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
userBusiness.setFollowSituation(ub.getFollowSituation());
|
|
|
userBusiness.setRemarks(ub.getRemarks());
|
|
|
userBusiness.setUid(fbb.getUid());
|
|
|
- try {
|
|
|
- userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ userBusiness.setUpdateTime(followTime);
|
|
|
userBusiness.setAid(TokenManager.getAdminId());
|
|
|
userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
|
|
// 更新业务中间表
|
|
|
@@ -847,12 +875,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
// 更新业务表
|
|
|
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.setCreateTime(followTime);
|
|
|
+ userBusiness.setUpdateTime(followTime);
|
|
|
userBusiness.setCustomerStatus(ub.getCustomerStatus());
|
|
|
userBusiness.setFollowSituation(ub.getFollowSituation());
|
|
|
userBusiness.setUid(fbb.getUid());
|
|
|
@@ -875,9 +899,47 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
if (mainStatus==1){
|
|
|
followProject(fbb.getUid());
|
|
|
}
|
|
|
+ updateADminUserCountFollow(aid,followTime);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void updateADminUserCountFollow(String aid, Date transferTime) {
|
|
|
+ {
|
|
|
+ String startTime= DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
|
|
|
+ String endTime=startTime+" 23:59:59";
|
|
|
+ AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);
|
|
|
+ int count = userFollowMapper.selectByaidAndDate(aid, startTime, endTime);
|
|
|
+ if (adminUserCount==null){
|
|
|
+ AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
|
|
|
+ if (selectAUC==null)selectAUC=new AdminUserCount();
|
|
|
+ selectAUC.setFollowCount(count);
|
|
|
+ selectAUC.setAid(aid);
|
|
|
+ selectAUC.setDateTime(transferTime);
|
|
|
+ adminUserCountMapper.insertSelective(selectAUC);
|
|
|
+ }else {
|
|
|
+ AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
|
|
|
+ AdminUserCount newAUC=new AdminUserCount();
|
|
|
+ newAUC.setId(adminUserCount.getId());
|
|
|
+ newAUC.setFollowCount(count);
|
|
|
+ if (selectAUC==null){
|
|
|
+ newAUC.setPrivateCount(0);
|
|
|
+ newAUC.setChannelCount(0);
|
|
|
+ newAUC.setSignCount(0);
|
|
|
+ }else {
|
|
|
+ if (selectAUC.getPrivateCount()==null)selectAUC.setPrivateCount(0);
|
|
|
+ if (selectAUC.getChannelCount()==null)selectAUC.setChannelCount(0);
|
|
|
+ if (selectAUC.getSignCount()==null)selectAUC.setSignCount(0);
|
|
|
+ newAUC.setPrivateCount(selectAUC.getPrivateCount());
|
|
|
+ newAUC.setChannelCount(selectAUC.getChannelCount());
|
|
|
+ newAUC.setSignCount(selectAUC.getSignCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ adminUserCountMapper.updateByPrimaryKeySelective(newAUC);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 跟进更新用户中间表
|
|
|
*
|
|
|
@@ -1234,6 +1296,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
user.setId(uid);
|
|
|
user.setTransferTime(now);
|
|
|
int flag = 0;
|
|
|
+ //记录旧数据值,与新数据值 将旧数据与新数据都需要更新
|
|
|
+ List<User> useList=new ArrayList<>();
|
|
|
+ List<User> newList=new ArrayList<>();
|
|
|
//领取
|
|
|
if (AFTConstants.USER_RECEIVE.equals(operatorType)) {
|
|
|
user.setAid(TokenManager.getAdminId());
|
|
|
@@ -1248,6 +1313,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
} else if (AFTConstants.USER_TRANSFER_TO_OTHER.equals(operatorType)
|
|
|
|| AFTConstants.SIGN_USER_TRANSFER_TO_OTHER .equals(operatorType)
|
|
|
|| AFTConstants.CHANNEL_USER_TRANSFER_TO_OTHER .equals(operatorType)) {
|
|
|
+
|
|
|
if (!isUs) {
|
|
|
user.setAid(aid);
|
|
|
if (data==1||data==3){
|
|
|
@@ -1270,6 +1336,14 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
throw new BusinessException(new Error(ErrorConstants.CUSTOMER_TRANSFER_FAIL, ""));
|
|
|
}
|
|
|
updateUserMid(aid,uid,0,null);
|
|
|
+ //单客户转交,需要将客户原来得数据修改,需要将新数据刷新
|
|
|
+ User use = userMapper.selectByPrimaryKey(uid);
|
|
|
+ useList.add(use);
|
|
|
+ User newUser=new User();
|
|
|
+ newUser.setAid(aid);
|
|
|
+ newUser.setTransferTime(now);
|
|
|
+ newUser.setShareType(use.getShareType());
|
|
|
+ newList.add(newUser);
|
|
|
} else {
|
|
|
for (String us : uList) {
|
|
|
if (userMapper.getAidAndUser(us, TokenManager.getAdminId()) <= 0){
|
|
|
@@ -1281,6 +1355,14 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
if (data==2||data==3){
|
|
|
updateOrderHandOver(uid,aid,oldAid);
|
|
|
}
|
|
|
+ //单客户转交,需要将客户原来得数据修改,需要将新数据刷新
|
|
|
+ User use = userMapper.selectByPrimaryKey(us);
|
|
|
+ useList.add(use);
|
|
|
+ User newUser=new User();
|
|
|
+ newUser.setAid(aid);
|
|
|
+ newUser.setTransferTime(use.getTransferTime());
|
|
|
+ newUser.setShareType(use.getShareType());
|
|
|
+ newList.add(newUser);
|
|
|
}
|
|
|
if (AFTConstants.USER_TRANSFER_TO_OTHER == operatorType) {
|
|
|
flag = updateUsersLock(uList, oldAid, UserLockReleaseStatus.LOCKED.getCode(),
|
|
|
@@ -1309,9 +1391,35 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
} else {
|
|
|
userMapper.updateByPrimaryKeySelective(user);
|
|
|
}
|
|
|
+ //处理用户客户统计
|
|
|
+ if (AFTConstants.USER_RECEIVE.equals(operatorType)){
|
|
|
+ updateAdminUserCount(user.getAid(),user.getTransferTime());
|
|
|
+ }
|
|
|
+ if (AFTConstants.USER_TRANSFER_TO_OTHER.equals(operatorType)
|
|
|
+ || AFTConstants.SIGN_USER_TRANSFER_TO_OTHER .equals(operatorType)
|
|
|
+ || AFTConstants.CHANNEL_USER_TRANSFER_TO_OTHER .equals(operatorType)) {
|
|
|
+ updateAdminUserCountTransfer(useList,newList);
|
|
|
+ }
|
|
|
return errors;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param useList
|
|
|
+ * @param newList
|
|
|
+ */
|
|
|
+ private void updateAdminUserCountTransfer(List<User> useList, List<User> newList) {
|
|
|
+ for (User u : useList) {
|
|
|
+
|
|
|
+ updateAdminUserCount(u.getAid(),u.getTransferTime());
|
|
|
+ }
|
|
|
+ for (User u : newList) {
|
|
|
+
|
|
|
+ updateAdminUserCount(u.getAid(),u.getTransferTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void transferUser(List<String> uList, String aid, String uid) {
|
|
|
if(uList.isEmpty())uList.add(uid);
|
|
|
@@ -1411,6 +1519,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
@Override
|
|
|
public int pushReceiveAsChannel(String uid) {
|
|
|
Date date = new Date();
|
|
|
+ User use=userMapper.selectByPrimaryKey(uid);
|
|
|
User u =new User();
|
|
|
String aid=TokenManager.getAdminId();
|
|
|
u.setId(uid);
|
|
|
@@ -1424,7 +1533,9 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
addUserLock(uid,aid, date, null); // 指定用户锁定客户
|
|
|
updateUserMid(aid,uid,0,null);
|
|
|
addUserTransferLog(uid, aid,null, 15, null, date, null);
|
|
|
- return userMapper.updateByPrimaryKeySelective(u);
|
|
|
+ userMapper.updateByPrimaryKeySelective(u);
|
|
|
+ updateAdminUserCount(use.getAid(),use.getTransferTime());
|
|
|
+ return 1;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -2266,9 +2377,13 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
utl.setUid(id);
|
|
|
userTransferLogMapper.insertSelective(utl);
|
|
|
userLockReleaseMapper.updateUserTypeLock(u.getId(), TokenManager.getAdminId(), 0, 2, date);
|
|
|
+ //用户客户统计移除时修改
|
|
|
+ updateAdminUserCount(u.getAid(),u.getTransferTime());
|
|
|
+
|
|
|
} else {
|
|
|
List<String> list = Arrays.asList(id.split(","));
|
|
|
List<UserTransferLog> ulList = new ArrayList<UserTransferLog>();
|
|
|
+ List<User> userList=new ArrayList<>();
|
|
|
for (String str : list) {
|
|
|
User u = userMapper.selectByPrimaryKey(str);
|
|
|
if (!u.getAid().equals(TokenManager.getAdminId())) {
|
|
|
@@ -2280,14 +2395,25 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
utl.setType(6);
|
|
|
utl.setUid(str);
|
|
|
ulList.add(utl);
|
|
|
+ userList.add(u);
|
|
|
}
|
|
|
+
|
|
|
userTransferLogMapper.insertList(ulList);
|
|
|
userMapper.updateList(null, null, null, date, 1, list,null);
|
|
|
userLockReleaseMapper.updateUserTypeLockList(list, TokenManager.getAdminId(), 0, 2, date);
|
|
|
+ //批量移除客户,需要单独处理客户每天得计算。
|
|
|
+ updateAdminUserAllCount(userList);
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void updateAdminUserAllCount(List<User> userList) {
|
|
|
+ for (User user : userList) {
|
|
|
+ updateAdminUserCount(user.getAid(),user.getTransferTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<userDaysBo> selectReleaseUserDays(String id) {
|
|
|
//渠道
|