From 5367ea4aaee0db6261bf0e73a1a0f9b629fd552f Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 20 Jul 2020 22:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteCompanyController.class.php | 200 +++++----------- .../Admin/View/PromoteCompany/lists.html | 222 ++++++++++-------- 2 files changed, 176 insertions(+), 246 deletions(-) diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index fa5e63c2f..8d84dded3 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -64,147 +64,27 @@ class PromoteCompanyController extends ThinkController }else{ $companyres = $companyres->page($page,$row)->select(); } - //获取公司id - $companyids = implode(',', array_column($companyres, 'id')); - //获取所属会长及其游戏分成 - $promotemap['company_id']=["in",$companyids]; - $promotemap['level'] = 1; + //获取公司信息 + if(!empty($companyres)){ + foreach($companyres as $k=>&$v){ - $promoteres = M("Promote","tab_") - ->field("id,company_id,account,settlement_type") - ->where($promotemap) - ->select(); - //获取会长id - $promoteids = implode(',', array_column($promoteres, 'id')); - //获取游戏比例 - $gameradiores = M("PromoteGameRatio","tab_") - ->alias("pg") - ->field("pg.ratio,pg.relation_game_id,pg.turnover_ratio,pg.game_id,pg.promote_id,ga.relation_game_name,ga.game_type_name") - ->join("tab_game ga ON pg.game_id = ga.id") - ->where(array( - "status"=>1, - "promote_id"=>["in",$promoteids] - )) - ->group("relation_game_id,promote_id") - ->select(); - //比例数据处理 - $gameradiotemp = array(); - foreach($gameradiores as $k=>$v){ - $turnover_ratio = json_decode($v['turnover_ratio'],true); - $v['turnover_ratio'] = array( - array("ratio"=>$v['ratio']."%","name"=>"默认比例") - ); - - foreach($turnover_ratio as $ke=>$va){ - $t=array("ratio"=>$va["ratio"]."%"); - if(array_key_exists("instanceof",$va)){ - //存在 - if($va['instanceof']=='1'){ - $t['name']="月流水≥".$va['turnover']; - }else{ - $t['name']="月流水>".$va['turnover']; - } + //遍历获取游戏信息 + if(empty($v["game_ids"])){ + $game = $this->getPromoteGameRadio($v["id"],false); }else{ - $t['name']="月流水≥".$va['turnover']; - } - $v['turnover_ratio'][]=$t; - } - $v['row'] = count($v['turnover_ratio']); - unset($v["ratio"]); - unset($v["relation_game_id"]); - unset($v["game_id"]); - $gameradiotemp[$v['promote_id']][]=$v; - } - unset($gameradiores); - //会长数据处理 - $promoterestemp=[]; - foreach($promoteres as $k=>$v){ - if(array_key_exists($v['id'],$gameradiotemp)){ - //存在 - $v['list'] = $gameradiotemp[$v['id']]; - foreach($gameradiotemp[$v['id']] as $ke=>$va){ - $v['row'] += $va['row']; + $game = $this->getGamePromoteCompanyRadio($v["id"],$v["game_ids"],$is_export); } - }else{ - $v['list']=[ - ["relation_game_name"=>"--","game_type_name"=>"--", - "turnover_ratio"=>[ - ["name"=>"--","ratio"=>"--"] - ], - "row"=>1 - ] - ]; - $v["row"]=1; + $v += $game; } - if($v['settlement_type'] == 1){ - $v['settlement_type']="周结"; - }else{ - $v['settlement_type']="月结"; - } - $promoterestemp[$v['company_id']]["list"][]=$v; } - unset($promoteres); - - //处理公司数据 - foreach($companyres as $k=>&$v){ - if(array_key_exists($v['id'],$promoterestemp)){ - //存在 - $v['list'] = $promoterestemp[$v['id']]['list']; - foreach($promoterestemp[$v['id']] as $ke=>$va){ - foreach($va as $key=>$val){ - $v['row'] += $val['row']; - } - - } - $v['can_del'] = 0; - }else{ - //空值 - $v['can_del'] = 1; - $v['list']=[ - [ - "account"=>"--", - "settlement_type"=>"--", - 'list'=>[ - [ - "relation_game_name"=>"--", - "game_type_name"=>"--", - "turnover_ratio"=>[ - ["name"=>"--","ratio"=>"--"] - ], - "row"=>1 - ] - ] - ] - ]; - $v['row'] += 1; - } - if( $v["contact_begin"] >0 ){ - $v["contact_begin"] = date('Y/m/d', $v["contact_begin"]); - }else{ - $v["contact_begin"] = "--"; - } - if( $v["contact_end"] > 0){ - $v["contact_end"] = date('Y/m/d', $v["contact_end"]); - }else{ - $v["contact_end"] = "--"; - } - if($v['platform_name'] == '' || $v['platform_name'] == "0"){ - $v['platform_name'] = "--"; - } - - $v["is_sign_contact"] = ($v["is_sign_contact"]=="1" ? "是" :'否'); - $v["company_type"] = ($v["company_type"]=="1" ? "公司" :'个人'); - $v["company_belong"] = ($v["company_belong"]=="0" ? "内团" : ($v["company_belong"]=="1" ? "外团" : ($v["company_belong"]=="2" ? "外团分发" : '无'))); - } - - //公司及会长数量统计 $companycount = $model->field("id")->where($map)->select(); $count = count($companycount); $companyallids = implode(',', array_column($companycount, 'id')); $promotemap['company_id']=["in",$companyallids]; $promotecount = M("Promote","tab_")->where($promotemap)->count(); + // dd($companyres); $this->assign('listData', $companyres); $this->assign('count', $count); $this->assign('promotecount', $promotecount); @@ -1147,9 +1027,10 @@ class PromoteCompanyController extends ThinkController * @param boolean $is_export * @return void */ - public function getGamePromoteCompanyRadio($company_id,$game_ids,$is_export = false){ + protected function getGamePromoteCompanyRadio($company_id,$game_ids,$is_export = false){ //判断是否有生效 $senddata = []; + $game = $this->getGameInfo($game_ids); //获取cp分成比例 if($is_export){ $CpRadio = $this->getPromoteCompanyCpRadio($game_ids); @@ -1165,6 +1046,8 @@ class PromoteCompanyController extends ThinkController $t_gid = $v['relation_game_id']; unset($game_arr[$t_gid]); $senddata[$t_gid] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>$v['ratio'],"relation_game_id"=>$v['relation_game_id']]; + $senddata[$t_gid] += $game[$t_gid]; + $this->setPromoteRadio($senddata[$t_gid]); if($is_export){ @@ -1177,9 +1060,8 @@ class PromoteCompanyController extends ThinkController } } } - if(empty($game_arr)){ - //结束 + return $this->getPromoteGameRadio($company_id,$senddata); } $diff_ids = implode(",",array_keys($game_arr)); @@ -1190,9 +1072,9 @@ class PromoteCompanyController extends ThinkController if(!empty($m_res)){ foreach ($m_res as $k => $v) { $t_gid = $v['relation_game_id']; - unset($game_arr[$t_gid]); $senddata[$t_gid] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>$v['ratio'],"relation_game_id"=>$v['relation_game_id']]; + $senddata[$t_gid] += $game[$t_gid]; $this->setPromoteRadio($senddata[$t_gid]); if($is_export){ if(isset($CpRadio[$t_gid])){ @@ -1206,40 +1088,52 @@ class PromoteCompanyController extends ThinkController } } if(empty($game_arr)){ - //结束 + return $this->getPromoteGameRadio($company_id,$senddata); } foreach($game_arr as $k=>$v){ - $senddata[$k]= ["turnover_ratio"=>'[]',"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>'[]',"row"=>1]; + $senddata[$k]= ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],"row"=>1,"relation_game_name"=>"--","game_type_name"=>"--"]; } - // dd($senddata); - - $this->getPromoteGameRadio($company_id,$senddata); + return $this->getPromoteGameRadio($company_id,$senddata); } protected function getPromoteGameRadio($company_id,$ratio){ //获取会长信息 $rdata = []; $promotemap['company_id']=$company_id; $promotemap['level'] = 1; + $company_row = 0; $promoteres = M("Promote","tab_") ->field("id,company_id,account,game_ids") ->where($promotemap) ->select(); + if(empty($promoteres)){ - //结束 + //无会长 + return ["list"=>["account" => "--","list" => ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],"row"=>1,"relation_game_name"=>"--","game_type_name"=>"--"]],"row"=>1]; } + foreach ($promoteres as $k => &$v) { - $v['list'] = []; - $game_arr = array_flip(explode(",",$v['game_ids'])); - foreach($game_arr as $ke=>$va){ - if(isset($ratio[$ke])){ - $v['list'][] = $ratio[$ke]; + if($ratio == false || empty($v['game_ids'])){ + $v['row']=1; + $v['list'] = ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],"row"=>1,"relation_game_name"=>"--","game_type_name"=>"--"]; + $rdata[] = $v; + $company_row += $v['row']; + }else{ + $v['list'] = []; + $v['row']=0; + $game_arr = array_flip(explode(",",$v['game_ids'])); + foreach($game_arr as $ke=>$va){ + if(isset($ratio[$ke])){ + $v['list'][] = $ratio[$ke]; + $v['row'] += $ratio[$ke]["row"]; + } } + $rdata[] = $v; + $company_row += $v['row']; } - $rdata[] = $v; } - dd($rdata); + return ["list"=>$rdata,"row"=>$company_row]; } //获取cp分成比例 protected function getPromoteCompanyCpRadio($game_ids) @@ -1294,7 +1188,19 @@ class PromoteCompanyController extends ThinkController $v['turnover_ratio'][]=$t; } $v['row'] = count($v['turnover_ratio']); - + } + //获取游戏基础信息 + protected function getGameInfo($game_ids){ + $gameinfo = []; + $dbres = M("Game","tab_")->where("id in ($game_ids)")->field("relation_game_id,relation_game_name,game_type_name")->select(); + foreach($dbres as $k=>$v){ + $gameinfo[$v['relation_game_id']] = $v; + } + return $gameinfo; + } + //无游戏id获取比例 + protected function noGameidsGetPromote($company_id){ + } diff --git a/Application/Admin/View/PromoteCompany/lists.html b/Application/Admin/View/PromoteCompany/lists.html index ffe83d18a..5a9580807 100644 --- a/Application/Admin/View/PromoteCompany/lists.html +++ b/Application/Admin/View/PromoteCompany/lists.html @@ -120,26 +120,22 @@ - 操作 合作方名称 - 推广游戏 - 对应平台 + 内外团 + 开发类型 + 市场专员 公司性质 - 内外团归属 - 合同期限 - 开票税点 - 开户行 - 银行账号 - 是否签署合同 - 备注 + 押金 + 结算周期 会长账号 - 结算周期 + 原包名 + 现包名 产品类型 - 游戏名称 - 合作方分成比例 + 游戏分成比例 + 操作 @@ -151,6 +147,48 @@ + + {$data.company_name} + 查看 + {$data.platform_name} + {$data.company_belong} + {$data.develop_type} + {$data.uid} + {$data.company_type} + {$data.yj} + {$data.jszq} + + {$data['list'][0]['account']} + + + {$data['list'][0]['list'][0]['relation_game_name']} + {$data['list'][0]['list'][0]['relation_game_name']} + {$data['list'][0]['list'][0]['relation_game_name']} + + + {$data['list'][0]['list'][0]['turnover_ratio'][0]['name']} + {$data['list'][0]['list'][0]['turnover_ratio'][0]['ratio']} + + - + - + + + - + - + - + - + - + + + - + - + - + - + - + - + + + 查看 编辑 @@ -158,97 +196,83 @@ 删除 - {$data.company_name} - 查看 - {$data.platform_name} - {$data.company_type} - {$data.company_belong} - {$data.contact_begin} - {$data.contact_end} - {$data.fax_ratio}% - {$data.bank_name} - {$data.bank_card} - {$data.is_sign_contact} - {$data.content} - - - - - {$promote['account']} - {$promote['settlement_type']} - - - - {$game['game_type_name']} - {$game['relation_game_name']} - - - - {$ratio['name']} - {$ratio['ratio']} - - - {$ratio['name']} - {$ratio['ratio']} - - - - - {$game['game_type_name']} - {$game['relation_game_name']} - - - - {$ratio['name']} - {$ratio['ratio']} - - - {$ratio['name']} - {$ratio['ratio']} - - - - - - - {$promote['account']} - {$promote['settlement_type']} - - - {$game['game_type_name']} - {$game['relation_game_name']} - - - - {$ratio['name']} - {$ratio['ratio']} - - - {$ratio['name']} - {$ratio['ratio']} - - - + + + + + + + {$game_ratio['name']} + {$game_ratio['ratio']}% + + + + + + + + + + + + + {$p_ratio['relation_game_name']} + {$p_ratio['relation_game_name']} + {$p_ratio['relation_game_name']} + + + + {$p_ratio['turnover_ratio'][0]['name']} + {$p_ratio['turnover_ratio'][0]['ratio']} + + - + - + + + + + + - {$game['game_type_name']} - {$game['relation_game_name']} - - - - {$ratio['name']} - {$ratio['ratio']} - - - {$ratio['name']} - {$ratio['ratio']} - - + {$game_ratio['name']} + {$game_ratio['ratio']}% - - - + + + + + + + + + {$promote['account']} + + {$promote['list']['relation_game_name']} + {$promote['list']['relation_game_name']} + {$promote['list']['relation_game_name']} + + + {$promote['list']['turnover_ratio'][0]['name']} + {$promote['list']['turnover_ratio'][0]['ratio']} + + - + - + + + - + - + - + - + - + + + + + + 汇总: