0])->count(); $lists = ShopVip::where(['del'=>0])->order('id', 'desc')->page($get['page'], $get['limit'])->select()->toArray(); return ['count' => $count, 'lists' => $lists]; } public static function add($post) { try{ $userLevel = ShopVip::where(['name'=>trim($post['name']), 'del'=>0])->findOrEmpty(); if(!$userLevel->isEmpty()) { throw new \think\Exception('等级名称已被使用,请更换后重试'); } $time = time(); $data = [ 'name' => trim($post['name']), 'create_time' => $time, 'update_time' => $time, 'del' => 0 ]; ShopVip::create($data); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } public static function detail($id) { $detail = ShopVip::where(['id'=>$id])->findOrEmpty(); if($detail->isEmpty()) { return []; } $detail = $detail->toArray(); return $detail; } public static function edit($post) { try{ $userLevel = ShopVip::where([ ['name', '=', trim($post['name'])], ['del', '=', 0], ['id', '<>', $post['id']] ])->findOrEmpty(); if(!$userLevel->isEmpty()) { throw new \think\Exception('名称已被使用,请更换后重试'); } $time = time(); $data = [ 'name' => trim($post['name']), 'update_time' => $time, 'del' => 0 ]; ShopLevel::update($data); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } public static function del($id) { try{ $data = [ 'id' => $id, 'del' => 1, 'update_time' => time() ]; ShopVip::update($data); return true; }catch(\Exception $e) { self::$error = $e->getMessage(); return false; } } /** * @Notes: 隐藏 * @Author: 张无忌 * @param $id * @return bool */ public static function hide($id) { try { $model = new ShopVip(); $category = $model->findOrEmpty($id)->toArray(); ShopVip::update([ 'is_show' => !$category['is_show'], 'update_time' => time() ], ['id'=>$id]); return true; } catch (\Exception $e) { static::$error = $e->getMessage(); return false; } } /** * NOTE: 获取主营类目 * @author: 张无忌 * @return array */ public static function getCategory() { try { $model = new ShopVip(); return $model->field(true) ->where('del', 0) ->order('id', 'desc') ->select()->toArray(); } catch (\Exception $e) { return []; } } }