award.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. // 奖池服务 - 对应 supermart-mini/service/award.js
  2. import { get, post, postL } from './http';
  3. const apis = {
  4. INDEX: '/api/app/index/magicMartIndex',
  5. IP_LIST: '/api/spu/basic/listWorksLimit',
  6. MAGIC_INDEX: '/api/app/index/magicBoxIndex',
  7. LIST: '/api/luckPool/list',
  8. HORSE: '/api/luckPool/horseRaceLampByIndex',
  9. DETAIL: '/api/luckPool/detail',
  10. PRODUCTS: '/api/luckPool/prize',
  11. HORSE_DETAIL: '/api/luckPool/horseRaceLampByDetail',
  12. BUY_RECORD: '/api/luckPool/buyRecord',
  13. VERSION: '/api/luckPool/version',
  14. PREVIEW: '/api/luckOrder/preSubmit',
  15. APPLY: '/api/luckOrder/submit',
  16. APPLY_TRY: '/api/luckOrder/demo',
  17. APPLY_RESULT: '/api/luckOrder/luckResult',
  18. ORDERS: '/api/luckOrder/pageMy',
  19. STORE: '/api/luckInventory',
  20. STORE_MOVE_SAFE: '/api/luckInventory/addToSafe',
  21. STORE_OUT_SAFE: '/api/luckInventory/moveFromSafe',
  22. CONVERT_PREVIEW: '/api/luckExchangeOrder/preSubmit',
  23. CONVERT_APPLY: '/api/luckExchangeOrder/submit',
  24. CONVERT_LIST: '/api/luckExchangeOrder/pageMy',
  25. CONVERT_ALL_PREVIEW: '/api/luckExchangeOrder/preOneKeySubmit',
  26. CONVERT_ALL: '/api/luckExchangeOrder/oneKeySubmit',
  27. TAKE_PREVIEW: '/api/luckPickupOrder/preSubmit',
  28. TAKE_APPLY: '/api/luckPickupOrder/submit',
  29. TAKE_LIST: '/api/luckPickupOrder/pageMy',
  30. TAKE_PAY_ORDER: '/api/luckPickupOrder/pay',
  31. POOL_IN: '/api/luckPool/participate',
  32. POOL_OUT: '/api/luckPool/unparticipate',
  33. PACKAGES: '/api/luckPickupOrder/expressInfo',
  34. EXPRESS: '/api/luckPickupOrder/expressDetail',
  35. KING: '/api/luckKing/getTheLatestLuckKingRecord',
  36. KING_USER: '/api/luckKing/listBillboard',
  37. KING_GOODS: '/api/luckKing/listGoods',
  38. CHECK_PAYMENT_STATUS: '/api/luckOrder/checkPaymentStatus',
  39. GENERATE_PAYMENT_LINK: '/api/luckOrder/generatePaymentLink',
  40. KING_PRE: '/api/luckKing/getThePrev',
  41. BOX_LIST: '/api/luckBox',
  42. BOX_DETAIL: '/api/luckBox/detail',
  43. BOX_PRE: '/api/luckBox/getThePrev',
  44. BOX_NEXT: '/api/luckBox/getTheNext',
  45. UNAVAILABLE_SEAT_NUMBERS: '/api/luckBox/getUnavaliableSeatNumbers',
  46. BOX_LOCK: '/api/luckBox/lock',
  47. BOX_UN_LOCK: '/api/luckBox/unlock',
  48. FEEDBACK_LIST: '/api/app/feedback/list',
  49. FEEDBACK_SUBMIT: '/api/app/feedback/submit',
  50. MY_BOXES: '/api/luck/treasure-box/my-boxes',
  51. OPEN_BOX: '/api/luck/treasure-box/open',
  52. HARRY_EXCHANGE: '/api/redeemCode/exchange',
  53. WIN_RECORDS: '/api/luck/treasure-box/win-records',
  54. };
  55. export interface IPItem {
  56. id: string;
  57. name: string;
  58. cover?: string;
  59. }
  60. export interface PoolItem {
  61. id: string;
  62. name: string;
  63. cover: string;
  64. price: number;
  65. mode?: string;
  66. type?: number;
  67. status?: number;
  68. }
  69. // 获取首页数据
  70. export const getIndex = async (type = 0) => {
  71. const res = await get(apis.INDEX, { type });
  72. return res.data;
  73. };
  74. // 获取 IP 列表
  75. export const getIPList = async (limit = 200): Promise<IPItem[]> => {
  76. const res = await get<IPItem[]>(apis.IP_LIST, { limit });
  77. return res.data || [];
  78. };
  79. // 获取魔盒首页
  80. export const getMagicIndex = async () => {
  81. const res = await get(apis.MAGIC_INDEX);
  82. return res.data;
  83. };
  84. // 获取奖池列表
  85. export const getPoolList = async (params: {
  86. current: number;
  87. size: number;
  88. mode?: string;
  89. type?: number;
  90. worksId?: string;
  91. keyword?: string;
  92. priceMin?: number;
  93. priceMax?: number;
  94. priceSort?: number;
  95. }) => {
  96. // 处理 mode 参数
  97. let processedMode = params.mode;
  98. if (processedMode && processedMode.startsWith('UNLIMITED')) {
  99. processedMode = 'UNLIMITED';
  100. }
  101. const res = await post<PoolItem[]>(apis.LIST, { ...params, mode: processedMode });
  102. return res;
  103. };
  104. // 获取跑马灯数据
  105. export const getHorse = async () => {
  106. const res = await post(apis.HORSE);
  107. return res.success ? res.data : null;
  108. };
  109. // 获取奖池详情
  110. export const getPoolDetail = async (poolId: string) => {
  111. const res = await get(apis.DETAIL, { poolId });
  112. return res.data;
  113. };
  114. // 获取奖池商品
  115. export const getPoolProducts = async (poolId: string) => {
  116. const res = await get(apis.PRODUCTS, { poolId });
  117. return res.data;
  118. };
  119. // 获取详情跑马灯
  120. export const getDetailHorse = async (poolId: string, size = 50) => {
  121. const res = await post(apis.HORSE_DETAIL, { poolId, size });
  122. return res.success ? res.data : null;
  123. };
  124. // 获取购买记录
  125. export const getBuyRecord = async (poolId: string, lastId?: string, level?: number, size = 200) => {
  126. const res = await post(apis.BUY_RECORD, { poolId, lastId, level, size });
  127. return res.data;
  128. };
  129. // 获取版本信息
  130. export const getVersion = async (poolId: string, size = 20) => {
  131. const res = await post(apis.VERSION, { poolId, size });
  132. return res.data;
  133. };
  134. // 试玩
  135. export const tryDemo = async (poolId: string, quantity: number) => {
  136. const res = await postL(apis.APPLY_TRY, { poolId, quantity });
  137. return res.data;
  138. };
  139. // 预提交订单
  140. export const previewOrder = async (poolId: string, quantity?: number, boxNumber?: string, seatNumbers?: number[], packFlag?: boolean) => {
  141. const param: any = { poolId };
  142. if (quantity) param.quantity = quantity;
  143. if (boxNumber) param.boxNumber = boxNumber;
  144. if (seatNumbers && seatNumbers.length > 0) param.seatNumbers = seatNumbers;
  145. if (packFlag) param.packFlag = packFlag;
  146. const res = await postL(apis.PREVIEW, param);
  147. // http.ts 已经统一处理了错误提示,这里只返回数据
  148. if (!res.success) {
  149. return null;
  150. }
  151. return res.data;
  152. };
  153. // 提交订单
  154. export const applyOrder = async (poolId: string, quantity: number, paymentType: string, boxNumber?: string, seatNumbers?: number[], packFlag?: boolean) => {
  155. const param: any = { poolId, quantity, paymentType };
  156. if (boxNumber) param.boxNumber = boxNumber;
  157. if (seatNumbers && seatNumbers.length > 0) param.seatNumbers = seatNumbers;
  158. if (packFlag) param.packFlag = packFlag;
  159. const res = await postL(apis.APPLY, param);
  160. // http.ts 已经统一处理了错误提示,这里只返回数据
  161. if (!res.success) {
  162. return null;
  163. }
  164. return res.data;
  165. };
  166. // 获取抽奖结果
  167. export const getApplyResult = async (tradeNo: string) => {
  168. const res = await get(apis.APPLY_RESULT, { tradeNo });
  169. return res.data;
  170. };
  171. // 检查支付状态
  172. export const checkPaymentStatus = async (tradeNo: string) => {
  173. const res = await get(apis.CHECK_PAYMENT_STATUS, { tradeNo });
  174. return res.data;
  175. };
  176. // 获取盲盒订单列表
  177. export const getAwardOrders = async (current: number, size: number, tab?: string) => {
  178. const res = await post(apis.ORDERS, { current, size, tab });
  179. return res.data;
  180. };
  181. // 获取仓库列表
  182. export const getStore = async (current: number, size: number, safeFlag?: number, tab?: string, status: number = 0) => {
  183. const res = await post(apis.STORE, { current, size, status, tab, safeFlag });
  184. return res.data;
  185. };
  186. // 移入保险箱
  187. export const moveToSafeStore = async (inventoryIds: string[]) => {
  188. const res = await postL(apis.STORE_MOVE_SAFE, { inventoryIds });
  189. return res.success;
  190. };
  191. // 移出保险箱
  192. export const moveOutSafeStore = async (inventoryIds: string[]) => {
  193. const res = await postL(apis.STORE_OUT_SAFE, { inventoryIds });
  194. return res.success;
  195. };
  196. // 兑换预览
  197. export const convertPreview = async (inventoryIds: string[]) => {
  198. const res = await postL(apis.CONVERT_PREVIEW, { inventoryIds });
  199. return res;
  200. };
  201. // 兑换申请
  202. export const convertApply = async (inventoryIds: string[]) => {
  203. const res = await postL(apis.CONVERT_APPLY, { inventoryIds });
  204. return res.success;
  205. };
  206. // 兑换列表
  207. export const getConvertList = async (current: number, size: number) => {
  208. const res = await post(apis.CONVERT_LIST, { current, size });
  209. return res.data;
  210. };
  211. // 一键兑换预览
  212. export const convertAllPreview = async () => {
  213. const res = await postL(apis.CONVERT_ALL_PREVIEW);
  214. return res.data;
  215. };
  216. // 一键兑换
  217. export const convertAll = async (levels: number[]) => {
  218. const res = await postL(apis.CONVERT_ALL, { levels });
  219. return res.success;
  220. };
  221. // 提货预览
  222. export const takePreview = async (inventoryIds: string[], addressBookId: string) => {
  223. const res = await postL(apis.TAKE_PREVIEW, { inventoryIds, addressBookId });
  224. return res.data;
  225. };
  226. // 提货申请
  227. export const takeApply = async (inventoryIds: string[], addressBookId: string, paymentType: string) => {
  228. const res = await postL(apis.TAKE_APPLY, { inventoryIds, addressBookId, paymentType });
  229. return res.data;
  230. };
  231. // 提货列表
  232. export const getTakeList = async (current: number, size: number) => {
  233. const res = await post(apis.TAKE_LIST, { current, size });
  234. return res.data;
  235. };
  236. // 提货支付
  237. export const takePayOrder = async (inventoryIds: string[], addressBookId: string, paymentType: string, tradeNo?: string) => {
  238. const res = await postL(apis.TAKE_PAY_ORDER, { inventoryIds, addressBookId, paymentType, tradeNo });
  239. return res.data;
  240. };
  241. // 参与奖池
  242. export const poolIn = async (poolId: string) => {
  243. const res = await get(apis.POOL_IN, { poolId });
  244. return res.success;
  245. };
  246. // 退出奖池
  247. export const poolOut = async (poolId?: string) => {
  248. const param: any = {};
  249. if (poolId) param.poolId = poolId;
  250. const res = await get(apis.POOL_OUT, param);
  251. return res.success;
  252. };
  253. // 获取包裹信息
  254. export const getAwardPackages = async (tradeNo: string) => {
  255. const res = await get(apis.PACKAGES, { tradeNo });
  256. return res.data;
  257. };
  258. // 获取物流详情
  259. export const getAwardExpress = async (tradeNo: string, packageId: string) => {
  260. const res = await get(apis.EXPRESS, { tradeNo, packageId });
  261. return res.data;
  262. };
  263. // 获取欧皇信息
  264. export const getKing = async (poolId: string) => {
  265. const res = await get(apis.KING, { poolId });
  266. return res.success ? res.data : null;
  267. };
  268. // 获取欧皇榜单
  269. export const getKingUser = async (poolId: string) => {
  270. const res = await get(apis.KING_USER, { poolId });
  271. return res.data;
  272. };
  273. // 获取欧皇商品
  274. export const getKingGoods = async (poolId: string) => {
  275. const res = await get(apis.KING_GOODS, { poolId });
  276. return res.data;
  277. };
  278. // 获取上一期欧皇
  279. export const getPreKing = async (poolId: string) => {
  280. const res = await get(apis.KING_PRE, { poolId });
  281. return res.data;
  282. };
  283. // 获取盒子列表
  284. export const getBoxList = async (poolId: string, level?: number, current?: number, size?: number) => {
  285. const res = await post(apis.BOX_LIST, { poolId, current, size, level });
  286. return res.data;
  287. };
  288. // 获取盒子详情
  289. export const getBoxDetail = async (poolId: string, boxNumber?: string) => {
  290. const param: any = { poolId };
  291. if (boxNumber) param.boxNumber = boxNumber;
  292. const res = await get(apis.BOX_DETAIL, param);
  293. return res.data;
  294. };
  295. // 获取上一个盒子
  296. export const getPreBox = async (poolId: string, boxNumber: string) => {
  297. const res = await get(apis.BOX_PRE, { poolId, boxNumber });
  298. return res.data;
  299. };
  300. // 获取下一个盒子
  301. export const getNextBox = async (poolId: string, boxNumber: string) => {
  302. const res = await get(apis.BOX_NEXT, { poolId, boxNumber });
  303. return res.data;
  304. };
  305. // 锁定盒子
  306. export const lockBox = async (poolId: string, boxNumber: string) => {
  307. const res = await postL(apis.BOX_LOCK, { poolId, boxNumber });
  308. return res.success;
  309. };
  310. // 解锁盒子
  311. export const unlockBox = async (poolId: string, boxNumber: string) => {
  312. const res = await postL(apis.BOX_UN_LOCK, { poolId, boxNumber });
  313. return res.success;
  314. };
  315. // 获取不可用座位号
  316. export const getUnavailableSeatNumbers = async (poolId: string, boxNumber: string, startSeatNumber?: number, endSeatNumber?: number) => {
  317. const params: any = { poolId, boxNumber };
  318. if (startSeatNumber) params.startSeatNumber = startSeatNumber;
  319. if (endSeatNumber) params.endSeatNumber = endSeatNumber;
  320. const res = await post(apis.UNAVAILABLE_SEAT_NUMBERS, params);
  321. return res.data;
  322. };
  323. // 获取弹幕列表
  324. export const getFeedbackList = async () => {
  325. const res = await get(apis.FEEDBACK_LIST);
  326. return res;
  327. };
  328. // 发送弹幕
  329. export const submitFeedback = async (content: string) => {
  330. const res = await postL(apis.FEEDBACK_SUBMIT, { content });
  331. return res;
  332. };
  333. // 获取我的宝箱列表
  334. export const getMyBoxes = async () => {
  335. const res = await get(apis.MY_BOXES);
  336. return res.data;
  337. };
  338. // 开启宝箱
  339. export const openBox = async (params: { boxIds: string }) => {
  340. // 按照小程序的方式,boxIds 作为 query 参数
  341. const res = await post(`${apis.OPEN_BOX}?boxIds=${params.boxIds}`, {});
  342. return res;
  343. };
  344. // 获取仓库商品详情
  345. export const getLuckDetail = async (id: string) => {
  346. const res = await get('/api/luckInventory/detail', { id });
  347. return res.data;
  348. };
  349. // 获取仓库商品总数
  350. export const getSumInventory = async () => {
  351. const res = await get('/api/luckInventory');
  352. return res.data;
  353. };
  354. // 兑换码兑换
  355. export const harryExchange = async (params: { code: string }) => {
  356. const res = await postL(apis.HARRY_EXCHANGE, params);
  357. return res;
  358. };
  359. // 获取中奖记录
  360. export const getWinRecords = async (poolId: string, boxNumber: string) => {
  361. const res = await get(apis.WIN_RECORDS, { poolId, boxNumber });
  362. return res.data;
  363. };
  364. export default {
  365. getIndex,
  366. getIPList,
  367. getMagicIndex,
  368. getPoolList,
  369. getHorse,
  370. getPoolDetail,
  371. getPoolProducts,
  372. getDetailHorse,
  373. getBuyRecord,
  374. getVersion,
  375. tryDemo,
  376. previewOrder,
  377. applyOrder,
  378. getApplyResult,
  379. checkPaymentStatus,
  380. getAwardOrders,
  381. getStore,
  382. moveToSafeStore,
  383. moveOutSafeStore,
  384. convertPreview,
  385. convertApply,
  386. getConvertList,
  387. convertAllPreview,
  388. convertAll,
  389. takePreview,
  390. takeApply,
  391. getTakeList,
  392. takePayOrder,
  393. poolIn,
  394. poolOut,
  395. getAwardPackages,
  396. getAwardExpress,
  397. getKing,
  398. getKingUser,
  399. getKingGoods,
  400. getPreKing,
  401. getBoxList,
  402. getBoxDetail,
  403. getPreBox,
  404. getNextBox,
  405. lockBox,
  406. unlockBox,
  407. getUnavailableSeatNumbers,
  408. getFeedbackList,
  409. submitFeedback,
  410. getLuckDetail,
  411. getSumInventory,
  412. harryExchange,
  413. getWinRecords,
  414. };