master
chenzhi 5 years ago
parent 6a3b9b6da3
commit 4533b84d2c

@ -6,6 +6,7 @@ class CompanyGameRatioController extends AdminController
{
public $admininfo;
public $DBModel;
public $OpAuthList=[];
public $Status = [
"-2"=>"管理员拒绝",
"-1"=>"市场部拒绝",
@ -22,11 +23,14 @@ class CompanyGameRatioController extends AdminController
public function index()
{
dd(MODULE_NAME."/".CONTROLLER_NAME );
$params = I('get.');
$page = $params['p'] ? intval($params['p']) : 1;
$row = $params['row'] ? intval($params['row']) : 10;
//权限分配
if(!IS_ROOT){
$this->OpAuthList= getModuleControllerAuth();
}
$gamewhere['_string'] = '1 = 1';
$where['_string'] = '1 = 1';
if(isset($params['relation_game_id'])){
@ -39,7 +43,7 @@ class CompanyGameRatioController extends AdminController
if(isset($params['status'])){
$where['m.status'] = $params['status'];
}
//TODO:未计算公司类型
//TODO:未计算公司类型,未进行排序
$this->checkListOrCountAuthRestMap($where);
$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_")
@ -112,6 +116,7 @@ class CompanyGameRatioController extends AdminController
}
}
$v['last_turnover_ratio_str'] = $lastRatioDtl;
$v['oplist'] = $this->OpAuth($v);
}
$count = M("company_game_ratio_log","tab_")->alias('m')->field("count(id) count")->where($where)->find()['count'];
@ -122,11 +127,115 @@ class CompanyGameRatioController extends AdminController
}
$this->assign('status',$this->Status);
$this->assign('menubtn',$this->menuAuth());
$this->assign("companyList",D("PromoteCompany")->getList());
$this->assign("gameList",D("Game")->getRelationGameLits());
$this->display();
}
public function marketAgree(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$company_game_ratio_log = M("company_game_ratio_log","tab_");
$dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select();
foreach($dbres as $k=>&$v){
if($v['status'] != 0) continue;
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log']['market_user']=$this->admininfo["username"];
$v['verify_log']['market_time']=date("Y-m-d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['status']=1;
$company_game_ratio_log->save($v);
addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"市场部审核",'url'=>U('index')]);
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"市场部审核通过成功"
));
}
public function marketRefuse(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$company_game_ratio_log = M("company_game_ratio_log","tab_");
$dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select();
foreach($dbres as $k=>&$v){
if($v['status'] != 0) continue;
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log']['market_user']=$this->admininfo["username"];
$v['verify_log']['market_time']=date("Y-m-d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['status']=-1;
$company_game_ratio_log->save($v);
addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"市场部审核",'url'=>U('index')]);
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"市场部审核拒绝成功"
));
}
public function adminRefuse(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$company_game_ratio_log = M("company_game_ratio_log","tab_");
$dbres = $company_game_ratio_log->field("id,status,verify_log")->where("id in ({$ids})")->select();
foreach($dbres as $k=>&$v){
if($v['status'] != 1) continue;
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log']['admin_user']=$this->admininfo["username"];
$v['verify_log']['admin_time']=date("Y-m-d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['status']=-2;
$company_game_ratio_log->save($v);
addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"管理员审核",'url'=>U('index')]);
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"管理员审核拒绝成功"
));
}
//管理员成功
public function adminAgree(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$company_game_ratio_log = M("company_game_ratio_log","tab_");
$company_game_ratio = M("company_game_ratio","tab_");
$dbres = $company_game_ratio_log->field("*")->where("id in ({$ids})")->select();
foreach($dbres as $k=>&$v){
if($v['status'] != 1) continue;
$v['verify_log'] = json_decode($v['verify_log'],true);
$v['verify_log']['admin_user']=$this->admininfo["username"];
$v['verify_log']['admin_time']=date("Y-m-d H:i:s");
$v['verify_log'] = json_encode($v['verify_log']);
$v['status']=2;
$company_game_ratio_log->save($v);
//保存到其他表
//查找是否存在
$ratiov = [
"company_id"=>$v['company_id'],
"relation_game_id"=>$v['relation_game_id'],
"ratio"=>$v['ratio'],
"turnover_ratio"=>$v['turnover_ratio'],
"begin_time"=>$v['begin_time'],
"end_time"=>$v['end_time'],
];
$has = $company_game_ratio->where("company_id='{$v['company_id']}' and relation_game_id='{$v['relation_game_id']}'")->find();
if(isset($has['id'])){
$ratiov['id'] = $has['id'];
$company_game_ratio->save($ratiov);
}else{
$company_game_ratio->add($ratiov);
}
//
addOperationLog(['op_type'=>1,'key'=>$v['id'],"op_name"=>"管理员审核",'url'=>U('index')]);
}
$this->ajaxReturn(array(
'status' => 1,
"info"=>"市场部审核通过成功"
));
}
public function add()
{
if ($_POST) {
@ -184,6 +293,57 @@ class CompanyGameRatioController extends AdminController
{
}
public function menuAuth()
{
$addurl = U("add");
$mentBtn = [
"addRatio"=>"<a class='butn' href='{$addurl}'>新增推广游戏分成</a>",
"marketAgree"=>"<a class='butn' id='marketAgree'>市场部审批通过</a>",
"marketRefuse"=>"<a class='butn' id='marketRefuse' style='background-color: red;'>市场部审核拒绝</a>",
"adminAgree"=>"<a class='butn' id='adminAgree'>管理员审核通过</a>",
"adminRefuse"=>"<a class='butn' id='marketRefuse' style='background-color: red;'>管理员审核拒绝</a>"
];
$resarr = [];
foreach ($mentBtn as $k => $v) {
if(IS_ROOT){
$resarr[] = $v;
}else{
if(in_array($k,$this->OpAuthList)){
$resarr[] = $v;
}
}
}
return $resarr;
}
public function OpAuth($info)
{
$id = $info['id'];
//原始列表
$opBtn = [
"editRatio"=>"<a class='confirm editRatio' data-id='{$id}'>编辑</a>",
"delRatio"=>"<a class='confirm delRatio' data-id='{$id}' style='color: red;'>删除</a>",
];
//操作对应菜单
if($info['status'] == 2){
$optist = [];
}else{
$optist = ["editRatio","delRatio"];
}
//
$resarr = [];
foreach ($optist as $k => $v) {
if(IS_ROOT){
$resarr[] = $opBtn[$v];
}else{
if(in_array($v,$this->OpAuthList)){
$resarr[] = $opBtn[$v];
}
}
}
return $resarr;
}
public function setTurnoverRatio($params)
{
$save['turnover_ratio'] = [];

@ -97,12 +97,9 @@
</div>
<div class="butnbox" style="margin-bottom: 10px;">
<div class="butnlist jscheckbutn" style="margin-left: 2px">
<a class="butn" href="{:U('add')}">新增推广游戏分成</a>
<a class="butn" id="downstream">市场部审批通过</a>
<a class="butn" id="persondownstream" style="width: 150px;background-color: red;">市场部审批拒绝</a>
<a class="butn" id="shenhe" >管理员审批通过</a>
<a class="butn" id="reject" style="background-color: red;">管理员审批拒绝</a>
<foreach name="menubtn" item="vo" >
{$vo}
</foreach>
</div>
</div>
@ -143,11 +140,7 @@
<volist name="data" id="data">
<tr>
<td>
<eq name="record.status" value="0">
<input class="ids" type="checkbox" value="{$record['id']}" name="ids[]">
<else />
<input class="ids disabled" disabled="disabled" type="checkbox" value="{$record['id']}" name="ids[]">
</eq>
<input class="ids" type="checkbox" data-status="{$data.status}" value="{$data['id']}" name="ids[]" >
</td>
<td>{$data.company_name}</td>
<td>{$data.company_belong}</td>
@ -200,8 +193,9 @@
{$data.remark}
</td>
<td>
<a href="{:U('edit', array('id'=>$data['id']))}" class="">编辑</a>
<a data-url="{:U('del', array('id'=>$data['id']))}" class="ratio_del">删除</a>
<foreach name="data.oplist" item="vo" >
{$vo}
</foreach>
</td>
</tr>
</volist>
@ -267,8 +261,6 @@ $(function(){
}
});
$(".ratio_del").on("click",function(){
var url = $(this).data("url");
layer.confirm('删除后将无法恢复,请慎重选择', {
@ -288,6 +280,71 @@ $(function(){
});
});
})
$("#marketAgree,#marketRefuse,#adminAgree").on("click",function(){
var id = $(this).attr("id");
if(id == "marketAgree"){
var opname = "市场部审批通过";
var opurl = "{:U('marketAgree')}";
var opst ="[未进行审批]";
var status = 0;
}else if(id=="marketRefuse"){
var opname = "市场部审批拒绝";
var opurl = "{:U('marketRefuse')}";
var opst ="[未进行审批]";
var status = 0;
}else if(id=="adminAgree"){
var opname = "管理员审批通过";
var opurl = "{:U('adminAgree')}";
var opst ="[市场部审批通过]";
var status = 1;
}else if(id=="adminRefuse"){
var opname = "管理员审批拒绝";
var opurl = "{:U('adminRefuse')}";
var opst ="[市场部审批通过]";
var status = 1;
}
var flag = false;
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
if($(elem).data("status") != status){
flag = true;
}else{
return $(elem).val();
}
}).get().join(",");
if(text == ''){
layer.msg("<font style='color:white'>" + '无需要'+opname+'的申请,仅'+opst+'状态可以进行'+opname+"</font>");
return;
}
if(flag){
layer.confirm(opname+"仅会对"+opst+"的申请进行处理,选择中包含其他的状态的申请将被忽略,点击取消停止操作",{title:false}, function(index){
_doAgreeApply();
layer.close(index);
});
}else{
_doAgreeApply();
}
function _doAgreeApply(){
//执行
$.ajax({
type: "POST",
url: opurl,
dataType: 'json',
async: false,
data: {ids:text},
success:function(data){
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}
}
});
}
})
})

Loading…
Cancel
Save