Files
webman-buildadmin/app/common/model/BetOrder.php
2026-04-18 15:19:36 +08:00

52 lines
1.3 KiB
PHP

<?php
namespace app\common\model;
use app\common\service\GameLiveService;
use support\think\Model;
use Throwable;
class BetOrder extends Model
{
protected $name = 'bet_order';
protected $autoWriteTimestamp = true;
protected $type = [
'create_time' => 'integer',
'update_time' => 'integer',
'pick_numbers' => 'json',
'total_amount' => 'string',
'win_amount' => 'string',
'jackpot_extra_amount' => 'string',
'status' => 'integer',
'streak_at_bet' => 'integer',
'is_auto' => 'integer',
];
public function user(): \think\model\relation\BelongsTo
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
public function channel(): \think\model\relation\BelongsTo
{
return $this->belongsTo(Channel::class, 'channel_id', 'id');
}
protected static function onAfterInsert($model): void
{
try {
$periodId = isset($model['period_id']) ? (int) $model['period_id'] : null;
GameLiveService::publishSnapshot($periodId);
} catch (Throwable) {
}
}
public function gameRecord(): \think\model\relation\BelongsTo
{
return $this->belongsTo(GameRecord::class, 'period_id', 'id');
}
}