- 拆分 HomeController → TransactionController, ReportWebController, FollowPlanController - 新增 Service 层: TransactionService, ReportService, FollowPlanService - pk10.php JS 抽离为 4 个独立文件 (sound/race/bet/poll) - 前台新增报表查询页面 (/report) + 跟单计划页面 (/follow-plan) - 后台新增跟单计划管理 + 用户输赢明细统计 - 封盘状态显示倒计时 (x:xx) - 音效仅在开奖弹窗打开时播放 - 路由按模块分组整理 - autoload 支持 App\Services 命名空间
54 lines
2.0 KiB
PHP
54 lines
2.0 KiB
PHP
<?php
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Core\AdminBaseController;
|
|
use App\Services\FollowPlanService;
|
|
use Db\Database;
|
|
|
|
class FollowPlanController extends AdminBaseController {
|
|
private $db;
|
|
|
|
public function __construct(Database $db) {
|
|
$this->db = $db;
|
|
}
|
|
|
|
public function index() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
$service = new FollowPlanService($this->db);
|
|
$plans = $service->getAllPlans();
|
|
$games = $this->db->select('games', ['id', 'name', 'code'], ['status' => 1]);
|
|
$this->render('Admin/follow_plans.php', compact('plans', 'games'));
|
|
}
|
|
|
|
public function save() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
header('Content-Type: application/json');
|
|
$data = json_decode(file_get_contents('php://input'), true) ?: $_POST;
|
|
$data['created_by'] = $_SESSION['admin_id'] ?? 0;
|
|
$service = new FollowPlanService($this->db);
|
|
echo json_encode($service->savePlan($data));
|
|
}
|
|
|
|
public function delete() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
header('Content-Type: application/json');
|
|
$data = json_decode(file_get_contents('php://input'), true) ?: $_POST;
|
|
$id = intval($data['id'] ?? 0);
|
|
if ($id <= 0) { echo json_encode(['success' => false, 'message' => 'ID invalid']); return; }
|
|
$service = new FollowPlanService($this->db);
|
|
echo json_encode($service->deletePlan($id));
|
|
}
|
|
|
|
public function toggle() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
header('Content-Type: application/json');
|
|
$data = json_decode(file_get_contents('php://input'), true) ?: $_POST;
|
|
$id = intval($data['id'] ?? 0);
|
|
$plan = $this->db->get('follow_plans', '*', ['id' => $id]);
|
|
if (!$plan) { echo json_encode(['success' => false, 'message' => 'Not found']); return; }
|
|
$newStatus = $plan['status'] ? 0 : 1;
|
|
$this->db->update('follow_plans', ['status' => $newStatus], ['id' => $id]);
|
|
echo json_encode(['success' => true, 'status' => $newStatus]);
|
|
}
|
|
}
|