@ -955,9 +955,9 @@ class CompanyStatementSetController extends Controller {
// dump($spenMap);
// dump($spenMap);
$cpMap = $spenMap;
$cpMap = $spenMap;
$cpMap["s.payed_time"] = ['between', [strtotime(date("Y-m-1",$begintime)),$endtime]];
$cpAllMap = $spenMap;
$cpAllMap = $spenMap;
$cpAllMap["s.payed_time"] = ['elt',$endtime];
$cpAllMap["s.payed_time"] = ['elt',$endtime];
for ($i=0; $i < count ( $ idarr ) ; $ i + + ) {
for ($i=0; $i < count ( $ idarr ) ; $ i + + ) {
@ -1117,8 +1117,51 @@ class CompanyStatementSetController extends Controller {
if ($turnover_type == 2) {
if ($turnover_type == 2) {
$res[$key][$k]['ratio_pay_amount'] = $all_res[$key][$k]['pay_amount'];
$res[$key][$k]['ratio_pay_amount'] = $all_res[$key][$k]['pay_amount'];
} elseif($turnover_type == 3){
} elseif($turnover_type == 3){
if (empty($cp_res)) {
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
foreach($cpSpendList as $ck=>$cv){
try {
$cp_res[$company_id]["pay_amount"] += $cv['pay_amount'];
} catch (\Throwable $th) {
$cp_res[$company_id]["pay_amount"] = $cv['pay_amount'];
}
if(isset($cp_res[$company_id][$cv['relation_game_id']])){
//
$cp_res[$company_id][$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
}else{
unset($cv['game_id']);
$cp_res[$company_id][$cv['relation_game_id']]= $cv;
}
}
}
$res[$key][$k]['ratio_pay_amount'] = $cp_res[$key][$k]['pay_amount'];
$res[$key][$k]['ratio_pay_amount'] = $cp_res[$key][$k]['pay_amount'];
} elseif($turnover_type == 4){
} elseif($turnover_type == 4){
if (empty($cp_all_res)) {
$cpAllSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpAllMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
foreach ($cpAllSpendList as $ck => $cv) {
try {
$cp_all_res[$company_id]["pay_amount"] += $cv['pay_amount'];
} catch (\Throwable $th) {
$cp_all_res[$company_id]["pay_amount"] = $cv['pay_amount'];
}
if (isset($cp_all_res[$company_id][$cv['relation_game_id']])) {
//
$cp_all_res[$company_id][$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
} else {
unset($cv['game_id']);
$cp_all_res[$company_id][$cv['relation_game_id']] = $cv;
}
}
}
$res[$key][$k]['ratio_pay_amount'] = $cp_all_res[$key][$k]['pay_amount'];
$res[$key][$k]['ratio_pay_amount'] = $cp_all_res[$key][$k]['pay_amount'];
}
}
@ -1205,7 +1248,7 @@ class CompanyStatementSetController extends Controller {
$cpgame = [];
$cpgame = [];
$cpMap = $spenMap;
$cpMap = $spenMap;
$cpMap["s.payed_time"] = ['between', [strtotime(date("Y-m-1",$begintime)),$endtime]];
$cpAllMap = $spenMap;
$cpAllMap = $spenMap;
$cpAllMap["s.payed_time"] = ['elt',$endtime];
$cpAllMap["s.payed_time"] = ['elt',$endtime];
@ -1285,7 +1328,9 @@ class CompanyStatementSetController extends Controller {
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpMap)->group('game_id')
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->join("left join tab_game g on s.game_id = g.id")
->select();
->select();
if ($company_id == 43) {
dump($cpMap);
}
foreach($cpSpendList as $ck=>$cv){
foreach($cpSpendList as $ck=>$cv){
if(isset($cpgame[$cv['relation_game_id']])){
if(isset($cpgame[$cv['relation_game_id']])){
$cpgame[$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
$cpgame[$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
@ -1349,9 +1394,40 @@ class CompanyStatementSetController extends Controller {
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $allgame[$v['relation_game_id']]['pay_amount'];
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $allgame[$v['relation_game_id']]['pay_amount'];
} elseif($turnover_type == 3) {
} elseif($turnover_type == 3) {
if (empty($cpgame)) {
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
if ($company_id == 43) {
dump($cpMap);
}
foreach($cpSpendList as $ck=>$cv){
if(isset($cpgame[$cv['relation_game_id']])){
$cpgame[$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
}else{
$cpgame[$cv['relation_game_id']]['pay_amount'] = $cv['pay_amount'];
}
}
}
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpgame[$v['relation_game_id']]['pay_amount'];
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpgame[$v['relation_game_id']]['pay_amount'];
} elseif($turnover_type == 4) {
} elseif($turnover_type == 4) {
if (empty($cpallgame)) {
$cpAllSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpAllMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
foreach($cpAllSpendList as $ck=>$cv){
if(isset($cpallgame[$cv['relation_game_id']])){
$cpallgame[$cv['relation_game_id']]['pay_amount'] += $cv['pay_amount'];
}else{
$cpallgame[$cv['relation_game_id']]['pay_amount'] = $cv['pay_amount'];
}
}
}
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpallgame[$v['relation_game_id']]['pay_amount'];
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpallgame[$v['relation_game_id']]['pay_amount'];
} else {
} else {
// $res[$company_id][$v[$j]]['ratio_pay_amount'] = $res[$company_id][$v[$j]]['pay_amount'];
// $res[$company_id][$v[$j]]['ratio_pay_amount'] = $res[$company_id][$v[$j]]['pay_amount'];
@ -1564,6 +1640,12 @@ class CompanyStatementSetController extends Controller {
// $tratio = $tmp_game_ratio['ratio'];
// $tratio = $tmp_game_ratio['ratio'];
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
// if ($v['id'] == 43) {
// dump($p_info['all_pay_amount']);
// dump($turnover_type);
// dump($tmp_game_ratio);
// }
if ($turnover_type == 2||$turnover_type == 4) {
if ($turnover_type == 2||$turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
} else {
@ -1634,7 +1716,11 @@ class CompanyStatementSetController extends Controller {
}elseif($type == 0){
}elseif($type == 0){
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
// if ($v['id'] == 43) {
// dump($p_info['all_pay_amount']);
// dump($turnover_type);
// dump($tmp_game_ratio);
// }
if ($turnover_type == 2 || $turnover_type == 4) {
if ($turnover_type == 2 || $turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
} else {