61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\channel\service;
|
||
|
|
||
|
use app\core\Service;
|
||
|
use think\admin\extend\DataExtend;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 店铺服务
|
||
|
* Class ChannelService
|
||
|
* @package app\channel\service
|
||
|
*/
|
||
|
class ShopService extends Service
|
||
|
{
|
||
|
/**
|
||
|
* 设置默认操作表
|
||
|
* @var string
|
||
|
*/
|
||
|
public $table = 'channel_shop';
|
||
|
|
||
|
# 获取商品信息
|
||
|
public function getInfo($id)
|
||
|
{
|
||
|
$where['id'] = $id;
|
||
|
$data = $this->db()->where($where)->find();
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
# 获取缓存
|
||
|
public function get($id, $get = true)
|
||
|
{
|
||
|
if (!$get) {
|
||
|
return false;
|
||
|
}
|
||
|
$cache_key = 'shopv2_' . $id;
|
||
|
|
||
|
$data = !$get ? false : $this->cache($cache_key);
|
||
|
|
||
|
if (!$data) {
|
||
|
|
||
|
$data = $this->getInfo($id);
|
||
|
if ($data) {
|
||
|
$this->cache($cache_key, $data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($data) {
|
||
|
if ($data['status'] != 1) {
|
||
|
return false;
|
||
|
}
|
||
|
if ($data['is_deleted'] != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
}
|