This commit is contained in:
sion
2026-04-07 01:05:05 +08:00
parent edad10ff06
commit 5ca1274607
83 changed files with 1561 additions and 1241 deletions

View File

@@ -1,4 +1,4 @@
/// 资产总览模型
/// 資產總覽模型
class AssetOverview {
final String totalAsset;
final String fundBalance;
@@ -22,7 +22,7 @@ class AssetOverview {
}
}
/// 资金账户模型
/// 資金賬戶模型
class AccountFund {
final int id;
final int userId;
@@ -51,7 +51,7 @@ class AccountFund {
}
}
/// 交易账户模型(持
/// 交易賬戶模型(持
class AccountTrade {
final int id;
final int userId;
@@ -78,7 +78,7 @@ class AccountTrade {
});
factory AccountTrade.fromJson(Map<String, dynamic> json) {
// 端返回 value当前价值),前端用 currentValue
// 端返回 value當前價值),前端用 currentValue
final quantityNum =
double.tryParse(json['quantity']?.toString() ?? '0') ?? 0;
final avgPriceNum =
@@ -108,7 +108,7 @@ class AccountTrade {
);
}
/// 格式化盈
/// 格式化盈
String get formattedProfitRate {
final prefix = profitRate >= 0 ? '+' : '';
return '$prefix${profitRate.toStringAsFixed(2)}%';
@@ -118,7 +118,7 @@ class AccountTrade {
bool get isProfit => profitRate >= 0;
}
/// 金流水模型
/// 金流水模型
class AccountFlow {
final int id;
final int userId;
@@ -155,26 +155,26 @@ class AccountFlow {
);
}
/// 流水型文字
/// 流水型文字
String get flowTypeText {
switch (flowType) {
case '1':
return '充值';
case '2':
return '';
return '';
case '3':
return '入交易账户';
return '入交易賬戶';
case '4':
return '交易账户转';
return '交易賬戶轉';
case '5':
return '出收入';
return '出收入';
case '6':
return '入支出';
return '入支出';
default:
return '未知';
}
}
/// 是否收入
/// 是否收入
bool get isIncome => ['1', '3', '5'].contains(flowType);
}

View File

@@ -1,4 +1,4 @@
/// 币种模型
/// 幣種模型
class Coin {
final int id;
final String code;
@@ -7,7 +7,7 @@ class Coin {
final double price;
final double? priceUsd;
final double? priceCny;
final int priceType; // 1=实时价格, 2=管理员设
final int priceType; // 1=實時價格, 2=管理員設
final double change24h;
final double? high24h;
final double? low24h;
@@ -70,7 +70,7 @@ class Coin {
};
}
/// 显示图标Unicode 符
/// 顯示圖標Unicode 符
String get displayIcon {
const icons = {
'BTC': '\u20BF',
@@ -85,22 +85,22 @@ class Coin {
return icons[code] ?? '\u25CF';
}
/// 格式化价格显
/// 格式化價格顯
String get formattedPrice {
if (price >= 1000) return price.toStringAsFixed(2);
if (price >= 1) return price.toStringAsFixed(4);
return price.toStringAsFixed(6);
}
/// 格式化跌幅
/// 格式化跌幅
String get formattedChange {
final prefix = change24h >= 0 ? '+' : '';
return '$prefix${change24h.toStringAsFixed(2)}%';
}
/// 是否上
/// 是否上
bool get isUp => change24h >= 0;
/// 是否为实时价
/// 是否為實時價
bool get isRealtime => priceType == 1;
}

View File

@@ -1,14 +1,14 @@
/// 交易订单模型
/// 交易訂單模型
class OrderTrade {
final int id;
final String orderNo;
final int userId;
final String coinCode;
final int direction; // 1=入, 2=
final int direction; // 1=入, 2=
final String price;
final String quantity;
final String amount;
final int status; // 1=待理, 2=已完成, 3=已取消
final int status; // 1=待理, 2=已完成, 3=已取消
final DateTime? createTime;
final DateTime? updateTime;
@@ -47,13 +47,13 @@ class OrderTrade {
}
/// 方向文字
String get directionText => direction == 1 ? '' : '';
String get directionText => direction == 1 ? '' : '';
/// 状态文字
/// 狀態文字
String get statusText {
switch (status) {
case 1:
return '';
return '';
case 2:
return '已完成';
case 3:
@@ -63,33 +63,33 @@ class OrderTrade {
}
}
/// 是否为买
/// 是否為買
bool get isBuy => direction == 1;
}
/// 充提订单模型
/// 充提訂單模型
class OrderFund {
final int id;
final String orderNo;
final int userId;
final String username;
final int type; // 1=充值, 2=提
final int type; // 1=充值, 2=提
final String amount;
final String? fee; // 手续费
final String? receivableAmount; // 收款
final String? fee; // 手續費
final String? receivableAmount; // 收款
final int status;
// 充值状态: 1=待付款, 2=待确认, 3=已完成, 4=已回, 5=已取消
// 提现状态: 1=待批, 2=已出款, 3=已回, 4=已取消, 5=待财务审
final int? walletId; // 冷包ID(充值)
final String? walletAddress; // 包地址(充值/提)
final String? network; // 提现网络类
final String? withdrawContact; // 提现联系方式
// 充值狀態: 1=待付款, 2=待確認, 3=已完成, 4=已回, 5=已取消
// 提現狀態: 1=待批, 2=已出款, 3=已回, 4=已取消, 5=待財務審
final int? walletId; // 冷包ID(充值)
final String? walletAddress; // 包地址(充值/提)
final String? network; // 提現網絡類
final String? withdrawContact; // 提現聯繫方式
final String remark;
final String? rejectReason;
final String? adminRemark;
final DateTime? createTime;
final DateTime? payTime; // 用户确认打款时间
final DateTime? confirmTime; // 管理员确认时间
final DateTime? payTime; // 用戶確認打款時間
final DateTime? confirmTime; // 管理員確認時間
OrderFund({
required this.id,
@@ -143,72 +143,72 @@ class OrderFund {
);
}
/// 订单类型文字
String get typeText => type == 1 ? '充值' : '';
/// 訂單類型文字
String get typeText => type == 1 ? '充值' : '';
/// 状态文字 (根据类型区分)
/// 狀態文字 (根據類型區分)
String get statusText {
if (type == 1) {
// 充值状态
// 充值狀態
switch (status) {
case 1:
return '待付款';
case 2:
return '确认';
return '確認';
case 3:
return '已完成';
case 4:
return '';
return '';
case 5:
return '已取消';
default:
return '未知';
}
} else {
// 提现状态
// 提現狀態
switch (status) {
case 1:
return '';
return '';
case 2:
return '已出款';
case 3:
return '';
return '';
case 4:
return '已取消';
case 5:
return '财务审';
return '財務審';
default:
return '未知';
}
}
}
/// 是否充值
/// 是否充值
bool get isDeposit => type == 1;
/// 是否可取消
/// 充值: 待付款可取消
/// 提: 仅待审批可取消
/// 充值: 待付款可取消
/// 提: 僅待審批可取消
bool get canCancel {
if (type == 1) {
return status == 1; // 充值待付款
} else {
return status == 1; // 提现待审
return status == 1; // 提現待審
}
}
/// 是否可确认打款 (充值待付款)
/// 是否可確認打款 (充值待付款)
bool get canConfirmPay => type == 1 && status == 1;
}
/// 冷包模型
/// 冷包模型
class ColdWallet {
final int id;
final String name;
final String address;
final String network;
final bool isDefault;
final int status; // 0=禁用, 1=
final int status; // 0=禁用, 1=
final DateTime? createTime;
ColdWallet({

View File

@@ -1,4 +1,4 @@
/// 用模型
/// 用模型
class User {
final int id;
final String username;
@@ -62,21 +62,21 @@ class User {
};
}
/// 获取头像显示文字(用名首字母)
/// 獲取頭像顯示文字(用名首字母)
String get avatarText =>
username.isNotEmpty ? username.substring(0, 1).toUpperCase() : 'U';
/// KYC 状态文字
/// KYC 狀態文字
String get kycStatusText {
switch (kycStatus) {
case 0:
return '认证';
return '認證';
case 1:
return '核中';
return '核中';
case 2:
return '认证';
return '認證';
case 3:
return '认证失败';
return '認證失敗';
default:
return '未知';
}

View File

@@ -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 ?? '取每日盈虧數據失敗');
}
}

View File

@@ -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,
},
);
}
}

View File

@@ -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();

View File

@@ -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 ?? '搜索失');
}
}

View File

@@ -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 ?? '獲取訂單詳情失');
}
}

View File

@@ -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);
}