diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index b2c537cfa..65c1a46da 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2885,6 +2885,23 @@ function getAdminUsernameList(array $ids) return $items; } +function getAdminDepartmentList(array $ids) +{ + if (count($ids) == 0) { + return []; + } + $rows = M('auth_group_access', 'sys_')->field(['uid', 'group_id'])->where(['uid' => ['in', $ids]])->select(); + $groups = M('auth_group', 'sys_')->field(['id', 'department_id', 'department_name'])->where(['uid' => ['in', array_column($rows, 'group_id')]])->select(); + $groups = index_by_column('id', $groups); + $items = []; + foreach ($rows as $row) { + $group = $groups[$row['group_id']] ?? null; + $items[$row['uid']] = $group ? $group['department_name'] : '--'; + } + return $items; +} + + function isMarketLeader() { if(IS_SUBSITE){ @@ -2919,9 +2936,9 @@ function isMarketAdmin() * 获取市场专员 * */ -function getMarketAdmin() { - - $map['group_id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()]; +function getMarketAdmin($departmentId = null) { + $map = []; + $map['group_id'] = ['in',A("Market","Event")->getNoLeaderMarketGroupId($departmentId)]; $data = M("auth_group_access") ->field("real_name,menber.uid,nickname") diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index b32b2477c..c59a1b101 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -664,4 +664,11 @@ class AjaxController extends ThinkController{ $promotes = M('promote', 'tab_')->where($companyMap)->field(['id', 'account'])->select(); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['promotes' => $promotes]]); } + + public function getAdminsByDepartment() + { + $departmentId = I('department_id', 0); + $admins = getMarketAdmin($departmentId); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['admins' => $admins]]); + } } \ No newline at end of file diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 01b480c80..2c63ca9b5 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -142,7 +142,9 @@ class FinancePromoteController extends AdminController } } $promotes = index_by_column('id', $promotes); - $adminUsernames = getAdminUsernameList(array_column($promotes, 'admin_id')); + $adminIds = array_column($promotes, 'admin_id'); + $adminUsernames = getAdminUsernameList($adminIds); + $adminDepartments = getAdminDepartmentList($adminIds); foreach($senddata as $k=>$v){ $promote = $promotes[$v['p_id']] ?? null; $v['company_belong'] = $v['company_belong'] ?:0; @@ -156,6 +158,7 @@ class FinancePromoteController extends AdminController $v['promote_account'] = get_promote_name($v['p_id']); ($v['promote_account']=='官方渠道')?($v['promote_account']=C('OFFICIEL_CHANNEL')):''; $v['admin_username'] = $adminUsernames[$promote['admin_id']] ?? '无'; + $v['admin_department'] = $adminDepartments[$promote['admin_id']] ?? '无'; $v['develop_type_text'] = getCompanyDevelopTypeText($v['develop_type']); $v['inside_cash_count'] = number_format($v['inside_cash_count'],2,'.',''); $v['allcount'] = number_format($v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'],2,'.',''); @@ -179,6 +182,7 @@ class FinancePromoteController extends AdminController "company_name"=>"推广公司", "promote_account"=>"会长渠道", "admin_username"=>"所属市场专员", + "admin_department"=>"所属市场部", "company_belong"=>"团体类型", "develop_type_text"=>"开发类型", "cash_count"=>"游戏现金金额", @@ -219,6 +223,9 @@ class FinancePromoteController extends AdminController $this->checkListOrCountAuthRestMap($map,[]); + $departments = M('department', 'sys_')->select(); + $this->assign('departments', $departments); + //外团占比 $this->assign('outBelong',number_format($outBelong/$count['all_count']*100,2,'.','')); //内团占比 @@ -264,21 +271,22 @@ class FinancePromoteController extends AdminController $map['company.develop_type'] = ['in',I('develop_type')]; } - $adminId = 0; + $adminIds = null; // $havingPids = []; $isMarketAdmin = isMarketAdmin(); if ($isMarketAdmin) { $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; + $adminIds = [$userAuth['uid']]; } else { if (!empty(I('admin_id'))) { - $adminId = I('admin_id'); + $adminIds = [I('admin_id')]; } } - /* if ($adminId > 0) { - $havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true); - $havingPids = count($havingPids) > 0 ? $havingPids : [0]; - } */ + + if (is_null($adminIds) && isset($_REQUEST['department_id'])) { + $admins = getMarketAdmin($_REQUEST['department_id']); + $adminIds = count($admins) ? array_column($admins, 'uid') : [-1]; + } if($type == "spend"){ if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { @@ -290,8 +298,8 @@ class FinancePromoteController extends AdminController if ($isMarketLeader) { $map['s.market_admin_id'] = ['gt', 0]; } - if ($adminId > 0) { - $map['s.market_admin_id'] = $adminId; + if (is_array($adminIds)) { + $map['s.market_admin_id'] = ['in', $adminIds]; } $map['s.pay_status']=1; $map['s.is_check']=2; @@ -348,22 +356,23 @@ class FinancePromoteController extends AdminController if (!empty(I('develop_type'))) { $map['company.develop_type'] = ['in',I('develop_type')]; } - - $adminId = 0; + + $adminIds = null; // $havingPids = []; $isMarketAdmin = isMarketAdmin(); if ($isMarketAdmin) { $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; + $adminIds = [$userAuth['uid']]; } else { if (!empty(I('admin_id'))) { - $adminId = I('admin_id'); + $adminIds = [I('admin_id')]; } } - /* if ($adminId > 0) { - $havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true); - $havingPids = count($havingPids) > 0 ? $havingPids : [0]; - } */ + + if (is_null($adminIds) && isset($_REQUEST['department_id'])) { + $admins = getMarketAdmin($_REQUEST['department_id']); + $adminIds = count($admins) ? array_column($admins, 'uid') : [-1]; + } if($type == "spend"){ if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { @@ -375,8 +384,8 @@ class FinancePromoteController extends AdminController if ($isMarketLeader) { $map['s.market_admin_id'] = ['gt', 0]; } - if ($adminId > 0) { - $map['s.market_admin_id'] = $adminId; + if (is_array($adminIds)) { + $map['s.market_admin_id'] = ['in', $adminIds]; } $map['s.pay_status']=1; // $map['s.is_check']=1; @@ -400,20 +409,9 @@ class FinancePromoteController extends AdminController if($istimeselect){ $map['s.create_time']=$istimeselect; } - $adminId = 0; - // $havingPids = []; - $isMarketAdmin = isMarketAdmin(); - if ($isMarketAdmin) { - $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; - } else { - if (!empty(I('admin_id'))) { - $adminId = I('admin_id'); - } - } - if ($adminId > 0) { - $map['promote.admin_id'] = $adminId; - // $havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true); + if (is_array($adminIds)) { + $map['promote.admin_id'] = ['in', $adminIds]; + // $havingPids = M('promote', 'tab_')->where(['admin_id' => ['in', $adminIds]])->getField('id', true); // $havingPids = count($havingPids) > 0 ? $havingPids : [0]; } $map['s.status']=1; diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index c7817f566..369df1ee5 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -30,11 +30,12 @@ class MarketEvent extends Controller /** * 获取市场专员gid(除了总监) */ - public function getNoLeaderMarketGroupId() + public function getNoLeaderMarketGroupId($departmentId = null) { + $departmentIds = $departmentId ? [$departmentId] : $this->MarketDepartmentId; $where = [ - "department_id"=>['in',$this->MarketDepartmentId], - "department_level"=>['neq',$this->DirectorLevel] + "department_id"=>['in', $departmentIds], + "department_level"=>['neq', $this->DirectorLevel] ]; $dbres = M('auth_group','sys_')->where($where)->getField("id",true); return implode(",",$dbres); diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index c6605e1b5..7da9ab751 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -137,6 +137,15 @@ +
+ +
+