diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index b70fd7b..e6f9716 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -124,6 +124,9 @@ class Order extends Backend if ($this->request->request('keyField')) { return $this->selectpage(); } + + $type = request()->get('type',1); + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $build = $this->model ->field(['id', 'order_no', 'admin_id', 'customer', 'tel', 'status', 'area_id', 'address', @@ -131,6 +134,14 @@ class Order extends Backend 'detail', 'remark', 'images', 'create_time', 'update_time', 'admin_id', 'dispatch_type', 'receive_type']) ->where($where); + if ($type == 1){ + $build->where('status','>=', 0); + } + + if ($type == 2){ + $build->where('status','<', 0); + } + if ($group == 2) { // 生成 SQL 语句 $area_codes = $this->filterAreaCodes(explode(',', $user->area_ids)); @@ -425,9 +436,13 @@ class Order extends Backend public function delete($ids = null){ if (false === $this->request->isPost()) { - $options = \app\admin\model\Order::DELETED_TYPE; + $options = \model('abnormal')->where('type',2)->select(); + $op = []; + foreach ($options as $option){ + $op[] = ['id' =>$option->id,'title'=>$option->title]; + } $order = model('order')->get($ids); - return $this->fetch('delete',['row' => $order,'options'=>$options]); + return $this->fetch('delete',['row' => $order,'options'=>$op]); } $params = $this->request->post('row/a'); if (empty($params)) { @@ -456,6 +471,46 @@ class Order extends Backend $this->success(); } + + public function send($ids = null){ + if (false === $this->request->isPost()) { + + $options = \model('admin')->select(); + $op = []; + foreach ($options as $option){ + $op[] = ['id' =>$option->id,'title'=>$option->nickname]; + } + $order = model('order')->get($ids); + return $this->fetch('delete',['row' => $order,'options'=>$op]); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + + $result = false; + Db::startTrans(); + try { + $order = model('order')->get($params['order_id']); + if (!$order){ + $this->error('Not Find'); + } + $params['status'] = \app\admin\model\Order::STATUS_CANCEL; + $result = $order->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + private function filterAreaCodes(array $area_codes) { // 提取所有两位区号 diff --git a/application/admin/controller/setting/Abnormal.php b/application/admin/controller/setting/Abnormal.php index 4bf262b..12fdf86 100644 --- a/application/admin/controller/setting/Abnormal.php +++ b/application/admin/controller/setting/Abnormal.php @@ -33,5 +33,28 @@ class Abnormal extends Backend * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if (false === $this->request->isAjax()) { + return $this->view->fetch(); + } + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); + + $type = request()->get('type',1); + + $list = $this->model + ->where($where) + ->where('type',$type) + ->order($sort, $order) + ->paginate($limit); + $result = ['total' => $list->total(), 'rows' => $list->items()]; + return json($result); + } } diff --git a/application/admin/view/order/delete.html b/application/admin/view/order/delete.html index 8a53540..b60bd41 100644 --- a/application/admin/view/order/delete.html +++ b/application/admin/view/order/delete.html @@ -16,9 +16,9 @@