118 lines
3.1 KiB
PHP
Executable File
118 lines
3.1 KiB
PHP
Executable File
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: HcyShop-kiki
|
|
// +----------------------------------------------------------------------
|
|
namespace app\admin\logic;
|
|
use think\db;
|
|
use app\common\server\UrlServer;
|
|
|
|
class SupplierLogic{
|
|
/**
|
|
* 列表
|
|
*/
|
|
public static function lists($get,$category){
|
|
$where =[];
|
|
if(isset($get['keyword']) && $get['keyword']){
|
|
$where[] = ['name','like','%'.$get['keyword'].'%'];
|
|
}
|
|
if (isset($get['cid']) && $get['cid']) {
|
|
$where[] = ['cid', '=', $get['cid']];
|
|
}
|
|
$res = db::name('supplier')
|
|
->where('del',0)
|
|
->where($where);
|
|
$count = $res->count();
|
|
$lists = $res->page($get['page'],$get['limit'])->select();
|
|
foreach ($lists as &$item) {
|
|
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
|
|
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
|
if (isset($category[$item['cid']])) {
|
|
$item['cat_name'] = $category[$item['cid']]['name'];
|
|
}
|
|
}
|
|
return[
|
|
'count' =>$count,
|
|
'lists' =>$lists,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 添加
|
|
*/
|
|
public static function add($post){
|
|
|
|
$data = [
|
|
'name' => $post['name'],
|
|
'avatar' => $post['avatar'],
|
|
'cid' => $post['cid'],
|
|
'remark' => $post['remark'],
|
|
'honor' => $post['honor'],
|
|
'is_notice' => $post['is_notice'],
|
|
'position' => $post['position'],
|
|
'create_time' => time(),
|
|
];
|
|
|
|
db::name('supplier')
|
|
->insert($data);
|
|
}
|
|
|
|
/**
|
|
* 编辑
|
|
*/
|
|
public static function edit($post){
|
|
|
|
$data = [
|
|
'name' => $post['name'],
|
|
'avatar' => $post['avatar'],
|
|
'cid' => $post['cid'],
|
|
'remark' => $post['remark'],
|
|
'honor' => $post['honor'],
|
|
'is_notice' => $post['is_notice'],
|
|
'position' => $post['position'],
|
|
'update_time' => time(),
|
|
];
|
|
|
|
db::name('supplier')
|
|
->where(['id'=>$post['id']])
|
|
->update($data);
|
|
}
|
|
|
|
/**
|
|
* 信息
|
|
*/
|
|
public static function info($id){
|
|
$info = db::name('supplier')
|
|
->where(['id'=>$id])
|
|
->find();
|
|
$info['avatar'] = UrlServer::getFileUrl($info['avatar']);
|
|
return $info;
|
|
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
public static function del($id)
|
|
{
|
|
|
|
$data = [
|
|
'del' => 1,
|
|
'update_time' => time()];
|
|
return Db::name('supplier')->where(['del' => 0, 'id' =>$id])->update($data); //逻辑删除
|
|
|
|
|
|
}
|
|
/**
|
|
* note 获取所有供应商
|
|
*/
|
|
public static function getSupplierList(){
|
|
$list = Db::name('supplier')
|
|
->field('id,name')
|
|
->where(['del' => 0])
|
|
->select();
|
|
return $list;
|
|
}
|
|
} |