diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index baa534a27..628b6db50 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -955,9 +955,9 @@ class CompanyStatementSetController extends Controller { // dump($spenMap); $cpMap = $spenMap; + $cpMap["s.payed_time"] = ['between', [strtotime(date("Y-m-1",$begintime)),$endtime]]; $cpAllMap = $spenMap; - $cpAllMap["s.payed_time"] = ['elt',$endtime]; for ($i=0; $i 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']; } 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']; } @@ -1205,7 +1248,7 @@ class CompanyStatementSetController extends Controller { $cpgame = []; $cpMap = $spenMap; - + $cpMap["s.payed_time"] = ['between', [strtotime(date("Y-m-1",$begintime)),$endtime]]; $cpAllMap = $spenMap; $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') ->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']; @@ -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']; } 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']; } 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']; } else { // $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']; $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) { $tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); } else { @@ -1634,7 +1716,11 @@ class CompanyStatementSetController extends Controller { }elseif($type == 0){ $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) { $tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']); } else { diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index de6be4363..8b5c05f69 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -222,6 +222,9 @@ class PromoteCompanyController extends ThinkController $this->assign('listData', $companyres); $this->assign('count', $count); $this->assign('promotecount', $promotecount); + +// dump($companyres);die(); + if($is_export){ $getData = $_GET; @@ -1340,8 +1343,8 @@ class PromoteCompanyController extends ThinkController if (isset($_REQUEST['begintime']) && isset($_REQUEST['endtime'])) { $time_start = strtotime($_REQUEST['begintime']); $time_end = strtotime($_REQUEST['endtime'])+ 86399; - $rwhere["_string"] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end}) OR (begin_time <= {$time_end} AND end_time >= {$time_end}) OR (begin_time >0 AND end_time = 0)"; - $mwhere['_string'] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end}) OR (begin_time <= {$time_end} AND end_time >= {$time_end}) OR (begin_time >0 AND end_time = 0)"; + $rwhere["_string"] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end}) OR (begin_time <= {$time_end} AND end_time >= {$time_end}) OR (begin_time <{$time_start} AND (end_time >{$time_end} or end_time = 0))"; + $mwhere['_string'] = "(begin_time BETWEEN {$time_start} AND {$time_end}) OR (end_time BETWEEN {$time_start} AND {$time_end}) OR (begin_time <= {$time_end} AND end_time >= {$time_end}) OR (begin_time <{$time_start} AND (end_time >{$time_end} or end_time = 0))"; } elseif (isset($_REQUEST['begintime'])) { $time_start = strtotime($_REQUEST['begintime']); $rwhere["_string"] = "end_time >= {$time_start} OR end_time = 0"; @@ -1354,7 +1357,7 @@ class PromoteCompanyController extends ThinkController $company_belong = M("PromoteCompany","tab_")->field("company_belong")->where("id='{$company_id}'")->find()['company_belong']; $rwhere['company_id'] = $company_id; $rwhere['relation_game_id'] = ['in',$game_ids]; - $rwhere['company_belong'] = $company_belong; +// $rwhere['company_belong'] = $company_belong; // dump($rwhere); // $endtime = time(); // $rwhere = "(end_time = 0 OR end_time >= '{$endtime}') and company_id='{$company_id}' and relation_game_id in ({$game_ids})"; @@ -1366,7 +1369,7 @@ class PromoteCompanyController extends ThinkController foreach ($cgr_res as $k => $v) { $t_gid = $v['relation_game_id']; unset($game_arr[$t_gid]); - $senddata[$t_gid]['ratio_data'][$v['begin_time']] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>!$is_inside?$v['ratio']:0,"relation_game_id"=>$v['relation_game_id'],'time'=>date("Y-m-d",$v['begin_time'])."-".($v['end_time']?date("Y-m-d",$v['end_time']):"永久")]; + $senddata[$t_gid]['ratio_data'][$v['begin_time']] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>!$is_inside?$v['ratio']:0,"relation_game_id"=>$v['relation_game_id'],'time'=>($k == 0&&($v['begin_time']strtotime($_REQUEST['endtime']))?date("Y.m.d",$v['end_time']):date("Y.m.d",strtotime($_REQUEST['endtime'])))]; $senddata[$t_gid] += $game[$t_gid]; $this->setPromoteRadio($senddata[$t_gid]['ratio_data'][$v['begin_time']],$is_inside); @@ -1408,12 +1411,15 @@ class PromoteCompanyController extends ThinkController $m_res = M("GameRatioMould","tab_")->where($mwhere)->select(); +// dump($m_res);die(); + + if(!empty($m_res)){ foreach ($m_res as $k => $v) { $t_gid = $v['relation_game_id']; unset($game_arr[$t_gid]); - $senddata[$t_gid]['ratio_data'][$v['begin_time']] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>!$is_inside?$v['ratio']:0,"relation_game_id"=>$v['relation_game_id'],'time'=>date("Y-m-d",$v['begin_time'])."-".($v['end_time']?date("Y-m-d",$v['end_time']):"永久")]; + $senddata[$t_gid]['ratio_data'][$v['begin_time']] = ["turnover_ratio"=>$v['turnover_ratio'],"ratio"=>!$is_inside?$v['ratio']:0,"relation_game_id"=>$v['relation_game_id'],'time'=>($k == 0&&($v['begin_time']strtotime($_REQUEST['endtime']))?date("Y.m.d",$v['end_time']):date("Y.m.d",strtotime($_REQUEST['endtime'])))]; $senddata[$t_gid] += $game[$t_gid]; $this->setPromoteRadio($senddata[$t_gid]['ratio_data'][$v['begin_time']],$is_inside); @@ -1446,7 +1452,7 @@ class PromoteCompanyController extends ThinkController } foreach($game_arr as $k=>$v){ if(empty($game[$k])) continue; - $senddata[$k]['ratio_data']['1567267200']= ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],'time'=>date("Y-m-d",1567267200)."-"."永久"]; + $senddata[$k]['ratio_data']['1567267200']= ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],'time'=>date("Y.m.d",strtotime($_REQUEST['begintime']))."-".date("Y.m.d",strtotime($_REQUEST['endtime']))]; $senddata[$k]["row"] = 1; $senddata[$k] += $game[$k]; diff --git a/Application/Admin/View/PromoteCompany/export.html b/Application/Admin/View/PromoteCompany/export.html index 4be1b96a3..ab81f8d74 100644 --- a/Application/Admin/View/PromoteCompany/export.html +++ b/Application/Admin/View/PromoteCompany/export.html @@ -51,7 +51,7 @@ 现包名 聚合包名 产品类型 - 游戏比例生效时间 + 结算时间 推广分成比例 CP分成比例 @@ -269,7 +269,7 @@ {$promote['list'][0]['game_type_name']|default="--"} - {$promote['list'][0]['ratio_data'][0]['time']|default="--"} + {$promote['list'][0]['ratio_data'][0]['time']|default="--"} -- diff --git a/Application/Admin/View/PromoteCompany/lists.html b/Application/Admin/View/PromoteCompany/lists.html index de0997f56..780c5d373 100644 --- a/Application/Admin/View/PromoteCompany/lists.html +++ b/Application/Admin/View/PromoteCompany/lists.html @@ -316,7 +316,7 @@ {$promote['list'][0]['game_type_name']|default="--"} - {$promote['list'][0]['ratio_data'][0]['time']|default="--"} + {$promote['list'][0]['ratio_data'][0]['time']|default="--"} -- @@ -337,8 +337,8 @@ -- - - + + @@ -359,13 +359,15 @@ - - - + - + + + @@ -379,7 +381,7 @@ - +