agent-requests.ts 11 KB

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