From 4533b84d2cf0a7756c8899adab48f0266476f7d7 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 21 May 2020 18:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyGameRatioController.class.php | 166 +++++++++++++++++- .../Admin/View/CompanyGameRatio/index.html | 87 +++++++-- 2 files changed, 235 insertions(+), 18 deletions(-) diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php index 2b224f023..c7452beaf 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 $OpAuthList=[]; public $Status = [ "-2"=>"管理员拒绝", "-1"=>"市场部拒绝", @@ -22,11 +23,14 @@ class CompanyGameRatioController extends AdminController public function index() { - dd(MODULE_NAME."/".CONTROLLER_NAME ); $params = I('get.'); $page = $params['p'] ? intval($params['p']) : 1; $row = $params['row'] ? intval($params['row']) : 10; - + //权限分配 + if(!IS_ROOT){ + $this->OpAuthList= getModuleControllerAuth(); + } + $gamewhere['_string'] = '1 = 1'; $where['_string'] = '1 = 1'; if(isset($params['relation_game_id'])){ @@ -39,7 +43,7 @@ class CompanyGameRatioController extends AdminController if(isset($params['status'])){ $where['m.status'] = $params['status']; } - //TODO:未计算公司类型 + //TODO:未计算公司类型,未进行排序 $this->checkListOrCountAuthRestMap($where); $gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false); $dbres = M("company_game_ratio_log","tab_") @@ -112,6 +116,7 @@ class CompanyGameRatioController extends AdminController } } $v['last_turnover_ratio_str'] = $lastRatioDtl; + $v['oplist'] = $this->OpAuth($v); } $count = M("company_game_ratio_log","tab_")->alias('m')->field("count(id) count")->where($where)->find()['count']; @@ -122,11 +127,115 @@ class CompanyGameRatioController extends AdminController } $this->assign('status',$this->Status); + $this->assign('menubtn',$this->menuAuth()); + $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign("gameList",D("Game")->getRelationGameLits()); $this->display(); } + public function marketAgree(){ + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $company_game_ratio_log = M("company_game_ratio_log","tab_"); + $dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select(); + foreach($dbres as $k=>&$v){ + if($v['status'] != 0) continue; + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['market_user']=$this->admininfo["username"]; + $v['verify_log']['market_time']=date("Y-m-d H:i:s"); + $v['verify_log'] = json_encode($v['verify_log']); + $v['status']=1; + $company_game_ratio_log->save($v); + addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"市场部审核",'url'=>U('index')]); + } + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"市场部审核通过成功" + )); + } + public function marketRefuse(){ + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $company_game_ratio_log = M("company_game_ratio_log","tab_"); + $dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select(); + foreach($dbres as $k=>&$v){ + if($v['status'] != 0) continue; + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['market_user']=$this->admininfo["username"]; + $v['verify_log']['market_time']=date("Y-m-d H:i:s"); + $v['verify_log'] = json_encode($v['verify_log']); + $v['status']=-1; + $company_game_ratio_log->save($v); + addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"市场部审核",'url'=>U('index')]); + } + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"市场部审核拒绝成功" + )); + } + public function adminRefuse(){ + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $company_game_ratio_log = M("company_game_ratio_log","tab_"); + $dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select(); + foreach($dbres as $k=>&$v){ + if($v['status'] != 1) continue; + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['admin_user']=$this->admininfo["username"]; + $v['verify_log']['admin_time']=date("Y-m-d H:i:s"); + $v['verify_log'] = json_encode($v['verify_log']); + $v['status']=-2; + $company_game_ratio_log->save($v); + addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"管理员审核",'url'=>U('index')]); + } + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"管理员审核拒绝成功" + )); + } + //管理员成功 + public function adminAgree(){ + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $company_game_ratio_log = M("company_game_ratio_log","tab_"); + $company_game_ratio = M("company_game_ratio","tab_"); + $dbres = $company_game_ratio_log->field("*")->where("id in ({$ids})")->select(); + foreach($dbres as $k=>&$v){ + if($v['status'] != 1) continue; + $v['verify_log'] = json_decode($v['verify_log'],true); + $v['verify_log']['admin_user']=$this->admininfo["username"]; + $v['verify_log']['admin_time']=date("Y-m-d H:i:s"); + $v['verify_log'] = json_encode($v['verify_log']); + $v['status']=2; + $company_game_ratio_log->save($v); + //保存到其他表 + //查找是否存在 + $ratiov = [ + "company_id"=>$v['company_id'], + "relation_game_id"=>$v['relation_game_id'], + "ratio"=>$v['ratio'], + "turnover_ratio"=>$v['turnover_ratio'], + "begin_time"=>$v['begin_time'], + "end_time"=>$v['end_time'], + ]; + + $has = $company_game_ratio->where("company_id='{$v['company_id']}' and relation_game_id='{$v['relation_game_id']}'")->find(); + if(isset($has['id'])){ + $ratiov['id'] = $has['id']; + $company_game_ratio->save($ratiov); + }else{ + $company_game_ratio->add($ratiov); + } + // + addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"管理员审核",'url'=>U('index')]); + } + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"市场部审核通过成功" + )); + } + public function add() { if ($_POST) { @@ -184,6 +293,57 @@ class CompanyGameRatioController extends AdminController { } + public function menuAuth() + { + $addurl = U("add"); + $mentBtn = [ + "addRatio"=>"新增推广游戏分成", + "marketAgree"=>"市场部审批通过", + "marketRefuse"=>"市场部审核拒绝", + "adminAgree"=>"管理员审核通过", + "adminRefuse"=>"管理员审核拒绝" + ]; + $resarr = []; + foreach ($mentBtn as $k => $v) { + if(IS_ROOT){ + $resarr[] = $v; + }else{ + if(in_array($k,$this->OpAuthList)){ + $resarr[] = $v; + } + } + } + return $resarr; + } + public function OpAuth($info) + { + $id = $info['id']; + //原始列表 + $opBtn = [ + "editRatio"=>"编辑", + "delRatio"=>"删除", + ]; + //操作对应菜单 + + if($info['status'] == 2){ + $optist = []; + }else{ + $optist = ["editRatio","delRatio"]; + } + // + $resarr = []; + foreach ($optist as $k => $v) { + if(IS_ROOT){ + $resarr[] = $opBtn[$v]; + }else{ + if(in_array($v,$this->OpAuthList)){ + $resarr[] = $opBtn[$v]; + } + } + } + return $resarr; + } + public function setTurnoverRatio($params) { $save['turnover_ratio'] = []; diff --git a/Application/Admin/View/CompanyGameRatio/index.html b/Application/Admin/View/CompanyGameRatio/index.html index 2e8fee657..27f6bd16c 100644 --- a/Application/Admin/View/CompanyGameRatio/index.html +++ b/Application/Admin/View/CompanyGameRatio/index.html @@ -97,12 +97,9 @@
@@ -143,11 +140,7 @@ - - - - - + {$data.company_name} {$data.company_belong} @@ -200,8 +193,9 @@ {$data.remark} - 编辑 - 删除 + + {$vo} + @@ -267,8 +261,6 @@ $(function(){ } }); - - $(".ratio_del").on("click",function(){ var url = $(this).data("url"); layer.confirm('删除后将无法恢复,请慎重选择', { @@ -288,6 +280,71 @@ $(function(){ }); }); }) + + $("#marketAgree,#marketRefuse,#adminAgree").on("click",function(){ + var id = $(this).attr("id"); + if(id == "marketAgree"){ + var opname = "市场部审批通过"; + var opurl = "{:U('marketAgree')}"; + var opst ="[未进行审批]"; + var status = 0; + }else if(id=="marketRefuse"){ + var opname = "市场部审批拒绝"; + var opurl = "{:U('marketRefuse')}"; + var opst ="[未进行审批]"; + var status = 0; + }else if(id=="adminAgree"){ + var opname = "管理员审批通过"; + var opurl = "{:U('adminAgree')}"; + var opst ="[市场部审批通过]"; + var status = 1; + }else if(id=="adminRefuse"){ + var opname = "管理员审批拒绝"; + var opurl = "{:U('adminRefuse')}"; + var opst ="[市场部审批通过]"; + var status = 1; + } + + var flag = false; + var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + if($(elem).data("status") != status){ + flag = true; + }else{ + return $(elem).val(); + } + }).get().join(","); + if(text == ''){ + layer.msg("" + '无需要'+opname+'的申请,仅'+opst+'状态可以进行'+opname+""); + return; + } + if(flag){ + layer.confirm(opname+"仅会对"+opst+"的申请进行处理,选择中包含其他的状态的申请将被忽略,点击取消停止操作",{title:false}, function(index){ + _doAgreeApply(); + layer.close(index); + }); + }else{ + _doAgreeApply(); + } + function _doAgreeApply(){ + //执行 + $.ajax({ + type: "POST", + url: opurl, + dataType: 'json', + async: false, + data: {ids:text}, + success:function(data){ + if(data.status==1){ + layer.msg("" + data.info + ""); + setTimeout(function(){ + window.location.reload(); + },1500); + } + } + }); + } + }) + })