54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace app\store\model;
|
||
|
||
use think\Model;
|
||
|
||
/**
|
||
* 用户模型(门店端)
|
||
* 使用 ck_users 表,typeId=2 表示门店端用户
|
||
* Class CompanyAccountModel
|
||
* @package app\store\model
|
||
*/
|
||
class CompanyAccountModel extends Model
|
||
{
|
||
// 设置表名(门店端使用 users 表)
|
||
protected $name = 'users';
|
||
|
||
// 设置主键
|
||
protected $pk = 'id';
|
||
|
||
// 自动时间戳
|
||
protected $autoWriteTimestamp = false;
|
||
|
||
/**
|
||
* 根据公司ID获取账号
|
||
* @param int $companyId 公司ID
|
||
* @return array|null
|
||
*/
|
||
public static function getByCompanyId($companyId)
|
||
{
|
||
return self::where('companyId', $companyId)
|
||
->where('typeId', 2) // 门店端固定为2
|
||
->where('deleteTime', 0)
|
||
->find();
|
||
}
|
||
|
||
/**
|
||
* 根据账号或手机号查找用户
|
||
* @param string $account 账号或手机号
|
||
* @return array|null
|
||
*/
|
||
public static function getByAccountOrPhone($account)
|
||
{
|
||
return self::where(function($query) use ($account) {
|
||
$query->where('account', $account)
|
||
->whereOr('phone', $account);
|
||
})
|
||
->where('typeId', 2) // 门店端固定为2
|
||
->where('deleteTime', 0)
|
||
->find();
|
||
}
|
||
}
|
||
|