Files
pk10/App/Controllers/Web/FollowPlanController.php
T
li 4a94fe36cf feat: 重构代码架构 + 新增报表/跟单/输赢统计功能
- 拆分 HomeController → TransactionController, ReportWebController, FollowPlanController
- 新增 Service 层: TransactionService, ReportService, FollowPlanService
- pk10.php JS 抽离为 4 个独立文件 (sound/race/bet/poll)
- 前台新增报表查询页面 (/report) + 跟单计划页面 (/follow-plan)
- 后台新增跟单计划管理 + 用户输赢明细统计
- 封盘状态显示倒计时 (x:xx)
- 音效仅在开奖弹窗打开时播放
- 路由按模块分组整理
- autoload 支持 App\Services 命名空间
2026-03-27 18:41:06 +08:00

45 lines
1.4 KiB
PHP

<?php
namespace App\Controllers\Web;
use App\Core\WebBaseController;
use App\Core\I18n;
use App\Services\FollowPlanService;
use Db\Database;
class FollowPlanController extends WebBaseController {
public function followPlan() {
$this->checkWebLogin();
I18n::init();
$db = new Database();
$userId = $this->getCurrentUserId();
$user = $db->get('users', ['id','username','balance'], ['id' => $userId]);
$service = new FollowPlanService($db);
$game = $db->get('games', '*', ['code' => 'pk10', 'status' => 1]);
$gameId = $game['id'] ?? 0;
$plans = $service->getActivePlans($gameId);
$userFollows = $service->getUserFollowStatus($userId);
$summary = $service->getUserSummary($userId);
extract(compact('user', 'plans', 'userFollows', 'summary', 'game'));
include __DIR__ . '/../../Views/Web/follow_plan.php';
}
/**
* 切换跟单状态 API
*/
public function toggleFollow() {
$this->checkWebLogin();
header('Content-Type: application/json');
$db = new Database();
$data = json_decode(file_get_contents('php://input'), true);
$planId = intval($data['plan_id'] ?? 0);
$service = new FollowPlanService($db);
$result = $service->toggleFollow($this->getCurrentUserId(), $planId);
echo json_encode($result);
}
}