|
|
@@ -842,23 +842,15 @@ public class CorpServiceImpl implements CorpService {
|
|
|
corpKfServicerSessionRecord.setServiceState(1);
|
|
|
corpKfServicerSessionRecordMapper.updateById(corpKfServicerSessionRecord);
|
|
|
}
|
|
|
- DateTime now = DateTime.now();
|
|
|
- String thisHourDate = DateUtil.format(now, "HH:mm");
|
|
|
- //星期天为1
|
|
|
- int dayOfWeek = DateUtil.dayOfWeek(now);
|
|
|
- //是否值班期
|
|
|
- Integer dutyHourCount = corpKfAccountFollowMapper.selectCount(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
|
|
|
- .eq(CorpKfAccountFollow::getOpenKfId, openKfId)
|
|
|
- .le(CorpKfAccountFollow::getStartTime, thisHourDate)
|
|
|
- .ge(CorpKfAccountFollow::getEndTime, thisHourDate)
|
|
|
- .eq(CorpKfAccountFollow::getDutyWeek, dayOfWeek));
|
|
|
+ //当前时间段值班客服
|
|
|
+ Set<String> dutyFollowIds = getDutyFollowIds(openKfId);
|
|
|
//非值班
|
|
|
- if (dutyHourCount == 0) {
|
|
|
+ if (dutyFollowIds.isEmpty()) {
|
|
|
//非值班时间 移入等待池
|
|
|
- log.info("当前客服账号:{}处于非值班时间:{},将客户:{}移入等待池", openKfId, thisHourDate, externalUserid);
|
|
|
- moveWaitingQueue(corpId, openKfId, externalUserid);
|
|
|
+ log.info("当前客服账号:{}处于非值班时间:{},将客户:{}移入等待池", openKfId, DateTime.now(), externalUserid);
|
|
|
//发送进入等待池消息
|
|
|
sendCorpKfTextTips(corpId, externalUserid, openKfId, corpKfAccountSessionConfig.getQueueTips());
|
|
|
+ moveWaitingQueue(corpId, openKfId, externalUserid);
|
|
|
return;
|
|
|
}
|
|
|
//获取接待人员列表
|
|
|
@@ -866,20 +858,20 @@ public class CorpServiceImpl implements CorpService {
|
|
|
List<CorpKfServicerResp.CorpKfServicer> servicerList = corpKfServicerResp.getServicerList();
|
|
|
//目前值班客服id
|
|
|
List<String> corpKfServiceIds = new ArrayList<>();
|
|
|
- List<CorpKfServicerResp.CorpKfServicer> corpKfServicers = servicerList.stream().filter(servicer -> {
|
|
|
- if (servicer.getUserid() != null && servicer.getStatus() == 0) {
|
|
|
+ servicerList.stream().filter(servicer -> {
|
|
|
+ if (servicer.getUserid() != null && servicer.getStatus() == 0 && dutyFollowIds.contains(servicer.getUserid())) {
|
|
|
corpKfServiceIds.add(servicer.getUserid());
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ });
|
|
|
//客服是否已经开始值班
|
|
|
//没有值班人员
|
|
|
- if (CollUtil.isEmpty(corpKfServicers)) {
|
|
|
+ if (CollUtil.isEmpty(corpKfServiceIds)) {
|
|
|
log.info("当前客服账号:{}无值班人员,将客户:{}移入等待池", openKfId, externalUserid);
|
|
|
+ sendCorpKfTextTips(corpId, externalUserid, openKfId, corpKfAccountSessionConfig.getQueueTips());
|
|
|
//接入等待池
|
|
|
moveWaitingQueue(corpId, openKfId, externalUserid);
|
|
|
- sendCorpKfTextTips(corpId, externalUserid, openKfId, corpKfAccountSessionConfig.getQueueTips());
|
|
|
return;
|
|
|
}
|
|
|
//是否有空闲接待人员
|
|
|
@@ -887,9 +879,9 @@ public class CorpServiceImpl implements CorpService {
|
|
|
//暂无分配会话 初始化
|
|
|
if (CollUtil.isEmpty(corpKfServicerDtos)) {
|
|
|
//随机分配一个客服
|
|
|
- CorpKfServicerResp.CorpKfServicer corpKfServicer = corpKfServicers.get(RandomUtil.randomInt(corpKfServicers.size()));
|
|
|
+ String servicerUserid = corpKfServiceIds.get(RandomUtil.randomInt(corpKfServiceIds.size()));
|
|
|
//变更会话状态
|
|
|
- transCorpKfSessionToServicer(corpId, openKfId, null, corpKfServicer.getUserid(), externalUserid, null, 3, sendDate, msgid);
|
|
|
+ transCorpKfSessionToServicer(corpId, openKfId, null, servicerUserid, externalUserid, null, 3, sendDate, msgid);
|
|
|
return;
|
|
|
}
|
|
|
//筛选符合条件的客服
|
|
|
@@ -899,10 +891,10 @@ public class CorpServiceImpl implements CorpService {
|
|
|
List<CorpKfServicerDto> filterKfCs = corpKfServicerDtos.stream().filter(kfCs -> corpKfServiceIds.contains(kfCs.getServicerUserid()) && kfCs.getNum() < maxNum).collect(Collectors.toList());
|
|
|
if (CollUtil.isEmpty(filterKfCs)) {
|
|
|
log.info("当前客服账号:{}值班接待上限:{},将客户:{}移入等待池", openKfId, maxNum, externalUserid);
|
|
|
- //移入等待池
|
|
|
- moveWaitingQueue(corpId, openKfId, externalUserid);
|
|
|
//发送进入等待池消息
|
|
|
sendCorpKfTextTips(corpId, externalUserid, openKfId, corpKfAccountSessionConfig.getQueueTips());
|
|
|
+ //移入等待池
|
|
|
+ moveWaitingQueue(corpId, openKfId, externalUserid);
|
|
|
return;
|
|
|
}
|
|
|
//选择第一个分配接待
|
|
|
@@ -985,4 +977,27 @@ public class CorpServiceImpl implements CorpService {
|
|
|
.le(CorpKfWaitingQueueUser::getCreatedTime, sendDate)
|
|
|
.last("limit 1"))).ifPresent(queueUser -> corpKfWaitingQueueUserMapper.deleteById(queueUser.getId()));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前值班客服
|
|
|
+ */
|
|
|
+ public Set<String> getDutyFollowIds(String openKfId) throws Exception {
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ String thisHourDate = DateUtil.format(now, "HH:mm");
|
|
|
+ //星期天为1
|
|
|
+ int dayOfWeek = DateUtil.dayOfWeek(now);
|
|
|
+ //是否值班期
|
|
|
+ List<CorpKfAccountFollow> corpKfAccountFollows = corpKfAccountFollowMapper.selectList(Wrappers.lambdaQuery(CorpKfAccountFollow.class)
|
|
|
+ .eq(CorpKfAccountFollow::getOpenKfId, openKfId)
|
|
|
+ .le(CorpKfAccountFollow::getStartTime, thisHourDate)
|
|
|
+ .ge(CorpKfAccountFollow::getEndTime, thisHourDate)
|
|
|
+ .eq(CorpKfAccountFollow::getDutyWeek, dayOfWeek));
|
|
|
+
|
|
|
+ //目前时间段需要值班的客服
|
|
|
+ Set<String> thisHourDutyFollows = new HashSet<>();
|
|
|
+ for (CorpKfAccountFollow corpKfAccountFollow : corpKfAccountFollows) {
|
|
|
+ thisHourDutyFollows.addAll(Jsons.parseList(corpKfAccountFollow.getUserIdList(), String.class));
|
|
|
+ }
|
|
|
+ return thisHourDutyFollows;
|
|
|
+ }
|
|
|
}
|