市场业绩的功能提交

master
zhengyongxing 4 years ago
parent 32b139a976
commit 3855d8d3a9

@ -361,29 +361,6 @@ class GameRatioMouldController extends AdminController
}
return $save['turnover_ratio'];
}
//设置比例阶梯
// protected function readTurnoverRatio(&$v){
// $turnover_ratio = json_decode($v['turnover_ratio'],true);
// $v['turnover_ratio'] = array(
// array("ratio"=>floatval($v['ratio'])."%","name"=>"默认比例")
// );
//
// foreach($turnover_ratio as $ke=>$va){
// $t=array("ratio"=>floatval($va["ratio"])."%");
// if(array_key_exists("instanceof",$va)){
// //存在
// if($va['instanceof']=='1'){
// $t['name']="月流水≥".$va['turnover'];
// }else{
// $t['name']="月流水>".$va['turnover'];
// }
// }else{
// $t['name']="月流水≥".$va['turnover'];
// }
// $v['turnover_ratio'][]=$t;
// }
// $v['row'] = count($v['turnover_ratio']);
// }
//设置比例阶梯

@ -1232,4 +1232,238 @@ class MarketPercentageController extends ThinkController
}
public function companybelonggame($row = 10, $p = 1) {
if ($_REQUEST['relation_game_id']) {
$game_id = $_REQUEST['relation_game_id'];
$where['game_ids'] = ['like',"%,{$game_id},%"];
}
$where = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
$time_start = strtotime($_REQUEST['time_start']);
$time_end = strtotime($_REQUEST['time_end'])+ 86399;
$where["_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)";
} elseif (isset($_REQUEST['time_start'])) {
$time_start = strtotime($_REQUEST['time_start']);
$where["_string"] = "end_time >= {$time_start} OR end_time = 0";
} elseif (isset($_REQUEST['time_end'])) {
$time_end = strtotime($_REQUEST['time_end'])+ 86399;
$where["_string"] = "begin_time <= {$time_end}";
}
$data = M("company_belong_game","tab_")
->where($where)
->page($p, $row)
->select();
foreach ($data as $key => $value) {
$data[$key]["begin_time"] = date("Y-m-d",$value['begin_time']);
$data[$key]["end_time"] = date("Y-m-d",$value['end_time']);
$where_game = $value['game_ids'];
if ($_REQUEST['relation_game_id']) {
$where_game = $_REQUEST['relation_game_id'];
}
// dump($where_game);die();
$game = [];
if ($where_game) {
$game = M("game","tab_")
->field("original_package_name,relation_game_name,relation_game_id,game_type_name")
->where(['relation_game_id'=>['in',$where_game]])
->group("relation_game_id")
->select();
}
$data[$key]['row'] = count($game);
$data[$key]['game_data'] = $game;
}
$count = M("company_belong_game","tab_")
->where($where)
->count();
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign("gameList",D("Game")->getRelationGameLits());
$this->assign("data",$data);
$this->display();
}
public function addcompanybelonggame() {
if (IS_POST) {
$data = $_POST;
if (!$data['begin_time']) {
$this->ajaxReturn(['msg'=>"请填写开始时间","status"=>0]);
}
if (!$data['end_time']) {
$this->ajaxReturn(['msg'=>"请填写截止时间","status"=>0]);
}
if (!$data['game_ids']) {
$this->ajaxReturn(['msg'=>"请选择推广游戏","status"=>0]);
}
$data['game_ids'] = explode(',',$data['game_ids']);
$data['game_ids'] = array_merge([''],$data['game_ids'],['']);
$data['game_ids'] = implode(',',$data['game_ids']);
// $data['game_ids'] = json_encode($data['game_ids']);
$data['begin_time'] = strtotime($data['begin_time']);
$data['end_time'] = strtotime($data['end_time']);
$belong_game = M("company_belong_game","tab_")
->where("(begin_time<={$data['begin_time']} and end_time >={$data['begin_time']}) or (begin_time<={$data['end_time']} and end_time >={$data['end_time']})")
->select();
if ($belong_game) {
$this->ajaxReturn(['msg'=>"时间段重叠,不能增加已经相交的时间段","status"=>0]);
}
M("company_belong_game","tab_")->add($data);
$this->ajaxReturn(['msg'=>"添加成功","status"=>1]);
} else {
$this->display();
}
}
public function editcompanybelonggame() {
$id = $_REQUEST["id"];
if (IS_POST) {
$data = $_POST;
if (!$data['begin_time']) {
$this->ajaxReturn(['msg'=>"请填写开始时间","status"=>0]);
}
if (!$data['end_time']) {
$this->ajaxReturn(['msg'=>"请填写截止时间","status"=>0]);
}
if (!$data['game_ids']) {
$this->ajaxReturn(['msg'=>"请选择推广游戏","status"=>0]);
}
// $data['game_ids'] = json_encode($data['game_ids']);
$data['begin_time'] = strtotime($data['begin_time']);
$data['end_time'] = strtotime($data['end_time']);
$belong_game = M("company_belong_game","tab_")
->where("((begin_time<={$data['begin_time']} and end_time >={$data['begin_time']}) or (begin_time<={$data['end_time']} and end_time >={$data['end_time']})) and id != {$id}")
->select();
if ($belong_game) {
$this->ajaxReturn(['msg'=>"时间段重叠,不能修改成已经相交的时间段","status"=>0]);
}
// dump($data);die();
M("company_belong_game","tab_")->where(['id'=>$id])->save($data);
$this->ajaxReturn(['msg'=>"编辑成功","status"=>1]);
} else {
$data = M("company_belong_game","tab_")
->where(['id'=>$id])
->find();
// $data['game_ids'] = json_encode(explode(',',$data['game_ids']));
$game_ids = explode(',',$data['game_ids']);
$data['game_ids'] = explode(',',$data['game_ids']);
foreach($game_ids as $key => $value) {
if ($value == "\"") {
unset($game_ids[$key]);
} else {
$game_ids[$key] = $value-0;
}
}
// dump($game_ids);
$data['ids'] = implode(',',$game_ids);
// dump($data);die();
$game_ids = json_encode(array_values($game_ids));
// dump($game_ids);
$data['game_ids'] = $game_ids;
$data['begin_time'] = date("Y-m-d",$data['begin_time']);
$data['end_time'] = date("Y-m-d",$data['end_time']);
if ($game_ids) {
$game = M("game","tab_")->field("relation_game_name")
->where(['relation_game_id'=>['in',$data['ids']]])
->group("relation_game_id")
->select();
$span_str = "";
foreach ($game as $key => $value) {
$span_str .= "<span style='margin-left: 15px'>{$value['relation_game_name']}</span>";
if (($key+1)%5 == 0) {
$span_str .= "<br>";
}
}
$data['span_str'] = $span_str;
}
$this->assign("data",$data);
$this->display();
}
}
public function showGame() {
$data = $_REQUEST;
if (!$data['game_ids']) {
$this->ajaxReturn(['msg'=>"请选择游戏后点击确定","status"=>0]);
}
$game_data = M("game","tab_")
->field("relation_game_name,relation_game_id,game_type_name")
->where(['relation_game_id'=>['in',$data['game_ids']]])
->group("relation_game_id")
->select();
$this->ajaxReturn(['msg'=>"选择游戏成功","status"=>1,"data"=>$game_data]);
}
}

Loading…
Cancel
Save