From 919fbbc1486e61c2748fcaa85354144cad03f22d Mon Sep 17 00:00:00 2001 From: leon <916117771@qq.com> Date: Sat, 2 May 2026 15:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E6=96=B0=E5=A2=9E=E5=B0=BE?= =?UTF-8?q?=E9=A6=96=E6=A6=82=E7=8E=87=E5=88=86=E6=9E=90=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在history页面工具栏添加"尾首概率"按钮,弹窗显示: - 下一期尾数与前一期尾数相同的概率 - 下一期首位与前一期首位相同的概率 支持切换统计期数(30/50/100/200期) --- application/admin/controller/History.php | 14 ++++- application/admin/model/History.php | 54 +++++++++++++++++++ application/admin/view/history/index.html | 1 + public/assets/js/backend/history.js | 66 +++++++++++++++++++++++ 4 files changed, 134 insertions(+), 1 deletion(-) diff --git a/application/admin/controller/History.php b/application/admin/controller/History.php index 3d9fd2d..92bcb66 100644 --- a/application/admin/controller/History.php +++ b/application/admin/controller/History.php @@ -22,7 +22,7 @@ class History extends Backend * 无需额外权限检查的方法(但仍在 admin 模块内,需要 admin 登录) * @var array */ - protected $noNeedRight = ['missingNum', 'trendData', 'hotColdNumbers', 'colorWaveAnalysis', 'zodiacAnalysis', 'oddEvenAnalysis', 'bigSmallAnalysis', 'specialTrend', 'consecutiveNumbers', 'tailNumbers', 'dashboard', 'specialHeatmap', 'specialHotColdAction', 'zoneTransition', 'colorWaveTransition', 'zoneToColorTransition', 'zodiacTransition', 'tailNumberTransition', 'headNumberTransition', 'predict', 'predictV2', 'predictV3', 'optimizeWeights', 'predictByNormalRelation']; + protected $noNeedRight = ['missingNum', 'trendData', 'hotColdNumbers', 'colorWaveAnalysis', 'zodiacAnalysis', 'oddEvenAnalysis', 'bigSmallAnalysis', 'specialTrend', 'consecutiveNumbers', 'tailNumbers', 'dashboard', 'specialHeatmap', 'specialHotColdAction', 'zoneTransition', 'colorWaveTransition', 'zoneToColorTransition', 'zodiacTransition', 'tailNumberTransition', 'headNumberTransition', 'tailHeadProb', 'predict', 'predictV2', 'predictV3', 'optimizeWeights', 'predictByNormalRelation']; public function _initialize() { @@ -388,6 +388,18 @@ class History extends Backend } } + /** + * 尾首概率分析 + */ + public function tailHeadProb() + { + if ($this->request->isAjax()) { + $periods = $this->request->get('periods', 100, 'intval'); + $result = $this->model->getTailHeadProbability($periods); + $this->success('查询成功', null, $result); + } + } + /** * 综合预测号码 * 基于历史多维度转移概率分析,给出号码预测建议 diff --git a/application/admin/model/History.php b/application/admin/model/History.php index 1f29da2..9f2cece 100644 --- a/application/admin/model/History.php +++ b/application/admin/model/History.php @@ -984,6 +984,60 @@ class History extends Model ]; } + /** + * 尾首概率:下一期尾数/首位与前一期相同的概率 + * 统计相邻两期特码的尾数(num%10)和首位(floor(num/10))变化 + * @param int $periods 查询最近多少期 + * @return array {tailProb: float, headProb: float, totalTransitions: int, periodCount: int} + */ + public function getTailHeadProbability($periods = 100) + { + $history = $this + ->field('expect,num7,openTime') + ->order('openTime', 'desc') + ->limit($periods) + ->select(); + + if (empty($history) || count($history) < 2) { + return ['tailProb' => 0, 'headProb' => 0, 'totalTransitions' => 0, 'periodCount' => 0]; + } + + // 按时间升序排列(旧→新) + $history = array_reverse($history); + + $tailSame = 0; + $headSame = 0; + $totalTransitions = 0; + + for ($i = 0; $i < count($history) - 1; $i++) { + $currentNum = (int)$history[$i]['num7']; + $nextNum = (int)$history[$i + 1]['num7']; + + if ($currentNum < 1 || $currentNum > 49 || $nextNum < 1 || $nextNum > 49) { + continue; + } + + $totalTransitions++; + + // 尾数相同(个位相同) + if (($currentNum % 10) === ($nextNum % 10)) { + $tailSame++; + } + + // 首位相同(十位相同) + if (intval(floor($currentNum / 10)) === intval(floor($nextNum / 10))) { + $headSame++; + } + } + + return [ + 'tailProb' => $totalTransitions > 0 ? round($tailSame / $totalTransitions * 100, 2) : 0, + 'headProb' => $totalTransitions > 0 ? round($headSame / $totalTransitions * 100, 2) : 0, + 'totalTransitions' => $totalTransitions, + 'periodCount' => count($history) + ]; + } + /** * 区域→区域转移矩阵,单元格内显示波色概率 * 统计上一期特码所在区域后,下一期特码在各区域的分布,以及每个区域内的波色占比 diff --git a/application/admin/view/history/index.html b/application/admin/view/history/index.html index 1f1844c..bda1a22 100644 --- a/application/admin/view/history/index.html +++ b/application/admin/view/history/index.html @@ -21,6 +21,7 @@ 筛号器 智能预测 正码关联预测 + 尾首概率 diff --git a/public/assets/js/backend/history.js b/public/assets/js/backend/history.js index a6365ce..d3bf3aa 100644 --- a/public/assets/js/backend/history.js +++ b/public/assets/js/backend/history.js @@ -112,6 +112,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin $(document).off('click', '.btn-normal-relation').on('click', '.btn-normal-relation', function () { Controller.api.showNormalRelationDialog(); }); + + // 尾首概率按钮事件 + $(document).off('click', '.btn-tailheadprob').on('click', '.btn-tailheadprob', function () { + Controller.api.showTailHeadProbabilityDialog(); + }); }, add: function () { Controller.api.bindevent(); @@ -2163,6 +2168,67 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } $('#nr-result', layero).html(html); + }, + + /** + * 尾首概率弹窗 + */ + showTailHeadProbabilityDialog: function () { + var content = '
'; + content += '
'; + content += ''; + content += ''; + content += ' '; + content += '
'; + content += '
'; + content += '
'; + + layer.open({ + type: 1, + title: '尾首概率分析', + area: ['500px', '380px'], + content: content, + success: function (layero) { + $('#btn-tailheadprob-query', layero).on('click', function () { + var periods = $('#tailheadprob-periods').val(); + $.ajax({ + url: 'history/tailHeadProb', + type: 'GET', + data: { periods: periods }, + dataType: 'json', + success: function (ret) { + if (ret.code == 1) { + var d = ret.msg; + var html = '
'; + html += '
'; + html += '
概率统计
'; + html += ''; + html += ''; + html += ''; + html += ''; + html += '
对比项相同概率
下一期尾数与前一期尾数相同' + d.tailProb + '%
下一期首位与前一期首位相同' + d.headProb + '%
'; + html += '
共分析 ' + d.periodCount + ' 期数据,' + d.totalTransitions + ' 次转移
'; + html += '
'; + $('#tailheadprob-result').html(html); + } else { + Toastr.error(ret.msg); + } + }, + error: function () { + Toastr.error('请求失败,请重试'); + } + }); + }); + + // 初始加载 + $('#btn-tailheadprob-query', layero).trigger('click'); + } + }); } } };