feat: 添加业务分析后端接口
新增 AnalysisController 提供 6 个分析接口: - /admin/analysis/profit - 盈利分析(交易手续费/充提手续费/资金利差) - /admin/analysis/cash-flow - 资金流动趋势(按月统计充值/提现/净流入) - /admin/analysis/trade - 交易分析(买入/卖出统计+趋势) - /admin/analysis/coin-distribution - 币种交易分布 - /admin/analysis/user-growth - 用户增长分析(新增/活跃用户) - /admin/analysis/risk - 风险指标(大额交易/异常提现/KYC/冻结账户) - /admin/analysis/health - 综合健康度评分 更新 Mapper 添加分析查询方法: - OrderFundMapper: 手续费统计、时间范围查询、大额交易、异常提现 - OrderTradeMapper: 交易金额统计、活跃用户、币种分布 前端 API 对接: - 新增 6 个分析相关 Query hooks - 更新 analytics.vue 使用真实数据 - 动态决策建议基于实际数据
This commit is contained in:
125
flutter_monisuo/lib/ui/components/trade_button.dart
Normal file
125
flutter_monisuo/lib/ui/components/trade_button.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
/// 交易按钮组件 - 买入/卖出按钮
|
||||
class TradeButton extends StatelessWidget {
|
||||
final bool isBuy;
|
||||
final String? coinCode;
|
||||
final VoidCallback? onPressed;
|
||||
final bool isLoading;
|
||||
final bool fullWidth;
|
||||
|
||||
// 颜色常量
|
||||
static const buyColor = Color(0xFF00C853);
|
||||
static const sellColor = Color(0xFFFF5252);
|
||||
|
||||
const TradeButton({
|
||||
super.key,
|
||||
this.isBuy = true,
|
||||
this.coinCode,
|
||||
this.onPressed,
|
||||
this.isLoading = false,
|
||||
this.fullWidth = false,
|
||||
});
|
||||
|
||||
/// 买入按钮
|
||||
const TradeButton.buy({
|
||||
super.key,
|
||||
this.coinCode,
|
||||
this.onPressed,
|
||||
this.isLoading = false,
|
||||
this.fullWidth = false,
|
||||
}) : isBuy = true;
|
||||
|
||||
/// 卖出按钮
|
||||
const TradeButton.sell({
|
||||
super.key,
|
||||
this.coinCode,
|
||||
this.onPressed,
|
||||
this.isLoading = false,
|
||||
this.fullWidth = false,
|
||||
}) : isBuy = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = isBuy ? buyColor : sellColor;
|
||||
final text = isBuy ? '买入${coinCode != null ? ' $coinCode' : ''}' : '卖出${coinCode != null ? ' $coinCode' : ''}';
|
||||
final icon = isBuy ? LucideIcons.arrowDownToLine : LucideIcons.arrowUpFromLine;
|
||||
|
||||
final button = ShadButton(
|
||||
backgroundColor: color,
|
||||
onPressed: isLoading ? null : onPressed,
|
||||
child: Row(
|
||||
mainAxisSize: fullWidth ? MainAxisSize.max : MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (isLoading)
|
||||
const SizedBox.square(
|
||||
dimension: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
else
|
||||
Icon(icon, size: 18, color: Colors.white),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (fullWidth) {
|
||||
return SizedBox(width: double.infinity, child: button);
|
||||
}
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
||||
/// 交易按钮组 - 同时显示买入和卖出按钮
|
||||
class TradeButtonGroup extends StatelessWidget {
|
||||
final String? coinCode;
|
||||
final VoidCallback? onBuyPressed;
|
||||
final VoidCallback? onSellPressed;
|
||||
final bool isBuyLoading;
|
||||
final bool isSellLoading;
|
||||
|
||||
const TradeButtonGroup({
|
||||
super.key,
|
||||
this.coinCode,
|
||||
this.onBuyPressed,
|
||||
this.onSellPressed,
|
||||
this.isBuyLoading = false,
|
||||
this.isSellLoading = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TradeButton.buy(
|
||||
coinCode: coinCode,
|
||||
onPressed: onBuyPressed,
|
||||
isLoading: isBuyLoading,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: TradeButton.sell(
|
||||
coinCode: coinCode,
|
||||
onPressed: onSellPressed,
|
||||
isLoading: isSellLoading,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user