Compare commits

..

4 Commits

Author SHA1 Message Date
916117771 7fb2ba4dcf feat(dashboard): 新增生肖转移概率表格
在控制台页面转移概率区域新增生肖(12生肖)转移概率矩阵,与现有
的区域转移和波色转移保持一致的展示风格。
2026-04-26 16:52:22 +08:00
916117771 cbca6217d6 test pull 2026-04-26 00:25:25 +08:00
916117771 04be883e4d test pull 2026-04-26 00:23:28 +08:00
916117771 cbdc5199f4 change(admin): 修改仪表板默认统计周期为100天
- 将dashboard控制器中的默认periods值从30修改为100
- 更新了数据统计展示的时间范围配置
2026-04-26 00:19:16 +08:00
5 changed files with 108 additions and 5 deletions
+2 -2
View File
@@ -7,9 +7,9 @@
</style>
<meta charset="UTF-8">
<html>
<head><title>404 Not Found</title></head>
<head><title>404 Not Found </title></head>
<body>
<center><h1>404 Not Found</h1></center>
<center><h1>404 Not Found </h1></center>
<hr>
<div style="text-align: center;font-size: 15px" >Power by <a class="btlink" href="https://www.bt.cn/?from=404" target="_blank">堡塔 (免费,高效和安全的托管控制面板)</a></div>
</body>
+1 -1
View File
@@ -13,7 +13,7 @@ class Dashboard extends Backend
{
public function index()
{
$this->assign('periods', 30);
$this->assign('periods', 100);
return $this->view->fetch();
}
}
+16 -1
View File
@@ -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'];
protected $noNeedRight = ['missingNum', 'trendData', 'hotColdNumbers', 'colorWaveAnalysis', 'zodiacAnalysis', 'oddEvenAnalysis', 'bigSmallAnalysis', 'specialTrend', 'consecutiveNumbers', 'tailNumbers', 'dashboard', 'specialHeatmap', 'specialHotColdAction', 'zoneTransition', 'colorWaveTransition', 'zoneToColorTransition', 'zodiacTransition'];
public function _initialize()
{
@@ -343,5 +343,20 @@ class History extends Backend
}
}
/**
* 生肖转移概率统计
*/
public function zodiacTransition()
{
if ($this->request->isAjax()) {
$periods = $this->request->get('periods', 100, 'intval');
if ($periods < 10 || $periods > 500) {
$this->error('期数范围必须在 10-500 之间');
}
$result = $this->model->getZodiacTransition($periods);
$this->success('查询成功', null, $result);
}
}
}
+66 -1
View File
@@ -467,7 +467,8 @@ class History extends Model
'heatmap' => $this->getSpecialHeatmap($periods),
'zonetransition' => $this->getZoneTransition($periods),
'colorwavetransition' => $this->getColorWaveTransition($periods),
'zonetocolortransition' => $this->getZoneToZoneColor($periods)
'zonetocolortransition' => $this->getZoneToZoneColor($periods),
'zodiactransition' => $this->getZodiacTransition($periods)
];
}
@@ -796,6 +797,70 @@ class History extends Model
];
}
/**
* 生肖转移概率统计
* 统计特码从一种生肖转移到另一种生肖的概率(12生肖)
* @param int $periods 查询最近多少期
* @return array {animals: [], matrix: [], probabilities: [], row_totals: [], total_transitions: int}
*/
public function getZodiacTransition($periods = 100)
{
$history = $this
->field('expect,num7,openTime')
->order('openTime', 'desc')
->limit($periods)
->select();
if (empty($history) || count($history) < 2) {
return ['animals' => ['鼠','牛','虎','兔','龙','蛇','马','羊','猴','鸡','狗','猪'], 'matrix' => [], 'probabilities' => [], 'row_totals' => [], 'total_transitions' => 0];
}
$history = array_reverse($history);
$num_model = new Num();
$animalMap = $num_model->column('animal', 'num');
$animalLabels = ['鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'];
$numAnimals = 12;
$matrix = array_fill(0, $numAnimals, array_fill(0, $numAnimals, 0));
$rowTotals = array_fill(0, $numAnimals, 0);
$getAnimalIdx = function ($num) use ($animalMap, $animalLabels) {
$animal = $animalMap[$num] ?? '';
$idx = array_search($animal, $animalLabels);
return $idx === false ? -1 : $idx;
};
$totalTransitions = 0;
for ($i = 0; $i < count($history) - 1; $i++) {
$currentNum = (int)$history[$i]['num7'];
$nextNum = (int)$history[$i + 1]['num7'];
$from = $getAnimalIdx($currentNum);
$to = $getAnimalIdx($nextNum);
if ($from < 0 || $to < 0) continue;
$matrix[$from][$to]++;
$rowTotals[$from]++;
$totalTransitions++;
}
$probabilities = array_fill(0, $numAnimals, array_fill(0, $numAnimals, 0));
for ($i = 0; $i < $numAnimals; $i++) {
if ($rowTotals[$i] > 0) {
for ($j = 0; $j < $numAnimals; $j++) {
$probabilities[$i][$j] = round($matrix[$i][$j] / $rowTotals[$i] * 100, 1);
}
}
}
return [
'animals' => $animalLabels,
'matrix' => $matrix,
'probabilities' => $probabilities,
'row_totals' => $rowTotals,
'total_transitions' => $totalTransitions
];
}
/**
* 区域→区域转移矩阵,单元格内显示波色概率
* 统计上一期特码所在区域后,下一期特码在各区域的分布,以及每个区域内的波色占比
+23
View File
@@ -88,6 +88,7 @@ define(['jquery'], function ($) {
// 区域转移概率 + 波色转移概率
if (zt && zt.matrix && zt.matrix.length > 0) {
var cwt = data.colorwavetransition;
var zt2 = data.zodiactransition;
html += '<div class="dash-section"><h4>🔄 转移概率</h4><div class="row">';
// 左侧:区域转移
html += '<div class="col-sm-7"><div style="font-size:12px;color:#999;margin-bottom:8px;">区域转移(共 ' + zt.total_transitions + ' 次)</div>';
@@ -153,6 +154,28 @@ define(['jquery'], function ($) {
}
html += '</tbody></table>';
}
// 下方:生肖转移矩阵
if (zt2 && zt2.matrix && zt2.matrix.length > 0) {
html += '<div style="margin-top:20px;font-size:12px;color:#999;margin-bottom:8px;">生肖转移(共 ' + zt2.total_transitions + ' 次)</div>';
html += '<table class="table table-bordered table-condensed text-center" style="max-width:720px;margin:0 auto;"><thead><tr><th style="width:50px;">特码</th>';
for (var z = 0; z < zt2.animals.length; z++) {
html += '<th>' + zt2.animals[z] + '</th>';
}
html += '</tr></thead><tbody>';
var animalColors = ['#e74c3c', '#3498db', '#2ecc71', '#f39c12', '#9b59b6', '#1abc9c', '#e67e22', '#34495e', '#e74c3c', '#3498db', '#2ecc71', '#f39c12'];
for (var r = 0; r < zt2.animals.length; r++) {
html += '<tr><td style="font-weight:bold;color:' + animalColors[r] + ';">' + zt2.animals[r] + '</td>';
for (var c = 0; c < zt2.animals.length; c++) {
var pct = zt2.probabilities[r][c];
var cnt = zt2.matrix[r][c];
var bg = pct > 30 ? '#e74c3c' : pct > 20 ? '#f39c12' : pct > 10 ? '#3498db' : pct > 0 ? '#95a5a6' : '#f5f5f5';
var txt = pct > 10 ? '#fff' : '#333';
html += '<td style="background-color:' + bg + ';color:' + txt + ';">' + cnt + '次<br>' + pct + '%</td>';
}
html += '</tr>';
}
html += '</tbody></table>';
}
html += '</div>';
}