From 02aa1bd08802f428f24c0f57e37ef706396656c4 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sun, 27 Sep 2020 11:05:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 2ff9ad3b9..aa85fc0f9 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -915,6 +915,9 @@ class CompanyStatementSetController extends Controller { } } } + $game_ids = implode(",",array_unique(array_column($list,"relation_game_id"))); + $sameGame = $this->getTheSameGame($game_ids); + dd($sameGame); foreach($res as $k=>$v){ $pcList[$k]["pay_amount"] = $v['pay_amount']; unset($v['pay_amount']); @@ -935,7 +938,7 @@ class CompanyStatementSetController extends Controller { "s.payed_time"=>['between', [$begintime,$endtime]], ]; for ($i=0; $i field("id,account")->where("company_id = '{$company_id}'")->select(); if(empty($pres)){continue;} @@ -963,6 +966,21 @@ class CompanyStatementSetController extends Controller { $game[$v['relation_game_id']]['pay_amount'] = $v['pay_amount']; } } + //同cp,同一个原包名的共享总流水分成 + $sameGame = $this->getTheSameGame(implode(",",array_keys($game))); + if(!empty($sameGame)){ + foreach ($sameGame as $k => $v) { + $temp = 0; + for ($j=0; $j < count($v); $j++) { + $temp += $game[$v[$j]]['pay_amount']; + } + $sameGame[$k] = $temp; + } + foreach ($sameGame as $k => $v) { + $game[$k]['pay_amount']= $v; + } + } + $pcList[$company_id]['game_ids'] = implode(",",array_keys($game)); foreach($list as $k=>$v){ @@ -1552,6 +1570,48 @@ class CompanyStatementSetController extends Controller { $pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find(); return $pay_amount['pay_amount'] ?? 0; } + /** + * 识别游戏为同款游戏,共享流水分成比例 + * return [ + * 148 =>["148","157"], + * 157=>["148","157"] + * ] + */ + protected function getTheSameGame($relation_game_ids) + { + + $where = [ + "id"=>["in",$relation_game_ids] + ]; + $Gameinfo = D("Game")->field("relation_game_id,partner_id,original_package_name")->where($where)->select(); + if(empty($Gameinfo)){ + return []; + } + $data = []; + foreach ($Gameinfo as $k => $v) { + if(empty($v['original_package_name'])) continue; + if(!isset($data[$v['partner_id']])){ + $data[$v['partner_id']] = []; + } + if(!isset($data[$v['partner_id']][$v['original_package_name']])){ + $data[$v['partner_id']][$v['original_package_name']] = [$v['relation_game_id']]; + }else{ + $data[$v['partner_id']][$v['original_package_name']][] = $v['relation_game_id']; + } + } + $senddata = []; + foreach ($data as $k => $partenr) { + foreach($partenr as $ke => $game){ + $gamecount = count($game); + if($gamecount > 1){ + for ($i=0; $i < $gamecount; $i++) { + $senddata[$game[$i]] = $game; + } + } + } + } + return $senddata; + } /** * 重算接口 From 7a8b91c8f0a1c49ac650e03856cd7cf8fd5aed5d Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sun, 27 Sep 2020 17:20:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E6=B8=B8?= =?UTF-8?q?=E5=90=8C=E6=B8=B8=E6=88=8F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 58 ++++++++++++++++--- .../PromoteCompanyController.class.php | 4 +- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index aa85fc0f9..58bd33ace 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -709,7 +709,11 @@ class CompanyStatementSetController extends Controller { $game =[]; $game['game_name'] =$v['game_list'][$t_game_id]['game_name']; $game['relation_game_id'] =$v['game_list'][$t_game_id]['relation_game_id']; - $game_all_payment = $v['game_list'][$t_game_id]['pay_amount']; + if(isset($v['game_list'][$t_game_id]['all_pay_amount'])){ + $game_all_payment = $v['game_list'][$t_game_id]['all_pay_amount']-0; + }else{ + $game_all_payment = $v['game_list'][$t_game_id]['pay_amount']-0; + } // dump($tratio); $game['fax_ratio']=$fax_ratio-0; @@ -718,7 +722,7 @@ class CompanyStatementSetController extends Controller { if(count($t_game_ratio) == 1){ $tmp_game_ratio = $t_game_ratio[0]; - $game['pay_amount'] =$game_all_payment; + $game['pay_amount'] = $v['game_list'][$t_game_id]['pay_amount']; $game['pay_amount'] -=0; $game['statement_begin_time']=$statement_begin_time; @@ -916,8 +920,24 @@ class CompanyStatementSetController extends Controller { } } $game_ids = implode(",",array_unique(array_column($list,"relation_game_id"))); + $game_ids = $this->getModuleRatioGame($company_id,$game_ids,$begintime,$endtime); $sameGame = $this->getTheSameGame($game_ids); - dd($sameGame); + + if(!empty($sameGame)){ + foreach ($sameGame as $k => $v) { + $temp = 0; + for ($j=0; $j < count($v); $j++) { + $temp += $res[$company_id][$v[$j]]['pay_amount']; + } + $sameGame[$k] = $temp; + } + foreach ($sameGame as $k => $v) { + $res[$company_id][$k]['all_pay_amount'] = $v; + // $game[$k]['pay_amount']= $v; + } + } + + foreach($res as $k=>$v){ $pcList[$k]["pay_amount"] = $v['pay_amount']; unset($v['pay_amount']); @@ -967,7 +987,9 @@ class CompanyStatementSetController extends Controller { } } //同cp,同一个原包名的共享总流水分成 - $sameGame = $this->getTheSameGame(implode(",",array_keys($game))); + $game_ids = implode(",",array_keys($game)); + $game_ids = $this->getModuleRatioGame($company_id,$game_ids,$begintime,$endtime); + $sameGame = $this->getTheSameGame($game_ids); if(!empty($sameGame)){ foreach ($sameGame as $k => $v) { $temp = 0; @@ -980,7 +1002,6 @@ class CompanyStatementSetController extends Controller { $game[$k]['pay_amount']= $v; } } - $pcList[$company_id]['game_ids'] = implode(",",array_keys($game)); foreach($list as $k=>$v){ @@ -1130,7 +1151,7 @@ class CompanyStatementSetController extends Controller { $pc[$v['id']]['is_payment']=$pcList[$v['id']]['is_payment']; } unset($tmpp); - + $this->getPuPromoteSpend($pc,array_unique(array_keys($pc)),$begintime,$endtime); $StatementDb = M("CompanyStatement","tab_"); @@ -1570,6 +1591,29 @@ class CompanyStatementSetController extends Controller { $pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find(); return $pay_amount['pay_amount'] ?? 0; } + /** + * 获取游戏是否有特殊比例,返回没有特殊比例的游戏 + * return string "148,157" + */ + protected function getModuleRatioGame($company_id,$relation_game_ids,$begintime,$endtime){ + $where = [ + "relation_game_id"=>["in",$relation_game_ids], + "company_id"=>$company_id, + "_string"=>"begin_time <={$endtime} AND ( end_time = 0 OR end_time >= {$begintime})" + ]; + $dbres = D("CompanyGameRatio")->field("relation_game_id")->where($where)->select(); + if(is_string($relation_game_ids)) $relation_game_ids = explode(",",$relation_game_ids); + + if(empty($dbres)){ + return implode(",",$relation_game_ids);; + }else{ + $dbres = array_column($dbres,"relation_game_id"); + $diff = array_diff($relation_game_ids,$dbres); + + return implode(",",$diff); + } + } + /** * 识别游戏为同款游戏,共享流水分成比例 * return [ @@ -1579,7 +1623,7 @@ class CompanyStatementSetController extends Controller { */ protected function getTheSameGame($relation_game_ids) { - + if(empty($relation_game_ids)) return []; $where = [ "id"=>["in",$relation_game_ids] ]; diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index e98b3ae92..b47b7c5af 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -1375,10 +1375,10 @@ class PromoteCompanyController extends ThinkController if(empty($game_arr)){ return $senddata; } - foreach($game_arr as $k=>$v){ + if(empty($game[$k])) continue; $senddata[$k]= ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],"row"=>1]; - $senddata[$k]+= $game[$k];; + $senddata[$k] += $game[$k]; } return $senddata; }