Merge branch 'feature/new_statement_0925' of wmtx/platform into release

优化下游同游戏判断
master
陈志 4 years ago committed by Gogs
commit 92336383d5

@ -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;
@ -915,6 +919,25 @@ 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);
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']);
@ -935,7 +958,7 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]],
];
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();
if(empty($pres)){continue;}
@ -963,6 +986,22 @@ class CompanyStatementSetController extends Controller {
$game[$v['relation_game_id']]['pay_amount'] = $v['pay_amount'];
}
}
//同cp同一个原包名的共享总流水分成
$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;
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){
@ -1112,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_");
@ -1552,6 +1591,71 @@ 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 [
* 148 =>["148","157"],
* 157=>["148","157"]
* ]
*/
protected function getTheSameGame($relation_game_ids)
{
if(empty($relation_game_ids)) return [];
$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;
}
/**
* 重算接口

Loading…
Cancel
Save