Merge pull request '优化独立减罚' (#280) from hotfix/fiance_statement_bug_20210420 into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/280
master
廖金灵 4 years ago
commit 8375c5f9bd

@ -1593,6 +1593,10 @@ class CompanyStatementSetController extends Controller {
$where = [ $where = [
"_string"=>"first_company_type = '2' OR second_company_type = '2'" "_string"=>"first_company_type = '2' OR second_company_type = '2'"
]; ];
//单一公司调试
// $where['_string'] = "( " . $where['_string'] .") AND ( first_company_id = '509' OR first_company_id = '509' )";
//获取哪些要结算 //获取哪些要结算
if($type == 1){//月结 if($type == 1){//月结
$where['settlement_type']=2; $where['settlement_type']=2;
@ -1680,200 +1684,199 @@ class CompanyStatementSetController extends Controller {
$v['reward'] = 0; $v['reward'] = 0;
} }
$v['platform_amount'] = 0; $v['platform_amount'] = 0;
if(!isset($v['list'])){continue;} if(!isset($v['list']) && $v['fine'] == 0 && $v['reward'] == 0){continue;}
$company_belong = $pc[$v['id']]['company_belong']; if(!array_key_exists('list',$v) && ($v['fine'] > 0 || $v['reward'] > 0)){
//服务器费用 //没有流水,但是有罚款
if ($type < 2) { $sta_info = [
if ($v['has_server_fee'] == 1 && $v['server_fee'] > 0) { "account" => $v['account'],
$v['statement_info'][] = [ "game_list" => [
"game_name"=>"服务器费用", [
"sum_money"=>-$v['server_fee'], "pay_amount" => 0,
"pay_amount"=>-$v['server_fee'], "relation_game_id" => 0,
'statement_type'=>1, "game_name" => "其他",
"statement_begin_time"=>$statement_begin_time, "p_id" => 0,
"statement_end_time"=>$statement_end_time "all_pay_amount" => 0,
]; "game_type_name" => "其他",
$v['pay_amount'] -= $v['server_fee']; "ratio"=>0,
$v['statement_money'] -= $v['server_fee']; "sum_money" => 0,
"fax_ratio" => 0,
"statement_begin_time" => $statement_begin_time,
"statement_end_time" => $statement_end_time,
"fine" => $v['fine'],
"reward" => $v['reward'],
"statement_type" => 0
]
]
];
$v['statement_info'][] = $sta_info;
}else{
$company_belong = $pc[$v['id']]['company_belong'];
//服务器费用
if ($type < 2) {
if ($v['has_server_fee'] == 1 && $v['server_fee'] > 0) {
$v['statement_info'][] = [
"game_name"=>"服务器费用",
"sum_money"=>-$v['server_fee'],
"pay_amount"=>-$v['server_fee'],
'statement_type'=>1,
"statement_begin_time"=>$statement_begin_time,
"statement_end_time"=>$statement_end_time
];
$v['pay_amount'] -= $v['server_fee'];
$v['statement_money'] -= $v['server_fee'];
}
} }
} $promoteCompanyGameRatio = D("CompanyGameRatio")->getPromoteCompanyGameRatio($v['id'], $v['game_ids'], $begintime, $endtime, $company_belong);
$promoteCompanyGameRatio = D("CompanyGameRatio")->getPromoteCompanyGameRatio($v['id'],$v['game_ids'],$begintime,$endtime,$company_belong);
$handleed_data = [];
foreach($v['list'] as $ke=>$va){ $handleed_data = [];
$templist = $va['game_list'];
$va['game_list'] = [];
foreach($templist as $p_id => $p_info){
$ratioCount = count($promoteCompanyGameRatio[$p_info['relation_game_id']]);
$isMoreRatio = $ratioCount > 1 ? true : false;
if(!$isMoreRatio){
$tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][0];
if($type == 1){
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio += $company_ratio;
}elseif($type == 0){
// $tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
// $tratio = $tmp_game_ratio['ratio'];
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
// if ($v['id'] == 5) { foreach ($v['list'] as $ke=>$va) {
// dump($p_info['all_pay_amount']); $templist = $va['game_list'];
// dump($turnover_type); $va['game_list'] = [];
// dump($tmp_game_ratio); foreach ($templist as $p_id => $p_info) {
// } $ratioCount = count($promoteCompanyGameRatio[$p_info['relation_game_id']]);
$isMoreRatio = $ratioCount > 1 ? true : false;
if ($turnover_type == 2||$turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); if (!$isMoreRatio) {
$tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][0];
if ($type == 1) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
$tratio += $company_ratio;
} elseif ($type == 0) {
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'], $k, $begintime, $endtime);
if ($turnover_type == 2||$turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
} else {
$tratio = $tmp_game_ratio['ratio'];
}
} else { } else {
$tratio = $tmp_game_ratio['ratio']; $turnover_type = $this->getTurnoverType($p_info['relation_game_id'], $k, $begintime, $endtime);
if ($turnover_type == 2||$turnover_type == 4) {
continue;
}
//补点
$tratio1 =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
$tratio2 =$tmp_game_ratio['ratio'];
$tratio = $tratio1-$tratio2+$company_ratio;
if ($tratio <= 0) {
continue;
}
}
$tratio -= 0;
if ($type == 2) {
$p_info['increment_ratio']=$tratio;
} else {
$p_info['ratio']=$tratio;
} }
}else{
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
if ($turnover_type == 2||$turnover_type == 4) {
continue;
}
//补点
$tratio1 =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio2 =$tmp_game_ratio['ratio'];
$tratio = $tratio1-$tratio2+$company_ratio;
if($tratio <= 0){ continue;}
}
$tratio -= 0;
if($type == 2){
$p_info['increment_ratio']=$tratio;
}else{
$p_info['ratio']=$tratio;
}
$p_info['pay_amount'] = $this->getRelationGameIdPromoteSpend($p_info["p_id"],$p_info['relation_game_id'],$tmp_game_ratio['begintime'],$tmp_game_ratio['endtime']); $p_info['pay_amount'] = $this->getRelationGameIdPromoteSpend($p_info["p_id"], $p_info['relation_game_id'], $tmp_game_ratio['begintime'], $tmp_game_ratio['endtime']);
$p_info['pay_amount'] = number_format($p_info['pay_amount'],2,'.',''); $p_info['pay_amount'] = number_format($p_info['pay_amount'], 2, '.', '');
$v['platform_amount'] += $p_info['pay_amount']; $v['platform_amount'] += $p_info['pay_amount'];
$p_info['sum_money']=round($p_info['pay_amount']*$tratio/100,2); //个人等于 结算金额*比例 $p_info['sum_money']=round($p_info['pay_amount']*$tratio/100, 2); //个人等于 结算金额*比例
$v['pay_amount'] += $p_info['sum_money']; $v['pay_amount'] += $p_info['sum_money'];
$v['statement_money'] += $p_info['sum_money']; $v['statement_money'] += $p_info['sum_money'];
$p_info['fax_ratio']=$fax_ratio; $p_info['fax_ratio']=$fax_ratio;
$p_info['statement_begin_time']=$statement_begin_time; $p_info['statement_begin_time']=$statement_begin_time;
$p_info['statement_end_time']=$statement_end_time; $p_info['statement_end_time']=$statement_end_time;
$RewardRecordRes = $this->getPromoteUserGameRewardRecord($v['id'],$statement_begin_time,$statement_end_time); $RewardRecordRes = $this->getPromoteUserGameRewardRecord($v['id'], $statement_begin_time, $statement_end_time);
if ( if (
($handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] || $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] == '0') ($handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] || $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] == '0')
|| ($handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] || $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] == '0') || ($handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] || $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] == '0')
) { ) {
$p_info['fine'] = 0; $p_info['fine'] = 0;
$p_info['reward'] = 0; $p_info['reward'] = 0;
} else { } else {
$p_info['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0; $p_info['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0;
$p_info['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']:0; $p_info['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']:0;
$handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] = (string)$RewardRecordRes['fine']; $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['fine'] = (string)$RewardRecordRes['fine'];
$handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] = (string)$RewardRecordRes['reward']; $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] = (string)$RewardRecordRes['reward'];
} }
// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) { $p_info['statement_type']=0;
// dump($RewardRecordRes);
// }
$p_info['statement_type']=0;
if ($p_info['pay_amount'] !='0') {
$va['game_list'][] = $p_info;
}
}else{ if ($p_info['pay_amount'] !='0') {
for ($i=0; $i < $ratioCount; $i++) { $va['game_list'][] = $p_info;
$temp_game = []; }
$tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][$i]; } else {
if($type == 1){ for ($i=0; $i < $ratioCount; $i++) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); $temp_game = [];
$tratio += $company_ratio; $tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][$i];
}elseif($type == 0){ if ($type == 1) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime); $tratio += $company_ratio;
// if ($v['id'] == 5) { } elseif ($type == 0) {
// dump($p_info['all_pay_amount']); $turnover_type = $this->getTurnoverType($p_info['relation_game_id'], $k, $begintime, $endtime);
// dump($turnover_type); if ($turnover_type == 2 || $turnover_type == 4) {
// dump($tmp_game_ratio); $tratio =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
// } } else {
if ($turnover_type == 2 || $turnover_type == 4) { $tratio = $tmp_game_ratio['ratio'];
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); }
} else { } else {
$tratio = $tmp_game_ratio['ratio']; $turnover_type = $this->getTurnoverType($p_info['relation_game_id'], $k, $begintime, $endtime);
if ($turnover_type == 2 || $turnover_type == 4) {
continue;
}
//补点
$tratio1 =$this->getTurnoverRatio($p_info['all_pay_amount'], $tmp_game_ratio['ratio'], $tmp_game_ratio['turnover_ratio']);
$tratio2 =$tmp_game_ratio['ratio'];
$tratio = $tratio1-$tratio2+$company_ratio;
if ($tratio <= 0) {
continue;
}
} }
$tratio -= 0;
if ($type == 2) {
$temp_game['increment_ratio']=$tratio;
} else {
$temp_game['ratio']=$tratio;
}
$temp_game['pay_amount'] = $this->getRelationGameIdPromoteSpend($p_info["p_id"], $p_info['relation_game_id'], $tmp_game_ratio['begintime'], $tmp_game_ratio['endtime']);
$temp_game['pay_amount'] -=0;
$temp_game['pay_amount'] = number_format($temp_game['pay_amount'], 2, '.', '');
$v['platform_amount'] += $temp_game['pay_amount'];
$temp_game['sum_money']=round($temp_game['pay_amount']*$tratio/100, 2); //个人等于 结算金额*比例
$v['pay_amount'] += $temp_game['sum_money'];
$v['statement_money'] += $temp_game['sum_money'];
}else{ $temp_game['fax_ratio']=$fax_ratio-0;
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime); $temp_game['statement_begin_time']=date("Y.m.d", $tmp_game_ratio['begintime']);
if ($turnover_type == 2 || $turnover_type == 4) { $temp_game['statement_end_time']=date("Y.m.d", $tmp_game_ratio['endtime']);
continue; $temp_game['statement_type']=0;
}
//补点
$tratio1 =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio2 =$tmp_game_ratio['ratio'];
$tratio = $tratio1-$tratio2+$company_ratio;
if($tratio <= 0){ continue;}
}
$tratio -= 0;
if($type == 2){
$temp_game['increment_ratio']=$tratio;
}else{
$temp_game['ratio']=$tratio;
}
$temp_game['pay_amount'] = $this->getRelationGameIdPromoteSpend($p_info["p_id"],$p_info['relation_game_id'],$tmp_game_ratio['begintime'],$tmp_game_ratio['endtime']);
$temp_game['pay_amount'] -=0;
$temp_game['pay_amount'] = number_format($temp_game['pay_amount'],2,'.','');
$v['platform_amount'] += $temp_game['pay_amount'];
$temp_game['sum_money']=round($temp_game['pay_amount']*$tratio/100,2); //个人等于 结算金额*比例
$v['pay_amount'] += $temp_game['sum_money'];
$v['statement_money'] += $temp_game['sum_money'];
$temp_game['fax_ratio']=$fax_ratio-0;
$temp_game['statement_begin_time']=date("Y.m.d",$tmp_game_ratio['begintime']);
$temp_game['statement_end_time']=date("Y.m.d",$tmp_game_ratio['endtime']);
$temp_game['statement_type']=0;
$RewardRecordRes = $this->getPromoteUserGameRewardRecord($v['id'],$temp_game['statement_begin_time'],$temp_game['statement_end_time']); $RewardRecordRes = $this->getPromoteUserGameRewardRecord($v['id'], $temp_game['statement_begin_time'], $temp_game['statement_end_time']);
if ( if (
($handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] || $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] == '0') ($handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] || $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] == '0')
|| ($handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] || $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] == '0') || ($handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] || $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] == '0')
) { ) {
$temp_game['fine'] = 0; $temp_game['fine'] = 0;
$temp_game['reward'] = 0; $temp_game['reward'] = 0;
} else { } else {
$temp_game['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0; $temp_game['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0;
$temp_game['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']:0; $temp_game['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']:0;
$handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] = (string)$RewardRecordRes['fine']; $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['fine'] = (string)$RewardRecordRes['fine'];
$handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] = (string)$RewardRecordRes['reward']; $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] = (string)$RewardRecordRes['reward'];
} }
// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) { $temp_game['statement_type']=0;
// dump($RewardRecordRes);
// }
$temp_game['statement_type']=0;
$temp_game['relation_game_id']=$p_info["relation_game_id"]; $temp_game['relation_game_id']=$p_info["relation_game_id"];
$temp_game['game_name']=$p_info["game_name"]; $temp_game['game_name']=$p_info["game_name"];
$temp_game['game_type_name']=$p_info["game_type_name"]; $temp_game['game_type_name']=$p_info["game_type_name"];
$temp_game['all_pay_amount']=$p_info["all_pay_amount"]; $temp_game['all_pay_amount']=$p_info["all_pay_amount"];
if ($temp_game['pay_amount'] != '0') { if ($temp_game['pay_amount'] != '0') {
$va['game_list'][] = $temp_game; $va['game_list'][] = $temp_game;
}
} }
}
} }
} $v['statement_info'][] = $va;
} }
$v['statement_info'][] = $va; }
}
$company_info = [ $company_info = [
'account'=>$v['account'], 'account'=>$v['account'],
"company_relation_str"=>$v['company_relation_str'], "company_relation_str"=>$v['company_relation_str'],

Loading…
Cancel
Save