From 1ac760222c3c8ddc6446721b69b32239d73569ac Mon Sep 17 00:00:00 2001 From: hant Date: Thu, 17 Apr 2025 11:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Order.php | 11 +- .../controller/{order => orders}/Invoice.php | 56 +++++++++- .../lang/zh-cn/{order => orders}/invoice.php | 0 application/admin/model/order/Invoice.php | 9 +- application/admin/view/order/edit.html | 2 +- application/admin/view/order/invoice/add.html | 6 +- .../admin/view/orders/invoice/add.html | 101 ++++++++++++++++++ .../view/{order => orders}/invoice/edit.html | 26 ++--- .../view/{order => orders}/invoice/index.html | 2 +- public/assets/js/backend/order.js | 30 ++++++ .../js/backend/{order => orders}/invoice.js | 56 ++++++++-- 11 files changed, 257 insertions(+), 42 deletions(-) rename application/admin/controller/{order => orders}/Invoice.php (52%) rename application/admin/lang/zh-cn/{order => orders}/invoice.php (100%) create mode 100644 application/admin/view/orders/invoice/add.html rename application/admin/view/{order => orders}/invoice/edit.html (82%) rename application/admin/view/{order => orders}/invoice/index.html (87%) rename public/assets/js/backend/{order => orders}/invoice.js (58%) diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 7917673..9333ff1 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\admin\addresmart\Address; use app\admin\model\AuthGroupAccess; +use app\admin\model\order\Invoice; use app\admin\model\OrderDispatch; use app\admin\model\Worker; use app\admin\model\WorkerItem; @@ -92,7 +93,6 @@ class Order extends Backend ->field(['id', 'nickname']) ->select(); - $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("sources", $res); $this->view->assign("coupons", $coupons); $this->view->assign("items", $formattedTree); @@ -598,13 +598,8 @@ class Order extends Backend $result = false; Db::startTrans(); try { - //是否采用模型验证 - if ($this->modelValidate) { - $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; - $this->model->validateFailException()->validate($validate); - } - $result = $this->model->allowField(true)->save($params); + $params['invoice_method'] = 1; + $result = (new Invoice())->allowField(true)->save($params); Db::commit(); } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); diff --git a/application/admin/controller/order/Invoice.php b/application/admin/controller/orders/Invoice.php similarity index 52% rename from application/admin/controller/order/Invoice.php rename to application/admin/controller/orders/Invoice.php index e84e689..b338bbd 100644 --- a/application/admin/controller/order/Invoice.php +++ b/application/admin/controller/orders/Invoice.php @@ -1,9 +1,11 @@ model = new \app\admin\model\order\Invoice; + $this->view->assign("statusList", $this->model->getStatusList()); } @@ -71,4 +73,54 @@ class Invoice extends Backend $this->success(); } + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $order = model('order')->get($row['order_id']); + $this->view->assign('order', $order); + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $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 { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + } diff --git a/application/admin/lang/zh-cn/order/invoice.php b/application/admin/lang/zh-cn/orders/invoice.php similarity index 100% rename from application/admin/lang/zh-cn/order/invoice.php rename to application/admin/lang/zh-cn/orders/invoice.php diff --git a/application/admin/model/order/Invoice.php b/application/admin/model/order/Invoice.php index 45a367c..5c5d550 100644 --- a/application/admin/model/order/Invoice.php +++ b/application/admin/model/order/Invoice.php @@ -27,8 +27,15 @@ class Invoice extends Model protected $append = [ ]; - + public function getStatusList() + { + return [ + '0' => '代处理', + '1' => '已开票', + '2' => '已完成', + ]; + } diff --git a/application/admin/view/order/edit.html b/application/admin/view/order/edit.html index 38d5473..a211ac9 100644 --- a/application/admin/view/order/edit.html +++ b/application/admin/view/order/edit.html @@ -120,7 +120,7 @@
- +
@@ -32,7 +32,7 @@
- +
diff --git a/application/admin/view/orders/invoice/add.html b/application/admin/view/orders/invoice/add.html new file mode 100644 index 0000000..258b627 --- /dev/null +++ b/application/admin/view/orders/invoice/add.html @@ -0,0 +1,101 @@ +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
diff --git a/application/admin/view/order/invoice/edit.html b/application/admin/view/orders/invoice/edit.html similarity index 82% rename from application/admin/view/order/invoice/edit.html rename to application/admin/view/orders/invoice/edit.html index 92638e8..eea1cb1 100644 --- a/application/admin/view/order/invoice/edit.html +++ b/application/admin/view/orders/invoice/edit.html @@ -3,13 +3,16 @@
- +
- +
@@ -93,7 +96,11 @@
- +
@@ -102,18 +109,7 @@
-
- -
- -
-
-
- -
- -
-
+