12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package com.free.service;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.free.entity.ChatRecord;
- import com.free.entity.TransferApply;
- import com.free.entity.system.Customer;
- import com.free.mapper.TransferApplyMapper;
- import com.free.service.system.CustomerService;
- import com.free.utils.Utils;
- @Service
- public class TransferApplyService extends ServiceImpl<TransferApplyMapper, TransferApply> {
- @Autowired
- private CustomerService customerService;
- @Autowired
- private ChatRecordService chatRecordService;
- // @Autowired
- // private UserService userService
- /**
- * 将列表中的客服id和用户io的数据取出来
- *
- * @param list
- * @return
- */
- public List<Map> getUserAndCustomerName(List<TransferApply> list) {
- List<Map> returnData = new ArrayList<>();
- for (TransferApply i : list) {
- Map map = Utils.objectToMap(i);
- Long 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;
- }
- /**
- * 获取每个转人工申请中聊天记录的最后一条
- *
- * @param list
- * @return
- */
- public List<Map> getDataLastRecord(List<Map> list) {
- for (Map map : list) {
- Long apply_id = Utils.getLongValue(map.get("id"));
- QueryWrapper qw = new QueryWrapper<>();
- qw.select("content", "time", "is_read");
- qw.eq("apply_id", apply_id);
- qw.orderByDesc("time");
- Map chatRecord = chatRecordService.getMap(qw);
- map.put("chatRecord", chatRecord);
- }
- return list;
- }
- }
|