feat: 重构充值提现功能,添加冷钱包管理
后端改动: - 新增冷钱包管理模块(ColdWallet实体、Mapper、Service、Controller) - 充值流程:创建订单→显示钱包地址→用户确认打款→管理员审核 - 提现流程:用户输入地址和联系方式→冻结余额→管理员审核 - OrderFund新增字段:walletId, walletAddress, withdrawContact, payTime, confirmTime 前端改动(monisuo-admin): - 新增冷钱包管理页面(wallets.vue) - 优化订单管理页面,支持新的状态流转 - 添加调试日志帮助排查登录问题 前端改动(flutter_monisuo): - 更新OrderFund模型支持新字段 - 充值成功后显示钱包地址弹窗 - 提现时收集提现地址和联系方式 - 新增资金订单页面 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../providers/asset_provider.dart';
|
||||
import '../orders/fund_orders_page.dart';
|
||||
|
||||
/// 资产页面 - 使用 shadcn_ui 现代化设计
|
||||
class AssetPage extends StatefulWidget {
|
||||
@@ -201,9 +203,38 @@ class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixi
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'USDT余额',
|
||||
style: theme.textTheme.muted,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'USDT余额',
|
||||
style: theme.textTheme.muted,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const FundOrdersPage()),
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'充提记录',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
LucideIcons.chevronRight,
|
||||
size: 14,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@@ -378,28 +409,241 @@ class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixi
|
||||
}
|
||||
|
||||
void _showDepositDialog(AssetProvider provider) {
|
||||
_showActionDialog(
|
||||
title: '充值',
|
||||
hint: '请输入充值金额(USDT)',
|
||||
onSubmit: (amount) async {
|
||||
final response = await provider.deposit(amount: amount);
|
||||
if (mounted) {
|
||||
_showResult(response.success ? '申请成功' : '申请失败', response.message);
|
||||
}
|
||||
},
|
||||
final amountController = TextEditingController();
|
||||
final formKey = GlobalKey<ShadFormState>();
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: const Text('充值'),
|
||||
child: ShadForm(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadInputFormField(
|
||||
id: 'amount',
|
||||
controller: amountController,
|
||||
placeholder: const Text('请输入充值金额(USDT)'),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入金额';
|
||||
}
|
||||
final amount = double.tryParse(value);
|
||||
if (amount == null || amount <= 0) {
|
||||
return '请输入有效金额';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
child: const Text('取消'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
ShadButton(
|
||||
child: const Text('下一步'),
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
Navigator.of(context).pop();
|
||||
// 提交充值申请
|
||||
final response = await provider.deposit(amount: amountController.text);
|
||||
if (mounted) {
|
||||
if (response.success && response.data != null) {
|
||||
// 显示钱包地址
|
||||
_showDepositResultDialog(response.data!);
|
||||
} else {
|
||||
_showResult('申请失败', response.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示充值结果 - 包含钱包地址
|
||||
void _showDepositResultDialog(Map<String, dynamic> data) {
|
||||
final orderNo = data['orderNo'] as String? ?? '';
|
||||
final amount = data['amount']?.toString() ?? '0.00';
|
||||
final walletAddress = data['walletAddress'] as String? ?? '';
|
||||
final walletNetwork = data['walletNetwork'] as String? ?? 'TRC20';
|
||||
final assetProvider = context.read<AssetProvider>();
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: const Text('充值申请成功'),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('订单号: $orderNo', style: const TextStyle(fontSize: 12)),
|
||||
const SizedBox(height: 8),
|
||||
Text('充值金额: $amount USDT', style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
const Text('请向以下地址转账:', style: TextStyle(fontSize: 12)),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
walletAddress,
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 12),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(LucideIcons.copy, size: 18),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: walletAddress));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('地址已复制到剪贴板')),
|
||||
);
|
||||
},
|
||||
tooltip: '复制地址',
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text('网络: $walletNetwork', style: const TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'转账完成后请点击"已打款"按钮确认',
|
||||
style: TextStyle(fontSize: 12, color: Colors.orange),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
child: const Text('稍后确认'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
ShadButton(
|
||||
child: const Text('已打款'),
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final response = await assetProvider.confirmPay(orderNo);
|
||||
if (mounted) {
|
||||
_showResult(
|
||||
response.success ? '确认成功' : '确认失败',
|
||||
response.success ? '请等待管理员审核' : response.message,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showWithdrawDialog(AssetProvider provider) {
|
||||
_showActionDialog(
|
||||
title: '提现',
|
||||
hint: '请输入提现金额(USDT)',
|
||||
onSubmit: (amount) async {
|
||||
final response = await provider.withdraw(amount: amount);
|
||||
if (mounted) {
|
||||
_showResult(response.success ? '申请成功' : '申请失败', response.message);
|
||||
}
|
||||
},
|
||||
final amountController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final contactController = TextEditingController();
|
||||
final formKey = GlobalKey<ShadFormState>();
|
||||
final fund = provider.fundAccount;
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: const Text('提现'),
|
||||
child: SingleChildScrollView(
|
||||
child: ShadForm(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (fund != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Text(
|
||||
'可用余额: ${fund.balance} USDT',
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
ShadInputFormField(
|
||||
id: 'amount',
|
||||
controller: amountController,
|
||||
placeholder: const Text('请输入提现金额(USDT)'),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入金额';
|
||||
}
|
||||
final amount = double.tryParse(value);
|
||||
if (amount == null || amount <= 0) {
|
||||
return '请输入有效金额';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ShadInputFormField(
|
||||
id: 'address',
|
||||
controller: addressController,
|
||||
placeholder: const Text('请输入提现地址'),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入提现地址';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ShadInputFormField(
|
||||
id: 'contact',
|
||||
controller: contactController,
|
||||
placeholder: const Text('联系方式(可选)'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
child: const Text('取消'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
ShadButton(
|
||||
child: const Text('提交'),
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
Navigator.of(context).pop();
|
||||
final response = await provider.withdraw(
|
||||
amount: amountController.text,
|
||||
withdrawAddress: addressController.text,
|
||||
withdrawContact: contactController.text.isNotEmpty ? contactController.text : null,
|
||||
);
|
||||
if (mounted) {
|
||||
_showResult(
|
||||
response.success ? '申请成功' : '申请失败',
|
||||
response.success ? '请等待管理员审批' : response.message,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -502,59 +746,7 @@ class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixi
|
||||
);
|
||||
}
|
||||
|
||||
void _showActionDialog({
|
||||
required String title,
|
||||
required String hint,
|
||||
required Function(String) onSubmit,
|
||||
}) {
|
||||
final controller = TextEditingController();
|
||||
final formKey = GlobalKey<ShadFormState>();
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: Text(title),
|
||||
child: ShadForm(
|
||||
key: formKey,
|
||||
child: ShadInputFormField(
|
||||
id: 'amount',
|
||||
controller: controller,
|
||||
placeholder: Text(hint),
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入金额';
|
||||
}
|
||||
final amount = double.tryParse(value);
|
||||
if (amount == null || amount <= 0) {
|
||||
return '请输入有效金额';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
child: const Text('取消'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
ShadButton(
|
||||
child: const Text('确认'),
|
||||
onPressed: () async {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
Navigator.of(context).pop();
|
||||
onSubmit(controller.text);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showResult(String title, String? message) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog.alert(
|
||||
|
||||
@@ -391,9 +391,81 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
|
||||
}
|
||||
|
||||
void _showWithdraw() {
|
||||
_showActionDialog('提现', '请输入提现金额(USDT)', (amount) {
|
||||
context.read<AssetProvider>().withdraw(amount: amount);
|
||||
});
|
||||
final amountController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final contactController = TextEditingController();
|
||||
final formKey = GlobalKey<ShadFormState>();
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) => ShadDialog(
|
||||
title: const Text('提现'),
|
||||
child: ShadForm(
|
||||
key: formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadInputFormField(
|
||||
id: 'amount',
|
||||
placeholder: const Text('请输入提现金额(USDT)'),
|
||||
controller: amountController,
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入金额';
|
||||
}
|
||||
final amount = double.tryParse(value);
|
||||
if (amount == null || amount <= 0) {
|
||||
return '请输入有效金额';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ShadInputFormField(
|
||||
id: 'address',
|
||||
placeholder: const Text('请输入提现地址'),
|
||||
controller: addressController,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return '请输入提现地址';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ShadInputFormField(
|
||||
id: 'contact',
|
||||
placeholder: const Text('联系方式(可选)'),
|
||||
controller: contactController,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ShadButton.outline(
|
||||
child: const Text('取消'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
ShadButton(
|
||||
child: const Text('确认'),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!.saveAndValidate()) {
|
||||
final amount = amountController.text.trim();
|
||||
final address = addressController.text.trim();
|
||||
final contact = contactController.text.trim();
|
||||
Navigator.of(context).pop();
|
||||
context.read<AssetProvider>().withdraw(
|
||||
amount: amount,
|
||||
withdrawAddress: address,
|
||||
withdrawContact: contact.isEmpty ? null : contact,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showTransfer() {
|
||||
|
||||
403
flutter_monisuo/lib/ui/pages/orders/fund_orders_page.dart
Normal file
403
flutter_monisuo/lib/ui/pages/orders/fund_orders_page.dart
Normal file
@@ -0,0 +1,403 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../providers/asset_provider.dart';
|
||||
import '../../../data/models/order_models.dart';
|
||||
|
||||
/// 充提订单页面
|
||||
class FundOrdersPage extends StatefulWidget {
|
||||
const FundOrdersPage({super.key});
|
||||
|
||||
@override
|
||||
State<FundOrdersPage> createState() => _FundOrdersPageState();
|
||||
}
|
||||
|
||||
class _FundOrdersPageState extends State<FundOrdersPage> {
|
||||
int _activeTab = 0; // 0=全部, 1=充值, 2=提现
|
||||
|
||||
// 颜色常量
|
||||
static const upColor = Color(0xFF00C853);
|
||||
static const downColor = Color(0xFFFF5252);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadData();
|
||||
});
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
final type = _activeTab == 0 ? null : _activeTab;
|
||||
context.read<AssetProvider>().loadFundOrders(type: type);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
appBar: AppBar(
|
||||
title: const Text('充提记录'),
|
||||
backgroundColor: theme.colorScheme.background,
|
||||
elevation: 0,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildTabs(),
|
||||
Expanded(child: _buildOrderList()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTabs() {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTab('全部', 0),
|
||||
const SizedBox(width: 12),
|
||||
_buildTab('充值', 1),
|
||||
const SizedBox(width: 12),
|
||||
_buildTab('提现', 2),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTab(String label, int index) {
|
||||
final theme = ShadTheme.of(context);
|
||||
final isActive = _activeTab == index;
|
||||
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (_activeTab != index) {
|
||||
setState(() => _activeTab = index);
|
||||
_loadData();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? theme.colorScheme.primary : theme.colorScheme.card,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isActive ? theme.colorScheme.primary : theme.colorScheme.border,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.white : theme.colorScheme.mutedForeground,
|
||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderList() {
|
||||
return Consumer<AssetProvider>(
|
||||
builder: (context, provider, _) {
|
||||
final orders = provider.fundOrders;
|
||||
final isLoading = provider.isLoadingOrders;
|
||||
|
||||
if (isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (orders.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
LucideIcons.inbox,
|
||||
size: 64,
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'暂无订单记录',
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async => _loadData(),
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: orders.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildOrderCard(orders[index]);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderCard(OrderFund order) {
|
||||
final theme = ShadTheme.of(context);
|
||||
final isDeposit = order.isDeposit;
|
||||
|
||||
return ShadCard(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isDeposit
|
||||
? upColor.withValues(alpha: 0.1)
|
||||
: downColor.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
order.typeText,
|
||||
style: TextStyle(
|
||||
color: isDeposit ? upColor : downColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildStatusBadge(order),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
order.orderNo,
|
||||
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${isDeposit ? '+' : '-'}${order.amount} USDT',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isDeposit ? upColor : downColor,
|
||||
),
|
||||
),
|
||||
if (order.canCancel || order.canConfirmPay)
|
||||
Row(
|
||||
children: [
|
||||
if (order.canConfirmPay)
|
||||
ShadButton.outline(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _confirmPay(order),
|
||||
child: const Text('已打款'),
|
||||
),
|
||||
if (order.canCancel) ...[
|
||||
const SizedBox(width: 8),
|
||||
ShadButton.destructive(
|
||||
size: ShadButtonSize.sm,
|
||||
onPressed: () => _cancelOrder(order),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 显示地址信息
|
||||
if (order.walletAddress != null) ...[
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'${isDeposit ? '充值地址' : '提现地址'}: ',
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
order.walletAddress!,
|
||||
style: const TextStyle(fontSize: 11, fontFamily: 'monospace'),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: order.walletAddress!));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('地址已复制')),
|
||||
);
|
||||
},
|
||||
child: Icon(LucideIcons.copy, size: 14, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
if (order.withdrawContact != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'联系方式: ${order.withdrawContact}',
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'创建: ${_formatTime(order.createTime)}',
|
||||
style: const TextStyle(fontSize: 11, color: Colors.grey),
|
||||
),
|
||||
if (order.rejectReason != null)
|
||||
Expanded(
|
||||
child: Text(
|
||||
'驳回: ${order.rejectReason}',
|
||||
style: const TextStyle(fontSize: 11, color: downColor),
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusBadge(OrderFund order) {
|
||||
Color bgColor;
|
||||
Color textColor;
|
||||
|
||||
// 根据类型和状态设置颜色
|
||||
if (order.type == 1) {
|
||||
// 充值状态
|
||||
switch (order.status) {
|
||||
case 1: // 待付款
|
||||
case 2: // 待确认
|
||||
bgColor = Colors.orange.withValues(alpha: 0.1);
|
||||
textColor = Colors.orange;
|
||||
break;
|
||||
case 3: // 已完成
|
||||
bgColor = upColor.withValues(alpha: 0.1);
|
||||
textColor = upColor;
|
||||
break;
|
||||
default: // 已驳回/已取消
|
||||
bgColor = downColor.withValues(alpha: 0.1);
|
||||
textColor = downColor;
|
||||
}
|
||||
} else {
|
||||
// 提现状态
|
||||
switch (order.status) {
|
||||
case 1: // 待审批
|
||||
bgColor = Colors.orange.withValues(alpha: 0.1);
|
||||
textColor = Colors.orange;
|
||||
break;
|
||||
case 2: // 已完成
|
||||
bgColor = upColor.withValues(alpha: 0.1);
|
||||
textColor = upColor;
|
||||
break;
|
||||
default: // 已驳回/已取消
|
||||
bgColor = downColor.withValues(alpha: 0.1);
|
||||
textColor = downColor;
|
||||
}
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
order.statusText,
|
||||
style: TextStyle(fontSize: 11, color: textColor),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatTime(DateTime? time) {
|
||||
if (time == null) return '-';
|
||||
return '${time.year}-${time.month.toString().padLeft(2, '0')}-${time.day.toString().padLeft(2, '0')} '
|
||||
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
void _confirmPay(OrderFund order) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('确认已打款'),
|
||||
content: const Text('确认您已完成向指定地址的转账?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true && mounted) {
|
||||
final response = await context.read<AssetProvider>().confirmPay(order.orderNo);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(response.success ? '确认成功,请等待审核' : response.message ?? '确认失败')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _cancelOrder(OrderFund order) async {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('取消订单'),
|
||||
content: Text('确定要取消订单 ${order.orderNo} 吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('返回'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
style: TextButton.styleFrom(foregroundColor: downColor),
|
||||
child: const Text('确定取消'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true && mounted) {
|
||||
final response = await context.read<AssetProvider>().cancelOrder(order.orderNo);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(response.success ? '订单已取消' : response.message ?? '取消失败')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user