From f9822fc344460a4ec2aa8259ce54116f5b75b276 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sun, 2 Mar 2025 17:06:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=B8=AD=E8=BD=AC=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Income.php | 54 +++++++++++++++++++ application/admin/view/orders/income/add.html | 39 +++++--------- public/assets/js/backend/order.js | 21 +++++++- public/assets/js/backend/orders/income.js | 4 +- 4 files changed, 88 insertions(+), 30 deletions(-) diff --git a/application/admin/controller/orders/Income.php b/application/admin/controller/orders/Income.php index b2485ef..6c0bdf3 100644 --- a/application/admin/controller/orders/Income.php +++ b/application/admin/controller/orders/Income.php @@ -2,7 +2,11 @@ namespace app\admin\controller\orders; +use app\admin\model\Order; use app\common\controller\Backend; +use think\Db; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 订单收款 @@ -38,4 +42,54 @@ class Income extends Backend */ + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + + $order_id = $this->request->get('order_id'); + + $order = Order::where('id',$order_id)->find(); + + $this->assign('order',$order); + 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); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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); + } + $params['admin_id'] = $this->auth->id; + $params['admin_user'] = $this->auth->username; + $result = $this->model->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(); + } + } diff --git a/application/admin/view/orders/income/add.html b/application/admin/view/orders/income/add.html index c5c6dc0..26cc573 100644 --- a/application/admin/view/orders/income/add.html +++ b/application/admin/view/orders/income/add.html @@ -1,23 +1,23 @@
-
- -
- -
-
+
- + + + +
+
- +
- +
+
@@ -30,12 +30,7 @@
-
- -
- -
-
+
@@ -48,24 +43,14 @@
-
- -
- -
-
+
-
- -
- -
-
+