小程序登录优化

This commit is contained in:
liu
2026-08-10 08:55:22 +08:00
parent c6f69c5c55
commit df7631c7a9
25 changed files with 954 additions and 549 deletions
+6 -34
View File
@@ -15,17 +15,10 @@ class UserModel extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/** 用户类型:待绑定(手机号未匹配到门店/供应商,需后台人工绑定) */
public const TYPE_PENDING = 0;
/** 用户类型:门店 */
public const TYPE_STORE = 1;
/** 用户类型:供应商 */
public const TYPE_SUPPLIER = 2;
/** 状态:停用 */
public const STATUS_DISABLED = 0;
public const int STATUS_DISABLED = 0;
/** 状态:正常 */
public const STATUS_NORMAL = 1;
public const int STATUS_NORMAL = 1;
protected $table = 'user';
@@ -45,38 +38,26 @@ class UserModel extends Authenticatable
'unionid',
'phone',
'avatar',
'type',
'store_id',
'supplier_id',
'status',
'last_login_at',
];
protected $casts = [
'email_verified_at' => 'datetime',
'last_login_at' => 'datetime',
'type' => 'integer',
'email_verified_at' => 'datetime:Y-m-d H:i:s',
'last_login_at' => 'datetime:Y-m-d H:i:s',
'created_at' => 'datetime:Y-m-d H:i:s',
'store_id' => 'integer',
'supplier_id' => 'integer',
'status' => 'integer',
];
/**
* 关联门店type=1 时有效)
* 关联门店
*/
public function store(): BelongsTo
{
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
}
/**
* 关联供应商(type=2 时有效)
*/
public function supplier(): BelongsTo
{
return $this->belongsTo(SupplierModel::class, 'supplier_id', 'id');
}
/**
* 用户通知
*/
@@ -84,13 +65,4 @@ class UserModel extends Authenticatable
{
return $this->hasMany(NoticeModel::class, 'user_id', 'id');
}
/**
* 是否已绑定业务主体(门店或供应商)
*/
public function isBound(): bool
{
return $this->type === self::TYPE_STORE && $this->store_id > 0
|| $this->type === self::TYPE_SUPPLIER && $this->supplier_id > 0;
}
}