From 7bc116cddf540160633175465e0102baeddb2416 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 3 Feb 2024 14:19:42 +0800 Subject: [PATCH] add --- app/adminapi/controller/TaskController.php | 34 ++++++++++++---------- app/adminapi/lists/user/UserLists.php | 19 +++++++++--- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/app/adminapi/controller/TaskController.php b/app/adminapi/controller/TaskController.php index 07c10825..5fa47521 100644 --- a/app/adminapi/controller/TaskController.php +++ b/app/adminapi/controller/TaskController.php @@ -239,23 +239,25 @@ class TaskController extends BaseAdminController public function addTask() { $params = $this->request->param(); // user_id title content + foreach ($params['director_uid'] as $director_uid) { + $arr = [ + 'template_id' => 0, + 'scheduling_plan_id' => 0, + 'company_id' => $params['company_id'], + 'title' => $params['title'], + 'money' => 0, + 'type' => 0, + 'status' => $params['status'], + 'content' => $params['content'], + 'start_time' => time(), + 'end_time' => strtotime($params['end_time']), + 'director_uid' => $director_uid, // 指派给负责人 + 'create_time' => time(), + 'update_time' => time(), + ]; + $task_id = (new Task())->insertGetId($arr); + } - $arr = [ - 'template_id' => 0, - 'scheduling_plan_id' => 0, - 'company_id' => $params['company_id'], - 'title' => $params['title'], - 'money' => 0, - 'type' => 0, - 'status' => $params['status'], - 'content' => $params['content'], - 'start_time' => time(), - 'end_time' => strtotime($params['end_time']), - 'director_uid' => $params['director_uid'], // 指派给负责人 - 'create_time' => time(), - 'update_time' => time(), - ]; - $task_id = (new Task())->insertGetId($arr); return $this->success('添加成功', ['task_id' => $task_id]); } diff --git a/app/adminapi/lists/user/UserLists.php b/app/adminapi/lists/user/UserLists.php index b6f7005f..ce14a98b 100644 --- a/app/adminapi/lists/user/UserLists.php +++ b/app/adminapi/lists/user/UserLists.php @@ -40,7 +40,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function setSearch(): array { - $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end', 'province', 'city', 'area', 'street', 'village']; + $allowSearch = ['keyword','channel', 'create_time_start', 'create_time_end', 'province', 'city', 'area', 'street', 'village']; return array_intersect(array_keys($this->params), $allowSearch); } @@ -56,10 +56,16 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function lists(): array { - + $params = $this->params; $field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract,group_id,invite_code"; $lists = User::withSearch($this->setSearch(), $this->params) + ->when(!empty($params['nickname']),function($query)use($params){ + $query->where('nickname', 'like', '%' . $this->params['nickname'] . '%'); + }) + ->when(!empty($params['group_id']),function($query)use($params){ + $query->where('group_id', $params['group_id']); + }) ->append(['role_name']) ->with(['company']) ->withAttr('role_name', function ($value, $data){ @@ -71,7 +77,6 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface ->order('id desc') ->select() ->toArray(); - foreach ($lists as &$item) { $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']); $inviteUserStatistics = ShopRequestLogic::getInviteUserInfo(['promotion_code' => $item['invite_code']]); @@ -92,7 +97,13 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function count(): int { - return User::withSearch($this->setSearch(), $this->params)->count(); + $params = $this->params; + return User::withSearch($this->setSearch(), $this->params) ->when(!empty($params['nickname']),function($query)use($params){ + $query->where('nickname', 'like', '%' . $this->params['nickname'] . '%'); + }) + ->when(!empty($params['group_id']),function($query)use($params){ + $query->where('group_id', $params['group_id']); + })->count(); }