agent-requests.ts 12 KB

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