diff --git a/admin/mining.php b/admin/mining.php
index 5c5cda9..51b7990 100644
--- a/admin/mining.php
+++ b/admin/mining.php
@@ -2,14 +2,14 @@
require_once __DIR__ . '/layout.php';
$db = db();
-$title = '质押挖矿管理';
+$title = __('mining_management');
ob_start();
$records = $db->query("SELECT r.*, u.username, u.uid FROM staking_records r JOIN users u ON r.user_id = u.id ORDER BY r.created_at DESC")->fetchAll();
?>
@@ -17,12 +17,13 @@ $records = $db->query("SELECT r.*, u.username, u.uid FROM staking_records r JOIN
| ID |
- 用户 |
- 项目 |
- 质押金额 |
- 日收益率 |
- 期限/结束 |
- 状态 |
+ = __('users') ?> |
+ = __('mining_pool') ?> |
+ = __('amount') ?> |
+ = __('total_profit') ?> |
+ = __('est_apy') ?> |
+ = __('cycle') ?> / = __('last_updated') ?> |
+ = __('status') ?> |
@@ -30,11 +31,21 @@ $records = $db->query("SELECT r.*, u.username, u.uid FROM staking_records r JOIN
| = $r['id'] ?> |
= htmlspecialchars($r['username']) ?>
= $r['uid'] ?> |
- = htmlspecialchars($r['plan_name']) ?> |
- = number_format($r['amount'], 2) ?> = $r['symbol'] ?> |
- = $r['daily_profit'] ?>% |
- = $r['period'] ?>天 = $r['end_date'] ?> |
- = $r['status'] === 'running' ? '运行中' : '已结束' ?> |
+ = htmlspecialchars($r['plan_name']) ?> (= $r['symbol'] ?>) |
+ = number_format($r['amount'], 4) ?> |
+ += number_format($r['total_profit'], 6) ?> |
+ = number_format($r['daily_profit'] * 365, 1) ?>% |
+
+ = $r['period'] ?> = __('day') ?>
+ = $r['last_settle_time'] ?: $r['created_at'] ?>
+ |
+
+
+ = __('running') ?>
+
+ = __('completed') ?>
+
+ |
diff --git a/api/mining.php b/api/mining.php
index 333f398..a9fb4e9 100644
--- a/api/mining.php
+++ b/api/mining.php
@@ -53,12 +53,12 @@ try {
$endDate = date('Y-m-d', strtotime("+$period days"));
if ($period == 0) $endDate = '2099-12-31';
- $stmt = $db->prepare("INSERT INTO staking_records (user_id, plan_name, amount, symbol, daily_profit, period, status, start_date, end_date, ip_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ $stmt = $db->prepare("INSERT INTO staking_records (user_id, plan_name, amount, symbol, daily_profit, period, status, start_date, end_date, last_settle_time, ip_address) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)");
$stmt->execute([$userId, $poolName, $amount, $symbol, $dailyProfit, $period, 'running', $startDate, $endDate, getRealIP()]);
// Add transaction record
$stmt = $db->prepare("INSERT INTO transactions (user_id, symbol, type, amount, status, ip_address) VALUES (?, ?, ?, ?, ?, ?)");
- $stmt->execute([$userId, $symbol, 'mining', $amount, 'completed', getRealIP()]);
+ $stmt->execute([$userId, $symbol, 'mining_invest', $amount, 'completed', getRealIP()]);
$db->commit();
echo json_encode(['success' => true]);
diff --git a/app.php b/app.php
index 2d2fd23..f236c24 100644
--- a/app.php
+++ b/app.php
@@ -1,6 +1,5 @@
diff --git a/assets/pasted-20260221-090248-161177f8.png b/assets/pasted-20260221-090248-161177f8.png
new file mode 100644
index 0000000..effec2b
Binary files /dev/null and b/assets/pasted-20260221-090248-161177f8.png differ
diff --git a/db/database.sql b/db/database.sql
index 54625cf..6196ccf 100644
--- a/db/database.sql
+++ b/db/database.sql
@@ -452,6 +452,7 @@ CREATE TABLE `staking_records` (
`user_id` int(11) NOT NULL,
`plan_name` varchar(100) NOT NULL,
`amount` decimal(20,8) NOT NULL,
+ `total_profit` decimal(20,8) DEFAULT 0.00000000,
`symbol` varchar(10) DEFAULT 'USDT',
`daily_profit` decimal(5,2) NOT NULL,
`period` int(11) NOT NULL COMMENT 'days',
@@ -459,6 +460,7 @@ CREATE TABLE `staking_records` (
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
+ `last_settle_time` datetime DEFAULT NULL,
`ip_address` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@@ -471,7 +473,7 @@ CREATE TABLE `staking_records` (
LOCK TABLES `staking_records` WRITE;
/*!40000 ALTER TABLE `staking_records` DISABLE KEYS */;
INSERT INTO `staking_records` VALUES
-(1,2,'ETH矿池',3.00000000,'ETH',0.02,0,'running','2026-02-20','2099-12-31','2026-02-20 05:29:16',NULL);
+(1,2,'ETH矿池',3.00000000,0.00000000,'ETH',0.02,0,'running','2026-02-20','2099-12-31','2026-02-20 05:29:16','2026-02-20 05:29:16',NULL);
/*!40000 ALTER TABLE `staking_records` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/includes/header.php b/includes/header.php
index 7ef396b..c59a7c1 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -8,6 +8,11 @@ if (isset($_SESSION['user_id'])) {
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
+
+ if ($user) {
+ require_once __DIR__ . '/mining_helper.php';
+ settleMining($user['id']);
+ }
}
// site settings are fetched via getSetting() in db/config.php
diff --git a/includes/lang.php b/includes/lang.php
index 2b4b43a..2b1a6ba 100644
--- a/includes/lang.php
+++ b/includes/lang.php
@@ -1209,6 +1209,23 @@ $translations = [
'contact_sup_title' => 'Contact Support',
'contact_sup_desc' => 'Our team is available 24/7 if you encounter any issues.',
'fees_content' => 'BYRO uses a transparent fee structure designed to provide competitive trading costs.',
+ 'platform_home' => 'Platform Home',
+ 'admin_panel' => 'Admin Panel',
+ 'agent_panel' => 'Agent Panel',
+ 'users' => 'Users',
+ 'agents' => 'Agents',
+ 'real_name' => 'KYC',
+ 'finance_management' => 'Finance',
+ 'finance_details' => 'Finance Details',
+ 'sec_contract_management' => 'Binary Management',
+ 'spot_trading' => 'Spot Trading',
+ 'contract_trading' => 'Contract Trading',
+ 'exchange_management' => 'Exchange Management',
+ 'mining_management' => 'Mining Management',
+ 'ai_control' => 'AI Control',
+ 'online_support' => 'Customer Service',
+ 'backend_settings' => 'System Settings',
+ 'personal_settings' => 'Profile Settings',
],
];
diff --git a/includes/mining_helper.php b/includes/mining_helper.php
new file mode 100644
index 0000000..a4e85a5
--- /dev/null
+++ b/includes/mining_helper.php
@@ -0,0 +1,63 @@
+beginTransaction();
+
+ // Find all running orders for this user
+ $stmt = $db->prepare("SELECT * FROM staking_records WHERE user_id = ? AND status = 'running' FOR UPDATE");
+ $stmt->execute([$userId]);
+ $orders = $stmt->fetchAll();
+
+ $now = new DateTime();
+
+ foreach ($orders as $order) {
+ $lastSettle = new DateTime($order['last_settle_time'] ?: $order['created_at']);
+ $diff = $now->getTimestamp() - $lastSettle->getTimestamp();
+
+ if ($diff <= 0) continue;
+
+ // Daily profit is a percentage (e.g. 0.02 is 2% daily)
+ // But looking at the SQL dump: daily_profit was 0.02 for "ETH矿池" which had "8.2%" APY.
+ // 8.2 / 365 = 0.02246... so 0.02 seems to be the daily percentage.
+
+ $dailyRate = $order['daily_profit'] / 100;
+ $profit = $order['amount'] * $dailyRate * ($diff / 86400);
+
+ if ($profit > 0.00000001) {
+ // Update balance
+ $stmt = $db->prepare("UPDATE user_balances SET available = available + ? WHERE user_id = ? AND symbol = ?");
+ $stmt->execute([$profit, $userId, $order['symbol']]);
+
+ // Add transaction record
+ $stmt = $db->prepare("INSERT INTO transactions (user_id, symbol, type, amount, status) VALUES (?, ?, ?, ?, ?)");
+ $stmt->execute([$userId, $order['symbol'], 'mining_profit', $profit, 'completed']);
+
+ // Update staking record
+ $stmt = $db->prepare("UPDATE staking_records SET total_profit = total_profit + ?, last_settle_time = NOW() WHERE id = ?");
+ $stmt->execute([$profit, $order['id']]);
+
+ // Check if it reached end_date
+ $endDate = new DateTime($order['end_date']);
+ if ($now >= $endDate) {
+ $stmt = $db->prepare("UPDATE staking_records SET status = 'ended' WHERE id = ?");
+ $stmt->execute([$order['id']]);
+
+ // Return principal
+ $stmt = $db->prepare("UPDATE user_balances SET frozen = frozen - ?, available = available + ? WHERE user_id = ? AND symbol = ?");
+ $stmt->execute([$order['amount'], $order['amount'], $userId, $order['symbol']]);
+
+ $stmt = $db->prepare("INSERT INTO transactions (user_id, symbol, type, amount, status) VALUES (?, ?, ?, ?, ?)");
+ $stmt->execute([$userId, $order['symbol'], 'mining_return', $order['amount'], 'completed']);
+ }
+ }
+ }
+
+ $db->commit();
+ } catch (Exception $e) {
+ if ($db->inTransaction()) $db->rollBack();
+ error_log("Mining settlement failed for user $userId: " . $e->getMessage());
+ }
+}
diff --git a/mining.php b/mining.php
index 3e0203e..0785d4d 100644
--- a/mining.php
+++ b/mining.php
@@ -1,6 +1,7 @@
prepare("SELECT SUM(amount) FROM staking_records WHERE user_id = ? AND status = 'running'");
$stmt->execute([$user['id']]);
$stakingAmount = $stmt->fetchColumn() ?: 0;
// 今日收益
- $stmt = db()->prepare("SELECT SUM(amount) FROM transactions WHERE user_id = ? AND type = 'mining' AND DATE(created_at) = CURDATE()");
+ $stmt = db()->prepare("SELECT SUM(amount) FROM transactions WHERE user_id = ? AND type = 'mining_profit' AND DATE(created_at) = CURDATE()");
$stmt->execute([$user['id']]);
$todayProfit = $stmt->fetchColumn() ?: 0;
// 累计收益
- $stmt = db()->prepare("SELECT SUM(amount) FROM transactions WHERE user_id = ? AND type = 'mining'");
+ $stmt = db()->prepare("SELECT SUM(total_profit) FROM staking_records WHERE user_id = ?");
$stmt->execute([$user['id']]);
$totalProfit = $stmt->fetchColumn() ?: 0;