111
This commit is contained in:
@@ -3,13 +3,13 @@ import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/account_models.dart';
|
||||
|
||||
/// 资产服务
|
||||
/// 資產服務
|
||||
class AssetService {
|
||||
final DioClient _client;
|
||||
|
||||
AssetService(this._client);
|
||||
|
||||
/// 获取资产总览
|
||||
/// 獲取資產總覽
|
||||
Future<ApiResponse<AssetOverview>> getOverview() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.assetOverview,
|
||||
@@ -21,17 +21,17 @@ class AssetService {
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取资产总览失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取資產總覽失敗');
|
||||
}
|
||||
|
||||
/// 获取资金账户
|
||||
/// 獲取資金賬戶
|
||||
Future<ApiResponse<AccountFund>> getFundAccount() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.fundAccount,
|
||||
);
|
||||
|
||||
if (response.success && response.data != null) {
|
||||
// 后端返回格式: {"fund": {...}}
|
||||
// 後端返回格式: {"fund": {...}}
|
||||
final fundData = response.data!['fund'] as Map<String, dynamic>?;
|
||||
if (fundData != null) {
|
||||
return ApiResponse.success(
|
||||
@@ -40,25 +40,25 @@ class AssetService {
|
||||
);
|
||||
}
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取资金账户失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取資金賬戶失敗');
|
||||
}
|
||||
|
||||
/// 获取交易账户
|
||||
/// 獲取交易賬戶
|
||||
Future<ApiResponse<List<AccountTrade>>> getTradeAccount() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.tradeAccount,
|
||||
);
|
||||
|
||||
if (response.success && response.data != null) {
|
||||
// 后端返回格式: {"positions": [...]}
|
||||
// 後端返回格式: {"positions": [...]}
|
||||
final list = response.data!['positions'] as List?;
|
||||
final accounts = list?.map((e) => AccountTrade.fromJson(e as Map<String, dynamic>)).toList() ?? [];
|
||||
return ApiResponse.success(accounts, response.message);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取交易账户失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取交易賬戶失敗');
|
||||
}
|
||||
|
||||
/// 资金划转
|
||||
/// 資金劃轉
|
||||
Future<ApiResponse<void>> transfer({
|
||||
required int direction,
|
||||
required String amount,
|
||||
@@ -72,7 +72,7 @@ class AssetService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取资金流水
|
||||
/// 獲取資金流水
|
||||
Future<ApiResponse<Map<String, dynamic>>> getFlow({
|
||||
int? flowType,
|
||||
int pageNum = 1,
|
||||
@@ -90,7 +90,7 @@ class AssetService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取每日盈亏数据
|
||||
/// 獲取每日盈虧數據
|
||||
Future<ApiResponse<Map<String, dynamic>>> getDailyProfit({
|
||||
required int year,
|
||||
required int month,
|
||||
@@ -102,6 +102,6 @@ class AssetService {
|
||||
if (response.success && response.data != null) {
|
||||
return ApiResponse.success(response.data!, response.message);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取每日盈亏数据失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取每日盈虧數據失敗');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ import '../../core/constants/api_endpoints.dart';
|
||||
import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
|
||||
/// 福利中心服务
|
||||
/// 福利中心服務
|
||||
class BonusService {
|
||||
final DioClient _client;
|
||||
|
||||
BonusService(this._client);
|
||||
|
||||
/// 获取福利中心状态
|
||||
/// 獲取福利中心狀態
|
||||
Future<ApiResponse<Map<String, dynamic>>> getWelfareStatus() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusWelfare,
|
||||
@@ -16,10 +16,10 @@ class BonusService {
|
||||
if (response.success && response.data != null) {
|
||||
return ApiResponse.success(response.data!, response.message);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取福利状态失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取福利狀態失敗');
|
||||
}
|
||||
|
||||
/// 领取首充福利
|
||||
/// 領取首充福利
|
||||
Future<ApiResponse<Map<String, dynamic>>> claimNewUserBonus() async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusClaim,
|
||||
@@ -27,7 +27,7 @@ class BonusService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 领取推广奖励
|
||||
/// 領取推廣獎勵
|
||||
Future<ApiResponse<Map<String, dynamic>>> claimReferralBonus(
|
||||
int referredUserId,
|
||||
int milestone,
|
||||
@@ -41,4 +41,21 @@ class BonusService {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 領取間接推廣獎勵
|
||||
Future<ApiResponse<Map<String, dynamic>>> claimIndirectReferralBonus(
|
||||
int directReferralId,
|
||||
int indirectReferredUserId,
|
||||
int milestone,
|
||||
) async {
|
||||
return _client.post<Map<String, dynamic>>(
|
||||
ApiEndpoints.bonusClaim,
|
||||
data: {
|
||||
'type': 'indirect_referral',
|
||||
'directReferralId': directReferralId,
|
||||
'indirectReferredUserId': indirectReferredUserId,
|
||||
'milestone': milestone,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/order_models.dart';
|
||||
|
||||
/// 充提服务
|
||||
/// 充提服務
|
||||
class FundService {
|
||||
final DioClient _client;
|
||||
|
||||
FundService(this._client);
|
||||
|
||||
/// 获取默认钱包地址
|
||||
/// 獲取默認錢包地址
|
||||
Future<ApiResponse<ColdWallet>> getDefaultWallet() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.defaultWallet,
|
||||
@@ -21,10 +21,10 @@ class FundService {
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取钱包地址失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取錢包地址失敗');
|
||||
}
|
||||
|
||||
/// 申请充值
|
||||
/// 申請充值
|
||||
/// 返回包含 orderNo, amount, status, walletAddress, walletNetwork 的信息
|
||||
Future<ApiResponse<Map<String, dynamic>>> deposit({
|
||||
required String amount,
|
||||
@@ -39,7 +39,7 @@ class FundService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 用户确认已打款
|
||||
/// 用戶確認已打款
|
||||
Future<ApiResponse<void>> confirmPay(String orderNo) async {
|
||||
return _client.post<void>(
|
||||
ApiEndpoints.confirmPay,
|
||||
@@ -47,7 +47,7 @@ class FundService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 申请提现
|
||||
/// 申請提現
|
||||
Future<ApiResponse<Map<String, dynamic>>> withdraw({
|
||||
required String amount,
|
||||
required String withdrawAddress,
|
||||
@@ -67,7 +67,7 @@ class FundService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取可用的提现网络列表
|
||||
/// 獲取可用的提現網絡列表
|
||||
Future<ApiResponse<List<String>>> getWalletNetworks() async {
|
||||
final response = await _client.get<List<dynamic>>(
|
||||
ApiEndpoints.walletNetworks,
|
||||
@@ -78,10 +78,10 @@ class FundService {
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取网络列表失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取網絡列表失敗');
|
||||
}
|
||||
|
||||
/// 取消订单
|
||||
/// 取消訂單
|
||||
Future<ApiResponse<void>> cancelOrder(String orderNo) async {
|
||||
return _client.post<void>(
|
||||
ApiEndpoints.cancelOrder,
|
||||
@@ -89,7 +89,7 @@ class FundService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取充提记录
|
||||
/// 獲取充提記錄
|
||||
Future<ApiResponse<Map<String, dynamic>>> getOrders({
|
||||
int? type,
|
||||
int pageNum = 1,
|
||||
@@ -107,7 +107,7 @@ class FundService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 解析充提记录列表
|
||||
/// 解析充提記錄列表
|
||||
List<OrderFund> parseOrderList(List<dynamic>? list) {
|
||||
if (list == null) return [];
|
||||
return list.map((e) => OrderFund.fromJson(e as Map<String, dynamic>)).toList();
|
||||
|
||||
@@ -3,13 +3,13 @@ import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/coin.dart';
|
||||
|
||||
/// 行情服务
|
||||
/// 行情服務
|
||||
class MarketService {
|
||||
final DioClient _client;
|
||||
|
||||
MarketService(this._client);
|
||||
|
||||
/// 获取币种列表
|
||||
/// 獲取幣種列表
|
||||
Future<ApiResponse<List<Coin>>> getCoinList() async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.coinList,
|
||||
@@ -20,10 +20,10 @@ class MarketService {
|
||||
final coins = list?.map((e) => Coin.fromJson(e as Map<String, dynamic>)).toList() ?? [];
|
||||
return ApiResponse.success(coins, response.message);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取币种列表失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取幣種列表失敗');
|
||||
}
|
||||
|
||||
/// 获取币种详情
|
||||
/// 獲取幣種詳情
|
||||
Future<ApiResponse<Coin>> getCoinDetail(String code) async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.coinDetail,
|
||||
@@ -36,10 +36,10 @@ class MarketService {
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取币种详情失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取幣種詳情失敗');
|
||||
}
|
||||
|
||||
/// 搜索币种
|
||||
/// 搜索幣種
|
||||
Future<ApiResponse<List<Coin>>> searchCoins(String keyword) async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.coinSearch,
|
||||
@@ -51,6 +51,6 @@ class MarketService {
|
||||
final coins = list?.map((e) => Coin.fromJson(e as Map<String, dynamic>)).toList() ?? [];
|
||||
return ApiResponse.success(coins, response.message);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '搜索失败');
|
||||
return ApiResponse.fail(response.message ?? '搜索失敗');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/order_models.dart';
|
||||
|
||||
/// 交易服务
|
||||
/// 交易服務
|
||||
class TradeService {
|
||||
final DioClient _client;
|
||||
|
||||
TradeService(this._client);
|
||||
|
||||
/// 买入
|
||||
/// 買入
|
||||
Future<ApiResponse<Map<String, dynamic>>> buy({
|
||||
required String coinCode,
|
||||
required String price,
|
||||
@@ -25,7 +25,7 @@ class TradeService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 卖出
|
||||
/// 賣出
|
||||
Future<ApiResponse<Map<String, dynamic>>> sell({
|
||||
required String coinCode,
|
||||
required String price,
|
||||
@@ -41,7 +41,7 @@ class TradeService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取交易记录
|
||||
/// 獲取交易記錄
|
||||
Future<ApiResponse<Map<String, dynamic>>> getOrders({
|
||||
String? coinCode,
|
||||
int? direction,
|
||||
@@ -61,7 +61,7 @@ class TradeService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取订单详情
|
||||
/// 獲取訂單詳情
|
||||
Future<ApiResponse<OrderTrade>> getOrderDetail(String orderNo) async {
|
||||
final response = await _client.get<Map<String, dynamic>>(
|
||||
ApiEndpoints.tradeOrderDetail,
|
||||
@@ -74,6 +74,6 @@ class TradeService {
|
||||
response.message,
|
||||
);
|
||||
}
|
||||
return ApiResponse.fail(response.message ?? '获取订单详情失败');
|
||||
return ApiResponse.fail(response.message ?? '獲取訂單詳情失敗');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import '../../core/network/api_response.dart';
|
||||
import '../../core/network/dio_client.dart';
|
||||
import '../models/user.dart';
|
||||
|
||||
/// 用户服务
|
||||
/// 用戶服務
|
||||
class UserService {
|
||||
final DioClient _client;
|
||||
|
||||
UserService(this._client);
|
||||
|
||||
/// 用户登录
|
||||
/// 用戶登錄
|
||||
Future<ApiResponse<Map<String, dynamic>>> login(
|
||||
String username,
|
||||
String password,
|
||||
@@ -22,7 +22,7 @@ class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 用户注册(multipart:含身份证图片和可选推广码)
|
||||
/// 用戶註冊(multipart:含身份證圖片和可選推廣碼)
|
||||
Future<ApiResponse<Map<String, dynamic>>> register(
|
||||
String username,
|
||||
String password, {
|
||||
@@ -43,7 +43,7 @@ class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取用户信息
|
||||
/// 獲取用戶信息
|
||||
Future<ApiResponse<User>> getUserInfo() async {
|
||||
return _client.get<User>(
|
||||
ApiEndpoints.userInfo,
|
||||
@@ -51,8 +51,8 @@ class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 上传 KYC 资料(身份证正反面图片字节)
|
||||
/// 使用 fromBytes 以兼容 Web 和移动端
|
||||
/// 上傳 KYC 資料(身份證正反面圖片字節)
|
||||
/// 使用 fromBytes 以兼容 Web 和移動端
|
||||
Future<ApiResponse<void>> uploadKyc(
|
||||
Uint8List frontBytes,
|
||||
Uint8List backBytes,
|
||||
@@ -67,7 +67,7 @@ class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
/// 退出登录
|
||||
/// 退出登錄
|
||||
Future<ApiResponse<void>> logout() async {
|
||||
return _client.post<void>(ApiEndpoints.logout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user