|
|
|
@ -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){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|