diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index ecd82bd39..c33ad2f93 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -1593,6 +1593,10 @@ class CompanyStatementSetController extends Controller { $where = [ "_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){//月结 $where['settlement_type']=2; @@ -1680,200 +1684,199 @@ class CompanyStatementSetController extends Controller { $v['reward'] = 0; } $v['platform_amount'] = 0; - if(!isset($v['list'])){continue;} - $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']; + if(!isset($v['list']) && $v['fine'] == 0 && $v['reward'] == 0){continue;} + if(!array_key_exists('list',$v) && ($v['fine'] > 0 || $v['reward'] > 0)){ + //没有流水,但是有罚款 + $sta_info = [ + "account" => $v['account'], + "game_list" => [ + [ + "pay_amount" => 0, + "relation_game_id" => 0, + "game_name" => "其他", + "p_id" => 0, + "all_pay_amount" => 0, + "game_type_name" => "其他", + "ratio"=>0, + "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); - - $handleed_data = []; + $promoteCompanyGameRatio = D("CompanyGameRatio")->getPromoteCompanyGameRatio($v['id'], $v['game_ids'], $begintime, $endtime, $company_belong); - foreach($v['list'] as $ke=>$va){ - $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); + $handleed_data = []; -// if ($v['id'] == 5) { -// dump($p_info['all_pay_amount']); -// dump($turnover_type); -// dump($tmp_game_ratio); -// } - - if ($turnover_type == 2||$turnover_type == 4) { - $tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); + foreach ($v['list'] as $ke=>$va) { + $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) { + $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 { - $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']; - $p_info['sum_money']=round($p_info['pay_amount']*$tratio/100,2); //个人等于 结算金额*比例 - $v['pay_amount'] += $p_info['sum_money']; - $v['statement_money'] += $p_info['sum_money']; - $p_info['fax_ratio']=$fax_ratio; - $p_info['statement_begin_time']=$statement_begin_time; - $p_info['statement_end_time']=$statement_end_time; + $v['platform_amount'] += $p_info['pay_amount']; + $p_info['sum_money']=round($p_info['pay_amount']*$tratio/100, 2); //个人等于 结算金额*比例 + $v['pay_amount'] += $p_info['sum_money']; + $v['statement_money'] += $p_info['sum_money']; + $p_info['fax_ratio']=$fax_ratio; + $p_info['statement_begin_time']=$statement_begin_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]['reward'] || $handleed_data[$v['id'].$statement_begin_time.$statement_end_time]['reward'] == '0') ) { - $p_info['fine'] = 0; - $p_info['reward'] = 0; - } else { - $p_info['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']: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]['reward'] = (string)$RewardRecordRes['reward']; - } -// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) { -// dump($RewardRecordRes); -// } - - - - $p_info['statement_type']=0; - - if ($p_info['pay_amount'] !='0') { - $va['game_list'][] = $p_info; - } - + $p_info['fine'] = 0; + $p_info['reward'] = 0; + } else { + $p_info['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']: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]['reward'] = (string)$RewardRecordRes['reward']; + } + $p_info['statement_type']=0; - }else{ - for ($i=0; $i < $ratioCount; $i++) { - $temp_game = []; - $tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][$i]; - 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 ($v['id'] == 5) { -// dump($p_info['all_pay_amount']); -// dump($turnover_type); -// dump($tmp_game_ratio); -// } - 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 ($p_info['pay_amount'] !='0') { + $va['game_list'][] = $p_info; + } + } else { + for ($i=0; $i < $ratioCount; $i++) { + $temp_game = []; + $tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][$i]; + 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 { - $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{ - $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']; - - $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; + $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']]['reward'] || $handleed_data[$v['id'].$temp_game['statement_begin_time'].$temp_game['statement_end_time']]['reward'] == '0') ) { - $temp_game['fine'] = 0; - $temp_game['reward'] = 0; - } else { - $temp_game['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']: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']]['reward'] = (string)$RewardRecordRes['reward']; - } -// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) { -// dump($RewardRecordRes); -// } - - $temp_game['statement_type']=0; + $temp_game['fine'] = 0; + $temp_game['reward'] = 0; + } else { + $temp_game['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']: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']]['reward'] = (string)$RewardRecordRes['reward']; + } + $temp_game['statement_type']=0; - $temp_game['relation_game_id']=$p_info["relation_game_id"]; - $temp_game['game_name']=$p_info["game_name"]; - $temp_game['game_type_name']=$p_info["game_type_name"]; - $temp_game['all_pay_amount']=$p_info["all_pay_amount"]; + $temp_game['relation_game_id']=$p_info["relation_game_id"]; + $temp_game['game_name']=$p_info["game_name"]; + $temp_game['game_type_name']=$p_info["game_type_name"]; + $temp_game['all_pay_amount']=$p_info["all_pay_amount"]; - if ($temp_game['pay_amount'] != '0') { - $va['game_list'][] = $temp_game; + if ($temp_game['pay_amount'] != '0') { + $va['game_list'][] = $temp_game; + } } - - } - } - } - $v['statement_info'][] = $va; - } + } + } + $v['statement_info'][] = $va; + } + } $company_info = [ 'account'=>$v['account'], "company_relation_str"=>$v['company_relation_str'],