|
|
|
@ -1261,8 +1261,6 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 获取公司奖罚
|
|
|
|
|
* @param [type] $paymount 支付金额
|
|
|
|
|
* @param [type] $turnover_ratio 梯度
|
|
|
|
|
*/
|
|
|
|
|
protected function getPromoteUserRewardRecord($cpmpamy_id,$begintime,$endtime)
|
|
|
|
|
{
|
|
|
|
@ -1286,7 +1284,94 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
|
}else{
|
|
|
|
|
$rfres;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public function getPromoteCompanyGameRatio($company_id,$game_ids,$begintime,$endtime,$company_belong=false){
|
|
|
|
|
//获取默认比例
|
|
|
|
|
if($company_belong === false){
|
|
|
|
|
$company_belong = M("PromoteCompany","tab_")->field("company_belong")->where("id='{$company_id}'")->find()['company_belong'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mwhere = [
|
|
|
|
|
"company_belong"=>$company_belong,
|
|
|
|
|
"relation_game_id"=>["in",$game_ids]
|
|
|
|
|
];
|
|
|
|
|
$m_res = M("GameRatioMould","tab_")->where($mwhere)->select();
|
|
|
|
|
$modul_ratio = [];
|
|
|
|
|
for ($i=0; $i < count($m_res); $i++) {
|
|
|
|
|
$modul_ratio[$m_res[$i]['relation_game_id']] = $m_res[$i];
|
|
|
|
|
}
|
|
|
|
|
unset($m_res);
|
|
|
|
|
//设置默认
|
|
|
|
|
$game_ratio = [];
|
|
|
|
|
$tmp_g = explode(",",$game_ids);
|
|
|
|
|
for ($i=0; $i < count($tmp_g); $i++) {
|
|
|
|
|
$game_ratio[$tmp_g[$i]] = [
|
|
|
|
|
["begintime"=>$begintime,"endtime"=>$endtime]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$map = [
|
|
|
|
|
"company_id"=>$company_id,
|
|
|
|
|
"relation_game_id"=>['in',$game_ids],
|
|
|
|
|
"_string"=>"begin_time <={$endtime} AND ( end_time = 0 OR end_time >= {$begintime})"
|
|
|
|
|
];
|
|
|
|
|
$res = M("company_game_ratio","tab_")->where($map)->order("begin_time asc")->select();
|
|
|
|
|
foreach($res as $k=>$v){
|
|
|
|
|
//获取最后一个数据
|
|
|
|
|
$tgr = &$game_ratio[$v['relation_game_id']];
|
|
|
|
|
$last_time_ratio = end($game_ratio[$v['relation_game_id']]);
|
|
|
|
|
if($v['end_time'] == 0 || ($v['end_time'] >= $last_time_ratio['endtime'])){
|
|
|
|
|
//全段
|
|
|
|
|
if($v['begin_time'] <= $last_time_ratio['begintime']){
|
|
|
|
|
$tgr[count($tgr)-1]['ratio'] = $v['ratio'];
|
|
|
|
|
$tgr[count($tgr)-1]['turnover_ratio'] = $v['turnover_ratio'];
|
|
|
|
|
continue;
|
|
|
|
|
}else{
|
|
|
|
|
//上分段
|
|
|
|
|
$tgr[count($tgr)-1]['endtime'] = $v['begin_time']-1;
|
|
|
|
|
$tgr[] = ['begintime'=>$v['begin_time'],"endtime"=>$last_time_ratio['endtime'],"ratio"=>$v['ratio'],"turnover_ratio"=>$v['turnover_ratio']];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($v['end_time'] < $last_time_ratio['endtime']){
|
|
|
|
|
if($last_time_ratio['begintime'] < $v['begin_time']){
|
|
|
|
|
//中段
|
|
|
|
|
$tgr[count($tgr)-1]['endtime'] = $v['begin_time']-1;
|
|
|
|
|
|
|
|
|
|
$tgr[] = ['begintime'=>$v['begin_time'],"endtime"=>$v['end_time'],"ratio"=>$v['ratio'],"turnover_ratio"=>$v['turnover_ratio']];
|
|
|
|
|
|
|
|
|
|
$tgr[] = ['begintime'=>$v['end_time']-0+1,"endtime"=>$last_time_ratio['endtime']];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if($last_time_ratio['begintime'] > $v['begin_time']){
|
|
|
|
|
//下分段
|
|
|
|
|
$tgr[count($tgr)-1]['endtime'] = $v['end_time'];
|
|
|
|
|
$tgr[] = ['begintime'=>$v['end_time']-0+1,"endtime"=>$last_time_ratio['endtime'],"ratio"=>$v['ratio'],"turnover_ratio"=>$v['turnover_ratio']];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if($last_time_ratio['begintime'] = $v['begin_time']){
|
|
|
|
|
$tgr[count($tgr)-1]['endtime'] = $v['end_time'];
|
|
|
|
|
$tgr[count($tgr)-1]['ratio'] = $v['ratio'];
|
|
|
|
|
$tgr[count($tgr)-1]['turnover_ratio'] = $v['turnover_ratio'];
|
|
|
|
|
|
|
|
|
|
$tgr[] = ['begintime'=>$v['end_time']-0+1,"endtime"=>$last_time_ratio['endtime']];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//模板填充
|
|
|
|
|
foreach($game_ratio as $k=>&$list){
|
|
|
|
|
foreach($list as $i => &$ratio){
|
|
|
|
|
if(!isset($ratio['ratio'])){
|
|
|
|
|
if(isset($modul_ratio[$k]['ratio'])){
|
|
|
|
|
$ratio['ratio'] = $modul_ratio[$k]['ratio'];
|
|
|
|
|
$ratio['turnover_ratio'] = $modul_ratio[$k]['turnover_ratio'];
|
|
|
|
|
}else{
|
|
|
|
|
$ratio['ratio'] = 0;
|
|
|
|
|
$ratio['turnover_ratio'] =null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $game_ratio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|