From 988708251682b1bceaeb0958e9075d0ffafa2578 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Sun, 21 Apr 2024 18:04:19 +0800 Subject: [PATCH] 1 --- app/api/controller/Server.php | 5 +++++ app/api/model/Server/ServerOrder.php | 27 ++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/api/controller/Server.php b/app/api/controller/Server.php index 69ed3ccc..32ab0dd9 100644 --- a/app/api/controller/Server.php +++ b/app/api/controller/Server.php @@ -8,6 +8,7 @@ namespace app\api\controller; use app\api\model\Server\ServerCategory; use app\api\model\Server\ServerOrder; use app\api\service\Server\ServerPayment; +use app\api\service\User as UserService; use app\common\enum\ServerEnum; use app\common\service\server\Order as ServerServiceOrder; use cores\exception\BaseException; @@ -229,6 +230,10 @@ class Server extends Controller if (!$serverId) { return $this->renderError('非法请求'); } + //分销工程师限制下单 + if (UserService::isDealerEngineer()) { + return $this->renderError('当前角色无法下单'); + } $orderService = new ServerServiceOrder(); $data = [ 'server_id' => $serverId, diff --git a/app/api/model/Server/ServerOrder.php b/app/api/model/Server/ServerOrder.php index 96cee119..3e769b61 100644 --- a/app/api/model/Server/ServerOrder.php +++ b/app/api/model/Server/ServerOrder.php @@ -216,15 +216,24 @@ class ServerOrder extends Order $dataTypeFilter = $this->getFilterDataType($dataType); // 当前用户ID $userId = UserService::getCurrentLoginUserId(); - // 查询数据 - $query = $this; - // 非店长不带入user_id查询 - if (!UserService::isStore()) { - $query = $query->where('user_id', '=', $userId); + //判断当前用户身份 + if (UserService::isDealerEngineer()) { + //分销商工程师 + return $this->where($dataTypeFilter) + ->where('dealer_id', '=', $userId) + ->where('is_delete', '=', 0) + ->count(); + } elseif (UserService::isStore()) { + // 店主 + return $this->where($dataTypeFilter) + ->where('is_delete', '=', 0) + ->count(); + } else { + return $this->where($dataTypeFilter) + ->where('user_id', '=', $userId) + ->where('is_delete', '=', 0) + ->count(); } - return $query->where($dataTypeFilter) - ->where('is_delete', '=', 0) - ->count(); } /** @@ -240,7 +249,7 @@ class ServerOrder extends Order switch ($dataType) { case 'all': break; - //待确认 + //待确认 case 'confirm': $filter[] = ['pay_status', '=', PayStatusEnum::SUCCESS]; $filter[] = ['order_status', '=', ServerEnum::APPLYDISPATCH];