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 @@ -