wallet.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { get, post, postL } from './http';
  2. const apis = {
  3. PRE_ONE_KEY: '/api/substituteOrder/preOneKeySubmit',
  4. COUPON: '/api/coupon/pageMyValidCoupon',
  5. BILL: '/api/wallet/bill',
  6. WITHDRAW_PRE: '/api/wallet/withdrawPre',
  7. WITHDRAW: '/api/wallet/withdraw',
  8. WITHDRAW_INFO: '/api/user/withdraw/info', // Bank info
  9. WITHDRAW_SAVE: '/api/user/withdraw/save',
  10. RECHARGE_SUBMIT: '/api/wallet/recharge/submit',
  11. RECHARGE_GENERATE_LINK: '/api/user/recharge/generatePaymentLink',
  12. RECHARGE_CHECK_PAYMENT_STATUS: '/api/user/recharge/checkPaymentStatus',
  13. INFO: '/api/wallet/getByType',
  14. NEW_USER_PROMOTION: '/api/activity/newUserPromotion',
  15. };
  16. export const preOneKeySubmit = async () => {
  17. const res = await post(apis.PRE_ONE_KEY);
  18. return res;
  19. };
  20. export const info = async (type: string, loading = false) => {
  21. // loading handled manually if needed, or pass header
  22. const res = await get(apis.INFO, { type }, { loading });
  23. return res.data;
  24. };
  25. export const bill = async (current: number, size: number, walletType: string, type: string) => {
  26. const res = await post(apis.BILL, { current, size, walletType, type });
  27. return res.data;
  28. };
  29. export const withdrawPre = async (type: string, walletType: string) => {
  30. const res = await get(apis.WITHDRAW_PRE, { type, walletType });
  31. return res.data;
  32. };
  33. export const getWithdraw = async () => {
  34. const res = await get(apis.WITHDRAW_INFO);
  35. return res.data;
  36. };
  37. export const saveWithdraw = async (data: any) => {
  38. const res = await post(apis.WITHDRAW_SAVE, data);
  39. return res.success;
  40. };
  41. export const withdraw = async (data: any) => {
  42. const res = await postL(apis.WITHDRAW, data);
  43. return res.success;
  44. };
  45. export const generatePaymentLink = async (amount: number, payType: string, walletType: string) => {
  46. const res = await postL(apis.RECHARGE_GENERATE_LINK, { amount, payType, walletType });
  47. return res;
  48. };
  49. export const rechargeSubmit = async (amount: number, paymentType: string, walletType: string) => {
  50. const res = await postL(apis.RECHARGE_SUBMIT, { amount, paymentType, walletType });
  51. return res;
  52. };
  53. export const checkPaymentStatus = async (data: { tradeNo: string }) => {
  54. const res = await post(apis.RECHARGE_CHECK_PAYMENT_STATUS, data);
  55. return res;
  56. };
  57. export const getNewUserPromotion = async () => {
  58. const res = await get(apis.NEW_USER_PROMOTION);
  59. return res.data;
  60. };
  61. export default {
  62. preOneKeySubmit,
  63. info,
  64. bill,
  65. withdrawPre,
  66. getWithdraw,
  67. saveWithdraw,
  68. withdraw,
  69. generatePaymentLink,
  70. rechargeSubmit,
  71. checkPaymentStatus,
  72. getNewUserPromotion,
  73. coupons: async (size = 30) => {
  74. const res = await post(apis.COUPON, { size }, { loading: true });
  75. return res.data;
  76. },
  77. };