新版数智员工
This commit is contained in:
53
application/store/model/CompanyAccountModel.php
Normal file
53
application/store/model/CompanyAccountModel.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user