From e1d07d4238af3bafbd8e2131377faf9365031870 Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 13 Mar 2018 15:53:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E5=8E=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E6=95=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/controller/BasicAdmin.php | 37 -------- extend/controller/BasicApp.php | 145 ------------------------------- extend/controller/BasicPda.php | 122 -------------------------- 3 files changed, 304 deletions(-) delete mode 100644 extend/controller/BasicApp.php delete mode 100644 extend/controller/BasicPda.php diff --git a/extend/controller/BasicAdmin.php b/extend/controller/BasicAdmin.php index 858f35d2a..d05c5be06 100644 --- a/extend/controller/BasicAdmin.php +++ b/extend/controller/BasicAdmin.php @@ -145,43 +145,6 @@ class BasicAdmin extends Controller return $result; } - protected function _list_modal($dbQuery = null, $isPage = true, $isDisplay = true, $total = false, $result = [], $template = '') - { - $db = is_null($dbQuery) ? Db::name($this->table) : (is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery); - // 列表排序默认处理 - if ($this->request->isPost() && $this->request->post('action') === 'resort') { - $data = $this->request->post(); - unset($data['action']); - foreach ($data as $key => $value) { - if (false === $db->where('id', intval(ltrim($key, '_')))->setField('sort', $value)) { - $this->error('列表排序失败, 请稍候再试'); - } - } - $this->success('列表排序成功, 正在刷新列表', ''); - } - // 列表数据查询与显示 - if (null === $db->getOptions('order')) { - in_array('sort', $db->getTableFields($db->getTable())) && $db->order('sort asc'); - } - if ($isPage) { - $rows = 10; - // 分页数据处理 - $query = $this->request->get('', '', 'urlencode'); - $page = $db->paginate($rows, $total, ['query' => $query]); - list($totalNum) = [$page->total()]; - list($pattern, $replacement) = [['|href="(.*?)"|', '|pagination|'], ['href="javascript:;" onclick="pageto(this)"', 'pagination pull-right']]; - $html = "共 {$totalNum} 条记录," . " 共 " . ceil($totalNum / $rows) . " 页。"; - list($result['total'], $result['list'], $result['page']) = [$totalNum, $page->all(), $html . preg_replace($pattern, $replacement, $page->render())]; - } else { - $result['list'] = $db->select(); - } - if ($isDisplay && (false !== $this->_callback('_data_filter', $result['list'], []))) { - !empty($this->title) && $this->assign('title', $this->title); - return $this->fetch($template, $result); - } - return $result; - } - /** * 当前对象回调成员方法 * @param string $method diff --git a/extend/controller/BasicApp.php b/extend/controller/BasicApp.php deleted file mode 100644 index 1f4fd55f1..000000000 --- a/extend/controller/BasicApp.php +++ /dev/null @@ -1,145 +0,0 @@ -request = app('request'); - $this->unionid = $this->request->post('unionid', ''); - $this->deviceid = $this->request->post('deviceid', ''); - $this->_initialize(); - } - - /** - * App接口初始化 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function _initialize() - { - if (empty($this->deviceid) && empty($this->unionid)) { - $this->error("接口异常,缺少必要参数!"); - } - return $this->checkLogin(); - } - - /** - * 检查用户登录 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - protected function checkLogin() - { - $this->member = $this->initMember(); - empty($this->member) && $this->error('还没有登录哦,请登录后再来访问!'); - } - - /** - * 初始化会员数据 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - protected function initMember() - { - $where = "(deviceid='{$this->deviceid}' and deviceid<>'') or (unionid='{$this->unionid}' and unionid<>'')"; - $this->member = Db::name('Member')->where(['status' => '1'])->where($where)->find(); - if (!empty($this->member)) { - $where = ['level' => $this->member['level']]; - $this->member['nickname'] = ToolsService::emojiDecode($this->member['nickname']); - $this->member['level_title'] = Db::name('MemberLevel')->where($where)->value('title', ''); - // 计算会员的积分排行榜 - $rateWhere = ['is_pass' => '1', 'total_integral' => ['>', $this->member['total_integral']]]; - $rateCount = Db::name('Member')->where($rateWhere)->count(); - $count = Db::name('Member')->where(['is_pass' => '1'])->count(); - $this->member['integral_rate'] = number_format(floatval(100 - $rateCount * 100 / $count), 2); - } - return $this->member; - } - - /** - * 返回成功的操作 - * @param string $msg 消息内容 - * @param array $data 返回数据 - */ - protected function success($msg, $data = []) - { - $result = ['code' => 1, 'msg' => $msg, 'data' => $data]; - throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander())); - } - - /** - * 返回失败的请求 - * @param string $msg 消息内容 - * @param array $data 返回数据 - */ - protected function error($msg, $data = []) - { - $result = ['code' => 0, 'msg' => $msg, 'data' => $data]; - throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander())); - } - -} diff --git a/extend/controller/BasicPda.php b/extend/controller/BasicPda.php deleted file mode 100644 index e39c7d84c..000000000 --- a/extend/controller/BasicPda.php +++ /dev/null @@ -1,122 +0,0 @@ -request = app('request'); - $this->deviceid = $this->request->post('deviceid', ''); - $this->_initialize(); - } - - /** - * PDA接口初始化 - */ - public function _initialize() - { - empty($this->deviceid) && $this->error("接口异常,缺少必要参数!"); - sysconf('depot_pda_secret_key') !== $this->request->post('appkey') && $this->error("PDA密钥有误!"); - $this->checkLogin && !$this->checkLogin() && $this->error('请登录后再操作!'); - } - - /** - * 检查用户登录 - * @return bool - */ - protected function checkLogin() - { - return !!$this->initUser(); - } - - /** - * 初始化用户数据 - * @return array|false|\PDOStatement|string|\think\Model - */ - protected function initUser() - { - $where = "deviceid='{$this->deviceid}' and deviceid<>''"; - $this->user = Db::name('GoodsDepotKeeper')->where(['status' => '1', 'is_deleted' => 0])->where($where)->find(); - if (!empty($this->user)) { - $this->user['depot'] = Db::name('GoodsDepot')->where(['id' => $this->user['depot_id']])->value('name'); - } - return $this->user; - } - - /** - * 返回成功的操作 - * @param string $msg 消息内容 - * @param array $data 返回数据 - */ - protected function success($msg, $data = []) - { - $result = ['code' => 1, 'msg' => $msg, 'data' => $data]; - throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander())); - } - - /** - * 返回失败的请求 - * @param string $msg 消息内容 - * @param array $data 返回数据 - */ - protected function error($msg, $data = []) - { - $result = ['code' => 0, 'msg' => $msg, 'data' => $data]; - throw new HttpResponseException(Response::create($result, 'json', 200, ToolsService::corsRequestHander())); - } - -}