quanwei
2025-10-29 76ed09d116f484b261d44219de300b79eb2013b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
 
 
namespace app\common\model\store;
 
use app\common\model\BaseModel;
 
/**
 * 门店店员模型
 */
class Clerk extends BaseModel
{
    protected $pk = 'clerk_id';
    protected $name = 'store_clerk';
 
    /**
     * 关联用户表
     */
    public function user()
    {
        return $this->BelongsTo('app\common\model\user\User', 'user_id', 'user_id');
    }
 
    /**
     * 关联门店表
     */
    public function store()
    {
        return $this->BelongsTo('app\\common\\model\\store\\Store', 'store_id', 'store_id');
    }
 
    /**
     * 店员详情
     */
    public static function detail($where, $with = ['user'])
    {
        $filter = is_array($where) ? $where : ['clerk_id' => $where];
        return (new static())->with($with)->where(array_merge(['is_delete' => 0], $filter))->find();
    }
 
    /**
     * 状态
     */
    public function getStatusAttr($value)
    {
        $status = [0 => '禁用', 1 => '启用'];
        return ['text' => $status[$value], 'value' => $value];
    }
    /**
     * 类型
     */
    public function getTypeAttr($value)
    {
        $type = [0 => '普通店员', 20 => '门店管理员'];
        return ['text' => $type[$value], 'value' => $value];
    }
}