'department_id']; const TYPE_SYSTEM = 1; // 系统 const TYPE_EXAMINE_RECHARGE = 2; // 充值审核 const TYPE_EXAMINE_WITHDRAW = 3; // 提现审核 const TYPE_PAY = 4; // 三方充值 const TYPE_WITHDRAW = 5; // 三方提现 const RECEIVER_PLAYER = 1; // 玩家 const RECEIVER_ADMIN = 2; // 总站 const RECEIVER_DEPARTMENT = 3; // 子站 /** * 时间转换 * @param DateTimeInterface $date * @return string */ protected function serializeDate(DateTimeInterface $date): string { return $date->format('Y-m-d H:i:s'); } public function __construct(array $attributes = []) { parent::__construct($attributes); $this->setTable(plugin()->webman->config('database.notice_table')); } /** * 游戏类别 * @return BelongsTo */ public function adminUser(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.user_model'), 'admin_id'); } /** * 渠道信息 * @return BelongsTo */ public function channel(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.channel_model'), 'department_id', 'department_id')->withTrashed(); } /** * 玩家信息 * @return BelongsTo */ public function player(): BelongsTo { return $this->belongsTo(plugin()->webman->config('database.player_model'), 'player_id', 'department_id')->withTrashed(); } /** * 模型的 "booted" 方法 * * @return void */ protected static function booted() { static::created(function (Notice $notice) { if ($notice->is_private == 1) { sendSocketMessage('player-' . $notice->player_id, [ 'msg_type' => 'player_notice_num', 'notice_num' => Notice::query() ->where('player_id', $notice->player_id) ->where('receiver', Notice::RECEIVER_PLAYER) ->where('is_private', 1) ->where('status', 0) ->count('*'), ]); } }); } }