zs 8 months ago
parent
commit
bb5a5cf08f

+ 6 - 3
src/main/java/com/free/controller/ChatRecordController.java

@@ -116,7 +116,7 @@ public class ChatRecordController {
     Long skip = null, limit = null;
     Map map = new HashMap();
     QueryWrapper qw = new QueryWrapper<>();
-    qw.orderByDesc("time");
+    qw.orderByAsc("time");
     /** 参数处理处理 */
     for (String key : allParams.keySet()) {
       Object value = allParams.get(key);
@@ -130,17 +130,20 @@ public class ChatRecordController {
       }
     }
     /** 分页处理 */
+    List returnList = null;
     if (null != skip && null != limit) {
       IPage page = new Page<>(skip, limit);
       IPage pageResult = service.page(page, qw);
       List data = pageResult.getRecords();
+      returnList = service.getUserAndCustomerName(data);
       long total = pageResult.getTotal();
-      map.put("data", data);
       map.put("total", total);
     } else {
       List list = service.list(qw);
-      map.put("data", list);
+      returnList = service.getUserAndCustomerName(list);
     }
+    map.put("data", returnList);
+
     return ResponseFormat.success(map);
   }
 

+ 1 - 1
src/main/java/com/free/mq/MqService.java

@@ -52,7 +52,7 @@ public class MqService {
     Map map = new HashMap<>();
     map.put("type", "chat");
     map.put("data", data);
-    Long apply_id = Long.valueOf(String.valueOf(data.get("apply_id")));
+    String apply_id = (String) data.get("apply_id");
     String queue = MqListeners.queueName + "." + apply_id;
     try {
       this.sendMsg(MqListeners.exName, queue, map);

+ 38 - 0
src/main/java/com/free/service/ChatRecordService.java

@@ -1,12 +1,50 @@
 package com.free.service;
 
+import com.free.entity.TransferApply;
+import com.free.entity.system.Customer;
+import com.free.service.system.CustomerService;
+import com.free.utils.Utils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.free.entity.ChatRecord;
 import com.free.mapper.ChatRecordMapper;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class ChatRecordService extends ServiceImpl<ChatRecordMapper, ChatRecord> {
 
+    @Autowired
+    private CustomerService customerService;
+
+    /**
+     * 将列表中的客服id和用户io的数据取出来
+     *
+     * @param list
+     * @return
+     */
+    public List<Map> getUserAndCustomerName(List<ChatRecord> list) {
+        List<Map> returnData = new ArrayList<>();
+        for (ChatRecord i : list) {
+            Map map = Utils.objectToMap(i);
+            String customer_id = i.getCustomer_id();
+            if (null != customer_id) {
+                Customer cData = customerService.getById(customer_id);
+                if (null != cData) {
+                    map.put("customer_name", cData.getNick_name());
+                }
+            }
+            // TODO:查询用户名称
+            map.put("user_name", "还没有呢");
+
+            returnData.add(map);
+
+        }
+        return returnData;
+    }
+
 }