From c89d1540e7fa8093670c3344dd1934d23dbaa7ae Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 19 Jul 2021 18:11:04 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/OldCountController.class.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 8bf3a519c..5cd2c9094 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -9,6 +9,70 @@ namespace Admin\Controller; */ class OldCountController extends \Think\Controller { + /** + * 新增市场部其他用户组 + */ + public function moreDepartment() + { + //1.新增组 + $manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find(); + $dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select(); + foreach ($dbres as &$v) { + if($v['id'] == 25){ + $v['rules'] = $manager['rules']; + $v['data_empower_type'] =3; + $v['show_data'] =1; + $v['show_market_admin'] =1; + $v['show_promote'] =1; + } + $v['title'] = "一部".$v['title']; + $v['department_id'] = 1; + $v['department_name'] = "市场一部"; + M('auth_group','sys_')->save($v); + + unset($v['id']); + $v['title'] = str_replace("一部","二部",$v['title']); + $v['department_id'] = 2; + $v['department_name'] = '市场二部'; + M('auth_group','sys_')->add($v); + } + + //2.增加配置 + M("kv")->add([ + 'key'=>"market_manager_group_ids", + 'value'=>'25,30', + 'type'=>'string', + 'remark'=>'市场经理组id' + ]); + M("kv")->add([ + 'key'=>"market_director_group_ids", + 'value'=>'14,28', + 'type'=>'string', + 'remark'=>'市场总监组id' + ]); + //3.增加部门表数据 + M("department")->add([ + 'id'=>1, + 'name'=>'市场一部', + 'group_ids'=>'11,12,14,21,25', + 'leader_group'=>'14', + 'create_time'=>time(), + 'update_time'=>time() + ]); + M("department")->add([ + 'id'=>2, + 'name'=>'市场二部', + 'group_ids'=>'26,27,28,29,30', + 'leader_group'=>'28', + 'create_time'=>time(), + 'update_time'=>time() + ]); + + + } + + + //删除吴宏还是高级时候的数据 public function deleteWuhongAltogether() { From 4b28077e12082b960fb8238b7d932dcfe1e29de2 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 20 Jul 2021 11:22:41 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E9=83=A8=E9=83=A8=E9=97=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/AuthManagerController.class.php | 7 +++++++ Application/Admin/Event/MarketEvent.class.php | 18 ++++++++++++++++++ Application/Admin/View/AuthManager/index.html | 14 ++++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 Application/Admin/Event/MarketEvent.class.php diff --git a/Application/Admin/Controller/AuthManagerController.class.php b/Application/Admin/Controller/AuthManagerController.class.php index d709568a9..586701fd3 100644 --- a/Application/Admin/Controller/AuthManagerController.class.php +++ b/Application/Admin/Controller/AuthManagerController.class.php @@ -92,8 +92,15 @@ class AuthManagerController extends AdminController{ public function index(){ $list = $this->lists('AuthGroup',array('module'=>'admin'),'id asc',true,true); $list = int_to_string($list); + foreach ($list as &$v) { + if(empty($v['department_name'])) $v['department_name'] = "--"; + } $this->assign( '_list', $list ); $this->assign( '_use_tip', true ); + + $marketGroup = A("Market","Event")->getMarketGroupId(); + $this->assign( 'market_group', explode(",",$marketGroup)); + $this->meta_title = '权限管理'; $this->checkListOrCountAuthRestMap($map,[]); diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php new file mode 100644 index 000000000..00c2a1991 --- /dev/null +++ b/Application/Admin/Event/MarketEvent.class.php @@ -0,0 +1,18 @@ +where("id in ({$this->MarketDepartmentId})")->getField("group_ids",true); + $sendData = ''; + foreach ($res as $value) { + $sendData .= $value.","; + } + return rtrim($sendData,","); + } +} \ No newline at end of file diff --git a/Application/Admin/View/AuthManager/index.html b/Application/Admin/View/AuthManager/index.html index 4f79999c7..6e154ae31 100644 --- a/Application/Admin/View/AuthManager/index.html +++ b/Application/Admin/View/AuthManager/index.html @@ -22,6 +22,8 @@ 用户组 详情 + 部门 + 授权 状态 操作 @@ -33,11 +35,7 @@ - - {$vo.title} - - {$vo.title} - + {$vo.title} @@ -48,13 +46,17 @@ + + {$vo.department_name} + + 访问授权 成员授权 分类授权 数据授权 - + 市场专员分成 From 8ebecb551762bbab99d7760b1ca7994692bda3ca Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 20 Jul 2021 20:16:40 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E7=BB=A9=E6=95=88=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MarketPerformanceSetController.class.php | 97 ++++++++------- .../Controller/OldCountController.class.php | 116 ++++++++++-------- .../Controller/TimingController.class.php | 9 +- Application/Admin/Event/MarketEvent.class.php | 39 ++++++ 4 files changed, 159 insertions(+), 102 deletions(-) diff --git a/Application/Admin/Controller/MarketPerformanceSetController.class.php b/Application/Admin/Controller/MarketPerformanceSetController.class.php index 0cf9806bd..b0e40de65 100644 --- a/Application/Admin/Controller/MarketPerformanceSetController.class.php +++ b/Application/Admin/Controller/MarketPerformanceSetController.class.php @@ -246,7 +246,12 @@ class MarketPerformanceSetController extends Controller { $userid = array_merge(array_keys($value),$userid); } $userid = array_unique($userid); - $this->marketUserInfo = M("member")->where(["uid"=>['in',$userid]])->getField("uid,real_name",true); + $this->marketUserInfo = M("auth_group_access") + ->alias("acc") + ->where(["acc.uid"=>['in',$userid]]) + ->join("sys_member as mem on acc.uid = mem.uid") + ->join("sys_auth_group as gro on acc.group_id = gro.id") + ->getField("acc.uid,mem.real_name,gro.department_id",true); } /** @@ -468,7 +473,8 @@ class MarketPerformanceSetController extends Controller { $baseArr = $this->companyInfo[$company_id]; $baseArr['pay_time'] = $this->date; $baseArr['is_settlement'] = 1; - $baseArr['real_name'] = $this->marketUserInfo[$markertUserId]; + $baseArr['real_name'] = $this->marketUserInfo[$markertUserId]['real_name']; + $baseArr['department_id'] = $this->marketUserInfo[$markertUserId]['department_id']; $baseArr['admin_id'] = $markertUserId; foreach ($games as $k => $v) { $game = $this->gameInfo[$k]; @@ -520,54 +526,51 @@ class MarketPerformanceSetController extends Controller { public function marketManagerSet($count_date) { if(!$this->isInit) $this->configInit($count_date); - - $marketManagerGroupId = "25"; - $this->marketAltogetherModel->where(['pay_time'=>$this->date,'level'=>$marketManagerGroupId])->delete(); - //获取毛利统计 - $dbres = $this->settleupMarketorderModel->where(['pay_time'=>$this->date])->field("sum(pay_amount) pay_amount,sum(refund_amount) refund_amount,develop_type")->group('develop_type')->select(); - $count = [ - 'pay_amount'=>0, - 'performance_revenue'=>0, - 'appraisal_bonuses'=>0 - ]; - foreach ($dbres as $k => $v) { - $tmpPayAmount = $v['pay_amount']-$v['refund_amount']; - $count['pay_amount'] += $tmpPayAmount; - if($v['develop_type'] == 3){ - $count['appraisal_bonuses'] += $tmpPayAmount; - }else{ - $count['performance_revenue'] += $tmpPayAmount; + //获取所有的经理 + $MarketEvent = A("Market","Event"); + $level = $MarketEvent->getConfig('ManagerLevel'); + $this->marketAltogetherModel->where(['pay_time'=>$this->date,'level'=>$level])->delete(); + $markertManager = $MarketEvent->getManagerPerformanInfo(); + if(!$markertManager) return; + foreach ($markertManager as $k => $manager) { + //获取毛利统计 + $dbres = $this->settleupMarketorderModel->where(['pay_time'=>$this->date,'department_id'=>$manager['department_id']])->field("sum(pay_amount) pay_amount,sum(refund_amount) refund_amount,develop_type")->group('develop_type')->select(); + $count = [ + 'pay_amount'=>0, + 'performance_revenue'=>0, + 'appraisal_bonuses'=>0 + ]; + foreach ($dbres as $k => $v) { + $tmpPayAmount = $v['pay_amount']-$v['refund_amount']; + $count['pay_amount'] += $tmpPayAmount; + if($v['develop_type'] == 3){ + $count['appraisal_bonuses'] += $tmpPayAmount; + }else{ + $count['performance_revenue'] += $tmpPayAmount; + } } - } - //获取经理配置及经理 - $config = M("auth_group")->where("id = {$marketManagerGroupId}")->getField("market_percentage"); - $config = json_decode($config,true); - $user = M("auth_group_access")->alias("access")->join("left join sys_member member on access.uid=member.uid")->where(['group_id'=>$marketManagerGroupId])->field("access.uid,real_name,nickname")->select(); - if(!$user) return; - //获取经理抽成公式 - $achievement_bonus = round(($count['appraisal_bonuses']*$config['maintain_appraisal_bonuses_ratio'] + $count['performance_revenue']*$config['appraisal_bonuses_ratio'])/100,2); - $baseData = [ - 'pay_time'=>$this->date, - 'level'=>$marketManagerGroupId, - 'pay_amount' => $count['pay_amount'], - 'extend_commission'=> round($achievement_bonus*$config['month_bonus_ratio']/100,2), - 'wait_commission' => round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2), - 'create_time'=>time(), - 'performance_revenue'=>$count['performance_revenue'], - 'appraisal_bonuses'=>$count['appraisal_bonuses'], - 'achievement_bonus'=>$achievement_bonus, - 'wait_achievement_commission'=>round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2) - ]; - foreach ($user as $k=> $v) { - $baseData['real_name'] = $v['real_name']; - $baseData['nickname'] = $v['nickname']; - $baseData['admin_id'] = $v['uid']; - - $res = $this->marketAltogetherModel->add($baseData); + $config = json_decode($manager['market_percentage'],true); + $achievement_bonus = round(($count['appraisal_bonuses']*$config['maintain_appraisal_bonuses_ratio'] + $count['performance_revenue']*$config['appraisal_bonuses_ratio'])/100,2); - echo "marketManagerSet {$v['real_name']}/{$res}".PHP_EOL; + $baseData = [ + 'pay_time'=>$this->date, + 'level'=>$level, + 'pay_amount' => $count['pay_amount'], + 'extend_commission'=> round($achievement_bonus*$config['month_bonus_ratio']/100,2), + 'wait_commission' => round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2), + 'create_time'=>time(), + 'performance_revenue'=>$count['performance_revenue'], + 'appraisal_bonuses'=>$count['appraisal_bonuses'], + 'achievement_bonus'=>$achievement_bonus, + 'wait_achievement_commission'=>round($achievement_bonus*(100-$config['month_bonus_ratio'])/100,2), + 'real_name'=>$manager['real_name'], + 'admin_id'=>$manager['uid'], + 'nickname'=>$manager['nickname'], + 'department_id'=>$manager['department_id'] + ]; + $res = $this->marketAltogetherModel->add($baseData); + echo "marketManagerSet {$manager['real_name']}/{$res}".PHP_EOL; } - } /** * 设置每月第一个周一自动重算 diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 5cd2c9094..60df464d3 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -15,59 +15,67 @@ class OldCountController extends \Think\Controller public function moreDepartment() { //1.新增组 - $manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find(); - $dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select(); - foreach ($dbres as &$v) { - if($v['id'] == 25){ - $v['rules'] = $manager['rules']; - $v['data_empower_type'] =3; - $v['show_data'] =1; - $v['show_market_admin'] =1; - $v['show_promote'] =1; - } - $v['title'] = "一部".$v['title']; - $v['department_id'] = 1; - $v['department_name'] = "市场一部"; - M('auth_group','sys_')->save($v); - - unset($v['id']); - $v['title'] = str_replace("一部","二部",$v['title']); - $v['department_id'] = 2; - $v['department_name'] = '市场二部'; - M('auth_group','sys_')->add($v); - } + // $manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find(); + // $dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select(); + // foreach ($dbres as &$v) { + // if($v['id'] == 25){ + // $v['rules'] = $manager['rules']; + // $v['data_empower_type'] =3; + // $v['show_data'] =1; + // $v['show_market_admin'] =1; + // $v['show_promote'] =1; + // } + // if(mb_strpos($v['title'],"初级")){ + // $v['department_level'] = 1; + // } + // if(mb_strpos($v['title'],"中级")){ + // $v['department_level'] = 2; + // } + // if(mb_strpos($v['title'],"高级")){ + // $v['department_level'] = 3; + // } + // if(mb_strpos($v['title'],"经理")){ + // $v['department_level'] = 4; + // } + // if(mb_strpos($v['title'],"总监")){ + // $v['department_level'] = 5; + // } + // $v['title'] = "一部".$v['title']; + // $v['department_id'] = 1; + // $v['department_name'] = "市场一部"; + // M('auth_group','sys_')->save($v); + + // unset($v['id']); + // $v['title'] = str_replace("一部","二部",$v['title']); + // $v['department_id'] = 2; + // $v['department_name'] = '市场二部'; + // M('auth_group','sys_')->add($v); + // } - //2.增加配置 - M("kv")->add([ - 'key'=>"market_manager_group_ids", - 'value'=>'25,30', - 'type'=>'string', - 'remark'=>'市场经理组id' - ]); - M("kv")->add([ - 'key'=>"market_director_group_ids", - 'value'=>'14,28', - 'type'=>'string', - 'remark'=>'市场总监组id' - ]); - //3.增加部门表数据 - M("department")->add([ - 'id'=>1, - 'name'=>'市场一部', - 'group_ids'=>'11,12,14,21,25', - 'leader_group'=>'14', - 'create_time'=>time(), - 'update_time'=>time() - ]); - M("department")->add([ - 'id'=>2, - 'name'=>'市场二部', - 'group_ids'=>'26,27,28,29,30', - 'leader_group'=>'28', - 'create_time'=>time(), - 'update_time'=>time() - ]); + //3.增加部门表数据 + // M("department")->add([ + // 'id'=>1, + // 'name'=>'市场一部', + // 'group_ids'=>'11,12,14,21,25', + // 'leader_group'=>'14', + // 'create_time'=>time(), + // 'update_time'=>time() + // ]); + // M("department")->add([ + // 'id'=>2, + // 'name'=>'市场二部', + // 'group_ids'=>'26,27,28,29,30', + // 'leader_group'=>'28', + // 'create_time'=>time(), + // 'update_time'=>time() + // ]); + + //4.修改旧等级 + // M("market_altogether","tab_")->where("level = 21")->save(['level'=>1]); + // M("market_altogether","tab_")->where("level = 11")->save(['level'=>2]); + // M("market_altogether","tab_")->where("level = 12")->save(['level'=>3]); + // M("market_altogether","tab_")->where("level = 25")->save(['level'=>4]); } @@ -755,6 +763,12 @@ class OldCountController extends \Think\Controller } return $time_arr; } + public function eventTest($event,$action) + { + $Event = A($event,"Event"); + $res = $Event->$action(); + dd($res); + } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 216b75332..540809b69 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -853,11 +853,12 @@ class TimingController extends AdminController { public function insertAllUserBonus($time) { // $time = $_REQUEST['time']; + $groupIds = A("Market","Event")->getGeneralMarketGroup(); $data = M("member") - ->field("access.uid admin_id,real_name,nickname,group_id level") + ->field("access.uid admin_id,real_name,nickname,auth.department_level level") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id'=>['in','11,12,21']]) + ->where(['group_id'=>['in',$groupIds]]) ->select(); foreach ($data as $key => $value) { @@ -909,13 +910,13 @@ class TimingController extends AdminController { } $map['is_settlement'] = 1; - + $groupIds = A("Market","Event")->getGeneralMarketGroup(); //获取admin_id $accessData = M("auth_group_access") ->alias("access") ->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_member member on access.uid=member.uid") - ->where(['group_id'=>['in','11,12,21']]) + ->where(['group_id'=>['in',$groupIds]]) ->getField("access.uid,group_id,market_percentage,nickname"); $all_data = SM("settleup_marketorder","tab_") diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index 00c2a1991..c46067bbc 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -6,6 +6,10 @@ use Think\Controller; class MarketEvent extends Controller { private $MarketDepartmentId = "1,2"; + private $ManagerLevel = "4"; + /** + * 获取所有市场部组id + */ public function getMarketGroupId() { $res = M('department','sys_')->where("id in ({$this->MarketDepartmentId})")->getField("group_ids",true); @@ -15,4 +19,39 @@ class MarketEvent extends Controller } return rtrim($sendData,","); } + /** + * 获取普通的市场专员(初中高)的gid + */ + public function getGeneralMarketGroup() + { + $where = [ + "department_id"=>['in',$this->MarketDepartmentId], + "department_level"=>['LT',4] + ]; + $dbres = M('auth_group','sys_')->where($where)->getField("id",true); + return implode(",",$dbres); + } + /** + * 获取经理信息 + */ + public function getManagerPerformanInfo() + { + $where = [ + "department_id"=>['in',$this->MarketDepartmentId], + "department_level"=>['eq',$this->ManagerLevel] + ]; + $dbres = M('auth_group','sys_')->where($where)->getField("id",true); + $market = M("auth_group_access") + ->alias("acc") + ->where(["acc.group_id"=>['in',$dbres]]) + ->join("sys_member as mem on acc.uid = mem.uid") + ->join("sys_auth_group as gro on acc.group_id = gro.id") + ->getField("acc.uid,mem.nickname,mem.real_name,gro.department_id,gro.market_percentage",true); + return $market; + } + public function getConfig($key) + { + return $this->$key; + } + } \ No newline at end of file From b679708156cc895a696706cd9e64e36e79caaa80 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 20 Jul 2021 20:25:29 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/TimingController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 540809b69..9e1a14f25 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -917,7 +917,7 @@ class TimingController extends AdminController { ->join("left join sys_auth_group auth on access.group_id=auth.id") ->join("left join sys_member member on access.uid=member.uid") ->where(['group_id'=>['in',$groupIds]]) - ->getField("access.uid,group_id,market_percentage,nickname"); + ->getField("access.uid,auth.department_level level,group_id,market_percentage,nickname"); $all_data = SM("settleup_marketorder","tab_") ->field("id,admin_id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name, @@ -1004,7 +1004,7 @@ class TimingController extends AdminController { $insert['admin_id'] = $value['admin_id']; $insert['nickname'] = $value['nickname']; - $insert['level'] = $value['group_id']; + $insert['level'] = $value['level']; $insert['pay_amount'] = $value['pay_amount']; $insert['extend_commission'] = substr( number_format(($all_data[$key]['performance_commission'] * ($market_percentage['performance_monthly_ratio']/100) From b0ac054745e30a39e9069da66360d9af49679abb Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 21 Jul 2021 12:31:35 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Event/MarketEvent.class.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index c46067bbc..4a4ca1938 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -7,6 +7,7 @@ class MarketEvent extends Controller { private $MarketDepartmentId = "1,2"; private $ManagerLevel = "4"; + private $DirectorLevel = "5"; /** * 获取所有市场部组id */ @@ -49,9 +50,78 @@ class MarketEvent extends Controller ->getField("acc.uid,mem.nickname,mem.real_name,gro.department_id,gro.market_percentage",true); return $market; } + /** + * 获取配置信息 + * @param [string] $key + * @return void + */ public function getConfig($key) { return $this->$key; } + public function isMarketAdminGroup($gid) + { + $where = [ + "department_id"=>['in',$this->MarketDepartmentId], + "id"=>$gid + ]; + return M('auth_group','sys_')->field("id,department_id,department_level")->where($where)->find(); + } + + public function isDepartmentLeder($department_id,$uid) + { + $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); + return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find(); + } + + public function getDepartmentUserId($department_id) + { + $res = M("auth_group_access") + ->alias("acc") + ->field("acc.uid") + ->where(['gro.department_id'=>$department_id]) + ->join("sys_member as mem on acc.uid = mem.uid") + ->join("sys_auth_group as gro on acc.group_id = gro.id") + ->select(); + return array_column($res,'uid'); + } + + public function getAdminCompanyId() + { + if (!empty(session('user_auth_company_ids'))) { + return session('user_auth_company_ids'); + } + $userAuth = session('user_auth'); + $companyIds = 'all'; + $userAuth['data_president']= trim($userAuth['data_president'], ","); + if (!empty($userAuth['data_empower_type'])) {//数据权限 1 全部 2 部分数据 3 自己底下的会长 + //等于1默认全部数据,不进行筛选 + if (in_array($userAuth['data_empower_type'], [2, 3])) { + $companyIds = ''; + //自己创建的会长 + $myPromote_ids = M('promote', 'tab_') + ->field('GROUP_CONCAT(id) as promote_ids') + ->where(['admin_id' => $userAuth['uid']]) + ->find(); + $myPromote_ids = $myPromote_ids['promote_ids']; + if ($myPromote_ids) { + if ($userAuth['data_empower_type'] == 2) {//部分会长加上自己创建的会长 + + // $userAuth['data_president'] .= "," . $myPromote_ids; + } elseif ($userAuth['data_empower_type'] == 3) {//自己创建的会长和底下推广员 + $userAuth['data_president'] = $myPromote_ids; + } + } + $dbres = M('promote', 'tab_') + ->field('company_id') + ->where(['id' =>['in',$userAuth['data_president']],'level'=>1]) + ->group('company_id') + ->getField('company_id',true); + $companyIds = implode(",",$dbres); + } + } + session('user_auth_company_ids', $companyIds); + return $companyIds; + } } \ No newline at end of file From f66b7088e3cb603830b8a9127f2cda8fbb2acd17 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 21 Jul 2021 12:31:53 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 18 +++---- Application/Admin/Common/function.php | 9 +++- .../MarketPercentageController.class.php | 51 ++++++++++++------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 8cf3a1c3e..21d8119c0 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2917,13 +2917,7 @@ function isMarketAdmin() */ function getMarketAdmin() { - $map['group_id'] = ['in','11,12,21,25']; - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['menber.uid'] = $admin_id; - if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23||session('user_group_id') == 25) { - unset($map['menber.uid']); - } - + $map['group_id'] =['in',A("Market","Event")->getMarketGroupId()]; $data = M("auth_group_access") ->field("real_name,menber.uid,nickname") ->join("left join sys_member menber on sys_auth_group_access.uid = menber.uid") @@ -3116,11 +3110,11 @@ function promote_listsMarket($type){ setPowerPromoteIds($map,'id'); - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['admin_id'] = $admin_id; - if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) { - unset($map['admin_id']); - } + // $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + // $map['admin_id'] = $admin_id; + // if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) { + // unset($map['admin_id']); + // } $data = M('promote','tab_')->where($map)->select(); diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 185a6143b..b77be82d9 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -617,9 +617,16 @@ function getAllGame() */ function getPromoteCompany() { + $companyId = A("Market","Event")->getAdminCompanyId(); + $where = [ + "status"=>1 + ]; + if($companyId != 'all'){ + $where['id'] = ["in",$companyId]; + } $list = M("PromoteCompany", 'tab_') ->field('id,company_name') - ->where("status = 1") + ->where($where) ->select(); array_unshift($list,array("id"=>0,"company_name"=>C(DEFAULT_COMPANY)));//默认0 return $list; diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 50485731b..6f7b3423b 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -17,6 +17,7 @@ class MarketPercentageController extends ThinkController private $leavePercentage; private $unSettlementList; private $marketPercentage; + private $MarketEvent; private $returnMarketPercentageArray = []; private $returnWaitMarketPercentageArray = []; @@ -39,14 +40,19 @@ class MarketPercentageController extends ThinkController //不结算列表 $this->leavePercentage->unSettlementList(); $this->unSettlementList = $this->leavePercentage->returnUnSettlementList(); + $this->MarketEvent = A("Market","Event"); parent::_initialize(); } public function index($row = 10, $p = 1) { - - $map = []; + + // $this->MarketEvent->getAdminCompanyId(); + $map = [ + "is_settlement"=>1, + "_string"=>"1=1" + ]; // $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; $_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : ''; @@ -55,22 +61,33 @@ class MarketPercentageController extends ThinkController $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; ($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : ''; + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['admin_id'] = $admin_id; - $map['is_settlement'] = 1; - if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) { - unset($map['admin_id']); - $admin_data = M("member") - ->field("access.uid admin_id") - ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21,25']]) - ->select(); - if ($admin_data) { - $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; - } - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; - } + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $map['department_id'] =["in",[0,$markerGroup['department_id']]]; + if( !$this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ + $map['admin_id'] = $admin_id ; + } + } + // dd($map); + + // $map['admin_id'] = $admin_id; + // if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) { + // unset($map['admin_id']); + // $admin_data = M("member") + // ->field("access.uid admin_id") + // ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") + // ->join("left join sys_auth_group auth on access.group_id=auth.id") + // ->where(['group_id' => ['in', '11,12,21,25']]) + // ->select(); + // if ($admin_data) { + // $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; + // } + // $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; + // } + $search_date = []; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { From 29e03a17183d2672690c92b3217e213c36a16129 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 21 Jul 2021 20:09:23 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E9=83=A8=E6=8F=90=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 3 +- Application/Admin/Common/function.php | 5 + .../MarketPercentageController.class.php | 118 ++++++------------ Application/Admin/Event/MarketEvent.class.php | 24 ++++ .../MarketPercentage/marketstaffsettle.html | 9 +- .../View/MarketPercentage/showbonuslist.html | 6 +- 6 files changed, 73 insertions(+), 92 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 21d8119c0..89552f680 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2917,7 +2917,8 @@ function isMarketAdmin() */ function getMarketAdmin() { - $map['group_id'] =['in',A("Market","Event")->getMarketGroupId()]; + $map['group_id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()]; + $data = M("auth_group_access") ->field("real_name,menber.uid,nickname") ->join("left join sys_member menber on sys_auth_group_access.uid = menber.uid") diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index b77be82d9..6681ecc5c 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1100,3 +1100,8 @@ function getAffairMember() { } +function getMarketLevel() +{ + return A("Market","Event")->getConfig('LevelConfig'); +} + diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 6f7b3423b..980eea7b1 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -606,9 +606,9 @@ class MarketPercentageController extends ThinkController } else { - + $map['id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()]; $data = M("auth_group") - ->where("title like '%市场%' and title != '市场总监'") + ->where($map) ->select(false); $data = M("auth_group_access") @@ -636,47 +636,30 @@ class MarketPercentageController extends ThinkController public function marketStaffSettle($row = 10, $p = 1) { - $map = []; + $map = [ + "_string"=>'1=1' + ]; - $map['group_id'] = ['in', '11,12,21,25']; //获取权限 $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); -// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; - $_REQUEST['group_id'] ? ($map['level'] = $_REQUEST['group_id']) : ''; - + $_REQUEST['level'] ? ($map['level'] = $_REQUEST['level']) : ''; + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['admin_id'] = $admin_id; - if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23 || session('user_group_id') == 25) { - unset($map['admin_id']); - -// $markerData = M("ucenter_member")->field("id")->where(['work_status' => 1])->select(); -// -// if ($markerData) { -// $admin_map['sys_member.uid'] = ['not in', array_column($markerData, 'id')]; -// } - - $admin_data = M("member") - ->field("access.uid admin_id") - ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21,25']]) -// ->where($admin_map) - ->select(); - if ($admin_data) { - $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ + $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])]; + }else{ + $map['admin_id'] = $admin_id ; } -// if (!in_array($_REQUEST['admin_id'], array_column($markerData, 'id'))) { - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; -// } else { -// $this->display("marketstaffsettle"); -// die(); -// } - } + $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; + $search_date = []; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -832,15 +815,7 @@ class MarketPercentageController extends ThinkController $data[$key]['start_time'] = date("Y-m-1", strtotime($value['pay_time'])); $data[$key]['end_time'] = date("Y-m-t", strtotime($value['pay_time'])); - if ($value['level'] == 21) { - $data[$key]['level'] = '初级'; - } else if ($value['level'] == 11) { - $data[$key]['level'] = '中级'; - } else if ($value['level'] == 12) { - $data[$key]['level'] = '高级'; - }else if ($value['level'] == 25) { - $data[$key]['level'] = '经理'; - } + $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']); if (!$value['market_check']) { $data[$key]['market_check_detail'] = "-----"; @@ -1036,15 +1011,11 @@ class MarketPercentageController extends ThinkController public function personMarketStaffSettle($row = 10, $p = 1) { -// var_dump(getMarketAdmin()); - $map = []; - - $map['group_id'] = ['in', '11,12,21,25']; + $map = [ + "_string"=>'1=1' + ]; //获取权限 $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); - -// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; -// $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; $_REQUEST['group_id'] ? ($map['group_id'] = $_REQUEST['group_id']) : ''; ($_REQUEST['status'] || $_REQUEST['status'] == '0') ? ($map['tab_market_altogether.status'] = $_REQUEST['status']) : ''; @@ -1057,22 +1028,17 @@ class MarketPercentageController extends ThinkController } $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['admin_id'] = $admin_id; - if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23 || session('user_group_id') == 25) { - unset($map['admin_id']); - - $admin_data = M("member") - ->field("access.uid admin_id") - ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21,25']]) - ->select(); - if ($admin_data) { - $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ + $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])]; + }else{ + $map['admin_id'] = $admin_id ; } - - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; } + $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; + $search_date = []; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -1165,15 +1131,7 @@ class MarketPercentageController extends ThinkController $market_percentage = json_decode($value['market_percentage'], true); - if ($value['level'] == 21) { - $data[$key]['level'] = '初级'; - } else if ($value['level'] == 11) { - $data[$key]['level'] = '中级'; - } else if ($value['level'] == 12) { - $data[$key]['level'] = '高级'; - }else if ($value['level'] == 25) { - $data[$key]['level'] = '经理'; - } + $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']); if ($value['status'] > 0) { $data[$key]['is_send'] = '已发放'; @@ -1279,13 +1237,14 @@ class MarketPercentageController extends ThinkController public function sendBonus() { + $groupIds = $this->MarketEvent->getMarketGroupId(); $map['pay_time'] = $_REQUEST['pay_time']; $admin_data = M("member") ->field("access.uid admin_id") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21']]) + ->where(['group_id' => ['in', $groupIds]]) ->select(); if ($admin_data) { $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; @@ -1365,12 +1324,12 @@ class MarketPercentageController extends ThinkController } $map = []; - + $groupIds = $this->MarketEvent->getMarketGroupId(); $admin_data = M("member") ->field("access.uid admin_id") ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21']]) + ->where(['group_id' => ['in', $groupIds]]) ->select(); if ($admin_data) { $map['tab_market_altogether.admin_id'] = ['in', array_column($admin_data, 'admin_id')]; @@ -1441,7 +1400,6 @@ class MarketPercentageController extends ThinkController $map['tab_market_altogether.pay_time'] = $_REQUEST['pay_time']; } } - $data = SM("market_altogether", "tab_") ->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, IF((work_status!=0 and ((leave_time-UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))<86400*30) or UNIX_TIMESTAMP(concat(tab_market_altogether.pay_time,'-01'))>leave_time)),0,performance_commission) performance_commission, @@ -1485,13 +1443,7 @@ class MarketPercentageController extends ThinkController foreach ($data as $key => $value) { // dump($value); - if ($value['level'] == 21) { - $data[$key]['level'] = '初级'; - } else if ($value['level'] == 11) { - $data[$key]['level'] = '中级'; - } else if ($value['level'] == 12) { - $data[$key]['level'] = '高级'; - } + $data[$key]['level'] = $this->MarketEvent->getLevelName($value['level']); //绩效系数计算 // $data[$key]['achievement_bonus'] = $data[$key]['achievement_bonus'] * ($this->coefficient[$value['pay_time']][$value['admin_id']]?$this->coefficient[$value['pay_time']][$value['admin_id']]:1); diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index 4a4ca1938..29c72eb68 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -8,6 +8,13 @@ class MarketEvent extends Controller private $MarketDepartmentId = "1,2"; private $ManagerLevel = "4"; private $DirectorLevel = "5"; + private $LevelConfig = [ + '1'=>'初级', + '2'=>'中级', + '3'=>'高级', + '4'=>'经理' + ]; + /** * 获取所有市场部组id */ @@ -20,6 +27,18 @@ class MarketEvent extends Controller } return rtrim($sendData,","); } + /** + * 获取所有市场部组id + */ + public function getNoLeaderMarketGroupId() + { + $where = [ + "department_id"=>['in',$this->MarketDepartmentId], + "department_level"=>['neq',$this->DirectorLevel] + ]; + $dbres = M('auth_group','sys_')->where($where)->getField("id",true); + return implode(",",$dbres); + } /** * 获取普通的市场专员(初中高)的gid */ @@ -59,6 +78,10 @@ class MarketEvent extends Controller { return $this->$key; } + public function getLevelName($level) + { + return $this->LevelConfig[$level]; + } public function isMarketAdminGroup($gid) { $where = [ @@ -74,6 +97,7 @@ class MarketEvent extends Controller return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find(); } + public function getDepartmentUserId($department_id) { $res = M("auth_group_access") diff --git a/Application/Admin/View/MarketPercentage/marketstaffsettle.html b/Application/Admin/View/MarketPercentage/marketstaffsettle.html index 2971657a0..89efdf748 100644 --- a/Application/Admin/View/MarketPercentage/marketstaffsettle.html +++ b/Application/Admin/View/MarketPercentage/marketstaffsettle.html @@ -150,12 +150,11 @@
- - - - - + + +
diff --git a/Application/Admin/View/MarketPercentage/showbonuslist.html b/Application/Admin/View/MarketPercentage/showbonuslist.html index 188005047..fa66a2552 100644 --- a/Application/Admin/View/MarketPercentage/showbonuslist.html +++ b/Application/Admin/View/MarketPercentage/showbonuslist.html @@ -88,9 +88,9 @@
From e97d763bc89c0168b4b170ee74619f38a254870e Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 21 Jul 2021 20:40:34 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 3 ++- Application/Admin/Event/MarketEvent.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 89552f680..318e61a59 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2819,7 +2819,8 @@ function getAvailableBalance($promote_id=0,$game_id=0,$server_id='') { function getMarketGroupIds() { - return M('auth_group', 'sys_')->where(['title' => ['like', '%市场专员%']])->getField('id', true); + $map['id'] = ['in',A('Market','Event')->getNoLeaderMarketGroupId()]; + return M('auth_group', 'sys_')->where($map)->getField('id', true); } function getAdmins() diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index 29c72eb68..20b83fa50 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -28,7 +28,7 @@ class MarketEvent extends Controller return rtrim($sendData,","); } /** - * 获取所有市场部组id + * 获取市场专员gid(除了总监) */ public function getNoLeaderMarketGroupId() { From aae58f024bdde2491397de34eb5faa8dc76122a3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 22 Jul 2021 16:23:38 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BC=9A=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Event/MarketEvent.class.php | 19 ++++++++++++++++++- .../Base/Service/PromoteService.class.php | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index 20b83fa50..fc4af54c4 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -96,7 +96,24 @@ class MarketEvent extends Controller $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find(); } - + /** + * 添加部门总监的会长权限 + * $uid,$promote_id + */ + public function addPresident($uid,$promote_id) + { + $leader_group = M("auth_group_access") + ->alias("acc") + ->where(['acc.uid'=>$uid]) + ->join("sys_auth_group as gro on acc.group_id = gro.id") + ->join("sys_department as dep on gro.department_id = dep.id") + ->getField("dep.leader_group",1); + if(!$leader_group){ + return true; + } + $info = M('auth_group','sys_')->where(['id'=>$leader_group])->find(); + return M('auth_group','sys_')->where(['id'=>$leader_group])->save(['data_president'=>$info['data_president'].",".$promote_id]); + } public function getDepartmentUserId($department_id) { diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index 9d2c63173..d41e7e4c1 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -1123,8 +1123,9 @@ class PromoteService { // 如果是外团的,则自动加入市场总监审核列表 if ($data['level'] == 1 && in_array($data['company_belong'], [1, 2])) { $id = M('promote', 'tab_')->getLastInsID(); - $info = M('sys_auth_group')->where(['title'=>'市场总监'])->find(); - M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]); + A('Market','Event')->addPresident($data['admin_id'],$id); + // $info = M('sys_auth_group')->where(['title'=>'市场总监'])->find(); + // M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]); resetUserAuth(); } From 3d215d57aa20876f1238d16c8ec8ef3d102f1773 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 24 Jul 2021 15:11:58 +0800 Subject: [PATCH 10/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BC=9A=E9=95=BF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=88=96=E8=80=85=E6=8D=A2=E7=BB=91=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E7=9A=84=E5=B8=82=E5=9C=BA=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/OldCountController.class.php | 9 ++- .../PromoteCompanyController.class.php | 7 +-- Application/Admin/Event/MarketEvent.class.php | 62 ++++++++++++++++++- .../Base/Service/MarketService.class.php | 12 ++-- .../Service/PromoteCompanyService.class.php | 8 +-- .../Base/Service/PromoteService.class.php | 2 - 6 files changed, 78 insertions(+), 22 deletions(-) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 60df464d3..770c0875e 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -763,10 +763,15 @@ class OldCountController extends \Think\Controller } return $time_arr; } - public function eventTest($event,$action) + public function eventTest($event,$action,$arg = false) { $Event = A($event,"Event"); - $res = $Event->$action(); + if(!$arg){ + $res = $Event->$action(); + }else{ + $res = call_user_func_array(array($Event, $action), explode(":",$arg)); + } + dd($res); } diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index b38df25ba..01f3cb1b3 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -1436,15 +1436,12 @@ class PromoteCompanyController extends ThinkController M("Promote","tab_")->where("company_id = '{$company_id}'")->save($savedata); // 权限跟随 if($is_change_belong){ - $authGroup = M('auth_group',"sys_")->where(['title'=>'市场总监'])->find(); $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $company_id])->getField('id', true); - $dataPresident = explode(',', $authGroup['data_president']); if ($save['company_belong'] == 1 || $save['company_belong'] == 2) { - $dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds)); + A("Market","Event")->pushPresident($subPromoteIds); } else { - $dataPresident = array_diff($dataPresident, $subPromoteIds); + A("Market","Event")->removePresident($subPromoteIds); } - M('auth_group',"sys_")->where(['title'=>'市场总监'])->save(['data_president'=>implode(',', $dataPresident)]); resetUserAuth(); } } diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index fc4af54c4..a37235944 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -78,6 +78,9 @@ class MarketEvent extends Controller { return $this->$key; } + /** + * 获取等级名称 + */ public function getLevelName($level) { return $this->LevelConfig[$level]; @@ -112,7 +115,64 @@ class MarketEvent extends Controller return true; } $info = M('auth_group','sys_')->where(['id'=>$leader_group])->find(); - return M('auth_group','sys_')->where(['id'=>$leader_group])->save(['data_president'=>$info['data_president'].",".$promote_id]); + $dataPresident = explode(',', $info['data_president']); + $dataPresident = array_unique(array_merge($dataPresident, array($promote_id))); + return $this->saveLeaderPresident($leader_group,$dataPresident);; + } + + /** + * 移除原有权限 + * @param [array] $promoteIds + * @return void + */ + public function removePresident($promoteIds) + { + if(!is_array($promoteIds)){ + $promoteIds = explode(",",$promoteIds); + }; + $leaderPresident = $this->getLeaderPresident(); + foreach ($leaderPresident as $k => $v) { + $dataPresident = explode(',', $v); + $dataPresident = array_diff($dataPresident, $promoteIds); + $this->saveLeaderPresident($k,$dataPresident); + } + } + + /** + * 添加原有权限,设计重复问题 + * @param [array] $promoteIds + * @return void + */ + public function pushPresident($promoteIds) + { + if(!is_array($promoteIds)){ + $promoteIds = explode(",",$promoteIds); + }; + foreach ($promoteIds as $k => $v) { + $admin_id = M("Promote","tab_")->where("id = {$v}")->getField("admin_id"); + $this->addPresident($admin_id,$v); + } + return true; + } + + private function getLeaderPresident() + { + $where = [ + "department_id"=>['in',$this->MarketDepartmentId], + "department_level"=>['eq',$this->DirectorLevel] + ]; + return M('auth_group','sys_')->where($where)->getField("id,data_president",true); + } + private function saveLeaderPresident($gid,$data_president) + { + if(is_array($data_president)){ + $data_president = implode(",",$data_president); + }; + $savedata = [ + "id"=>$gid, + "data_president"=>$data_president + ]; + return M('auth_group','sys_')->save($savedata); } public function getDepartmentUserId($department_id) diff --git a/Application/Base/Service/MarketService.class.php b/Application/Base/Service/MarketService.class.php index 522064a5f..e8b979143 100644 --- a/Application/Base/Service/MarketService.class.php +++ b/Application/Base/Service/MarketService.class.php @@ -42,13 +42,11 @@ class MarketService $map['admin_id'] = $fromId; M('promote', 'tab_')->where($map)->save(['admin_id' => $toId]); M('promote', 'tab_')->where(['chain' => ['like', $promote['chain'] . $promote['id'] . '/%']])->save(['admin_id' => $toId]); - - $authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find(); - $dataPresident = explode(',', $authGroup['data_president']); - if (!in_array($promote['id'], $dataPresident)) { - M('auth_group', 'sys_')->where(['title'=>'市场总监'])->save(['data_president' => $authGroup['data_president'] . ',' . $promote['id']]); - resetUserAuth(); - } + + $marketEvent = A("Market","Event"); + $marketEvent->removePresident($promote['id']); + $marketEvent->addPresident($toId,$promote['id']); + resetUserAuth(); } public function shiftSpend($promoteIds, $fromId, $toId, $time = null) diff --git a/Application/Base/Service/PromoteCompanyService.class.php b/Application/Base/Service/PromoteCompanyService.class.php index d72917a04..e4b46b431 100644 --- a/Application/Base/Service/PromoteCompanyService.class.php +++ b/Application/Base/Service/PromoteCompanyService.class.php @@ -272,15 +272,13 @@ class PromoteCompanyService // 权限跟随 if($isChangeBelong){ - $authGroup = M('auth_group', 'sys_')->where(['title'=>'市场总监'])->find(); + $subPromoteIds = M('promote', 'tab_')->where(['level' => 1, 'company_id' => $companyId])->getField('id', true); - $dataPresident = explode(',', $authGroup['data_president']); if ($companyInfo['company_belong'] == 1 || $companyInfo['company_belong'] == 2) { - $dataPresident = array_unique(array_merge($dataPresident, $subPromoteIds)); + A("Market","Event")->pushPresident($subPromoteIds); } else { - $dataPresident = array_diff($dataPresident, $subPromoteIds); + A("Market","Event")->removePresident($subPromoteIds); } - M('auth_group', 'sys_')->where(['title' => '市场总监'])->save(['data_president' => implode(',', $dataPresident)]); resetUserAuth(); } } diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index d41e7e4c1..48a018520 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -1124,8 +1124,6 @@ class PromoteService { if ($data['level'] == 1 && in_array($data['company_belong'], [1, 2])) { $id = M('promote', 'tab_')->getLastInsID(); A('Market','Event')->addPresident($data['admin_id'],$id); - // $info = M('sys_auth_group')->where(['title'=>'市场总监'])->find(); - // M('sys_auth_group')->where(['title'=>'市场总监'])->save(['data_president'=>$info['data_president'].",".$id]); resetUserAuth(); } From 2ddb07426a7f667671672d257a710ad35cd66dd3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 26 Jul 2021 14:29:17 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E9=A2=86=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/OldCountController.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 770c0875e..3b4dfcd1b 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -58,7 +58,6 @@ class OldCountController extends \Think\Controller // 'id'=>1, // 'name'=>'市场一部', // 'group_ids'=>'11,12,14,21,25', - // 'leader_group'=>'14', // 'create_time'=>time(), // 'update_time'=>time() // ]); @@ -66,7 +65,6 @@ class OldCountController extends \Think\Controller // 'id'=>2, // 'name'=>'市场二部', // 'group_ids'=>'26,27,28,29,30', - // 'leader_group'=>'28', // 'create_time'=>time(), // 'update_time'=>time() // ]); From c01b37040571a272fc62dff29986d709c8174277 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 26 Jul 2021 15:06:31 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=85=AC=E5=8F=B8=E4=B8=8D=E5=8C=BA=E5=88=86=E5=B8=82=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index 6681ecc5c..0ff4826ff 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -617,13 +617,13 @@ function getAllGame() */ function getPromoteCompany() { - $companyId = A("Market","Event")->getAdminCompanyId(); + // $companyId = A("Market","Event")->getAdminCompanyId(); $where = [ "status"=>1 ]; - if($companyId != 'all'){ - $where['id'] = ["in",$companyId]; - } + // if($companyId != 'all'){ + // $where['id'] = ["in",$companyId]; + // } $list = M("PromoteCompany", 'tab_') ->field('id,company_name') ->where($where) From 22619dff0ce4982e7baace7dabfdcd2b91268d20 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 26 Jul 2021 17:33:35 +0800 Subject: [PATCH 13/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyGameRatioController.class.php | 40 +++++++++++++------ .../Controller/OldCountController.class.php | 2 + Application/Admin/Event/MarketEvent.class.php | 7 ++++ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php index 20db93a21..e19b6002e 100644 --- a/Application/Admin/Controller/CompanyGameRatioController.class.php +++ b/Application/Admin/Controller/CompanyGameRatioController.class.php @@ -6,6 +6,7 @@ class CompanyGameRatioController extends AdminController { public $admininfo; public $DBModel; + public $MarketEvent; public $OpAuthList=[]; public $Status = [ "-2"=>"管理员拒绝", @@ -24,6 +25,7 @@ class CompanyGameRatioController extends AdminController { $this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->DBModel = M("company_game_ratio","tab_"); + $this->MarketEvent = A("Market","Event"); parent::_initialize(); } @@ -78,18 +80,16 @@ class CompanyGameRatioController extends AdminController } } } - - $isMarketAdmin = isMarketAdmin(); - if($isMarketAdmin) { - $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; - $companyIds = M('promote', 'tab_')->where(['admin_id' => $adminId, 'level' => 1])->getField('company_id', true); - $companyIds = array_unique($companyIds); - $marketCondition = ''; - if (count($companyIds) > 0) { - $marketCondition = 'm.company_id in(' . implode(',', $companyIds) . ')'; - } else { - $marketCondition = '1<>1'; + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $companyIds = $this->MarketEvent->getAdminCompanyId(); + //取消0 + $companyIds = implode(",",array_diff(explode(",",$companyIds),[0])); + $marketCondition = 'm.company_id in(' . $companyIds . ')'; + if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){ + //总监 + $marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )"; } $where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition; } @@ -265,6 +265,22 @@ class CompanyGameRatioController extends AdminController } } + + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $companyIds = $this->MarketEvent->getAdminCompanyId(); + //取消0 + $companyIds = implode(",",array_diff(explode(",",$companyIds),[0])); + $marketCondition = 'm.company_id in(' . $companyIds . ')'; + if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){ + //总监 + $marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )"; + } + $where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition; + } + + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $time_start = strtotime($_REQUEST['time_start']); $time_end = strtotime($_REQUEST['time_end'])+ 86399; diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 3b4dfcd1b..770c0875e 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -58,6 +58,7 @@ class OldCountController extends \Think\Controller // 'id'=>1, // 'name'=>'市场一部', // 'group_ids'=>'11,12,14,21,25', + // 'leader_group'=>'14', // 'create_time'=>time(), // 'update_time'=>time() // ]); @@ -65,6 +66,7 @@ class OldCountController extends \Think\Controller // 'id'=>2, // 'name'=>'市场二部', // 'group_ids'=>'26,27,28,29,30', + // 'leader_group'=>'28', // 'create_time'=>time(), // 'update_time'=>time() // ]); diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index a37235944..23a888829 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -99,6 +99,13 @@ class MarketEvent extends Controller $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find(); } + + public function isMarketLeder($uid) + { + $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); + return M("auth_group")->where("id = '{$gid}' and department_level = '{$this->DirectorLevel}'")->field("id")->find(); + } + /** * 添加部门总监的会长权限 * $uid,$promote_id From e523dc7e884b6e93cad6bb064c5c57e874f2836b Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 26 Jul 2021 18:06:02 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=9D=83=E9=99=90=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/GameRatioMouldController.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Application/Admin/Controller/GameRatioMouldController.class.php b/Application/Admin/Controller/GameRatioMouldController.class.php index 988d6bc21..03311377c 100644 --- a/Application/Admin/Controller/GameRatioMouldController.class.php +++ b/Application/Admin/Controller/GameRatioMouldController.class.php @@ -23,6 +23,13 @@ class GameRatioMouldController extends AdminController //获取游戏id $gamewhere['_string'] = '1 = 1'; $where['_string'] = '1 = 1'; + + $markerGroup = A("Market","Event")->isMarketAdminGroup(session('user_group_id')); + if($markerGroup){ + $where['_string'] .= " AND m.company_belong > 0"; + } + + if(isset($params['relation_game_id'])){ $gamewhere['relation_game_id'] = $params['relation_game_id']; $where['m.relation_game_id'] = $params['relation_game_id']; From acaf3ec37089863e72db0c0f1b3d590c309d2fe3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 26 Jul 2021 18:23:16 +0800 Subject: [PATCH 15/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/SocietyInfoController.class.php | 17 ++++++++++++++--- Application/Admin/Event/MarketEvent.class.php | 7 ++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Controller/SocietyInfoController.class.php b/Application/Admin/Controller/SocietyInfoController.class.php index 2c57ab64e..bb5ef3064 100644 --- a/Application/Admin/Controller/SocietyInfoController.class.php +++ b/Application/Admin/Controller/SocietyInfoController.class.php @@ -14,6 +14,7 @@ class SocietyInfoController extends ThinkController { private $modelName = 'SocietyInfo'; private $admininfo = ''; + private $MarketEvent; private $level = [ 1=>'S', 2=>'A', @@ -24,6 +25,7 @@ class SocietyInfoController extends ThinkController public function _initialize() { $this->admininfo = $_SESSION['onethink_admin']['user_auth']; + $this->MarketEvent = A("Market","Event"); parent::_initialize(); } //列表 @@ -32,11 +34,20 @@ class SocietyInfoController extends ThinkController $model = M($this->modelName, 'tab_'); $map = []; - if ($this->checkRule("Admin/SocietyInfo/lists", array('in','1,2')) || isMarketLeader() || is_administrator()) { + if (is_administrator()) { // 设置权限、admin、市场总监可以看所有数据 } else { - // 其他用户只能看自己的 - $map['create_account'] = $this->admininfo['username']; + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){ + //总监 + $map['create_account'] = ["in",$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'],"nickname")]; + } + }else{ + // 其他用户只能看自己的 + $map['create_account'] = $this->admininfo['username']; + } } if ($_REQUEST['text']||$_REQUEST['text']=='0') { diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index 23a888829..c7817f566 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -182,16 +182,17 @@ class MarketEvent extends Controller return M('auth_group','sys_')->save($savedata); } - public function getDepartmentUserId($department_id) + public function getDepartmentUserId($department_id,$type = "uid") { + $field = "mem.".$type; $res = M("auth_group_access") ->alias("acc") - ->field("acc.uid") + ->field($field) ->where(['gro.department_id'=>$department_id]) ->join("sys_member as mem on acc.uid = mem.uid") ->join("sys_auth_group as gro on acc.group_id = gro.id") ->select(); - return array_column($res,'uid'); + return array_column($res,$type); } public function getAdminCompanyId() From 5ccda517b385c9791ae8538b84771a46e984a502 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 14:49:54 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 40 ------------------- .../PromoteCompanyController.class.php | 4 +- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 318e61a59..18cc09921 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -3132,46 +3132,6 @@ function promote_listsMarket($type){ return $data; } -//市场部获取公司或推广员id -function getMarketAuthPromoteId() -{ - $map['level'] = 1; - if (isMarketLeader()) { - //搜索所有市场部管理员id - $mid = M("AuthGroup")->where("title like '%市场%'")->getField("id",true); - $mid = implode(",",$mid); - - $admin_id = M("AuthGroupAccess")->where("group_id in ({$mid})")->getField("uid",true); - $admin_id = implode(",",$admin_id); - - $map['admin_id'] = ['in', $admin_id]; - }elseif(isMarketAdmin()){ - $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; - $map['admin_id'] = $adminId; - - }else{ - return false; - } - $dbres = M("Promote","tab_")->where($map)->getField("id",true); - if(empty($dbres)){ - return -1; - }else{ - return implode(",",$dbres); - } -} - -function throwPromoteIdToCompanyId($p_ids) -{ - $dbres = M("Promote","tab_")->where("id in ({$p_ids})")->field("count(*) count,company_id")->group("company_id")->select(); - if(empty($dbres)){ - return -1; - }else{ - return implode(",",array_column($dbres,"company_id")); - } -} - - /** * 选择收款商户 diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 01f3cb1b3..1de4601ec 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -49,10 +49,10 @@ class PromoteCompanyController extends ThinkController $company_name = trim(I('company_name')); //市场部权限begin - $pro_id = getMarketAuthPromoteId(); + $pro_id = getPowerPromoteIds(); if($pro_id){ $promotemap["_string"] .=" AND p.id in ({$pro_id})"; - $c_id = throwPromoteIdToCompanyId($pro_id); + $c_id = A("Market",'Event')->getAdminCompanyId(); $map["_string"] .=" AND id in ({$c_id})"; } From 822894ea17445b394eefba1f104a74b3244cad4c Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 15:38:03 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 14 ++++++++------ .../Controller/FinancePromoteController.class.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 18cc09921..8ffab4e54 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2889,13 +2889,15 @@ function isMarketLeader() if(IS_SUBSITE){ return false; } - $authGroup = M('auth_group','sys_')->where(['title'=>'市场总监'])->find(); - if (!$authGroup) { - return false; + $gid = session('user_group_id'); + $markerGroup = A("Market","Event")->isMarketAdminGroup($gid); + if($markerGroup){ + if($markerGroup['department_level'] == A("Market","Event")->getConfig("DirectorLevel")){ + //总监 + return true; + } } - $userAuth = session('user_auth'); - $adminIds = M('auth_group_access', 'sys_')->where(['group_id' => $authGroup['id']])->getField('uid', true); - return in_array($userAuth['uid'], $adminIds); + return false; } function isMarketAdmin() diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index cafcd7fc6..01b480c80 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -42,20 +42,20 @@ class FinancePromoteController extends AdminController $senddata = []; //获取各会长的充值方式 - $cash = self::getJoinPromoteData([],$istimeselect); + $cash = $this->getJoinPromoteData([],$istimeselect); foreach($cash as $k=>$v){ $senddata[$v['p_id']] = $v; } $unsenddata = []; - $uncash = self::getJoinUnPayPromoteData([],$istimeselect); + $uncash = $this->getJoinUnPayPromoteData([],$istimeselect); foreach($uncash as $k=>$v){ $unsenddata[$v['p_id']] = $v; } //内冲 - $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); + $inside = $this->getJoinPromoteData([],$istimeselect,"promote_coin"); foreach($inside as $k=>$v){ if(array_key_exists($v['p_id'],$senddata)){ $senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; @@ -113,7 +113,7 @@ class FinancePromoteController extends AdminController unset($_REQUEST['company_id']); unset($_REQUEST['company_belong']); $_REQUEST['promote_id'] = 0; - $gfcash = self::getJoinPromoteData([],$istimeselect); + $gfcash = $this->getJoinPromoteData([],$istimeselect); $senddata[0] = $gfcash[0]; $pmap['status']=1; @@ -256,7 +256,8 @@ class FinancePromoteController extends AdminController } $isMarketLeader = isMarketLeader(); if ($isMarketLeader) { - $map['promote.admin_id'] = ['gt', 0]; + $marketPromoteIds = getPowerPromoteIds(); + $map['_string'] = "s.promote_id in ($marketPromoteIds)"; } if (!empty(I('develop_type'))) { @@ -340,7 +341,8 @@ class FinancePromoteController extends AdminController } $isMarketLeader = isMarketLeader(); if ($isMarketLeader) { - $map['promote.admin_id'] = ['gt', 0]; + $marketPromoteIds = getPowerPromoteIds(); + $map['_string'] = "s.promote_id in ($marketPromoteIds)"; } if (!empty(I('develop_type'))) { From 7d3dc9f8d29d6f7ea1cb42c169c65ccc3fc709a7 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 16:29:18 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E6=8A=BC=E9=87=91=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 1 + .../Admin/Controller/PresidentDepositController.class.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 8ffab4e54..8eec94c87 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1704,6 +1704,7 @@ function resetUserAuth() session('user_auth', $userAuth); session('user_auth_sign', data_auth_sign($userAuth)); session('user_auth_promote_ids', null); + session('user_auth_company_ids', null); } /** diff --git a/Application/Admin/Controller/PresidentDepositController.class.php b/Application/Admin/Controller/PresidentDepositController.class.php index 9720c4ed5..87d164a08 100644 --- a/Application/Admin/Controller/PresidentDepositController.class.php +++ b/Application/Admin/Controller/PresidentDepositController.class.php @@ -30,6 +30,11 @@ class PresidentDepositController extends ThinkController $where['_string'] .= ' and company_belong=' . $companyType; } + $marketCompanyIds = A("Market","Event")->getAdminCompanyId(); + if($marketCompanyIds != 'all'){ + $where['_string'] .= ' and id in (' . $marketCompanyIds .')'; + } + $depositWhere = []; $depositStrWhere = '1=1'; From a9400d3c0b98273f8f986acfb7b962d623afd09d Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 16:57:50 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementController.class.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index d126b051d..0acc9fe2f 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -34,6 +34,7 @@ class CompanyStatementController extends ThinkController ]; public $admininfo; public $DBModel; + private $MarketEvent; static $specialCompoent; @@ -42,6 +43,7 @@ class CompanyStatementController extends ThinkController { $this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->DBModel = SM("CompanyStatement","tab_"); + $this->MarketEvent = A("Market","Event"); $Factory = BaseFactory::getInstance(); self::$specialCompoent = $Factory->factoryClass("SpecialCompoent"); @@ -60,16 +62,26 @@ class CompanyStatementController extends ThinkController $map = [ "_string"=>"1=1" ]; + + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $companyIds = $this->MarketEvent->getAdminCompanyId(); + $map['_string'] .= ' AND company_id in(' . $companyIds . ') and company_belong not in (0,9)'; + } + + + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $time_start = strtotime($_REQUEST['time_start']); $time_end = strtotime($_REQUEST['time_end'])+ 86399; - $map["_string"] = "( (statement_begin_time BETWEEN {$time_start} AND {$time_end}) OR (statement_end_time BETWEEN {$time_start} AND {$time_end}) )"; + $map["_string"] .= " AND ( (statement_begin_time BETWEEN {$time_start} AND {$time_end}) OR (statement_end_time BETWEEN {$time_start} AND {$time_end}) )"; } elseif (isset($_REQUEST['time_start'])) { $time_start = strtotime($_REQUEST['time_start']); - $map["_string"] = "( (statement_begin_time >= {$time_start} ) OR (statement_end_time >= {$time_start}) )"; + $map["_string"] .= " AND ( (statement_begin_time >= {$time_start} ) OR (statement_end_time >= {$time_start}) )"; } elseif (isset($_REQUEST['time_end'])) { $time_end = strtotime($_REQUEST['time_end'])+ 86399; - $map["_string"] = "( (statement_begin_time <= {$time_end} ) OR (statement_end_time <= {$time_end}) )"; + $map["_string"] .= " AND ( (statement_begin_time <= {$time_end} ) OR (statement_end_time <= {$time_end}) )"; } if (isset($_REQUEST['time_start2']) && isset($_REQUEST['time_end2'])) { From c234f9520b2b4f1b092ffdcff3ee83d5b480b263 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 17:17:40 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=B8=82?= =?UTF-8?q?=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 8eec94c87..b2c537cfa 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2831,7 +2831,7 @@ function getAdmins() function getMarketAdmins() { - $ids = getMarketGroupIds(); + $ids = A('Market','Event')->getMarketGroupId(); if (count($ids) == 0) { return []; } From 7b801017078252edbb616787341fcd43e2785422 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 27 Jul 2021 17:51:33 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=9D=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/OldCountController.class.php | 127 ++++++++++-------- .../PromoteCompanyController.class.php | 6 +- 2 files changed, 75 insertions(+), 58 deletions(-) diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 770c0875e..b3b4470b5 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -15,68 +15,83 @@ class OldCountController extends \Think\Controller public function moreDepartment() { //1.新增组 - // $manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find(); - // $dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select(); - // foreach ($dbres as &$v) { - // if($v['id'] == 25){ - // $v['rules'] = $manager['rules']; - // $v['data_empower_type'] =3; - // $v['show_data'] =1; - // $v['show_market_admin'] =1; - // $v['show_promote'] =1; - // } - // if(mb_strpos($v['title'],"初级")){ - // $v['department_level'] = 1; - // } - // if(mb_strpos($v['title'],"中级")){ - // $v['department_level'] = 2; - // } - // if(mb_strpos($v['title'],"高级")){ - // $v['department_level'] = 3; - // } - // if(mb_strpos($v['title'],"经理")){ - // $v['department_level'] = 4; - // } - // if(mb_strpos($v['title'],"总监")){ - // $v['department_level'] = 5; - // } - // $v['title'] = "一部".$v['title']; - // $v['department_id'] = 1; - // $v['department_name'] = "市场一部"; - // M('auth_group','sys_')->save($v); - - // unset($v['id']); - // $v['title'] = str_replace("一部","二部",$v['title']); - // $v['department_id'] = 2; - // $v['department_name'] = '市场二部'; - // M('auth_group','sys_')->add($v); - // } + $manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find(); + $dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select(); + foreach ($dbres as &$v) { + if($v['id'] == 25){ + $v['rules'] = $manager['rules']; + $v['data_empower_type'] =3; + $v['show_data'] =1; + $v['show_market_admin'] =1; + $v['show_promote'] =1; + } + if(mb_strpos($v['title'],"初级")){ + $v['department_level'] = 1; + } + if(mb_strpos($v['title'],"中级")){ + $v['department_level'] = 2; + } + if(mb_strpos($v['title'],"高级")){ + $v['department_level'] = 3; + } + if(mb_strpos($v['title'],"经理")){ + $v['department_level'] = 4; + } + if(mb_strpos($v['title'],"总监")){ + $v['department_level'] = 5; + } + $v['title'] = "一部".$v['title']; + $v['department_id'] = 1; + $v['department_name'] = "市场一部"; + M('auth_group','sys_')->save($v); + + unset($v['id']); + $v['title'] = str_replace("一部","二部",$v['title']); + $v['department_id'] = 2; + $v['department_name'] = '市场二部'; + M('auth_group','sys_')->add($v); + } //3.增加部门表数据 - // M("department")->add([ - // 'id'=>1, - // 'name'=>'市场一部', - // 'group_ids'=>'11,12,14,21,25', - // 'leader_group'=>'14', - // 'create_time'=>time(), - // 'update_time'=>time() - // ]); - // M("department")->add([ - // 'id'=>2, - // 'name'=>'市场二部', - // 'group_ids'=>'26,27,28,29,30', - // 'leader_group'=>'28', - // 'create_time'=>time(), - // 'update_time'=>time() - // ]); + M("department")->add([ + 'id'=>1, + 'name'=>'市场一部', + 'group_ids'=>'11,12,14,21,25', + 'leader_group'=>'14', + 'create_time'=>time(), + 'update_time'=>time() + ]); + M("department")->add([ + 'id'=>2, + 'name'=>'市场二部', + 'group_ids'=>'26,27,28,29,30', + 'leader_group'=>'28', + 'create_time'=>time(), + 'update_time'=>time() + ]); //4.修改旧等级 - // M("market_altogether","tab_")->where("level = 21")->save(['level'=>1]); - // M("market_altogether","tab_")->where("level = 11")->save(['level'=>2]); - // M("market_altogether","tab_")->where("level = 12")->save(['level'=>3]); - // M("market_altogether","tab_")->where("level = 25")->save(['level'=>4]); + M("market_altogether","tab_")->where("level = 21")->save(['level'=>1]); + M("market_altogether","tab_")->where("level = 11")->save(['level'=>2]); + M("market_altogether","tab_")->where("level = 12")->save(['level'=>3]); + M("market_altogether","tab_")->where("level = 25")->save(['level'=>4]); + + } + public function setDataPresidentInit() + { + $marketEvent = A("Market","Event"); + //获取所有二部公司 + $uids = $marketEvent->getDepartmentUserId(2); + $promoteids = M("Promote","tab_")->where(["admin_id"=>['in',$uids],"level"=>1])->getField("id",true); + + $marketEvent->removePresident($promoteids); + $save = [ + "id"=>28, + "data_president"=>implode(",",$promoteids) + ]; + M('auth_group','sys_')->save($save); } diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 1de4601ec..00c99a6ca 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -50,10 +50,12 @@ class PromoteCompanyController extends ThinkController //市场部权限begin $pro_id = getPowerPromoteIds(); - if($pro_id){ + if($pro_id != 'all'){ $promotemap["_string"] .=" AND p.id in ({$pro_id})"; $c_id = A("Market",'Event')->getAdminCompanyId(); - $map["_string"] .=" AND id in ({$c_id})"; + if($c_id != 'all'){ + $map["_string"] .=" AND id in ({$c_id})"; + } } //市场部权限end From 34d07e15783796587cd6f1f746627e91624ea61a Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 28 Jul 2021 10:57:03 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/SpendController.class.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index ec08c8661..e043c5c0f 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -86,6 +86,18 @@ class SpendController extends ThinkController unset($_REQUEST['merchant_id']); } + if (isset($_REQUEST['promote_id'])) { + $promoteId = intval($_REQUEST['promote_id']); + if ($promoteId == 0) { + $map['promote_id'] = 0; + } else { + $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; + } + } + $marketAdminId = 0; $isMarketAdmin = isMarketAdmin(); if ($isMarketAdmin) { @@ -99,18 +111,7 @@ class SpendController extends ThinkController } else { setPowerPromoteIds($map,'promote_id'); } - - if (isset($_REQUEST['promote_id'])) { - $promoteId = intval($_REQUEST['promote_id']); - if ($promoteId == 0) { - $map['promote_id'] = 0; - } else { - $promoteMap['chain'] = ['like', "%/$promoteId/%"]; - $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); - $promoteIds[] = $promoteId; - $map['promote_id'] = ['in', $promoteIds]; - } - } + if ($_REQUEST['data_order'] != '') { $data_order = reset(explode(',', $_REQUEST['data_order'])); $data_order_type = end(explode(',', $_REQUEST['data_order'])); From 41f22341085a478df77f7711586041637af7778c Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 28 Jul 2021 11:06:33 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/SpendController.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index e043c5c0f..7bc3f9317 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -108,9 +108,8 @@ class SpendController extends ThinkController } if ($marketAdminId > 0) { $map['market_admin_id'] = $marketAdminId; - } else { - setPowerPromoteIds($map,'promote_id'); - } + } + setPowerPromoteIds($map,'promote_id'); if ($_REQUEST['data_order'] != '') { $data_order = reset(explode(',', $_REQUEST['data_order'])); From ad028cd61356873a1747253e3c6a15064d4e27ef Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 28 Jul 2021 15:47:00 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/View/Market/rebind.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Application/Admin/View/Market/rebind.html b/Application/Admin/View/Market/rebind.html index 28b8331cb..122441cb6 100644 --- a/Application/Admin/View/Market/rebind.html +++ b/Application/Admin/View/Market/rebind.html @@ -109,16 +109,16 @@ - *原市场专员: + *原市场人员: -- - *新市场专员: + *新市场人员: