quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
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
<?php
 
namespace app\operations\model\plus\work;
 
use think\facade\Cache;
use app\common\model\plus\work\Setting as SettingModel;
 
class Setting extends SettingModel
{
    // 定义全局的查询范围
    protected $globalScope = ['status'];
    public function scopeStatus($query)
    {
        $shop_supplier_ids = \app\operations\model\supplier\Supplier::getSupplierIdsByUser(session('jjjshop_operations')['user']);
        if (empty($shop_supplier_ids)){
            $query->where($query->getTable() . '.shop_supplier_id', -1);
        }else{
            $query->where($query->getTable() . '.shop_supplier_id', 'in', $shop_supplier_ids);
        }
    }
    /**
     * 更新系统设置
     */
    public function edit($key, $values, $shop_supplier_id = 0)
    {
        $model = self::detail($key, $shop_supplier_id) ?: $this;
        // 删除系统设置缓存
        Cache::delete('setting_work' . self::$app_id . '_' . $shop_supplier_id);
        return $model->save([
                'key' => $key,
                'describe' => '基础设置',
                'values' => $values,
                'app_id' => self::$app_id,
                'shop_supplier_id' => $shop_supplier_id
            ]) !== false;
    }
 
}