visitor.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import { bluebookAiAgent } from "@/xiaolanbenlib/api/index";
  2. import request from "@/xiaolanbenlib/module/axios.js";
  3. import {
  4. TVisitorAgent,
  5. TVisitorMessage,
  6. TVisitorChat,
  7. TSessionItem,
  8. } from "@/types/visitor";
  9. // 编辑差评记录的答案消息--编辑后则自动标识为已处理
  10. export const editVisitorDislikeAnswer = (data: {
  11. agentId: string,
  12. answer: string ,
  13. links: string[],
  14. msgId: string,
  15. pics: string[],
  16. questions : string[],
  17. visitorId: string
  18. }) => {
  19. return request.put(
  20. `${bluebookAiAgent}api/v1/my/visitor/message/answer`,
  21. data
  22. );
  23. };
  24. // 删除指定的差评待处理记录
  25. export const deleteVisitorDislikeAnswer = (data: {
  26. visitorId: string|number;
  27. msgId: string|number;
  28. }) => {
  29. return request.delete(`${bluebookAiAgent}api/v1/my/visitor/dislike/message`, {
  30. params: data,
  31. });
  32. };
  33. // 获取未处理的差评记录列表
  34. export type TVisitorDislikeMessagesResponse = {
  35. data: [TVisitorChat[]];
  36. nextId: string;
  37. totalCount: number;
  38. };
  39. export const getVisitorDislikeMessages = (data: {
  40. agentId: string;
  41. startId: string;
  42. pageSize: number;
  43. }) => {
  44. return request.get<TVisitorDislikeMessagesResponse>(
  45. `${bluebookAiAgent}api/v1/my/visitor/dislike/messages`,
  46. { params: data }
  47. );
  48. };
  49. // 访客访问详情--访客信息
  50. export type TVisotorInfoResponse = {
  51. agentId: string;
  52. agentStatus: string;
  53. avatarUrl: string;
  54. chatRound: number;
  55. dislikeCnt: number;
  56. isEnt: false;
  57. lastChatTime: "2025-05-21T07:09:45.814Z";
  58. myAgentId: string;
  59. myAgentName: string;
  60. name: string;
  61. position: string;
  62. visitTimes: number;
  63. visitorId: number;
  64. };
  65. export const getVisitorInfo = (visitorId: number | string) => {
  66. return request.get<TVisotorInfoResponse>(
  67. `${bluebookAiAgent}api/v1/my/visitor/info`,
  68. { params: { visitorId } }
  69. );
  70. };
  71. // 获取好评记录列表--包含已读未读
  72. export type TVisitorLikeMessagesResponse = {
  73. data: TVisitorMessage[];
  74. nextId: string;
  75. totalCount: number;
  76. };
  77. export const getVisitorLikeMessages = (data: {
  78. visitorId: string;
  79. startId: string;
  80. pageSize: number;
  81. }) => {
  82. return request.get<TVisitorLikeMessagesResponse>(
  83. `${bluebookAiAgent}api/v1/my/visitor/like/messages`,
  84. { params: data }
  85. );
  86. };
  87. // 访客数据列表--列表会按我的智能体明细展示
  88. export type TVisitorListResponse = {
  89. data: [];
  90. nextId: string;
  91. totalCount: number;
  92. };
  93. export const getVisitorList = (data: {
  94. agentId: string;
  95. startId: string;
  96. pageSize: string;
  97. }) => {
  98. return request.get<TVisitorListResponse>(
  99. `${bluebookAiAgent}api/v1/my/visitor/list`,
  100. { params: data }
  101. );
  102. };
  103. // 访客访问详情--访客聊天记录
  104. export type TVisitorMessagesResponse = {
  105. data: TVisitorChat[];
  106. nextId: string;
  107. totalCount: number;
  108. };
  109. export const getVisitorMessages = (data: {
  110. visitorId: string | number;
  111. startId?: string;
  112. sessionId: string;
  113. pageSize: number;
  114. }) => {
  115. return request.get<TVisitorMessagesResponse>(
  116. `${bluebookAiAgent}api/v1/my/visitor/session/messages`,
  117. { params: data }
  118. );
  119. };
  120. // 访客访问详情--获取访问的会话列表, 仅在 startId 为空时返回 totalCount
  121. export const getVisitorSessions = (data: {
  122. visitorId: string | number;
  123. startId: string;
  124. pageSize: number;
  125. }) => {
  126. return request.get<{
  127. data: TSessionItem[];
  128. nextId: string;
  129. totalCount: number;
  130. }>(`${bluebookAiAgent}api/v1/my/visitor/sessions`, { params: data });
  131. };
  132. // 访客聊天记录 获取指定 msgId 前后各N条;用于查看好差评记录的访客详情
  133. export const getVisitorMessagesByMsgId = (data: {
  134. visitorId: string;
  135. msgId: string;
  136. size: number;
  137. }) => {
  138. return request.get<TVisitorChat[]>(
  139. `${bluebookAiAgent}api/v1/my/visitor/messages/byMsgId`,
  140. { params: data }
  141. );
  142. };
  143. // 访问数据汇总
  144. export type TVisitorSummary = {
  145. sumChatUv?: number; // 总聊天UV ,
  146. sumPv?: number; // 总PV ,
  147. sumUv?: number; // 总UV ,
  148. todayChatUv?: number; // 今日聊天UV ,
  149. todayPv?: number; // 今日PV ,
  150. todayUv?: number; // 今日UV ,
  151. unprocessedDislikeCnt?: number; // 未处理差评记录数 ,
  152. unreadLikeCnt?: number; // 未查看点赞记录数
  153. };
  154. export const getVisitorSummary = (agentId?: string) => {
  155. return request.get<TVisitorSummary>(
  156. `${bluebookAiAgent}api/v1/my/visitor/summary`,
  157. { params: { agentId } }
  158. );
  159. };