feat(百家乐): 记录AI小班长每局决策日志到 daily 日志文件

- 新增 Log::channel('daily')->info() 记录:局次ID、决策来源(AI预测/本地兜底)、AI预测结果、最终下注方向、下注金额、路单序列
This commit is contained in:
2026-03-28 21:11:44 +08:00
parent 3814ea5e85
commit 3bfc0e358f

View File

@@ -30,6 +30,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
class AiBaccaratBetJob implements ShouldQueue
@@ -93,10 +94,13 @@ class AiBaccaratBetJob implements ShouldQueue
// 5. 优先调用 AI 接口预测下注方向
$predictionService = app(BaccaratPredictionService::class);
$betType = $predictionService->predict($recentResults);
$aiPrediction = $predictionService->predict($recentResults);
$decisionSource = 'ai';
$betType = $aiPrediction;
// AI 不可用时回退本地路单决策(保底逻辑)
if ($betType === null) {
$decisionSource = 'local';
$bigCount = count(array_filter($recentResults, fn (string $r) => $r === 'big'));
$smallCount = count(array_filter($recentResults, fn (string $r) => $r === 'small'));
@@ -113,6 +117,17 @@ class AiBaccaratBetJob implements ShouldQueue
}
}
// 记录 AI 小班长本次决策日志
$labelMap = ['big' => '大', 'small' => '小', 'triple' => '豹子'];
Log::channel('daily')->info('AI小班长百家乐决策', [
'round_id' => $round->id,
'decision_source' => $decisionSource === 'ai' ? 'AI接口预测' : '本地路单兜底',
'ai_prediction' => $aiPrediction ? $labelMap[$aiPrediction] : 'null不可用',
'final_bet' => $labelMap[$betType] ?? $betType,
'bet_amount' => $amount,
'roadmap_20' => implode('→', array_map(fn (string $r) => $labelMap[$r] ?? $r, array_reverse($recentResults))),
]);
// 5. 执行下注 (同 BaccaratController::bet 逻辑)
DB::transaction(function () use ($user, $round, $betType, $amount, $currency) {
// 幂等:同一局只能下一注