|
|
@ -644,7 +644,7 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
$tratio =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
|
|
|
|
$tratio =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
|
|
|
|
$tratio += $company_ratio;
|
|
|
|
$tratio += $company_ratio;
|
|
|
|
}elseif($type == 0){
|
|
|
|
}elseif($type == 0){
|
|
|
|
$tratio = $t_game_ratio['ratio'];
|
|
|
|
$tratio = $tmp_game_ratio['ratio'];
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
//补点
|
|
|
|
//补点
|
|
|
|
$tratio1 =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
|
|
|
|
$tratio1 =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
|
|
|
@ -878,6 +878,8 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
$game[$v['relation_game_id']]['pay_amount'] = $v['pay_amount'];
|
|
|
|
$game[$v['relation_game_id']]['pay_amount'] = $v['pay_amount'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$pcList[$company_id]['game_ids'] = implode(",",array_keys($game));
|
|
|
|
|
|
|
|
|
|
|
|
foreach($list as $k=>$v){
|
|
|
|
foreach($list as $k=>$v){
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$res[$company_id]["pay_amount"] += $v['pay_amount'];
|
|
|
|
$res[$company_id]["pay_amount"] += $v['pay_amount'];
|
|
|
@ -1075,40 +1077,88 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
$v['statement_money'] -= $v['server_fee'];
|
|
|
|
$v['statement_money'] -= $v['server_fee'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$promoteCompanyGameRatio = D("CompanyGameRatio")->getPromoteCompanyGameRatio($v['id'],$v['game_ids'],$begintime,$endtime,$company_belong);
|
|
|
|
foreach($v['list'] as $ke=>$va){
|
|
|
|
foreach($v['list'] as $ke=>$va){
|
|
|
|
$templist = $va['game_list'];
|
|
|
|
$templist = $va['game_list'];
|
|
|
|
$va['game_list'] = [];
|
|
|
|
$va['game_list'] = [];
|
|
|
|
foreach($templist as $p_id => $p_info){
|
|
|
|
foreach($templist as $p_id => $p_info){
|
|
|
|
// dd($p_info);
|
|
|
|
|
|
|
|
if($type == 1){
|
|
|
|
$ratioCount = count($promoteCompanyGameRatio[$p_info['relation_game_id']]);
|
|
|
|
$tratio = getGamePromoteCompanyRadio($v['id'],$p_info['relation_game_id'],$endtime,$p_info['all_pay_amount'],true,$company_belong);
|
|
|
|
$isMoreRatio = $ratioCount > 1 ? true : false;
|
|
|
|
$tratio += $company_ratio;
|
|
|
|
|
|
|
|
}elseif($type == 0){
|
|
|
|
if(!$isMoreRatio){
|
|
|
|
$tratio = getGamePromoteCompanyRadio($v['id'],$p_info['relation_game_id'],$endtime,$p_info['all_pay_amount'],false,$company_belong);
|
|
|
|
$tmp_game_ratio = $promoteCompanyGameRatio[$p_info['relation_game_id']][0];
|
|
|
|
}else{
|
|
|
|
if($type == 1){
|
|
|
|
//补点
|
|
|
|
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
|
|
|
|
$tratio1 = getGamePromoteCompanyRadio($v['id'],$p_info['relation_game_id'],$endtime,$p_info['all_pay_amount'],true,$company_belong);;
|
|
|
|
$tratio += $company_ratio;
|
|
|
|
$tratio2 = getGamePromoteCompanyRadio($v['id'],$p_info['relation_game_id'],$endtime,$p_info['all_pay_amount'],false,$company_belong);
|
|
|
|
}elseif($type == 0){
|
|
|
|
$tratio = $tratio1-$tratio2+$company_ratio;
|
|
|
|
$tratio = $tmp_game_ratio['ratio'];
|
|
|
|
if($tratio <= 0){
|
|
|
|
}else{
|
|
|
|
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){
|
|
|
|
if($type == 2){
|
|
|
|
$p_info['increment_ratio']=$tratio;
|
|
|
|
$p_info['increment_ratio']=$tratio;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$p_info['ratio']=$tratio;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
$p_info['statement_type']=0;
|
|
|
|
|
|
|
|
$va['game_list'][] = $p_info;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$p_info['ratio']=$tratio;
|
|
|
|
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){
|
|
|
|
|
|
|
|
$tratio = $tmp_game_ratio['ratio'];
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//补点
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$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['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"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$va['game_list'][] = $temp_game;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$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;
|
|
|
|
|
|
|
|
$p_info['statement_type']=0;
|
|
|
|
|
|
|
|
$va['game_list'][] = $p_info;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$v['statement_info'][] = $va;
|
|
|
|
$v['statement_info'][] = $va;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1383,6 +1433,35 @@ 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function getRelationGameIdPromoteSpend($promote_id,$relation_game_id,$begintime,$endtime)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$res = [];
|
|
|
|
|
|
|
|
//获取推广员
|
|
|
|
|
|
|
|
$Promote = M("Promote","tab_");
|
|
|
|
|
|
|
|
$Spend = M("Spend","tab_");
|
|
|
|
|
|
|
|
$spenMap = [
|
|
|
|
|
|
|
|
"s.pay_status"=>1,
|
|
|
|
|
|
|
|
"s.payed_time"=>['between', [$begintime,$endtime]],
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$Pmap = [
|
|
|
|
|
|
|
|
"chain"=>["LIKE","%/{$promote_id}/%"],
|
|
|
|
|
|
|
|
"_logic"=>"OR",
|
|
|
|
|
|
|
|
"id"=>$promote_id
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
$pres = $Promote->field("group_concat(id) ids,count(id) count")->where($Pmap)->group("company_id")->find();
|
|
|
|
|
|
|
|
if($pres['count'] ==0 ){return 0;}
|
|
|
|
|
|
|
|
$spenMap['s.promote_id']=["in",$pres['ids']];
|
|
|
|
|
|
|
|
//游戏
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$game_id = D("Game")->changeRelationGameidToGameid($relation_game_id);
|
|
|
|
|
|
|
|
// dd($game_id);
|
|
|
|
|
|
|
|
$spenMap['s.game_id'] =['in',$game_id];
|
|
|
|
|
|
|
|
//获取支付记录
|
|
|
|
|
|
|
|
$pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find();
|
|
|
|
|
|
|
|
return $pay_amount['pay_amount'] ?? 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 重算接口
|
|
|
|
* 重算接口
|
|
|
|