11月功能提交

master
zhengyongxing 4 years ago
parent 36d40bc24e
commit c749df4936

@ -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 <count($idarr); $i++) {
@ -1117,8 +1117,51 @@ class CompanyStatementSetController extends Controller {
if ($turnover_type == 2) {
$res[$key][$k]['ratio_pay_amount'] = $all_res[$key][$k]['pay_amount'];
} 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'];
} 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 {

@ -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['begintime'])) ? date("Y.m.d",strtotime($_REQUEST['begintime'])) : date("Y.m.d",$v['begin_time']))."-".(($v['end_time']&&$v['end_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['begintime'])) ? date("Y.m.d",strtotime($_REQUEST['begintime'])) : date("Y.m.d",$v['begin_time']))."-".(($v['end_time']&&$v['end_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];

@ -51,7 +51,7 @@
<th>现包名</th>
<th>聚合包名</th>
<th>产品类型</th>
<th>游戏比例生效时间</th>
<th>结算时间</th>
<th colspan="2">推广分成比例</th>
<th colspan="2">CP分成比例</th>
@ -269,7 +269,7 @@
<td rowspan="{$promote['list'][0]['row']}">{$promote['list'][0]['game_type_name']|default="--"}</td>
<notempty name="promote['list'][0]['ratio_data']">
<td rowspan="{$promote['list'][0]['ratio_data']['row']}">{$promote['list'][0]['ratio_data'][0]['time']|default="--"}</td>
<td rowspan="{$promote['list'][0]['row']}">{$promote['list'][0]['ratio_data'][0]['time']|default="--"}</td>
<else />
<td>--</td>
</notempty>

@ -316,7 +316,7 @@
<td rowspan="{$promote['list'][0]['row']}">{$promote['list'][0]['game_type_name']|default="--"}</td>
<notempty name="promote['list'][0]['ratio_data']">
<td rowspan="{$promote['list'][0]['ratio_data']['row']}">{$promote['list'][0]['ratio_data'][0]['time']|default="--"}</td>
<td rowspan="{$promote['list'][0]['row']}">{$promote['list'][0]['ratio_data'][0]['time']|default="--"}</td>
<else />
<td>--</td>
</notempty>
@ -337,8 +337,8 @@
<td>--</td>
</notempty>
</tr>
<!-- {$promote['list'][0]['ratio_data'][0]['turnover_ratio'][1]['name']}-->
<!-- dsfsa -->
<foreach name="promote['list']" item="game" key="gkey">
<if condition="$gkey gt 0">
<tr>
@ -359,13 +359,15 @@
<else />
<td >-</td>
<td>-</td>
</notempty>
</notempty>
</tr>
</if>
<if condition="$game['row'] gt 1">
<foreach name="game['ratio_data']" item="ratio" key="rkey">
<foreach name="ratio['turnover_ratio']" item="game_ratio2" key="gamekey2">
<if condition="$gamekey2 gt 0 or $rkey gt 0">
<tr>
<if condition="$rkey gt 0 and $gamekey2 eq 0">
@ -379,7 +381,7 @@
</foreach>
</if>
</if>
</foreach>
</if>

Loading…
Cancel
Save