award.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. return res.data;
  144. };
  145. // 提交订单
  146. export const applyOrder = async (poolId: string, quantity: number, paymentType: string, boxNumber?: string, seatNumbers?: number[], packFlag?: boolean) => {
  147. const param: any = { poolId, quantity, paymentType };
  148. if (boxNumber) param.boxNumber = boxNumber;
  149. if (seatNumbers && seatNumbers.length > 0) param.seatNumbers = seatNumbers;
  150. if (packFlag) param.packFlag = packFlag;
  151. const res = await postL(apis.APPLY, param);
  152. return res.data;
  153. };
  154. // 获取抽奖结果
  155. export const getApplyResult = async (tradeNo: string) => {
  156. const res = await get(apis.APPLY_RESULT, { tradeNo });
  157. return res.data;
  158. };
  159. // 检查支付状态
  160. export const checkPaymentStatus = async (tradeNo: string) => {
  161. const res = await get(apis.CHECK_PAYMENT_STATUS, { tradeNo });
  162. return res.data;
  163. };
  164. // 获取盲盒订单列表
  165. export const getAwardOrders = async (current: number, size: number, tab?: string) => {
  166. const res = await post(apis.ORDERS, { current, size, tab });
  167. return res.data;
  168. };
  169. // 获取仓库列表
  170. export const getStore = async (current: number, size: number, safeFlag?: number, tab?: string) => {
  171. const res = await post(apis.STORE, { current, size, status: 0, tab, safeFlag });
  172. return res.data;
  173. };
  174. // 移入保险箱
  175. export const moveToSafeStore = async (inventoryIds: string[]) => {
  176. const res = await postL(apis.STORE_MOVE_SAFE, { inventoryIds });
  177. return res.success;
  178. };
  179. // 移出保险箱
  180. export const moveOutSafeStore = async (inventoryIds: string[]) => {
  181. const res = await postL(apis.STORE_OUT_SAFE, { inventoryIds });
  182. return res.success;
  183. };
  184. // 兑换预览
  185. export const convertPreview = async (inventoryIds: string[]) => {
  186. const res = await postL(apis.CONVERT_PREVIEW, { inventoryIds });
  187. return res;
  188. };
  189. // 兑换申请
  190. export const convertApply = async (inventoryIds: string[]) => {
  191. const res = await postL(apis.CONVERT_APPLY, { inventoryIds });
  192. return res.success;
  193. };
  194. // 兑换列表
  195. export const getConvertList = async (current: number, size: number) => {
  196. const res = await post(apis.CONVERT_LIST, { current, size });
  197. return res.data;
  198. };
  199. // 一键兑换预览
  200. export const convertAllPreview = async () => {
  201. const res = await postL(apis.CONVERT_ALL_PREVIEW);
  202. return res.data;
  203. };
  204. // 一键兑换
  205. export const convertAll = async (levels: number[]) => {
  206. const res = await postL(apis.CONVERT_ALL, { levels });
  207. return res.success;
  208. };
  209. // 提货预览
  210. export const takePreview = async (inventoryIds: string[], addressBookId: string) => {
  211. const res = await postL(apis.TAKE_PREVIEW, { inventoryIds, addressBookId });
  212. return res.data;
  213. };
  214. // 提货申请
  215. export const takeApply = async (inventoryIds: string[], addressBookId: string, paymentType: string) => {
  216. const res = await postL(apis.TAKE_APPLY, { inventoryIds, addressBookId, paymentType });
  217. return res.data;
  218. };
  219. // 提货列表
  220. export const getTakeList = async (current: number, size: number) => {
  221. const res = await post(apis.TAKE_LIST, { current, size });
  222. return res.data;
  223. };
  224. // 提货支付
  225. export const takePayOrder = async (inventoryIds: string[], addressBookId: string, paymentType: string, tradeNo?: string) => {
  226. const res = await postL(apis.TAKE_PAY_ORDER, { inventoryIds, addressBookId, paymentType, tradeNo });
  227. return res.data;
  228. };
  229. // 参与奖池
  230. export const poolIn = async (poolId: string) => {
  231. const res = await get(apis.POOL_IN, { poolId });
  232. return res.success;
  233. };
  234. // 退出奖池
  235. export const poolOut = async (poolId?: string) => {
  236. const param: any = {};
  237. if (poolId) param.poolId = poolId;
  238. const res = await get(apis.POOL_OUT, param);
  239. return res.success;
  240. };
  241. // 获取包裹信息
  242. export const getAwardPackages = async (tradeNo: string) => {
  243. const res = await get(apis.PACKAGES, { tradeNo });
  244. return res.data;
  245. };
  246. // 获取物流详情
  247. export const getAwardExpress = async (tradeNo: string, packageId: string) => {
  248. const res = await get(apis.EXPRESS, { tradeNo, packageId });
  249. return res.data;
  250. };
  251. // 获取欧皇信息
  252. export const getKing = async (poolId: string) => {
  253. const res = await get(apis.KING, { poolId });
  254. return res.success ? res.data : null;
  255. };
  256. // 获取欧皇榜单
  257. export const getKingUser = async (poolId: string) => {
  258. const res = await get(apis.KING_USER, { poolId });
  259. return res.data;
  260. };
  261. // 获取欧皇商品
  262. export const getKingGoods = async (poolId: string) => {
  263. const res = await get(apis.KING_GOODS, { poolId });
  264. return res.data;
  265. };
  266. // 获取上一期欧皇
  267. export const getPreKing = async (poolId: string) => {
  268. const res = await get(apis.KING_PRE, { poolId });
  269. return res.data;
  270. };
  271. // 获取盒子列表
  272. export const getBoxList = async (poolId: string, level?: number, current?: number, size?: number) => {
  273. const res = await post(apis.BOX_LIST, { poolId, current, size, level });
  274. return res.data;
  275. };
  276. // 获取盒子详情
  277. export const getBoxDetail = async (poolId: string, boxNumber?: string) => {
  278. const param: any = { poolId };
  279. if (boxNumber) param.boxNumber = boxNumber;
  280. const res = await get(apis.BOX_DETAIL, param);
  281. return res.data;
  282. };
  283. // 获取弹幕列表
  284. export const getFeedbackList = async () => {
  285. const res = await get(apis.FEEDBACK_LIST);
  286. return res;
  287. };
  288. // 发送弹幕
  289. export const submitFeedback = async (content: string) => {
  290. const res = await postL(apis.FEEDBACK_SUBMIT, { content });
  291. return res;
  292. };
  293. // 获取仓库商品详情
  294. export const getLuckDetail = async (id: string) => {
  295. const res = await get('/api/luckInventory/detail', { id });
  296. return res.data;
  297. };
  298. // 获取仓库商品总数
  299. export const getSumInventory = async () => {
  300. const res = await get('/api/luckInventory');
  301. return res.data;
  302. };
  303. export default {
  304. getIndex,
  305. getIPList,
  306. getMagicIndex,
  307. getPoolList,
  308. getHorse,
  309. getPoolDetail,
  310. getPoolProducts,
  311. getDetailHorse,
  312. getBuyRecord,
  313. getVersion,
  314. tryDemo,
  315. previewOrder,
  316. applyOrder,
  317. getApplyResult,
  318. checkPaymentStatus,
  319. getAwardOrders,
  320. getStore,
  321. moveToSafeStore,
  322. moveOutSafeStore,
  323. convertPreview,
  324. convertApply,
  325. getConvertList,
  326. convertAllPreview,
  327. convertAll,
  328. takePreview,
  329. takeApply,
  330. getTakeList,
  331. takePayOrder,
  332. poolIn,
  333. poolOut,
  334. getAwardPackages,
  335. getAwardExpress,
  336. getKing,
  337. getKingUser,
  338. getKingGoods,
  339. getPreKing,
  340. getBoxList,
  341. getBoxDetail,
  342. getFeedbackList,
  343. submitFeedback,
  344. getLuckDetail,
  345. getSumInventory,
  346. };