From 09e94cd7b34abf917ef7a070855e7bfdb1b6b4d5 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sat, 29 Mar 2025 21:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Configorder.php | 9 ++--- .../admin/controller/orders/Dispatch2.php | 1 + .../admin/lang/zh-cn/aftersales/aftersale.php | 2 +- .../admin/lang/zh-cn/orders/configorder.php | 2 +- .../admin/lang/zh-cn/orders/dispatch.php | 2 +- .../admin/lang/zh-cn/orders/dispatch2.php | 2 +- application/admin/model/Order.php | 35 +++++++++++++++++++ application/admin/model/OrderDispatch.php | 19 ++++++++++ .../admin/view/orders/configorder/edit.html | 4 +-- .../admin/view/orders/dispatch2/edit.html | 3 +- application/config.php | 2 +- .../assets/js/backend/orders/configorder.js | 5 +++ 12 files changed, 73 insertions(+), 13 deletions(-) diff --git a/application/admin/controller/orders/Configorder.php b/application/admin/controller/orders/Configorder.php index 7e93cc1..819592b 100644 --- a/application/admin/controller/orders/Configorder.php +++ b/application/admin/controller/orders/Configorder.php @@ -56,9 +56,10 @@ class Configorder extends Backend return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $list = $this->model - ->scope('tab',Order::TAB_SETTING) + ->tab(Order::TAB_SETTING) + ->auth($this->auth) + ->areaauth($this->auth) ->with(['dispatch']) ->where($where) ->order($sort, $order) @@ -127,8 +128,8 @@ class Configorder extends Backend ]; $data['total'] = bcadd($row->online_amount,$params['offline_amount'],2); - $data['real_amount'] = bcdiv($data['total'],$params['refund_amount'],2); - $data['performance'] = bcdiv($data['real_amount'],$params['cost'],2); + $data['real_amount'] = bcsub($data['total'],$params['refund_amount'],2); + $data['performance'] = bcsub($data['real_amount'],$params['cost'],2); $result = $row->allowField(true)->save($data); //日志 diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 03eda33..3a61efe 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -70,6 +70,7 @@ class Dispatch2 extends Backend $list = $this->model ->with(['order']) + ->auth($this->auth) ->where($where) ->order($sort, $order) ->paginate($limit); diff --git a/application/admin/lang/zh-cn/aftersales/aftersale.php b/application/admin/lang/zh-cn/aftersales/aftersale.php index 5ca10f3..47dc7a0 100644 --- a/application/admin/lang/zh-cn/aftersales/aftersale.php +++ b/application/admin/lang/zh-cn/aftersales/aftersale.php @@ -21,7 +21,7 @@ return [ 'From 1' => '师傅', 'From 2' => '顾客', 'From 3' => '平台', - 'Refund_amount' => '总退款金额', + 'Refund_amount' => '退款金额', 'Company_refund_amount' => '公司退款金额', 'Worker_refund_amount' => '师傅退款金额', 'Refund_type' => '退款方式', diff --git a/application/admin/lang/zh-cn/orders/configorder.php b/application/admin/lang/zh-cn/orders/configorder.php index ce888c7..80e83dc 100644 --- a/application/admin/lang/zh-cn/orders/configorder.php +++ b/application/admin/lang/zh-cn/orders/configorder.php @@ -42,7 +42,7 @@ return [ 'Online_amount' => '线上收款', 'Offline_amount' => '线下收款', 'Discount_amount' => '优惠抵扣', - 'Refund_amount' => '总退款额', + 'Refund_amount' => '退款金额', 'Real_amount' => '实际收款', 'Cost' => '师傅成本', 'Performance' => '预计利润', diff --git a/application/admin/lang/zh-cn/orders/dispatch.php b/application/admin/lang/zh-cn/orders/dispatch.php index 279701f..17e3b46 100644 --- a/application/admin/lang/zh-cn/orders/dispatch.php +++ b/application/admin/lang/zh-cn/orders/dispatch.php @@ -68,7 +68,7 @@ return [ 'Order.online_amount' => '线上收款', 'Order.offline_amount' => '线下收款', 'Order.discount_amount' => '优惠抵扣', - 'Order.refund_amount' => '总退款额', + 'Order.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', 'Order.cost' => '师傅成本', 'Order.performance' => '预计利润', diff --git a/application/admin/lang/zh-cn/orders/dispatch2.php b/application/admin/lang/zh-cn/orders/dispatch2.php index 23b36fb..5d96287 100644 --- a/application/admin/lang/zh-cn/orders/dispatch2.php +++ b/application/admin/lang/zh-cn/orders/dispatch2.php @@ -68,7 +68,7 @@ return [ 'Order.online_amount' => '线上收款', 'Order.offline_amount' => '线下收款', 'Order.discount_amount' => '优惠抵扣', - 'Order.refund_amount' => '总退款额', + 'Order.refund_amount' => '退款金额', 'Order.real_amount' => '实际收款', 'Order.cost' => '师傅成本', 'Order.performance' => '预计利润', diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index 7c74feb..49e7437 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use app\admin\library\Auth; use think\Model; use traits\model\SoftDelete; @@ -158,4 +159,38 @@ class Order extends Model { return $this->hasOne(OrderDispatch::class, 'order_id', 'id', [], 'LEFT')->setEagerlyType(0)->where('fa_order_dispatch.status',OrderDispatch::STATUS_FINISH); } + + + /** + * 管理员权限 + * @param $query + * @param Auth $auth + * @param string $auth_admin_id + * @return mixed + */ + public function scopeAuth($query, Auth $auth, string $admin_id_field='admin_id'){ + + if(!$auth->isSuperAdmin()){ + $query->where('fa_order.'.$admin_id_field,$auth->id); + } + return $query; + } + + /** + * 地域权限 + * @param $query + * @param Auth $auth + * @param string $area_id_field + * @return mixed + */ + public function scopeAreaauth($query,Auth $auth,string $area_id_field='area_id'){ + if(!$auth->isSuperAdmin()){ + $areaIds = array_unique(array_filter(explode(',',trim($auth->area_ids)))); + if(!in_array('*',$areaIds)){ + $query->whereIn('fa_order.'.$area_id_field,$areaIds); + } + } + return $query; + } + } diff --git a/application/admin/model/OrderDispatch.php b/application/admin/model/OrderDispatch.php index 005252f..b4b073f 100644 --- a/application/admin/model/OrderDispatch.php +++ b/application/admin/model/OrderDispatch.php @@ -2,6 +2,7 @@ namespace app\admin\model; +use app\admin\library\Auth; use think\Model; @@ -151,4 +152,22 @@ class OrderDispatch extends Model return $btns[$btn]??[]; } + + + + /** + * 管理员权限 + * @param $query + * @param Auth $auth + * @param string $auth_admin_id + * @return mixed + */ + public function scopeAuth($query, Auth $auth, string $admin_id_field='admin_id'){ + + if(!$auth->isSuperAdmin()){ + $query->where('fa_order_dispatch.'.$admin_id_field,$auth->id); + } + return $query; + } + } diff --git a/application/admin/view/orders/configorder/edit.html b/application/admin/view/orders/configorder/edit.html index ce8694e..f364e58 100644 --- a/application/admin/view/orders/configorder/edit.html +++ b/application/admin/view/orders/configorder/edit.html @@ -58,13 +58,13 @@ -
+ {notempty name='row.audit_admin_id'} diff --git a/application/admin/view/orders/dispatch2/edit.html b/application/admin/view/orders/dispatch2/edit.html index 8e5ca56..f402e54 100644 --- a/application/admin/view/orders/dispatch2/edit.html +++ b/application/admin/view/orders/dispatch2/edit.html @@ -150,8 +150,7 @@ diff --git a/application/config.php b/application/config.php index 4582b2d..ff66689 100755 --- a/application/config.php +++ b/application/config.php @@ -173,7 +173,7 @@ return [ // 日志保存目录 'path' => LOG_PATH, // 日志记录级别 - 'level' => [], + 'level' => ['log','error'], ], // +---------------------------------------------------------------------- // | Trace设置 开启 app_trace 后 有效 diff --git a/public/assets/js/backend/orders/configorder.js b/public/assets/js/backend/orders/configorder.js index df3b4c8..4b740b7 100644 --- a/public/assets/js/backend/orders/configorder.js +++ b/public/assets/js/backend/orders/configorder.js @@ -49,6 +49,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'online_amount', title: __('Online_amount'), operate:'BETWEEN'}, {field: 'offline_amount', title: __('Offline_amount'), operate:'BETWEEN'}, + {field: 'refund_amount', title: __('Refund_amount'), operate:'BETWEEN'}, + {field: 'real_amount', title: __('Real_amount'), operate:'BETWEEN'}, + {field: 'cost', title: __('Cost'), operate:'BETWEEN'}, + {field: 'performance', title: __('Performance'), operate:'BETWEEN'}, + // {field: 'dispatch_type', title: __('Dispatch_type')}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},