ソースを参照

Merge branch 'dev_v1.3.8_20221209' into online

Eric 2 年 前
コミット
3e2da1b483

+ 5 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/io/request/im/CustomerServiceBatchSendingVo.java

@@ -85,6 +85,11 @@ public class CustomerServiceBatchSendingVo {
 		@ApiModelProperty("创建时间")
         private Date createTime;
 
+        @ApiModelProperty("客服人员")
+        private String sender;
+        @ApiModelProperty("客服联系方式")
+        private String mobile;
+
         @ApiModelProperty("目标人群")
         private List<CustomerServiceReceiveVo.CustomerServiceReceive> receives;
                 

+ 31 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceBatchSendingServiceImpl.java

@@ -12,6 +12,7 @@ import com.yonge.cooleshow.biz.dal.entity.CustomerServiceBatchSending;
 import com.yonge.cooleshow.biz.dal.entity.CustomerServiceReceive;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.MK;
 import com.yonge.cooleshow.biz.dal.enums.im.EImReceiveType;
@@ -22,6 +23,7 @@ import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceBatchSendingService;
 import com.yonge.cooleshow.biz.dal.service.CustomerServiceReceiveService;
 import com.yonge.cooleshow.biz.dal.service.SubjectService;
+import com.yonge.cooleshow.biz.dal.service.TeacherService;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerService;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceBatchSendingWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.im.CustomerServiceReceiveWrapper;
@@ -53,6 +55,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Random;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -74,6 +77,8 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
     private SysUserMapper sysUserMapper;
     @Autowired
     private RedissonClient redissonClient;
+    @Autowired
+    private TeacherService teacherService;
 
 	/**
      * 查询详情
@@ -148,17 +153,30 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
 
         // 创建用户
         List<Long> userIds = sendings.stream()
-                .map(CustomerServiceBatchSendingWrapper.CustomerServiceBatchSending::getCreateBy)
+                .flatMap(x -> Lists.newArrayList(x.getCreateBy(), x.getSenderId()).stream())
                 .filter(Objects::nonNull).distinct().collect(Collectors.toList());
 
-        Map<Long, String> usernameMap = sysUserMapper.selectBatchIds(userIds).stream()
+        List<SysUser> sysUsers = sysUserMapper.selectBatchIds(userIds);
+
+        Map<Long, String> usernameMap = sysUsers.stream()
                 .collect(Collectors.toMap(SysUser::getId, SysUser::getUsername, (o, n) -> n));
 
+        Map<Long, SysUser> senderMap = sysUsers.stream()
+                .collect(Collectors.toMap(SysUser::getId, Function.identity(), (o, n) -> n));
+
         // 发送群体,发送声部
+        SysUser sysUser;
         for (CustomerServiceBatchSendingWrapper.CustomerServiceBatchSending item : sendings) {
 
             // 创建用户
-            item.setCreateUser(usernameMap.getOrDefault(item.getCreateBy(), ""));
+            item.sender("").mobile("")
+                    .setCreateUser(usernameMap.getOrDefault(item.getCreateBy(), ""));
+
+            if (senderMap.containsKey(item.getSenderId())) {
+                sysUser = senderMap.get(item.getSenderId());
+
+                item.sender(sysUser.getUsername()).mobile(sysUser.getPhone());
+            }
 
             List<Long> collect = Arrays.stream(Optional.ofNullable(item.getSendSubject()).orElse("").split(","))
                     .map(Long::parseLong).distinct().collect(Collectors.toList());
@@ -190,7 +208,10 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
     public Boolean add(CustomerServiceBatchSendingWrapper.CustomerServiceBatchSending info) {
 
         // 发送客服ID
-        String customerService = customerServiceConfig.getCustomerService();
+        String customerService = info.getMobile();
+        if (StringUtils.isBlank(customerService)) {
+            customerService = customerServiceConfig.getCustomerService();
+        }
         if (StringUtils.isNotEmpty(customerService)) {
 
             List<String> collect = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
@@ -205,6 +226,12 @@ public class CustomerServiceBatchSendingServiceImpl extends ServiceImpl<Customer
                 throw new BizException("未匹配到客服人员");
             }
             info.setSenderId(senderUser.getId());
+
+            Teacher teacher = teacherService.getOne(Wrappers.<Teacher>lambdaQuery()
+                    .eq(Teacher::getUserId, info.getSenderId()));
+            if (Objects.isNull(teacher)) {
+                throw new BizException("当前帐号未注册老师帐号");
+            }
         }
 
         // 推送消息

+ 3 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CustomerServiceReceiveServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -55,10 +56,10 @@ public class CustomerServiceReceiveServiceImpl extends ServiceImpl<CustomerServi
         if (CollectionUtils.isNotEmpty(receives)) {
 
             List<Long> userIds = receives.stream()
-                    .map(CustomerServiceReceiveWrapper.CustomerServiceReceive::getId).distinct().collect(Collectors.toList());
+                    .map(CustomerServiceReceiveWrapper.CustomerServiceReceive::getUserId).distinct().collect(Collectors.toList());
 
             Map<Long, String> usernameMap = sysUserMapper.selectBatchIds(userIds).stream()
-                    .collect(Collectors.toMap(SysUser::getId, SysUser::getUsername, (o, n) -> n));
+                    .collect(Collectors.toMap(SysUser::getId, x -> Optional.ofNullable(x.getUsername()).orElse(""), (o, n) -> n));
 
             for (CustomerServiceReceiveWrapper.CustomerServiceReceive item : receives) {
 

+ 15 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/im/CustomerServiceBatchSendingWrapper.java

@@ -162,6 +162,11 @@ public class CustomerServiceBatchSendingWrapper {
 
         @ApiModelProperty("目标群体名称")
         private String targetGroupName;
+
+        @ApiModelProperty("客服人员")
+        private String sender;
+        @ApiModelProperty("客服联系方式")
+        private String mobile;
         
         public String jsonString() {
             return JSON.toJSONString(this);
@@ -186,6 +191,16 @@ public class CustomerServiceBatchSendingWrapper {
             this.createUser = createUser;
             return this;
         }
+
+        public CustomerServiceBatchSending sender(String sender) {
+            this.sender = sender;
+            return this;
+        }
+
+        public CustomerServiceBatchSending mobile(String mobile) {
+            this.mobile = mobile;
+            return this;
+        }
     }
 
 }