优化下游同游戏判断

master
chenzhi 4 years ago
parent 02aa1bd088
commit 7a8b91c8f0

@ -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){
@ -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]
];

@ -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;
}

Loading…
Cancel
Save