From 92721fca42900f607fb213c494656cb9a27c250e Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Thu, 30 Mar 2023 12:16:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=95=86=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminapi/controller/v1/agent/AgentManage.php | 2 +- .../app/adminapi/controller/v1/agent/Division.php | 9 +++++++-- crmeb/app/dao/BaseDao.php | 4 +++- crmeb/app/dao/user/UserDao.php | 1 + crmeb/app/services/agent/DivisionServices.php | 10 ++++++++-- crmeb/app/services/user/UserServices.php | 1 + template/admin/src/pages/division/agent/index.vue | 10 +++++----- template/admin/src/pages/division/list/index.vue | 15 +++++---------- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/agent/AgentManage.php b/crmeb/app/adminapi/controller/v1/agent/AgentManage.php index 7decf21f9..0383da60e 100644 --- a/crmeb/app/adminapi/controller/v1/agent/AgentManage.php +++ b/crmeb/app/adminapi/controller/v1/agent/AgentManage.php @@ -60,7 +60,7 @@ class AgentManage extends AuthController public function get_badge() { $where = $this->request->getMore([ - ['data', ''], + ['data', '', '', 'time'], ['nickname', ''], ]); return app('json')->success(['res' => $this->services->getSpreadBadge($where)]); diff --git a/crmeb/app/adminapi/controller/v1/agent/Division.php b/crmeb/app/adminapi/controller/v1/agent/Division.php index cbdc965ca..50cf1baa5 100644 --- a/crmeb/app/adminapi/controller/v1/agent/Division.php +++ b/crmeb/app/adminapi/controller/v1/agent/Division.php @@ -121,19 +121,24 @@ class Division extends AuthController * 保存代理商 * @param UserServices $userServices * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function divisionAgentSave(UserServices $userServices) { $data = $this->request->postMore([ + ['division_id', 0], ['uid', 0], ['division_percent', 0], ['division_end_time', ''], ['division_status', 1], ['edit', 0], ]); - $userInfo = $userServices->get((int)$data['uid']); + $userInfo = $userServices->count(['uid' => (int)$data['uid']]); if (!$userInfo) throw new AdminException(100100); - $data['division_id'] = $this->adminInfo['division_id']; + $divisionUserInfo = $userServices->count(['uid' => (int)$data['division_id'], 'is_division' => 1, 'division_id' => $data['division_id']]); + if (!$divisionUserInfo) throw new AdminException(100100); $this->services->divisionAgentSave($data); return app('json')->success(100000); } diff --git a/crmeb/app/dao/BaseDao.php b/crmeb/app/dao/BaseDao.php index d1e69ece7..8563bd493 100644 --- a/crmeb/app/dao/BaseDao.php +++ b/crmeb/app/dao/BaseDao.php @@ -304,13 +304,14 @@ abstract class BaseDao $with = []; $otherWhere = []; $responses = new \ReflectionClass($this->setModel()); + foreach ($where as $key => $value) { $method = 'search' . Str::studly($key) . 'Attr'; if ($responses->hasMethod($method)) { $with[] = $key; } else { if ($key != 'timeKey') { - $otherWhere[] = $value; + $otherWhere[] = is_array($value) ? $value : [$key, '=', $value]; } } } @@ -320,6 +321,7 @@ abstract class BaseDao /** * 根据搜索器获取搜索内容 * @param $where + * @param $search * @return BaseModel * @throws \ReflectionException * @author 吴汐 diff --git a/crmeb/app/dao/user/UserDao.php b/crmeb/app/dao/user/UserDao.php index 715374a5c..3c5a74a39 100644 --- a/crmeb/app/dao/user/UserDao.php +++ b/crmeb/app/dao/user/UserDao.php @@ -176,6 +176,7 @@ class UserDao extends BaseDao * 获取推广员ids * @param array $where * @return array + * @throws \ReflectionException */ public function getAgentUserIds(array $where) { diff --git a/crmeb/app/services/agent/DivisionServices.php b/crmeb/app/services/agent/DivisionServices.php index cfdb5a65a..ddcfab914 100644 --- a/crmeb/app/services/agent/DivisionServices.php +++ b/crmeb/app/services/agent/DivisionServices.php @@ -222,9 +222,11 @@ class DivisionServices extends BaseServices if ($uid && !$userInfo) throw new AdminException(400214); $field = []; if ($uid) { + $field[] = Form::number('division_id', '事业部UID', $userInfo['division_id'] ?? '')->disabled(true)->style(['width' => '173px']); $field[] = Form::number('uid', '用户UID', $userInfo['uid'] ?? '')->disabled(true)->style(['width' => '173px']); $field[] = Form::hidden('edit', 1); } else { + $field[] = Form::number('division_id', '事业部UID')->style(['width' => '173px']); $field[] = Form::number('uid', '用户UID')->style(['width' => '173px']); $field[] = Form::hidden('edit', 0); } @@ -238,20 +240,24 @@ class DivisionServices extends BaseServices * 保存代理商 * @param $data * @return bool + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException */ public function divisionAgentSave($data) { /** @var UserServices $userServices */ $userServices = app()->make(UserServices::class); $uid = $data['uid']; - $userInfo = $userServices->getUserInfo($uid, 'is_division,division_id,agent_id'); $agentData = [ + 'division_id' => $data['division_id'], 'division_status' => $data['division_status'], 'division_percent' => $data['division_percent'], 'division_change_time' => time(), 'division_end_time' => strtotime($data['division_end_time']), + 'division_type' => 2, ]; - $division_info = $userServices->getUserInfo($userInfo['division_id'], 'division_end_time,division_percent'); + $division_info = $userServices->getUserInfo($data['division_id'], 'division_end_time,division_percent'); if ($division_info) { if ($agentData['division_percent'] > $division_info['division_percent']) throw new AdminException(400448); if ($agentData['division_end_time'] > $division_info['division_end_time']) throw new AdminException(400449); diff --git a/crmeb/app/services/user/UserServices.php b/crmeb/app/services/user/UserServices.php index 408b5e9f9..dd15649fd 100644 --- a/crmeb/app/services/user/UserServices.php +++ b/crmeb/app/services/user/UserServices.php @@ -237,6 +237,7 @@ class UserServices extends BaseServices * 获取分销员ids * @param array $where * @return array + * @throws \ReflectionException */ public function getAgentUserIds(array $where) { diff --git a/template/admin/src/pages/division/agent/index.vue b/template/admin/src/pages/division/agent/index.vue index 556e2403b..7c0ad66b1 100644 --- a/template/admin/src/pages/division/agent/index.vue +++ b/template/admin/src/pages/division/agent/index.vue @@ -27,6 +27,11 @@ + + + + +