2022-08-02 11:43:46 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2022-10-21 13:09:30 +08:00
|
|
|
use App\Models\traits\Filter;
|
2022-08-02 11:43:46 +08:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Shop extends Model
|
|
|
|
|
{
|
2022-10-21 13:09:30 +08:00
|
|
|
use Filter;
|
|
|
|
|
|
2022-10-25 10:47:36 +08:00
|
|
|
public static $PLAT_KTT = 1;
|
|
|
|
|
public static $PLAT_MX = 0;
|
|
|
|
|
|
|
|
|
|
public static $STATUS_UNAUTHORIZED = 0;
|
|
|
|
|
public static $STATUS_AUTHORIZED = 1;
|
|
|
|
|
public static $STATUS_NO_AUTHORIZED = 2;
|
|
|
|
|
public static $STATUS_STOP = 3;
|
|
|
|
|
|
2022-10-21 13:09:30 +08:00
|
|
|
//查询字段
|
|
|
|
|
public $fieldSearchable = [
|
|
|
|
|
'plat_id',
|
|
|
|
|
];
|
|
|
|
|
|
2022-08-02 11:43:46 +08:00
|
|
|
protected $hidden = [
|
|
|
|
|
'access_token',
|
|
|
|
|
'expires_in',
|
|
|
|
|
'refresh_token',
|
|
|
|
|
'refresh_token_expires_at',
|
|
|
|
|
'refresh_token_expires_in',
|
|
|
|
|
'pop_auth_token_create_response',
|
|
|
|
|
];
|
|
|
|
|
|
2022-08-08 16:00:47 +08:00
|
|
|
protected $fillable = [
|
|
|
|
|
'access_token', 'expires_at', 'expires_in', 'owner_id', 'owner_name', 'refresh_token', 'refresh_token_expires_at', 'refresh_token_expires_in', 'scope', 'pop_auth_token_create_response', 'status'
|
|
|
|
|
];
|
2022-08-05 10:36:55 +08:00
|
|
|
|
2022-08-02 11:43:46 +08:00
|
|
|
public function getStatusAttribute($value)
|
|
|
|
|
{
|
|
|
|
|
$map = [
|
|
|
|
|
0 => '未授权',
|
|
|
|
|
1 => '已授权',
|
|
|
|
|
2 => '无需授权',
|
|
|
|
|
3 => '停用',
|
|
|
|
|
];
|
2022-08-11 18:47:35 +08:00
|
|
|
if (1 === (int)$value && ($this->attributes['expires_at'] - time()) / 3600 <= 72) {
|
|
|
|
|
return '重新授权';
|
|
|
|
|
}
|
2022-08-02 11:43:46 +08:00
|
|
|
|
|
|
|
|
return $map[$value];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPlatList()
|
|
|
|
|
{
|
|
|
|
|
return ['妙选', '快团团'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPlatIdAttribute($value)
|
|
|
|
|
{
|
|
|
|
|
$map = $this->getPlatList();
|
|
|
|
|
|
|
|
|
|
return $map[$value];
|
|
|
|
|
}
|
|
|
|
|
}
|