<?php
|
|
namespace app\common\model\shop;
|
|
use app\common\exception\BaseException;
|
use think\facade\Cache;
|
use app\common\model\BaseModel;
|
|
/**
|
* 应用模型
|
*/
|
class Client extends BaseModel
|
{
|
protected $name = 'dl_client';
|
protected $pk = 'client_id';
|
|
/**
|
* 获取应用信息
|
*/
|
public static function detail($client_id)
|
{
|
return (new static())->find($client_id);
|
}
|
|
/**
|
* 从缓存中获取app信息
|
*/
|
public static function getClientCache($client_id = null)
|
{
|
if (is_null($client_id)) {
|
$self = new static();
|
$client_id = $self::$client_id;
|
}
|
if (!$data = Cache::get('app_' . $client_id)) {
|
$data = self::detail($client_id);
|
if (empty($data)) throw new BaseException(['msg' => '未找到当前应用信息']);
|
Cache::tag('cache')->set('app_' . $client_id, $data);
|
}
|
return $data;
|
}
|
|
/**
|
* 启用商城
|
* @return bool
|
*/
|
public function updateStatus()
|
{
|
return $this->save([
|
'status' => !$this['status'],
|
]);
|
}
|
|
/**
|
* 所有商城
|
*/
|
public static function getAll(){
|
return (new self())->where('is_delete', '=', 0)
|
->where('is_recycle', '=', 0)
|
->select();
|
}
|
}
|