= 10 && $address) { if ($account['balance'] >= $amount) { try { $db = db(); $db->beginTransaction(); // Deduct balance and freeze it $stmt = $db->prepare("UPDATE accounts SET balance = balance - ?, frozen_balance = frozen_balance + ? WHERE id = ?"); $stmt->execute([$amount, $amount, $account['id']]); // Record transaction $stmt = $db->prepare("INSERT INTO transactions (account_id, transaction_type, amount, tx_hash, status) VALUES (?, 'withdraw', ?, ?, 'pending')"); $stmt->execute([$account['id'], $amount, $address]); $db->commit(); $success = "提现申请已提交,资金已冻结,请等待审核。"; $account = get_account($_SESSION['user_id']); // refresh } catch (Exception $e) { $db->rollBack(); $error = "系统错误: " . $e->getMessage(); } } else { $error = "余额不足。"; } } else { $error = "请输入有效金额(最小10)和地址。"; } } include 'header.php'; ?>