Files
chatroom/app/Models/LotteryPoolLog.php
lkddi 27371fe321 新增:双色球彩票系统后端基础(阶段一)
📦 数据库
  - lottery_issues(期次表)
  - lottery_tickets(购票记录表)
  - lottery_pool_logs(奖池流水表,透明展示)

🔩 核心组件
  - LotteryIssue / LotteryTicket / LotteryPoolLog 完整 Model
  - LotteryService:购票/机选/开奖/奖池派发/滚存/超级期预热/公屏广播
  - LotteryController:current/buy/quickPick/history/my 五个接口
  - DrawLotteryJob(每日定时开奖)/ OpenLotteryIssueJob(初始化首期)

💰 货币日志
  - CurrencySource 新增 LOTTERY_BUY / LOTTERY_WIN
  - 所有金币变动均通过 UserCurrencyService::change() 记录流水

🗓️ 调度器
  - 每分钟检查停售/开奖时机
  - 每日 18:00 超级期预热广播

🔧 配置
  - GameConfigSeeder 追加 lottery 默认配置(默认关闭)
  - /games/enabled 接口追加 lottery 开关状态
  - 新增 /lottery/* 路由组(auth 保护)
2026-03-04 15:38:02 +08:00

73 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* 文件功能:双色球奖池流水 Model
*
* 记录每期奖池的每笔变动,提供透明的奖池历史查询。
* reason 取值ticket_sale / carry_over / admin_inject / system_inject / payout / prize_4th / prize_5th
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class LotteryPoolLog extends Model
{
public $timestamps = false;
protected $fillable = [
'issue_id',
'change_amount',
'reason',
'pool_after',
'remark',
'created_at',
];
/**
* 字段类型转换。
*/
protected function casts(): array
{
return [
'change_amount' => 'integer',
'pool_after' => 'integer',
'created_at' => 'datetime',
];
}
// ─── 关联 ──────────────────────────────────────────────────────────
/**
* 关联的期次。
*/
public function issue(): BelongsTo
{
return $this->belongsTo(LotteryIssue::class, 'issue_id');
}
// ─── 业务方法 ──────────────────────────────────────────────────────
/**
* 返回 reason 的中文标签。
*/
public function reasonLabel(): string
{
return match ($this->reason) {
'ticket_sale' => '购票入池',
'carry_over' => '上期滚存',
'admin_inject' => '管理员注入',
'system_inject' => '超级期系统注入',
'payout' => '派奖扣除',
'prize_4th' => '四等奖固定扣除',
'prize_5th' => '五等奖固定扣除',
default => $this->reason,
};
}
}