From 37a39dbe5d2d952301adf486c10bf96fa5d20237 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sun, 1 Jun 2025 15:46:01 +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/Dispatch2.php | 38 +++++++++++++-- .../admin/view/orders/dispatch2/edit.html | 48 ++++++++++++++++++- application/common/Logic/OrderLogic.php | 30 +++++++----- .../js/backend/statistics/dispatcher.js | 13 ++++- 4 files changed, 112 insertions(+), 17 deletions(-) diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index e65a385..e5b3f15 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -5,6 +5,7 @@ namespace app\admin\controller\orders; use app\admin\model\Order; use app\admin\model\OrderDispatch; use app\admin\model\OrderDispatchLog; +use app\admin\model\Worker; use app\common\controller\Backend; use app\common\Logic\OrderLogic; use think\Db; @@ -253,12 +254,17 @@ class Dispatch2 extends Backend $this->view->assign('row', $row); $this->view->assign('order', $order); $this->view->assign('action','finish'); + + $workerRate = Worker::where('id',$row->worker_id)->value('rate'); + $this->view->assign('rate', $workerRate); return $this->view->fetch('edit'); } $params = $this->request->post('row/a'); - if (empty($params)) { + + $orderParsms = $this->request->post('order/a'); + if (empty($params) || empty($orderParsms)) { $this->error(__('Parameter %s can not be empty', '')); } @@ -285,19 +291,43 @@ class Dispatch2 extends Backend $params['status'] = OrderDispatch::STATUS_FINISH; $params['finish_time'] = date('Y-m-d H:i:s'); $params['follow'] = 2; + $params['material_cost'] = $orderParsms['material_cost']; if($row->admin_id == 0){ $params['admin_id'] = $this->auth->id; $params['admin_user'] = $this->auth->admin_user; - $order->dispatch_admin_id = $this->auth->id; - $order->save(); + $orderParsms['dispatch_admin_id'] = $this->auth->id; } $result = $row->allowField(true)->save($params); + //计算价格 + $data = [ + 'online_amount_last' => $row->online_total, //线上尾款 + 'offline_amount' => $row->total, //线下尾款 + 'cost' => $orderParsms['cost'], + 'cost_rate' => $orderParsms['cost_rate'], + 'offline_amount_type'=> $row->offline_total_type, + ]; + + if($row->type == 1){ //手动 + $data['status'] = Order::STATUS_AUDITING; + }else{ + $data['status'] = Order::STATUS_CHECKING; + } + $data = array_merge($data,$orderParsms); + $last_amount = bcadd($data['online_amount_last'],$data['offline_amount'],2); + + $cost = bcadd($data['cost'],$data['material_cost'],2); + + $data['total'] = bcadd($order->online_amount,$last_amount,2); + $data['real_amount'] = $data['total']; + $data['performance'] = bcsub($data['real_amount'],$cost,2); + $order->allowField(true)->save($data); + //修改订单状态 $OrderLogic = new OrderLogic(); - $OrderLogic -> dispachFinishAfter($row,['role'=>1,'auth'=>$this->auth,'remark'=>'后台完成任务,操作人:'.$this->auth->nickname]); + $OrderLogic -> dispachFinishAfter($row,['role'=>1,'auth'=>$this->auth,'remark'=>'后台完成任务,操作人:'.$this->auth->nickname],true); Db::commit(); } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); diff --git a/application/admin/view/orders/dispatch2/edit.html b/application/admin/view/orders/dispatch2/edit.html index 74f5d50..7fa37da 100644 --- a/application/admin/view/orders/dispatch2/edit.html +++ b/application/admin/view/orders/dispatch2/edit.html @@ -69,7 +69,6 @@ -