|
@@ -1,12 +1,13 @@
|
|
package com.free.service;
|
|
package com.free.service;
|
|
|
|
|
|
-import com.free.entity.TransferApply;
|
|
|
|
import com.free.entity.system.Customer;
|
|
import com.free.entity.system.Customer;
|
|
import com.free.service.system.CustomerService;
|
|
import com.free.service.system.CustomerService;
|
|
|
|
+import com.free.utils.JwtUtil;
|
|
import com.free.utils.Utils;
|
|
import com.free.utils.Utils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.free.entity.ChatRecord;
|
|
import com.free.entity.ChatRecord;
|
|
import com.free.mapper.ChatRecordMapper;
|
|
import com.free.mapper.ChatRecordMapper;
|
|
@@ -18,33 +19,56 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class ChatRecordService extends ServiceImpl<ChatRecordMapper, ChatRecord> {
|
|
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);
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CustomerService customerService;
|
|
|
|
|
|
|
|
+ /** 对话记录未读标识 */
|
|
|
|
+ public static final String chatRecordNotReadSign = "0";
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询当前用户查出的列表中的未读数量
|
|
|
|
+ * @param list
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Map> getUserNotReadNum(List<Map> list) {
|
|
|
|
+ Map userInfo = JwtUtil.getDetails(null);
|
|
|
|
+ String user_id = (String) userInfo.get("id");
|
|
|
|
+ for (Map map : list) {
|
|
|
|
+ String apply_id = (String) map.get("apply_id");
|
|
|
|
+ QueryWrapper qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("apply_id", apply_id);
|
|
|
|
+ qw.eq("is_read", chatRecordNotReadSign);
|
|
|
|
+ qw.ne("speaker", user_id);
|
|
|
|
+ Long num = this.count(qw);
|
|
|
|
+ map.put("notRead", num);
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 将列表中的客服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());
|
|
}
|
|
}
|
|
- return returnData;
|
|
|
|
|
|
+ }
|
|
|
|
+ // TODO:查询用户名称
|
|
|
|
+ map.put("user_name", "还没有呢");
|
|
|
|
+
|
|
|
|
+ returnData.add(map);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ return returnData;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|