104 lines
3.0 KiB
PHP
Executable File
104 lines
3.0 KiB
PHP
Executable File
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: HcyShop-kiki
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\admin\logic;
|
|
|
|
use app\admin\model\Store;
|
|
use app\common\server\UrlServer;
|
|
use think\Db;
|
|
|
|
class StoreLogic
|
|
{
|
|
|
|
public static function lists($get)
|
|
{
|
|
$store = Db::name('store');
|
|
|
|
$where = [];
|
|
$where[] = ['del', '=', '0'];
|
|
|
|
if (isset($get['title']) && $get['title']) {
|
|
$where[] = ['title|address|image|business', 'like', '%' . $get['title'] . '%'];
|
|
}
|
|
$count = $store->where($where)->count();
|
|
$list = $store->where($where)->page($get['page'], $get['limit'])->order('id desc')->select();
|
|
foreach ($list as &$item) {
|
|
$item['image'] = UrlServer::getFileUrl($item['image']);
|
|
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
|
if ($item['is_show'] == 1) {
|
|
$item['is_show_text'] = '显示';
|
|
} else {
|
|
$item['is_show_text'] = '隐藏';
|
|
}
|
|
}
|
|
return ['count' => $count, 'lists' => $list];
|
|
}
|
|
|
|
|
|
public static function addStore($post)
|
|
{
|
|
$store = new Store();
|
|
|
|
$data = [
|
|
'title' => $post['title'],
|
|
'address' => $post['address'],
|
|
'image' => $post['image'],
|
|
'business' => $post['business'],
|
|
'is_show' => $post['is_show'],
|
|
'traffic' => $post['traffic'],
|
|
'create_time' => time(),
|
|
'contact' => $post['contact'],
|
|
];
|
|
return $store->save($data);
|
|
}
|
|
|
|
public static function editStore($post)
|
|
{
|
|
$store = new Store();
|
|
$data = [
|
|
'title' => $post['title'],
|
|
'address' => $post['address'],
|
|
'image' => $post['image'],
|
|
'business' => $post['business'],
|
|
'is_show' => $post['is_show'],
|
|
'traffic' => $post['traffic'],
|
|
'update_time' => time(),
|
|
'contact' => $post['contact'],
|
|
];
|
|
return $store->save($data, ['id' => $post['id'], 'del' => 0]);
|
|
}
|
|
|
|
public static function getStore($id)
|
|
{
|
|
$store = new Store();
|
|
$detail = $store::get(['id' => $id, 'del' => 0]);
|
|
$detail['abs_image'] = UrlServer::getFileUrl($detail['image']);
|
|
return $detail;
|
|
}
|
|
|
|
public static function delStore($id)
|
|
{
|
|
$store = new Store();
|
|
|
|
$data = [
|
|
'del' => time(),
|
|
'update_time' => 1
|
|
];
|
|
return $article->save($data, ['id' => $id, 'del' => 0]);
|
|
}
|
|
|
|
public static function switchStatus($post)
|
|
{
|
|
$data = [
|
|
'is_show' => $post['is_show'],
|
|
'update_time' => time(),
|
|
];
|
|
return Db::name('store')->where(['del' => 0, 'id' => $post['id']])->update($data);
|
|
}
|
|
|
|
} |