mahjong_group/common/server/interface/earnings.js
2025-12-08 00:23:20 +08:00

84 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/common/system/request';
/**
* 获取收益统计信息
* @returns {Promise<{pendingAmount: number, extractedAmount: number}>}
*/
export const getEarningsSummary = async () => {
const res = await request.getOrCache("sq/GetEarningsSummary", {}, 1);
if (res.code == 0) {
return res.data || { pendingAmount: 0, extractedAmount: 0 };
}
return { pendingAmount: 0, extractedAmount: 0 };
}
/**
* 获取收益规则说明
* @returns {Promise<string>}
*/
export const getEarningsRule = async () => {
const res = await request.getOrCache("sq/GetEarningsRule", {}, 300);
if (res.code == 0) {
return res.data?.content || '';
}
return '';
}
/**
* 获取收益记录列表
* @param {number} pageIndex 页码从1开始
* @param {number} pageSize 每页数量
* @returns {Promise<Array>}
*/
export const getEarningsRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.post(
"sq/GetEarningsRecordList",
{ pageIndex, pageSize }
);
if (res.code == 0) {
return res.data || [];
}
return [];
}
/**
* 获取提现记录列表
* @param {number} pageIndex 页码从1开始
* @param {number} pageSize 每页数量
* @returns {Promise<Array>}
*/
export const getWithdrawRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.post(
"sq/GetWithdrawRecordList",
{ pageIndex, pageSize }
);
if (res.code == 0) {
return res.data || [];
}
return [];
}
/**
* 申请提现
* @param {number} amount 提现金额
* @returns {Promise<{success: boolean, msg?: string}>}
*/
export const applyWithdraw = async (amount) => {
const res = await request.post("sq/ApplyWithdraw", { amount });
if (res.code == 0) {
return { success: true, msg: res.msg || '提现申请已提交' };
}
return { success: false, msg: res.msg || '提现申请失败' };
}
// 导出收益接口对象
export const earningsInterface = {
getEarningsSummary,
getEarningsRule,
getEarningsRecordList,
getWithdrawRecordList,
applyWithdraw
}
export default earningsInterface;