|
|
@@ -451,23 +451,42 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
}
|
|
|
addUserLock(uid, TokenManager.getAdminId(), now, uList);
|
|
|
addUserTransferLog(uid, TokenManager.getAdminId(), null,0, null, now, uList);
|
|
|
- updateAdminUserCountAddPrivate(user);
|
|
|
+
|
|
|
+ updateAdminUserCount(user.getAid(),user.getTransferTime());
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- private void updateAdminUserCountAddPrivate(User user) {
|
|
|
- String startTime=DateUtils.formatDate(user.getTransferTime(),AFTConstants.YYYYMMDD);
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param aid 管理员编号
|
|
|
+ * @param transferTime 客户转换时间
|
|
|
+ */
|
|
|
+ private void updateAdminUserCount(String aid ,Date transferTime) {
|
|
|
+ String startTime=DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
|
|
|
String endTime=startTime+" 23:59:59";
|
|
|
- //
|
|
|
- Integer i = adminUserCountMapper.updateByaidAndDate(user.getAid(), startTime, endTime);
|
|
|
- if (i==null||i==0){
|
|
|
- AdminUserCount adminUserCount=new AdminUserCount();
|
|
|
- adminUserCount.setDateTime(user.getTransferTime());
|
|
|
- adminUserCount.setPrivateCount(1);
|
|
|
- adminUserCount.setAid(user.getAid());
|
|
|
- adminUserCountMapper.insertSelective(adminUserCount);
|
|
|
- }
|
|
|
+ AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);
|
|
|
+ if (adminUserCount==null){
|
|
|
+ AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
|
|
|
+ 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) {
|
|
|
@@ -1251,6 +1270,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());
|
|
|
@@ -1265,6 +1287,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){
|
|
|
@@ -1287,6 +1310,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){
|
|
|
@@ -1298,6 +1329,14 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
if (data==2||data==3){
|
|
|
updateOrderHandOver(uid,aid,oldAid);
|
|
|
}
|
|
|
+ //单客户转交,需要将客户原来得数据修改,需要将新数据刷新
|
|
|
+ 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);
|
|
|
}
|
|
|
if (AFTConstants.USER_TRANSFER_TO_OTHER == operatorType) {
|
|
|
flag = updateUsersLock(uList, oldAid, UserLockReleaseStatus.LOCKED.getCode(),
|
|
|
@@ -1328,11 +1367,33 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
|
|
|
}
|
|
|
//处理用户客户统计
|
|
|
if (AFTConstants.USER_RECEIVE.equals(operatorType)){
|
|
|
- updateAdminUserCountAddPrivate(user);
|
|
|
+ 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);
|
|
|
@@ -1432,6 +1493,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);
|
|
|
@@ -1445,7 +1507,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
|
|
|
@@ -2287,9 +2351,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())) {
|
|
|
@@ -2301,14 +2369,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) {
|
|
|
//渠道
|