DB数据库文件

This commit is contained in:
2026-05-26 09:43:42 +08:00
parent e0b303c5d4
commit a4c8f623be
30 changed files with 1416 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
define('BASE_PATH', dirname(__DIR__));
require_once BASE_PATH . '/vendor/autoload.php';
\Dotenv\Dotenv::createUnsafeMutable(BASE_PATH)->load();
\Webman\Config::load(BASE_PATH . '/config', ['route', 'plugin']);
\Webman\ThinkOrm\ThinkOrm::start(null);
use plugin\saiadmin\app\model\system\SystemDept;
use support\think\Db;
$deptIds = SystemDept::column('id');
echo "渠道数: " . count($deptIds) . " [" . implode(',', $deptIds) . "]\n\n";
$tables = [
'dice_config',
'dice_ante_config',
'dice_lottery_pool_config',
'dice_reward_config',
'dice_reward',
'dice_game',
];
echo "=== 配置按 dept_id 统计 ===\n";
foreach ($tables as $table) {
$rows = Db::query("SELECT dept_id, COUNT(*) AS cnt FROM `{$table}` GROUP BY dept_id ORDER BY dept_id");
echo "{$table}:\n";
foreach ($rows as $r) {
$dept = $r['dept_id'] === null ? 'NULL' : (string) $r['dept_id'];
echo " dept_id={$dept}: {$r['cnt']}\n";
}
}
echo "\n=== 业务数据未回填 dept_id ===\n";
$biz = ['dice_player', 'dice_play_record', 'dice_play_record_test'];
foreach ($biz as $table) {
if (!Db::getFields($table)) {
continue;
}
$nullCnt = Db::table($table)->where(function ($q) {
$q->whereNull('dept_id')->whereOr('dept_id', 0);
})->count();
$total = Db::table($table)->count();
echo "{$table}: 未回填 {$nullCnt} / 总计 {$total}\n";
}