11月功能提交

master
zhengyongxing 4 years ago
parent 4526b5b741
commit 3656c555d1

@ -26,6 +26,17 @@ class CompanyGameRatioController extends AdminController
$this->DBModel = M("company_game_ratio","tab_");
parent::_initialize();
}
public function setCompanyBelong($company_belong = 0) {
if($company_belong == '0') {
return '内团';
} elseif($company_belong == '0') {
return '外团';
} else {
return '外团-分发';
}
}
public function index()
{
$params = I('get.');
@ -103,9 +114,9 @@ class CompanyGameRatioController extends AdminController
->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")")
->join("left JOIN tab_company_relation r ON (r.first_company_type =2 AND r.first_company_id = m.company_id) OR (r.second_company_type =2 AND r.second_company_id = m.company_id)");
if(isset($params['export'])){
$dbres = $dbres->where($where)->group("company_id,m.relation_game_id")->select();
$dbres = $dbres->where($where)->group("company_id,m.relation_game_id,m.company_belong")->select();
}else{
$dbres = $dbres->where($where)->page($page, $row)->group("company_id,m.relation_game_id")->select();
$dbres = $dbres->where($where)->page($page, $row)->group("company_id,m.relation_game_id,m.company_belong")->select();
}
foreach($dbres as $k=>&$v){
@ -135,7 +146,9 @@ class CompanyGameRatioController extends AdminController
//
// $v["valid"] = "{$v['begin_time']} ~ {$v['end_time']}";
$v['company_belong'] ="下游".getCompanyBlong($v['company_belong']);
// $v['company_belong'] ="下游".getCompanyBlong($v['company_belong']);
$v['company_belong'] ="下游".$this->setCompanyBelong($v['company_belong']);
if (isset($params['export'])) {
$symbol = "\n";
} else {
@ -165,7 +178,7 @@ class CompanyGameRatioController extends AdminController
->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id")
->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")")
->where($where)
->group("company_id,m.relation_game_id")
->group("company_id,m.relation_game_id,m.company_belong")
->select(false);
$count = M()->table("({$count})a")->count();
@ -243,7 +256,7 @@ class CompanyGameRatioController extends AdminController
$gameres = M("game","tab_")->field("tab_game.relation_game_id,tab_game.relation_game_name,IF(tab_game.original_package_name='','未配置',tab_game.original_package_name) original_package_name,tab_game_type.type_name game_type_name")->where($gamewhere)->join("tab_game_type on tab_game.game_type_id = tab_game_type.id")->group("tab_game.relation_game_id")->select(false);
$dbres = M("company_game_ratio_log","tab_")
->alias('m')
->field("m.*,g.*,p.company_name,p.company_belong,IFNULL(r.settlement_type,0) settlement_type")
->field("m.*,g.*,p.company_name,m.company_belong,IFNULL(r.settlement_type,0) settlement_type")
->join("JOIN ({$gameres}) g ON m.relation_game_id = g.relation_game_id")
->join("JOIN tab_promote_company p ON ( m.company_id = p.id".$pwhere.")")
->join("left JOIN tab_company_relation r ON (r.first_company_type =2 AND r.first_company_id = m.company_id) OR (r.second_company_type =2 AND r.second_company_id = m.company_id)")
@ -271,7 +284,8 @@ class CompanyGameRatioController extends AdminController
}
$v['company_belong'] ="下游".getCompanyBlong($v['company_belong']);
// $v['company_belong'] ="下游".getCompanyBlong($v['company_belong']);
$v['company_belong'] ="下游".$this->setCompanyBelong($v['company_belong']);
$v['verify_log'] = json_decode($v['verify_log'], true);
if (isset($params['export'])) {
$symbol = "\n";
@ -447,6 +461,7 @@ class CompanyGameRatioController extends AdminController
//保存到其他表
//查找是否存在
$ratiov = [
'company_belong'=>$v['company_belong'],
"company_id"=>$v['company_id'],
"relation_game_id"=>$v['relation_game_id'],
"ratio"=>$v['ratio'],
@ -456,7 +471,7 @@ class CompanyGameRatioController extends AdminController
"turnover_type"=>$v['turnover_type'],
];
$this->companyRatioTimeChange($v['company_id'],$v['relation_game_id'],$v['begin_time'],$v['end_time'],$ratiov);
$this->companyRatioTimeChange($v['company_belong'],$v['company_id'],$v['relation_game_id'],$v['begin_time'],$v['end_time'],$ratiov);
// $has = $company_game_ratio->where("company_id='{$v['company_id']}' and relation_game_id='{$v['relation_game_id']}' and begin_time={$v['begin_time']} and end_time={$v['end_time']}")->find();
// if(isset($has['id'])){
@ -474,29 +489,29 @@ class CompanyGameRatioController extends AdminController
));
}
public function companyRatioTimeChange($company_id = 0, $relation_game_id = 0, $begin_time = 0, $end_time = 0,$ratiov=[]) {
public function companyRatioTimeChange($company_belong = 0,$company_id = 0, $relation_game_id = 0, $begin_time = 0, $end_time = 0,$ratiov=[]) {
if (!$company_id || !$relation_game_id) {
$this->error("公司与游戏的参数错误.");
}
// dump($end_time);dump($begin_time);die();
$check_data = M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$begin_time,'end_time'=>$end_time])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$begin_time,'end_time'=>$end_time])
->find();
if ($check_data) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$begin_time,'end_time'=>$end_time])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$begin_time,'end_time'=>$end_time])
->save($ratiov);
return;
}
M("company_game_ratio","tab_")
// ->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>['egt',$begin_time],'end_time'=>['elt',$end_time]])
->where("company_id={$company_id} and relation_game_id={$relation_game_id} and begin_time>={$begin_time} and end_time <= {$end_time} and end_time!=0")
->where("company_belong={$company_belong} and company_id={$company_id} and relation_game_id={$relation_game_id} and begin_time>={$begin_time} and end_time <= {$end_time} and end_time!=0")
->delete();
$data = M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id])
->order("begin_time DESC")
->select();
@ -506,7 +521,7 @@ class CompanyGameRatioController extends AdminController
if (!$end_time) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->delete();
continue;
}
@ -517,18 +532,18 @@ class CompanyGameRatioController extends AdminController
if ($end_time > $value['begin_time'] && ($end_time < $value['end_time']||$value['end_time']==0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['begin_time'=>$end_time+1]);
} else if ($end_time > $value['begin_time'] && ($end_time >= $value['end_time']&&$value['end_time']!=0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['begin_time'=>$begin_time,'end_time'=>$end_time]);
}
} else if ($value['begin_time'] <= $begin_time) {
if (!$end_time&&($value['end_time']>$begin_time||$value['end_time']==0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['end_time'=>$begin_time-1]);
continue;
}else if (!$end_time) {
@ -540,11 +555,11 @@ class CompanyGameRatioController extends AdminController
}
if ($begin_time > $value['begin_time'] && ($end_time >= $value['end_time'] && $value['end_time']!=0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['end_time'=>$begin_time-1]);
} else if ($begin_time > $value['begin_time'] && ($end_time < $value['end_time']||$value['end_time']==0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['end_time'=>$begin_time-1]);
$dataValue = $value;
$dataValue['begin_time'] = $end_time+1;
@ -553,15 +568,15 @@ class CompanyGameRatioController extends AdminController
} else if ($begin_time == $value['begin_time'] && ($end_time < $value['end_time']||$value['end_time']==0)) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['begin_time'=>$end_time+1]);
} else if ($end_time == $value['end_time']&&$begin_time>$value['begin_time']) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['end_time'=>$begin_time-1]);
} else if ($end_time == $value['end_time']&&$begin_time == $value['begin_time']) {
M("company_game_ratio","tab_")
->where(['company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->where(['company_belong'=>$company_belong,'company_id'=>$company_id,'relation_game_id'=>$relation_game_id,'begin_time'=>$value['begin_time'],'end_time'=>$value['end_time']])
->save(['begin_time'=>$begin_time,'end_time'=>$end_time]);
}
@ -694,6 +709,8 @@ class CompanyGameRatioController extends AdminController
->join("left JOIN tab_promote_company p ON m.company_id = p.id")
->where($map)
->find();
$dbres['company_belong'] ="下游".$this->setCompanyBelong($dbres['company_belong']);
$dbres['turnover_ratio'] = $dbres['turnover_ratio'] ? json_decode($dbres['turnover_ratio'], true) : $dbres['turnover_ratio'];
$dbres['begin_time'] = date("Y-m-d",$dbres['begin_time']);
$dbres['end_time'] = empty($dbres['end_time']) ? '' :date("Y-m-d",$dbres['end_time']);
@ -761,6 +778,7 @@ class CompanyGameRatioController extends AdminController
->join("left JOIN tab_promote_company p ON m.company_id = p.id")
->where($map)
->find();
$dbres['company_belong'] ="下游".$this->setCompanyBelong($dbres['company_belong']);
$dbres['turnover_ratio'] = $dbres['turnover_ratio'] ? json_decode($dbres['turnover_ratio'], true) : $dbres['turnover_ratio'];
$dbres['begin_time'] = date("Y-m-d",$dbres['begin_time']);
$dbres['end_time'] = empty($dbres['end_time']) ? '' :date("Y-m-d",$dbres['end_time']);

@ -593,6 +593,8 @@ class CompanyStatementPoolController extends ThinkController
for ($i=0;;$i++) {
if ($sv[$i]['sum_money']) {
$game_data['week_amount'] += $sv[$i]['sum_money'];
$game_data['fine'] += $sv[$i]['fine'];
$game_data['reward'] += $sv[$i]['reward'];
} else {
break;
}
@ -636,11 +638,15 @@ class CompanyStatementPoolController extends ThinkController
$old_line++;
} else {
$handle_data[$hk-$substract]['week_amount'] += $handle_data[$hk]['week_amount'];
$handle_data[$hk-$substract]['fine'] += $handle_data[$hk]['fine'];
$handle_data[$hk-$substract]['reward'] += $handle_data[$hk]['reward'];
}
unset($handle_data[$hk]['time']);
unset($handle_data[$hk]['time_row']);
unset($handle_data[$hk]['week_amount']);
unset($handle_data[$hk]['fine']);
unset($handle_data[$hk]['reward']);
} else {
if ($is_export) {
// dump($old_line);

@ -1424,6 +1424,16 @@ class CompanyStatementSetController extends Controller {
$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($p_info['relation_game_id'],$v['id'],$statement_begin_time,$statement_end_time);
// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) {
// dump($RewardRecordRes);
// }
$p_info['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0;
$p_info['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']:0;
$p_info['statement_type']=0;
$va['game_list'][] = $p_info;
}else{
@ -1474,6 +1484,16 @@ class CompanyStatementSetController extends Controller {
$temp_game['statement_end_time']=date("Y.m.d",$tmp_game_ratio['endtime']);
$temp_game['statement_type']=0;
$RewardRecordRes = $this->getPromoteUserGameRewardRecord($p_info["relation_game_id"],$v['id'],$tmp_game_ratio['begintime'],$tmp_game_ratio['endtime']);
// if ($p_info['relation_game_id'] == 191 && $v['id'] == 334) {
// dump($RewardRecordRes);
// }
$temp_game['statement_type']=0;
$temp_game['fine'] = $RewardRecordRes['fine']?$RewardRecordRes['fine']:0;
$temp_game['reward'] = $RewardRecordRes['reward']?$RewardRecordRes['reward']: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"];
@ -1679,6 +1699,55 @@ class CompanyStatementSetController extends Controller {
}
return $ratio;
}
/**
* 获取游戏奖罚
*/
protected function getPromoteUserGameRewardRecord($relation_game_id,$cpmpamy_id,$begintime,$endtime)
{
$begintime = strtotime(str_replace('.','-',$begintime));
$endtime = strtotime(str_replace('.','-',$endtime))+86499;
//获取所有公司的奖罚
$rrmap = array(
"d.confirm_time" => ['between', [$begintime,$endtime]],
"d.company_type"=>2,
"d.company_id"=>$cpmpamy_id,
"d.settlement_type"=>2,
"relation_game_id"=>$relation_game_id,
);
$rfres = M("RewardDetail","tab_")
->alias("d")
->field("
IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward,
IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine")
->join('tab_reward_record as r on d.record_id = r.id', 'LEFT')
->where($rrmap)
->group("company_id")
->find();
// $rfres = M('reward_record', 'tab_')
// ->alias('r')
// ->field("
// IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward,
// IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine")
// ->where($rrmap)
// ->join('tab_reward_detail as d on d.record_id = r.id', 'LEFT')
// ->group("company_id")
// ->find();
// if ($relation_game_id == 191 && $cpmpamy_id == 334) {
// dump($rfres);
// }
if(empty($rfres)){
return false;
}else{
return $rfres;
}
}
/**
* 获取公司奖罚
*/
@ -1702,7 +1771,7 @@ class CompanyStatementSetController extends Controller {
if(empty($rfres)){
return false;
}else{
$rfres;
return $rfres;
}
}
/**

@ -170,8 +170,10 @@
<td>{$com['statement_info'][0]['game_list'][0]['ratio']}%</td>
<td>{$com['statement_info'][0]['game_list'][0]['increment_ratio']}%</td>
<td><span class="sum_money_span">{$com['statement_info'][0]['game_list'][0]['sum_money']}</span></td>
<td rowspan="{$com.row}">{$com['reward']}</td>
<td rowspan="{$com.row}">{$com['fine']}</td>
<!-- <td rowspan="{$com.row}">{$com['reward']}</td>-->
<!-- <td rowspan="{$com.row}">{$com['fine']}</td>-->
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['reward']||default="0"}</td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['fine']||default="0"}</td>
<td rowspan="{$com['statement_info'][0]['time_row']}">{$com['statement_info'][0]['week_amount']||default="0"}</td>
<td rowspan="{$com.row}">{$com['statement_money']}</td>
@ -249,6 +251,8 @@
<td>{$account['game_list'][0]['game_type_name']}</td>
<notempty name="account['time']">
<td rowspan="{$account['time_row']}">{$account['time']|default="-----"}</td>
<else/>
<td>-</td>
</notempty>
<!-- <td>{$account['game_list'][0]['statement_begin_time']}-{$account['game_list'][0]['statement_end_time']}</td>-->
<td><span class="pay_amount">{$account['game_list'][0]['pay_amount']}</span></td>
@ -260,7 +264,13 @@
<td>{$account['game_list'][0]['increment_ratio']}%</td>
<td><span class="sum_money_span">{$account['game_list'][0]['sum_money']}</span></td>
<notempty name="account['time']">
<td rowspan="{$account['time_row']}">{$account['reward']}</td>
<td rowspan="{$account['time_row']}">{$account['fine']}</td>
<td rowspan="{$account['time_row']}">{$account['week_amount']}</td>
<else/>
<td>-</td>
<td>-</td>
<td>-</td>
</notempty>
<else />
@ -272,6 +282,10 @@
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
</notempty>
</tr>

Loading…
Cancel
Save