quanwei
2025-12-09 ca425b889f3c1b5847ffc26a0229307f7f8ef43e
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
58
59
60
61
62
63
64
<?php
 
namespace app\api\model\store;
 
use app\common\exception\BaseException;
use app\common\model\store\Clerk as ClerkModel;
 
/**
 * 商家门店店员模型
 */
class Clerk extends ClerkModel
{
    /**
     * 隐藏字段
     */
    protected $hidden = [
        'is_delete',
        'app_id',
        'create_time',
        'update_time'
    ];
 
    /**
     * 店员详情
     */
    public static function detail($where, $with = [])
    {
        $model = parent::detail($where);
        // if (!$model) {
        //     throw new BaseException(['msg' => '未找到店员信息']);
        // }
        return $model;
    }
 
    /**
     * 验证用户是否为核销员
     */
    public function checkUser($store_id)
    {
        if ($this['is_delete']) {
            $this->error = '未找到店员信息';
            return false;
        }
        if (!empty($store_id) && $this['store_id'] != $store_id) {
            $this->error = '当前店员不属于该门店,没有核销权限';
            return false;
        }
        if (!$this['status']) {
            $this->error = '当前店员状态已被禁用';
            return false;
        }
        return true;
    }
    /**
     * 资金冻结
     */
    public function freezeMoney($money)
    {
        return $this->save([
            'money' => $this['money'] - $money,
            'freeze_money' => $this['freeze_money'] + $money,
        ]);
    }
}