优化下游个人同游戏判断

master
chenzhi 4 years ago
parent 2cdc4e815b
commit f22dc90e96

@ -935,7 +935,7 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]], "s.payed_time"=>['between', [$begintime,$endtime]],
]; ];
for ($i=0; $i <count($idarr); $i++) { for ($i=0; $i <count($idarr); $i++) {
$company_id = $idarr[$i]; $company_id = $idarr[$i];
$pres = $Promote->field("id,account")->where("company_id = '{$company_id}'")->select(); $pres = $Promote->field("id,account")->where("company_id = '{$company_id}'")->select();
if(empty($pres)){continue;} if(empty($pres)){continue;}
@ -963,6 +963,21 @@ class CompanyStatementSetController extends Controller {
$game[$v['relation_game_id']]['pay_amount'] = $v['pay_amount']; $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)); $pcList[$company_id]['game_ids'] = implode(",",array_keys($game));
foreach($list as $k=>$v){ foreach($list as $k=>$v){
@ -1552,6 +1567,51 @@ class CompanyStatementSetController extends Controller {
$pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find(); $pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find();
return $pay_amount['pay_amount'] ?? 0; 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;
}
}
}
}
var_dump($relation_game_ids);
return $senddata;
# code...
}
/** /**
* 重算接口 * 重算接口

Loading…
Cancel
Save