50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\WebSocket;
|
|
|
|
use App\Cache\Table\TableCustomerUserCache;
|
|
use App\Models\Base\CustomerBaseModel;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class CustomerWsHistoryModel extends CustomerBaseModel
|
|
{
|
|
protected $table = 'customer_ws_history';
|
|
protected $primaryKey = 'id';
|
|
protected $fillable = [
|
|
'id',
|
|
'event',
|
|
'status',
|
|
'uid',
|
|
'device',
|
|
'created_at',
|
|
];
|
|
|
|
const EVENT_ON_CONNECT = 1;
|
|
const EVENT = [
|
|
self::EVENT_ON_CONNECT => 'onConnect',
|
|
];
|
|
|
|
const STATUS_SUCCESS = 1;
|
|
const STATUS_FAIL = 2;
|
|
const STATUS = [
|
|
self::STATUS_SUCCESS => '成功',
|
|
self::STATUS_FAIL => '失败',
|
|
];
|
|
|
|
function getActiveUserIdList($date, $days = 3): array
|
|
{
|
|
return $this->newQuery()
|
|
->where('event', self::EVENT_ON_CONNECT)
|
|
->where('status', self::STATUS_SUCCESS)
|
|
->whereBetween(DB::raw("DATE_FORMAT(created_at,'%Y-%m-%d')"), [Carbon::parse($date)->subDays($days - 1)->toDateString(), Carbon::parse($date)->toDateString()])
|
|
->distinct(['uid'])
|
|
->get()
|
|
->pluck('uid')
|
|
->toArray();
|
|
}
|
|
|
|
}
|