[色子游戏]玩家抽奖记录测试数据

This commit is contained in:
2026-03-12 19:21:10 +08:00
parent 7e4ba86afa
commit cc7e2d9a1a
21 changed files with 1712 additions and 4 deletions

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace app\process;
use app\dice\logic\reward_config_record\WeightTestRunner;
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
use Workerman\Timer;
use Workerman\Worker;
/**
* 一键测试权重定时任务进程:每隔一定时间检查 status=0 的测试记录并执行一条,不占用 HTTP worker 资源
*/
class WeightTestProcess
{
/** 轮询间隔(秒) */
private const INTERVAL = 15;
public function onWorkerStart(Worker $worker): void
{
Timer::add(self::INTERVAL, function () {
$this->runOnePending();
});
}
/**
* 执行一条待完成的测试记录status=0
*/
private function runOnePending(): void
{
$record = DiceRewardConfigRecord::where('status', DiceRewardConfigRecord::STATUS_RUNNING)
->order('id')
->find();
if (!$record) {
return;
}
$recordId = (int) $record->id;
try {
(new WeightTestRunner())->run($recordId);
} catch (\Throwable $e) {
// WeightTestRunner 内部会更新 status=-1 和 remark
}
}
}