award.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. };
  51. export interface IPItem {
  52. id: string;
  53. name: string;
  54. cover?: string;
  55. }
  56. export interface PoolItem {
  57. id: string;
  58. name: string;
  59. cover: string;
  60. price: number;
  61. mode?: string;
  62. type?: number;
  63. status?: number;
  64. }
  65. // 获取首页数据
  66. export const getIndex = async (type = 0) => {
  67. const res = await get(apis.INDEX, { type });
  68. return res.data;
  69. };
  70. // 获取 IP 列表
  71. export const getIPList = async (limit = 200): Promise<IPItem[]> => {
  72. const res = await get<IPItem[]>(apis.IP_LIST, { limit });
  73. return res.data || [];
  74. };
  75. // 获取魔盒首页
  76. export const getMagicIndex = async () => {
  77. const res = await get(apis.MAGIC_INDEX);
  78. return res.data;
  79. };
  80. // 获取奖池列表
  81. export const getPoolList = async (params: {
  82. current: number;
  83. size: number;
  84. mode?: string;
  85. type?: number;
  86. worksId?: string;
  87. keyword?: string;
  88. priceMin?: number;
  89. priceMax?: number;
  90. priceSort?: number;
  91. }) => {
  92. // 处理 mode 参数
  93. let processedMode = params.mode;
  94. if (processedMode && processedMode.startsWith('UNLIMITED')) {
  95. processedMode = 'UNLIMITED';
  96. }
  97. const res = await post<PoolItem[]>(apis.LIST, { ...params, mode: processedMode });
  98. return res;
  99. };
  100. // 获取跑马灯数据
  101. export const getHorse = async () => {
  102. const res = await post(apis.HORSE);
  103. return res.success ? res.data : null;
  104. };
  105. // 获取奖池详情
  106. export const getPoolDetail = async (poolId: string) => {
  107. const res = await get(apis.DETAIL, { poolId });
  108. return res.data;
  109. };
  110. // 获取奖池商品
  111. export const getPoolProducts = async (poolId: string) => {
  112. const res = await get(apis.PRODUCTS, { poolId });
  113. return res.data;
  114. };
  115. // 获取详情跑马灯
  116. export const getDetailHorse = async (poolId: string, size = 50) => {
  117. const res = await post(apis.HORSE_DETAIL, { poolId, size });
  118. return res.success ? res.data : null;
  119. };
  120. // 获取购买记录
  121. export const getBuyRecord = async (poolId: string, lastId?: string, level?: number, size = 200) => {
  122. const res = await post(apis.BUY_RECORD, { poolId, lastId, level, size });
  123. return res.data;
  124. };
  125. // 获取版本信息
  126. export const getVersion = async (poolId: string, size = 20) => {
  127. const res = await post(apis.VERSION, { poolId, size });
  128. return res.data;
  129. };
  130. // 试玩
  131. export const tryDemo = async (poolId: string, quantity: number) => {
  132. const res = await postL(apis.APPLY_TRY, { poolId, quantity });
  133. return res.data;
  134. };
  135. // 预提交订单
  136. export const previewOrder = async (poolId: string, quantity?: number, boxNumber?: string, seatNumbers?: number[], packFlag?: boolean) => {
  137. const param: any = { poolId };
  138. if (quantity) param.quantity = quantity;
  139. if (boxNumber) param.boxNumber = boxNumber;
  140. if (seatNumbers && seatNumbers.length > 0) param.seatNumbers = seatNumbers;
  141. if (packFlag) param.packFlag = packFlag;
  142. const res = await postL(apis.PREVIEW, param);
  143. // 如果请求失败,抛出错误
  144. if (!res.success) {
  145. throw new Error(res.msg || '获取订单信息失败');
  146. }
  147. return res.data;
  148. };
  149. // 提交订单
  150. export const applyOrder = async (poolId: string, quantity: number, paymentType: string, boxNumber?: string, seatNumbers?: number[], packFlag?: boolean) => {
  151. const param: any = { poolId, quantity, paymentType };
  152. if (boxNumber) param.boxNumber = boxNumber;
  153. if (seatNumbers && seatNumbers.length > 0) param.seatNumbers = seatNumbers;
  154. if (packFlag) param.packFlag = packFlag;
  155. const res = await postL(apis.APPLY, param);
  156. // 如果请求失败,抛出错误
  157. if (!res.success) {
  158. throw new Error(res.msg || '支付失败');
  159. }
  160. return res.data;
  161. };
  162. // 获取抽奖结果
  163. export const getApplyResult = async (tradeNo: string) => {
  164. const res = await get(apis.APPLY_RESULT, { tradeNo });
  165. return res.data;
  166. };
  167. // 检查支付状态
  168. export const checkPaymentStatus = async (tradeNo: string) => {
  169. const res = await get(apis.CHECK_PAYMENT_STATUS, { tradeNo });
  170. return res.data;
  171. };
  172. // 获取盲盒订单列表
  173. export const getAwardOrders = async (current: number, size: number, tab?: string) => {
  174. const res = await post(apis.ORDERS, { current, size, tab });
  175. return res.data;
  176. };
  177. // 获取仓库列表
  178. export const getStore = async (current: number, size: number, safeFlag?: number, tab?: string, status: number = 0) => {
  179. const res = await post(apis.STORE, { current, size, status, tab, safeFlag });
  180. return res.data;
  181. };
  182. // 移入保险箱
  183. export const moveToSafeStore = async (inventoryIds: string[]) => {
  184. const res = await postL(apis.STORE_MOVE_SAFE, { inventoryIds });
  185. return res.success;
  186. };
  187. // 移出保险箱
  188. export const moveOutSafeStore = async (inventoryIds: string[]) => {
  189. const res = await postL(apis.STORE_OUT_SAFE, { inventoryIds });
  190. return res.success;
  191. };
  192. // 兑换预览
  193. export const convertPreview = async (inventoryIds: string[]) => {
  194. const res = await postL(apis.CONVERT_PREVIEW, { inventoryIds });
  195. return res;
  196. };
  197. // 兑换申请
  198. export const convertApply = async (inventoryIds: string[]) => {
  199. const res = await postL(apis.CONVERT_APPLY, { inventoryIds });
  200. return res.success;
  201. };
  202. // 兑换列表
  203. export const getConvertList = async (current: number, size: number) => {
  204. const res = await post(apis.CONVERT_LIST, { current, size });
  205. return res.data;
  206. };
  207. // 一键兑换预览
  208. export const convertAllPreview = async () => {
  209. const res = await postL(apis.CONVERT_ALL_PREVIEW);
  210. return res.data;
  211. };
  212. // 一键兑换
  213. export const convertAll = async (levels: number[]) => {
  214. const res = await postL(apis.CONVERT_ALL, { levels });
  215. return res.success;
  216. };
  217. // 提货预览
  218. export const takePreview = async (inventoryIds: string[], addressBookId: string) => {
  219. const res = await postL(apis.TAKE_PREVIEW, { inventoryIds, addressBookId });
  220. return res.data;
  221. };
  222. // 提货申请
  223. export const takeApply = async (inventoryIds: string[], addressBookId: string, paymentType: string) => {
  224. const res = await postL(apis.TAKE_APPLY, { inventoryIds, addressBookId, paymentType });
  225. return res.data;
  226. };
  227. // 提货列表
  228. export const getTakeList = async (current: number, size: number) => {
  229. const res = await post(apis.TAKE_LIST, { current, size });
  230. return res.data;
  231. };
  232. // 提货支付
  233. export const takePayOrder = async (inventoryIds: string[], addressBookId: string, paymentType: string, tradeNo?: string) => {
  234. const res = await postL(apis.TAKE_PAY_ORDER, { inventoryIds, addressBookId, paymentType, tradeNo });
  235. return res.data;
  236. };
  237. // 参与奖池
  238. export const poolIn = async (poolId: string) => {
  239. const res = await get(apis.POOL_IN, { poolId });
  240. return res.success;
  241. };
  242. // 退出奖池
  243. export const poolOut = async (poolId?: string) => {
  244. const param: any = {};
  245. if (poolId) param.poolId = poolId;
  246. const res = await get(apis.POOL_OUT, param);
  247. return res.success;
  248. };
  249. // 获取包裹信息
  250. export const getAwardPackages = async (tradeNo: string) => {
  251. const res = await get(apis.PACKAGES, { tradeNo });
  252. return res.data;
  253. };
  254. // 获取物流详情
  255. export const getAwardExpress = async (tradeNo: string, packageId: string) => {
  256. const res = await get(apis.EXPRESS, { tradeNo, packageId });
  257. return res.data;
  258. };
  259. // 获取欧皇信息
  260. export const getKing = async (poolId: string) => {
  261. const res = await get(apis.KING, { poolId });
  262. return res.success ? res.data : null;
  263. };
  264. // 获取欧皇榜单
  265. export const getKingUser = async (poolId: string) => {
  266. const res = await get(apis.KING_USER, { poolId });
  267. return res.data;
  268. };
  269. // 获取欧皇商品
  270. export const getKingGoods = async (poolId: string) => {
  271. const res = await get(apis.KING_GOODS, { poolId });
  272. return res.data;
  273. };
  274. // 获取上一期欧皇
  275. export const getPreKing = async (poolId: string) => {
  276. const res = await get(apis.KING_PRE, { poolId });
  277. return res.data;
  278. };
  279. // 获取盒子列表
  280. export const getBoxList = async (poolId: string, level?: number, current?: number, size?: number) => {
  281. const res = await post(apis.BOX_LIST, { poolId, current, size, level });
  282. return res.data;
  283. };
  284. // 获取盒子详情
  285. export const getBoxDetail = async (poolId: string, boxNumber?: string) => {
  286. const param: any = { poolId };
  287. if (boxNumber) param.boxNumber = boxNumber;
  288. const res = await get(apis.BOX_DETAIL, param);
  289. return res.data;
  290. };
  291. // 获取上一个盒子
  292. export const getPreBox = async (poolId: string, boxNumber: string) => {
  293. const res = await get(apis.BOX_PRE, { poolId, boxNumber });
  294. return res.data;
  295. };
  296. // 获取下一个盒子
  297. export const getNextBox = async (poolId: string, boxNumber: string) => {
  298. const res = await get(apis.BOX_NEXT, { poolId, boxNumber });
  299. return res.data;
  300. };
  301. // 锁定盒子
  302. export const lockBox = async (poolId: string, boxNumber: string) => {
  303. const res = await postL(apis.BOX_LOCK, { poolId, boxNumber });
  304. return res.success;
  305. };
  306. // 解锁盒子
  307. export const unlockBox = async (poolId: string, boxNumber: string) => {
  308. const res = await postL(apis.BOX_UN_LOCK, { poolId, boxNumber });
  309. return res.success;
  310. };
  311. // 获取不可用座位号
  312. export const getUnavailableSeatNumbers = async (poolId: string, boxNumber: string) => {
  313. const res = await get(apis.UNAVAILABLE_SEAT_NUMBERS, { poolId, boxNumber });
  314. return res.data;
  315. };
  316. // 获取弹幕列表
  317. export const getFeedbackList = async () => {
  318. const res = await get(apis.FEEDBACK_LIST);
  319. return res;
  320. };
  321. // 发送弹幕
  322. export const submitFeedback = async (content: string) => {
  323. const res = await postL(apis.FEEDBACK_SUBMIT, { content });
  324. return res;
  325. };
  326. // 获取仓库商品详情
  327. export const getLuckDetail = async (id: string) => {
  328. const res = await get('/api/luckInventory/detail', { id });
  329. return res.data;
  330. };
  331. // 获取仓库商品总数
  332. export const getSumInventory = async () => {
  333. const res = await get('/api/luckInventory');
  334. return res.data;
  335. };
  336. export default {
  337. getIndex,
  338. getIPList,
  339. getMagicIndex,
  340. getPoolList,
  341. getHorse,
  342. getPoolDetail,
  343. getPoolProducts,
  344. getDetailHorse,
  345. getBuyRecord,
  346. getVersion,
  347. tryDemo,
  348. previewOrder,
  349. applyOrder,
  350. getApplyResult,
  351. checkPaymentStatus,
  352. getAwardOrders,
  353. getStore,
  354. moveToSafeStore,
  355. moveOutSafeStore,
  356. convertPreview,
  357. convertApply,
  358. getConvertList,
  359. convertAllPreview,
  360. convertAll,
  361. takePreview,
  362. takeApply,
  363. getTakeList,
  364. takePayOrder,
  365. poolIn,
  366. poolOut,
  367. getAwardPackages,
  368. getAwardExpress,
  369. getKing,
  370. getKingUser,
  371. getKingGoods,
  372. getPreKing,
  373. getBoxList,
  374. getBoxDetail,
  375. getPreBox,
  376. getNextBox,
  377. lockBox,
  378. unlockBox,
  379. getUnavailableSeatNumbers,
  380. getFeedbackList,
  381. submitFeedback,
  382. getLuckDetail,
  383. getSumInventory,
  384. };