TransferApplyService.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.free.service;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  9. import com.free.entity.ChatRecord;
  10. import com.free.entity.TransferApply;
  11. import com.free.entity.system.Customer;
  12. import com.free.mapper.TransferApplyMapper;
  13. import com.free.service.system.CustomerService;
  14. import com.free.utils.Utils;
  15. @Service
  16. public class TransferApplyService extends ServiceImpl<TransferApplyMapper, TransferApply> {
  17. @Autowired
  18. private CustomerService customerService;
  19. @Autowired
  20. private ChatRecordService chatRecordService;
  21. // @Autowired
  22. // private UserService userService
  23. /**
  24. * 将列表中的客服id和用户io的数据取出来
  25. *
  26. * @param list
  27. * @return
  28. */
  29. public List<Map> getUserAndCustomerName(List<TransferApply> list) {
  30. List<Map> returnData = new ArrayList<>();
  31. for (TransferApply i : list) {
  32. Map map = Utils.objectToMap(i);
  33. Long customer_id = i.getCustomer_id();
  34. if (null != customer_id) {
  35. Customer cData = customerService.getById(customer_id);
  36. if (null != cData) {
  37. map.put("customer_name", cData.getNick_name());
  38. }
  39. }
  40. // TODO:查询用户名称
  41. map.put("user_name", "还没有呢");
  42. returnData.add(map);
  43. }
  44. return returnData;
  45. }
  46. /**
  47. * 获取每个转人工申请中聊天记录的最后一条
  48. *
  49. * @param list
  50. * @return
  51. */
  52. public List<Map> getDataLastRecord(List<Map> list) {
  53. for (Map map : list) {
  54. Long apply_id = Utils.getLongValue(map.get("id"));
  55. QueryWrapper qw = new QueryWrapper<>();
  56. qw.select("content", "time", "is_read");
  57. qw.eq("apply_id", apply_id);
  58. qw.orderByDesc("time");
  59. Map chatRecord = chatRecordService.getMap(qw);
  60. map.put("chatRecord", chatRecord);
  61. }
  62. return list;
  63. }
  64. }