|
|
@@ -26,7 +26,6 @@ import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
import me.chanjar.weixin.cp.bean.kf.*;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
@@ -65,11 +64,10 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
.collect(Collectors.toList());
|
|
|
Map<String, List<SysWechatCustomerDeptVo>> parentGroup = deptVos.stream()
|
|
|
.collect(Collectors.groupingBy(SysWechatCustomerDeptVo::getParentId));
|
|
|
- Set<String> strings = parentGroup.keySet();
|
|
|
-
|
|
|
+ List<String> collect = deptVos.stream().map(SysWechatCustomerDeptVo::getDeptId).collect(Collectors.toList());
|
|
|
deptVos.forEach(node -> node.setChildDept(parentGroup.getOrDefault(node.getDeptId(), Collections.emptyList())));
|
|
|
return deptVos.stream()
|
|
|
- .filter(node -> node.getParentId() != null && strings.contains(node.getDeptId()))
|
|
|
+ .filter(node -> node.getParentId() != null && !collect.contains(node.getParentId()))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@@ -100,12 +98,33 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
// 设置值班时间
|
|
|
sysWechatCustomerVoPageInfo.getList().forEach(sysWechatCustomerVo -> {
|
|
|
List<SysWechatCustomerDuty> sysWechatCustomerDuties = dutyMap.get(Long.valueOf(sysWechatCustomerVo.getId()));
|
|
|
- if (!CollectionUtils.isEmpty(sysWechatCustomerDuties)) {
|
|
|
- List<String> collect = sysWechatCustomerDuties.stream()
|
|
|
+ if(CollectionUtils.isEmpty(sysWechatCustomerDuties)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, List<SysWechatCustomerDuty>> collect = sysWechatCustomerDuties.stream()
|
|
|
+ .collect(Collectors.groupingBy(SysWechatCustomerDuty::getDutyCustomerId));
|
|
|
+
|
|
|
+ Map<Long, SysWechatCustomer> collect2 = sysWechatCustomerService.lambdaQuery()
|
|
|
+ .in(SysWechatCustomer::getId, collect.keySet())
|
|
|
+ .list()
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(SysWechatCustomer::getId, x -> x));
|
|
|
+
|
|
|
+ collect.keySet().forEach(sysWechatCustomerVoId -> {
|
|
|
+ SysWechatCustomerVo.DutyCustomerDTO dutyCustomerDTO = new SysWechatCustomerVo.DutyCustomerDTO();
|
|
|
+ List<SysWechatCustomerDuty> sysWechatCustomerDuties1 = collect.get(sysWechatCustomerVoId);
|
|
|
+ List<String> collect1 = sysWechatCustomerDuties1.stream()
|
|
|
.map(x -> DateTimeUtil.startAndEndTimeFormatting(x.getStartTime(), x.getEndTime()))
|
|
|
.collect(Collectors.toList());
|
|
|
- sysWechatCustomerVo.setDutyDatetime(collect);
|
|
|
- }
|
|
|
+ SysWechatCustomer sysWechatCustomer = collect2.get(sysWechatCustomerVoId);
|
|
|
+ if(!ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
+ dutyCustomerDTO.setDutyCustomer(sysWechatCustomer.getNickname());
|
|
|
+ }
|
|
|
+ dutyCustomerDTO.setDutyDatetime(collect1);
|
|
|
+ sysWechatCustomerVo.getDutyCustomerDTO().add(dutyCustomerDTO);
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -158,7 +177,7 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
@Override
|
|
|
public void deleteWechatCustomer(String customerId) throws WxErrorException {
|
|
|
SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByIdExist(customerId, "客服不存在");
|
|
|
- sysWechatCustomerService.isDutyCustomerId(sysWechatCustomer.getId());
|
|
|
+ sysWechatCustomerDutyService.isDutyCustomerId(sysWechatCustomer.getId());
|
|
|
WxCpKfAccountDel wxCpKfAccountDel = new WxCpKfAccountDel();
|
|
|
wxCpKfAccountDel.setOpenKfid(sysWechatCustomer.getOpenKfId());
|
|
|
WxCpBaseResp wxCpBaseResp;
|
|
|
@@ -172,7 +191,7 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
@Override
|
|
|
public void updateWechatCustomer(String customerId, SysWechatCustomerAddVo sysWechatCustomerAddVo) throws WxErrorException {
|
|
|
SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByIdExist(customerId, "客服不存在");
|
|
|
- if(!sysWechatCustomer.getNickname().equals(sysWechatCustomerAddVo.getNickname())){
|
|
|
+ if (!sysWechatCustomer.getNickname().equals(sysWechatCustomerAddVo.getNickname())) {
|
|
|
sysWechatCustomerService.isNicknameRepeat(sysWechatCustomerAddVo.getNickname());
|
|
|
}
|
|
|
WxCpKfAccountUpd wxCpKfAccountUpd = new WxCpKfAccountUpd();
|
|
|
@@ -221,13 +240,16 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
|
|
|
@Override
|
|
|
public String getWeChatCustomer(SysUser user) throws WxErrorException {
|
|
|
- SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByUserId(user.getLeaderId());
|
|
|
- List<SysWechatCustomer> sysWechatCustomerList = sysWechatCustomerService.list();
|
|
|
- List<Long> sysWechatCustomerIdList = sysWechatCustomerList.stream()
|
|
|
- .map(SysWechatCustomer::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ SysWechatCustomer sysWechatCustomer = null;
|
|
|
+ if(!ObjectUtils.isEmpty(user)){
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.getByUserId(user.getLeaderId());
|
|
|
+ }
|
|
|
if (ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
// 获取最近一次的客服记录
|
|
|
+ List<SysWechatCustomer> sysWechatCustomerList = sysWechatCustomerService.list();
|
|
|
+ List<Long> sysWechatCustomerIdList = sysWechatCustomerList.stream()
|
|
|
+ .map(SysWechatCustomer::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
SysWechatCustomerRecording sysWechatCustomerRecording = sysWechatCustomerRecordingService.lambdaQuery()
|
|
|
.in(!sysWechatCustomerIdList.isEmpty(), SysWechatCustomerRecording::getCustomerId, sysWechatCustomerIdList)
|
|
|
.eq(SysWechatCustomerRecording::getUserId, user.getId())
|
|
|
@@ -235,14 +257,14 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
.last("limit 1")
|
|
|
.one();
|
|
|
if (ObjectUtils.isEmpty(sysWechatCustomerRecording)) {
|
|
|
- sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
|
|
|
} else {
|
|
|
// 使用上一次的客服
|
|
|
sysWechatCustomer = sysWechatCustomerService.lambdaQuery()
|
|
|
.eq(SysWechatCustomer::getId, sysWechatCustomerRecording.getCustomerId())
|
|
|
.one();
|
|
|
if (ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
- sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.getCacheCustomerId(sysWechatCustomer);
|
|
|
}
|
|
|
}
|
|
|
SysWechatCustomerRecording customerRecording = new SysWechatCustomerRecording();
|
|
|
@@ -256,8 +278,9 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
.le(SysWechatCustomerDuty::getStartTime, LocalDateTime.now())
|
|
|
.ge(SysWechatCustomerDuty::getEndTime, LocalDateTime.now())
|
|
|
.list();
|
|
|
- if (sysWechatCustomer.getDutyCustomerId() > 0 && list != null && !list.isEmpty()) {
|
|
|
- sysWechatCustomer = sysWechatCustomerService.getById(sysWechatCustomer.getDutyCustomerId());
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ SysWechatCustomerDuty sysWechatCustomerDuty = list.get(0);
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.getById(sysWechatCustomerDuty.getDutyCustomerId());
|
|
|
}
|
|
|
|
|
|
if (ObjectUtils.isEmpty(sysWechatCustomer)) {
|