agent-requests.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. import { httpDelete, httpGet, httpPost, httpPut } from '../../utils/http'
  2. import {
  3. ResPageData,
  4. Designer,
  5. AgentTask,
  6. ReportInfo,
  7. FollowUp,
  8. DesignerBasicInfo,
  9. DesignerEvent,
  10. DesignerFamilyInfo,
  11. AgentPoint,
  12. DesignerAward,
  13. DesignerPointsStatistics,
  14. PointsOrder,
  15. DesignerOrderSaleOther,
  16. BrowseRecordCountRes,
  17. BrowseRecord,
  18. } from '@designer-hub/app/src/core/libs/models'
  19. import dayjs from 'dayjs'
  20. /**
  21. * 通过ID获取用户信息
  22. */
  23. export const getUserInfoById = (id: string | number) =>
  24. httpGet<
  25. Partial<{
  26. mobile: string
  27. status: string
  28. nickname: string
  29. avatar: string
  30. name: string
  31. sex: string
  32. areaId: number
  33. areaName: string
  34. birthday: string
  35. mark: string
  36. tagIds: string
  37. levelId: number
  38. groupId: number
  39. id: number
  40. registerIp: string
  41. loginIp: string
  42. loginDate: string
  43. createTime: string
  44. point: number
  45. totalPoint: number
  46. tagNames: string
  47. levelName: string
  48. groupName: string
  49. experience: number
  50. retryStatus?: number
  51. focus?: string
  52. }>
  53. >('/app-api/member/user/getByUserId', { id })
  54. /**
  55. * 获取设计师信息
  56. */
  57. // export const getDesignerInfo = (userId: number) =>
  58. // httpGet<Designer>('/app-api/member/designer/getDesignerInfo', { userId })
  59. /**
  60. * 获取设计师基本信息
  61. */
  62. export const getDesignerBasicInfo = (userId: number) =>
  63. httpGet<DesignerBasicInfo>('/app-api/member/stylist-basic-info/get', { userId })
  64. /**
  65. * 更新设计师基本信息
  66. */
  67. export const updateDesignerBasicInfo = (data: Partial<DesignerBasicInfo>) =>
  68. httpPut('/app-api/member/stylist-basic-info/update', data)
  69. /**
  70. * 获取设计师家庭信息
  71. */
  72. export const getDesignerFamilyInfo = (query = {}) =>
  73. httpGet<ResPageData<DesignerFamilyInfo>>('/app-api/member/stylist-family/list', query)
  74. /**
  75. * 保存设计师家庭信息
  76. */
  77. export const saveDesignerFamilyInfo = (data: Partial<DesignerFamilyInfo>) =>
  78. httpPost('/app-api/member/stylist-family/save', data)
  79. /**
  80. * 获取设计师额外事件
  81. */
  82. export const getDesignerExtraEvents = (query = {}) =>
  83. httpGet<ResPageData<DesignerEvent>>('/app-api/member/stylist-extra-events/pageInfo', query)
  84. /**
  85. * /app-api/member/stylist-extra-events/getStudyAndActivity 获取设计师学习和活动
  86. */
  87. export const getDesignerActivity = (query = {}) =>
  88. httpGet<{
  89. [key in 'study' | 'activity' | 'extraEventsQuantity']:
  90. | { type: number; quantity: number }[]
  91. | number
  92. }>('/app-api/member/stylist-extra-events/getStudyAndActivity', query)
  93. /**
  94. * 设计师列表
  95. */
  96. export const getDesigners = (query = {}) =>
  97. httpGet<ResPageData<Designer>>('/app-api/member/app-broker/pageStylist', query)
  98. /**
  99. * 任务列表
  100. */
  101. export const getTasks = (query = {}) =>
  102. httpGet<ResPageData<AgentTask>>('/app-api/member/task/page', query)
  103. /**
  104. * 关系报备
  105. */
  106. export const getReportInfoPage = (query = {}) =>
  107. httpGet<ResPageData<ReportInfo>>('/app-api/member/report-info/page', query)
  108. /**
  109. * 删除关系报备
  110. */
  111. export const deleteReportInfo = (id: number) =>
  112. httpDelete(`/app-api/member/report-info/delete`, { id })
  113. /**
  114. * 创建设计师跟进
  115. */
  116. export const createFollowUp = (data: Partial<FollowUp>) =>
  117. httpPost('/app-api/member/stylist-follow-up/create', data)
  118. /**
  119. * 获取设计师跟进列表
  120. */
  121. export const getFollowUpPage = (query = {}) =>
  122. httpGet<ResPageData<FollowUp & { followTypeName: string; brokerName: string }>>(
  123. '/app-api/member/app-broker/pageFollowUp',
  124. query,
  125. )
  126. /**
  127. * 删除设计师跟进
  128. * */
  129. export const deleteFollowItem = (id: number) =>
  130. httpDelete(`/app-api/member/stylist-follow-up/delete`, { id })
  131. /**
  132. * 更新设计师跟进
  133. */
  134. export const updateFollowUp = (data: Partial<FollowUp>) =>
  135. httpPut('/app-api/member/stylist-follow-up/update', data)
  136. /**
  137. * /app-api/member/user-auth-info/focus 重点跟进或取消
  138. */
  139. export const focusOrCancel = (data: { brokerId: number; userId: number }) =>
  140. httpPost('/app-api/member/user-auth-info/focus', data)
  141. /**
  142. * /app-api/member/task/points_flow 积分流水
  143. */
  144. export const getPointsFlow = (query = {}) =>
  145. httpGet<ResPageData<AgentPoint>>('/app-api/member/task/points_flow', query)
  146. /**
  147. * /app-api/member/points-details/pageAllByYear/2024?pageNo=1&pageSize=10&stylistId=287&year=2024 设计师积分详情
  148. */
  149. export const getPointsDetails = (query: { year?: string } = {}) =>
  150. httpGet<
  151. ResPageData<{
  152. id: number
  153. pointsType: string
  154. typeName: string
  155. pointsCategory: string
  156. categoryName: string
  157. sourceId: number
  158. name: string
  159. pointsStauts: string
  160. points: number
  161. orderMoney: string
  162. materialsId: number
  163. materialsBrand: string
  164. stylistId: number
  165. brokerId: number
  166. stylistName: string
  167. brokerName: string
  168. generateTime: string
  169. verifyTime: string
  170. completeTime: string
  171. turnDownTime: string
  172. cancelTime: string
  173. cancelReason: string
  174. turnDownReason: string
  175. remark: string
  176. couponId: number
  177. orderNo: string
  178. createTime: string
  179. }>
  180. >(`/app-api/member/points-details/pageAllByYear/${query.year}`, query)
  181. /**
  182. * 设计师奖品列表
  183. */
  184. export const getAwards = (query = {}) =>
  185. httpGet<DesignerAward[]>('/app-api/member/stylist-awards/list', query)
  186. /**
  187. * 创建设计师奖品
  188. */
  189. export const createAward = (data: Partial<DesignerAward>) =>
  190. httpPost('/app-api/member/stylist-awards/create', data)
  191. /**
  192. * 删除设计师奖品
  193. */
  194. export const deleteAward = (id: number) =>
  195. httpDelete('/app-api/member/stylist-awards/delete', { id })
  196. /**
  197. * 获取设计师销售订单
  198. */
  199. export const getSalesOrders = (query = {}) =>
  200. httpGet<
  201. ResPageData<{
  202. id: number
  203. materials: string
  204. materialsBrand: string
  205. projectName: string
  206. customerName: string
  207. customerPhone: string
  208. orderMoney: number
  209. createTime: number
  210. }>
  211. >('/app-api/member/stylist-other-sales/pageByDate', query)
  212. /**
  213. * 获取设计师积分统计
  214. */
  215. export const getPointsCount = (query = {}) =>
  216. httpGet<DesignerPointsStatistics>('/app-api/member/points-details/getPointsCount', query)
  217. /**
  218. * 设计师积分订单
  219. */
  220. export const getPointsOrders = (query = {}) =>
  221. httpGet<ResPageData<PointsOrder>>('/app-api/member/points-order/pageDitch', query)
  222. /**
  223. * 获取设计师销售订单统计
  224. */
  225. export const getSalesOrdersCount = (query = {}) =>
  226. httpGet<{
  227. /**
  228. * 今年订单成交数量
  229. */
  230. orderCountYear: number
  231. /**
  232. * 今年成交金额
  233. */
  234. salesAmountYtd: number
  235. /**
  236. * 类型订单成交数量
  237. */
  238. orderCount: number
  239. /**
  240. * 累计成交金额
  241. */
  242. salesAmount: number
  243. /**
  244. * 其他订单数量
  245. */
  246. otherSale: number
  247. }>('/app-api/member/stylist-other-sales/get', query)
  248. /**
  249. * 其他销售列表
  250. */
  251. export const getOtherSalesPage = (query = {}) =>
  252. httpGet<ResPageData<DesignerOrderSaleOther>>(
  253. '/app-api/member/stylist-other-sales/OtherSalesPage',
  254. query,
  255. )
  256. /**
  257. * /app-api/member/stylist-other-sales/save 创建其他销售
  258. */
  259. export const saveOtherSales = (data: Partial<DesignerOrderSaleOther>) =>
  260. httpPost('/app-api/member/stylist-other-sales/save', data)
  261. /**
  262. * 删除其他销售
  263. */
  264. export const deleteOtherSales = (id: number) =>
  265. httpDelete('/app-api/member/stylist-other-sales/delete', { id })
  266. /**
  267. * 更新其他销售
  268. */
  269. export const updateOtherSales = (data: Partial<DesignerOrderSaleOther>) =>
  270. httpPost('/app-api/member/stylist-other-sales/update', data)
  271. /**
  272. * 创建设计师活动
  273. */
  274. export const createDesignerEvent = (query: Partial<DesignerEvent>) =>
  275. httpPost('/app-api/member/stylist-extra-events/create', query)
  276. /**
  277. * 删除设计师活动
  278. */
  279. export const deleteDesignerEvent = (id: number) =>
  280. httpDelete('/app-api/member/stylist-extra-events/delete?id='+id)
  281. /**
  282. * 删除家庭信息
  283. */
  284. export const deleteStylistFamily = (id: number) =>
  285. httpDelete('/app-api/member/stylist-family/delete', { id })
  286. /**
  287. * 创建设计师关注
  288. */
  289. export const createFocus = (data: { userId: number; focus: string }) =>
  290. httpPost('/app-api/member/stylist-extra-events/createFocus', data)
  291. /**
  292. * 获取设计师活动
  293. */
  294. export const getDesignerEvents = (query = {}) =>
  295. httpGet<ResPageData<DesignerEvent>>('/app-api/member/stylist-extra-events/pageInfo', query)
  296. /**
  297. * 更新设计师活动
  298. */
  299. export const updateDesignerEvent = (query: Partial<DesignerEvent>) =>
  300. httpPut('/app-api/member/stylist-extra-events/update', query)
  301. /**
  302. * /app-api/member/stylist-info-log/page 修改记录
  303. * @param query
  304. */
  305. export const getEditRecords = (query = {}) =>
  306. httpGet<ResPageData<EditRecord>>('/app-api/member/stylist-info-log/page', query)
  307. /**
  308. * 获取设计师浏览记录统计
  309. */
  310. export const getBrowseRecordCount = (stylistId: number) =>
  311. httpGet<BrowseRecordCountRes>(
  312. `/app-api/member/browse-record/browseRecordCount?stylistId=${stylistId}`,
  313. )
  314. /**
  315. * /app-api/member/browse-record/page 浏览记录
  316. * @param query
  317. */
  318. export const getBrowseRecords = (query = {}) =>
  319. httpGet<ResPageData<BrowseRecord>>('/app-api/member/browse-record/page', query)
  320. /**
  321. * 浏览记录备注
  322. * @param query
  323. */
  324. export const getBrowseRecordRemarks = (query = {}) =>
  325. httpGet<{ id: number; remark: string }[]>('/app-api/member/browse-record/listRemark', query)
  326. export const getSalesOrdersCounts = (query = {}) =>
  327. getSalesOrdersCount(query).then((res) => ({
  328. ...res,
  329. data: [
  330. { label: '今年成交订单数', value: res.data.orderCountYear ?? 0, userId: '' },
  331. { label: '今年成交金额', value: res.data.salesAmountYtd ?? 0 },
  332. { label: '累计成交订单数', value: res.data.orderCount ?? 0 },
  333. { label: '累计成交金额', value: res.data.salesAmount ?? 0 },
  334. { label: '其他销售信息', value: `${res.data.otherSale ?? 0}条` },
  335. ],
  336. }))
  337. /**
  338. * 获取设计师积分统计数组
  339. */
  340. export const getPointsCounts = (query = {}) =>
  341. getPointsCount(query).then((res) => ({
  342. ...res,
  343. data: [
  344. {
  345. userId: '',
  346. title: '当前剩余积分',
  347. value: res.data.points ?? 0,
  348. subTitle: '最近',
  349. subValue: res.data.pointsTime ? dayjs(res.data.pointsTime).format('YY/MM/DD') : '--',
  350. },
  351. {
  352. userId: '',
  353. title: '累计获得积分',
  354. value: res.data.gainPoints ?? 0,
  355. subTitle: '本年',
  356. subValue: res.data.gainPointsYear ?? 0,
  357. },
  358. {
  359. userId: '',
  360. title: '累计消耗积分',
  361. value: res.data.usePoints ?? 0,
  362. subTitle: '本年',
  363. subValue: res.data.usePointsYear ?? 0,
  364. },
  365. {
  366. userId: '',
  367. title: '累计跟进次数',
  368. value: res.data.followUpCount ?? 0,
  369. subTitle: '本年',
  370. subValue: res.data.followUpYearCount ?? 0,
  371. },
  372. {
  373. userId: '',
  374. title: '累计消耗次数',
  375. value: res.data.usageCount ?? 0,
  376. subTitle: '本年',
  377. subValue: res.data.usageYearCount ?? 0,
  378. },
  379. {
  380. userId: '',
  381. title: '累计获得次数',
  382. value: res.data.obtainedCount ?? 0,
  383. subTitle: '本年',
  384. subValue: res.data.obtainedYearCount ?? 0,
  385. },
  386. ],
  387. }))
  388. export const getDesignerActivities = (query = {}) =>
  389. getDesignerActivity(query).then((res) => ({
  390. ...res,
  391. data: [
  392. ...(res.data.study as any[]).map((it) => ({
  393. type: '',
  394. label: it.name,
  395. value: it.quantity + '次',
  396. path: '',
  397. })),
  398. { type: 'line', label: '', value: '' },
  399. ...(res.data.activity as any[]).map((it) => ({
  400. type: '',
  401. label: it.name,
  402. value: it.quantity + '次',
  403. path: '',
  404. })),
  405. {
  406. type: '',
  407. label: '其他活动',
  408. value: res.data.extraEventsQuantity + '次',
  409. path: '/pages/agent/designer/archives/index',
  410. },
  411. ],
  412. }))