فهرست منبع

update 客服增加多个客服

wks 1 سال پیش
والد
کامیت
dd1688e871

+ 0 - 10
src/main/java/com/ydtech/modules/admin/model/po/SysWechatCustomer.java

@@ -68,16 +68,6 @@ public class SysWechatCustomer implements Serializable {
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
-    public SysWechatCustomer(long id, String nickname, String avatar, String userId, String receptionist, String receptionistId, String openKfId) {
-        this.id = id;
-        this.nickname = nickname;
-        this.avatar = avatar;
-        this.userId = userId;
-        this.receptionist = receptionist;
-        this.receptionistId = receptionistId;
-        this.openKfId = openKfId;
-    }
-
     public SysWechatCustomer(SysWechatCustomerAddVo sysWechatCustomerAddVo) {
         this.nickname = sysWechatCustomerAddVo.getNickname();
         this.avatar = sysWechatCustomerAddVo.getAvatar();

+ 1 - 0
src/main/java/com/ydtech/modules/admin/model/vo/wechat/SysWechatCustomerDutyRulesVo.java

@@ -36,6 +36,7 @@ public class SysWechatCustomerDutyRulesVo implements Serializable {
         private static final long serialVersionUID = -6002812616686817550L;
 
         @ApiModelProperty("值班客服")
+        @NotBlank(message = "值班客服不能为空")
         private String dutyCustomerId;
 
         @ApiModelProperty("值班规则列表")

+ 1 - 1
src/main/java/com/ydtech/modules/admin/service/SysWechatCustomerService.java

@@ -68,6 +68,6 @@ public interface SysWechatCustomerService extends BaseIService<SysWechatCustomer
     }
 
 
-    void getCacheCustomerId(SysWechatCustomer sysWechatCustomer);
+    SysWechatCustomer getCacheCustomerId(SysWechatCustomer sysWechatCustomer);
 
 }

+ 12 - 10
src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerBusinessServiceImpl.java

@@ -64,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());
     }
 
@@ -241,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())
@@ -255,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();

+ 6 - 4
src/main/java/com/ydtech/modules/admin/service/impl/SysWechatCustomerServiceImpl.java

@@ -121,8 +121,9 @@ public class SysWechatCustomerServiceImpl extends ServiceImpl<SysWechatCustomerM
     }
 
     @Override
-    public void getCacheCustomerId(SysWechatCustomer sysWechatCustomer) {
-        String customerCache = redisTemplate.opsForValue().get("sys:wechat:customer");
+    public SysWechatCustomer getCacheCustomerId(SysWechatCustomer sysWechatCustomer) {
+        final String KEY = "sys:wechat:customer:";
+        String customerCache = redisTemplate.opsForValue().get(KEY);
         String s1 = Optional.ofNullable(customerCache)
                 .orElse("0");
         sysWechatCustomer = lambdaQuery()
@@ -132,12 +133,13 @@ public class SysWechatCustomerServiceImpl extends ServiceImpl<SysWechatCustomerM
                 .one();
 
         if (ObjectUtils.isEmpty(sysWechatCustomer)) {
-            sysWechatCustomer = lambdaQuery()
+             sysWechatCustomer = lambdaQuery()
                     .orderByAsc(SysWechatCustomer::getId)
                     .last("limit 1")
                     .one();
         }
-        redisTemplate.opsForValue().set("sys:wechat:customer", String.valueOf(sysWechatCustomer.getId()));
+        redisTemplate.opsForValue().set(KEY, String.valueOf(sysWechatCustomer.getId()));
+        return sysWechatCustomer;
     }
 }