|
|
@@ -2,11 +2,14 @@ package com.ydtech.modules.admin.service.impl;
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
import com.ydtech.modules.admin.model.po.SysWechatCustomer;
|
|
|
import com.ydtech.modules.admin.model.po.SysWechatCustomerDuty;
|
|
|
+import com.ydtech.modules.admin.model.po.SysWechatCustomerRecording;
|
|
|
import com.ydtech.modules.admin.model.vo.wechat.*;
|
|
|
import com.ydtech.modules.admin.service.SysWechatCustomerBusinessService;
|
|
|
import com.ydtech.modules.admin.service.SysWechatCustomerDutyService;
|
|
|
+import com.ydtech.modules.admin.service.SysWechatCustomerRecordingService;
|
|
|
import com.ydtech.modules.admin.service.SysWechatCustomerService;
|
|
|
import com.ydtech.modules.order.entity.BasePageResult;
|
|
|
import com.ydtech.modules.order.entity.po.InsUploadFiles;
|
|
|
@@ -24,9 +27,12 @@ import me.chanjar.weixin.cp.bean.WxCpDepart;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
import me.chanjar.weixin.cp.bean.kf.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -48,6 +54,8 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
|
|
|
private final SysWechatCustomerDutyService sysWechatCustomerDutyService;
|
|
|
|
|
|
+ private final SysWechatCustomerRecordingService sysWechatCustomerRecordingService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<SysWechatCustomerDeptVo> getDeptByDeptId() throws WxErrorException {
|
|
|
List<WxCpDepart> list = wxCpDepartmentService.list(null);
|
|
|
@@ -82,7 +90,7 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
.map(SysWechatCustomerVo::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- if(!customer.isEmpty()){
|
|
|
+ if (!customer.isEmpty()) {
|
|
|
// 获取值班时间列表
|
|
|
Map<Long, List<SysWechatCustomerDuty>> dutyMap = sysWechatCustomerDutyService.lambdaQuery()
|
|
|
.in(SysWechatCustomerDuty::getId, customer)
|
|
|
@@ -93,14 +101,15 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
// 设置值班时间
|
|
|
sysWechatCustomerVoPageInfo.getList().forEach(sysWechatCustomerVo -> {
|
|
|
List<SysWechatCustomerDuty> sysWechatCustomerDuties = dutyMap.get(Long.valueOf(sysWechatCustomerVo.getId()));
|
|
|
- List<String> collect = sysWechatCustomerDuties.stream()
|
|
|
- .map(x -> DateTimeUtil.startAndEndTimeFormatting(x.getStartTime(), x.getEndTime()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- sysWechatCustomerVo.setDutyDatetime(collect);
|
|
|
+ if (!CollectionUtils.isEmpty(sysWechatCustomerDuties)) {
|
|
|
+ List<String> collect = sysWechatCustomerDuties.stream()
|
|
|
+ .map(x -> DateTimeUtil.startAndEndTimeFormatting(x.getStartTime(), x.getEndTime()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ sysWechatCustomerVo.setDutyDatetime(collect);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return new BasePageResult<>(sysWechatCustomerQuery.getPageNum(), sysWechatCustomerQuery.getPageSize(), sysWechatCustomerVoPageInfo.getTotal(),
|
|
|
sysWechatCustomerVoPageInfo.getPages(), sysWechatCustomerVoPageInfo.getList());
|
|
|
}
|
|
|
@@ -205,4 +214,54 @@ public class SysWechatCustomerBusinessServiceImpl implements SysWechatCustomerBu
|
|
|
sysWechatCustomer.setAvatar(sysWechatCustomerAddVo.getAvatar());
|
|
|
sysWechatCustomerService.updateById(sysWechatCustomer);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getWeChatCustomer(SysUser user) throws WxErrorException {
|
|
|
+ SysWechatCustomer sysWechatCustomer = sysWechatCustomerService.getByUserId(user.getLeaderId());
|
|
|
+ if (!ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
+ List<SysWechatCustomerDuty> list = sysWechatCustomerDutyService.lambdaQuery()
|
|
|
+ .ge(SysWechatCustomerDuty::getStartTime, LocalDateTime.now())
|
|
|
+ .le(SysWechatCustomerDuty::getEndTime, LocalDateTime.now())
|
|
|
+ .list();
|
|
|
+ if (sysWechatCustomer.getDutyCustomerId() > 0 && list != null && !list.isEmpty()) {
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.getById(sysWechatCustomer.getDutyCustomerId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
+ SysWechatCustomerRecording sysWechatCustomerRecording = sysWechatCustomerRecordingService.lambdaQuery()
|
|
|
+ .eq(SysWechatCustomerRecording::getUserId, user.getId())
|
|
|
+ .orderByDesc(SysWechatCustomerRecording::getCreateTime)
|
|
|
+ .one();
|
|
|
+ if (!ObjectUtils.isEmpty(sysWechatCustomerRecording)) {
|
|
|
+ sysWechatCustomerRecording = sysWechatCustomerRecordingService.lambdaQuery()
|
|
|
+ .orderByDesc(SysWechatCustomerRecording::getCreateTime)
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+ }
|
|
|
+
|
|
|
+ Long i = Optional.ofNullable(sysWechatCustomerRecording)
|
|
|
+ .map(SysWechatCustomerRecording::getCustomerId)
|
|
|
+ .orElse(0L);
|
|
|
+ sysWechatCustomer = sysWechatCustomerService.lambdaQuery()
|
|
|
+ .ge(i > 0, SysWechatCustomer::getId, sysWechatCustomerRecording.getCustomerId())
|
|
|
+ .orderByDesc(SysWechatCustomer::getId)
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+ if (ObjectUtils.isEmpty(sysWechatCustomer)) {
|
|
|
+ throw new SystemException("请联系管理员穿件客服");
|
|
|
+ }
|
|
|
+ SysWechatCustomerRecording customerRecording = new SysWechatCustomerRecording();
|
|
|
+ customerRecording.setCustomerId(sysWechatCustomer.getId());
|
|
|
+ customerRecording.setUserId(user.getId());
|
|
|
+ sysWechatCustomerRecordingService.save(customerRecording);
|
|
|
+ }
|
|
|
+
|
|
|
+ String openKfId = sysWechatCustomer.getOpenKfId();
|
|
|
+ WxCpKfAccountLink wxCpKfAccountLink = new WxCpKfAccountLink();
|
|
|
+ wxCpKfAccountLink.setOpenKfid(openKfId);
|
|
|
+ wxCpKfAccountLink.setScene(user.getId());
|
|
|
+ WxCpKfAccountLinkResp accountLink = wxCpKfService.getAccountLink(wxCpKfAccountLink);
|
|
|
+ return accountLink.getUrl();
|
|
|
+ }
|
|
|
+
|
|
|
}
|