From d19845a0722d79a9fdf73e20c77b299352369e23 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sun, 1 Jun 2025 17:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A2=E5=8D=95=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Review.php | 15 ++ .../admin/controller/orders/Revisitorder.php | 219 ++++++++++++++++++ .../admin/view/orders/review/edit.html | 3 - .../admin/view/orders/revisitorder/edit.html | 15 ++ .../assets/js/backend/orders/revisitorder.js | 24 +- 5 files changed, 270 insertions(+), 6 deletions(-) diff --git a/application/admin/controller/orders/Review.php b/application/admin/controller/orders/Review.php index 219c0a8..a7d9e6d 100644 --- a/application/admin/controller/orders/Review.php +++ b/application/admin/controller/orders/Review.php @@ -3,6 +3,7 @@ namespace app\admin\controller\orders; use app\admin\model\Aftersale; +use app\admin\model\Message; use app\admin\model\Order; use app\common\controller\Backend; use Exception; @@ -111,10 +112,24 @@ class Review extends Backend if($order->status == 60){ $params['is_star'] = 1; } + $result = $this->model->allowField(true)->save($params); $order->revisit_id = $this->auth->id; + $order->revisit_truth = $params['is_same']; $order->save(); Db::commit(); + + if($params['is_same'] == 0){ + + Message::create([ + 'to_id' => $order->dispatch_admin_id, + 'title' => '回访订单异常', + 'content' => '【回访订单异常】:您有一条回访订单出现异常,原因是:'.$params['remark'].',请及时查看并核实!', + '' + ]); + + } + } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); diff --git a/application/admin/controller/orders/Revisitorder.php b/application/admin/controller/orders/Revisitorder.php index 9f913db..de4da92 100644 --- a/application/admin/controller/orders/Revisitorder.php +++ b/application/admin/controller/orders/Revisitorder.php @@ -6,6 +6,7 @@ use app\admin\model\Order; use app\admin\model\OrderReview; use app\common\controller\Backend; use think\Collection; +use think\Loader; /** * 订单列管理 @@ -21,6 +22,7 @@ class Revisitorder extends Backend */ protected $model = null; + public function _initialize() { parent::_initialize(); @@ -92,4 +94,221 @@ class Revisitorder extends Backend return $this->view->fetch(); } + + + + /** + * 生成查询所需要的条件,排序方式 + * @param mixed $searchfields 快速查询的字段 + * @param boolean $relationSearch 是否关联查询 + * @return array + */ + protected function buildparams($searchfields = null, $relationSearch = null) + { + $searchfields = is_null($searchfields) ? $this->searchFields : $searchfields; + $relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch; + $search = $this->request->get("search", ''); + $filter = $this->request->get("filter", ''); + $op = $this->request->get("op", '', 'trim'); + $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id'); + $order = $this->request->get("order", "DESC"); + $offset = max(0, $this->request->get("offset/d", 0)); + $limit = max(0, $this->request->get("limit/d", 0)); + $limit = $limit ?: 999999; + //新增自动计算页码 + $page = $limit ? intval($offset / $limit) + 1 : 1; + if ($this->request->has("page")) { + $page = max(0, $this->request->get("page/d", 1)); + } + $this->request->get([config('paginate.var_page') => $page]); + $filter = (array)json_decode($filter, true); + $revalue = 0; + + if(isset($filter['revisit_id'])){ + if($filter['revisit_id'] == 1){ + $revalue = 1; + } + $filter['revisit_id'] = 0; + } + $returnvalue = 0; + if(isset($filter['aftersale_id'])){ + if($filter['aftersale_id'] == 1){ + $returnvalue = 1; + } + $filter['aftersale_id'] = 0; + } + + $op = (array)json_decode($op, true); + if($revalue>0){ + $op['revisit_id'] = '>'; + } + if($revalue<=0){ + $op['revisit_id'] = '='; + } + + if($returnvalue>0){ + $op['aftersale_id'] = '>'; + } + if($returnvalue<=0){ + $op['aftersale_id'] = '='; + } + + $filter = $filter ? $filter : []; + $where = []; + $alias = []; + $bind = []; + $name = ''; + $aliasName = ''; + if (!empty($this->model) && $relationSearch) { + $name = $this->model->getTable(); + $alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model)))); + $aliasName = $alias[$name] . '.'; + } + $sortArr = explode(',', $sort); + foreach ($sortArr as $index => & $item) { + $item = stripos($item, ".") === false ? $aliasName . trim($item) : $item; + } + unset($item); + $sort = implode(',', $sortArr); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) { + $where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds]; + } + if ($search) { + $searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields); + foreach ($searcharr as $k => &$v) { + $v = stripos($v, ".") === false ? $aliasName . $v : $v; + } + unset($v); + $where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"]; + } + $index = 0; + foreach ($filter as $k => $v) { + if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) { + continue; + } + $sym = $op[$k] ?? '='; + if (stripos($k, ".") === false) { + $k = $aliasName . $k; + } + $v = !is_array($v) ? trim($v) : $v; + $sym = strtoupper($op[$k] ?? $sym); + //null和空字符串特殊处理 + if (!is_array($v)) { + if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) { + $sym = strtoupper($v); + } + if (in_array($v, ['""', "''"])) { + $v = ''; + $sym = '='; + } + } + + switch ($sym) { + case '=': + case '<>': + $where[] = [$k, $sym, (string)$v]; + break; + case 'LIKE': + case 'NOT LIKE': + case 'LIKE %...%': + case 'NOT LIKE %...%': + $where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"]; + break; + case '>': + case '>=': + case '<': + case '<=': + $where[] = [$k, $sym, intval($v)]; + break; + case 'FINDIN': + case 'FINDINSET': + case 'FIND_IN_SET': + $v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v)); + $findArr = array_values($v); + foreach ($findArr as $idx => $item) { + $bindName = "item_" . $index . "_" . $idx; + $bind[$bindName] = $item; + $where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)"; + } + break; + case 'IN': + case 'IN(...)': + case 'NOT IN': + case 'NOT IN(...)': + $where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)]; + break; + case 'BETWEEN': + case 'NOT BETWEEN': + $arr = array_slice(explode(',', $v), 0, 2); + if (stripos($v, ',') === false || !array_filter($arr, function ($v) { + return $v != '' && $v !== false && $v !== null; + })) { + continue 2; + } + //当出现一边为空时改变操作符 + if ($arr[0] === '') { + $sym = $sym == 'BETWEEN' ? '<=' : '>'; + $arr = $arr[1]; + } elseif ($arr[1] === '') { + $sym = $sym == 'BETWEEN' ? '>=' : '<'; + $arr = $arr[0]; + } + $where[] = [$k, $sym, $arr]; + break; + case 'RANGE': + case 'NOT RANGE': + $v = str_replace(' - ', ',', $v); + $arr = array_slice(explode(',', $v), 0, 2); + if (stripos($v, ',') === false || !array_filter($arr)) { + continue 2; + } + //当出现一边为空时改变操作符 + if ($arr[0] === '') { + $sym = $sym == 'RANGE' ? '<=' : '>'; + $arr = $arr[1]; + } elseif ($arr[1] === '') { + $sym = $sym == 'RANGE' ? '>=' : '<'; + $arr = $arr[0]; + } + $tableArr = explode('.', $k); + if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) + && !empty($this->model) && $this->relationSearch) { + //修复关联模型下时间无法搜索的BUG + $relation = Loader::parseName($tableArr[0], 1, false); + $alias[$this->model->$relation()->getTable()] = $tableArr[0]; + } + $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr]; + break; + case 'NULL': + case 'IS NULL': + case 'NOT NULL': + case 'IS NOT NULL': + $where[] = [$k, strtolower(str_replace('IS ', '', $sym))]; + break; + default: + break; + } + $index++; + } + if (!empty($this->model)) { + $this->model->alias($alias); + } + $model = $this->model; + $where = function ($query) use ($where, $alias, $bind, &$model) { + if (!empty($model)) { + $model->alias($alias); + $model->bind($bind); + } + foreach ($where as $k => $v) { + if (is_array($v)) { + call_user_func_array([$query, 'where'], $v); + } else { + $query->where($v); + } + } + }; + return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind]; + } + } diff --git a/application/admin/view/orders/review/edit.html b/application/admin/view/orders/review/edit.html index 2887cf4..353cf3a 100644 --- a/application/admin/view/orders/review/edit.html +++ b/application/admin/view/orders/review/edit.html @@ -67,17 +67,14 @@ {/notempty} -