diff --git a/Application/Admin/Controller/GameMarginController.class.php b/Application/Admin/Controller/GameMarginController.class.php index d89fa154c..4f7f190a7 100644 --- a/Application/Admin/Controller/GameMarginController.class.php +++ b/Application/Admin/Controller/GameMarginController.class.php @@ -24,13 +24,14 @@ class GameMarginController extends AdminController $where['count_year']=$m[0]; $where['count_month']=$m[1]; } - $data = $this->DBModel->where($where)->field("margin_info",true)->page($page,$row)->select(); + $data = $this->DBModel->where($where)->field("margin_info",true)->order("count_year desc,count_month desc")->page($page,$row)->select(); // dd($data); $count = $this->DBModel->where($where)->count(); $page = set_pagination($count,$row); if($page) {$this->assign('_page', $page);} $this->assign("data",$data); + $this->assign("isCanRecount",D("CmdTasks")->isCanAddTask("GameMargin")); $this->display(); } @@ -161,19 +162,34 @@ class GameMarginController extends AdminController } public function recount() { - if(!isset($_REQUEST['id'])) $this->error("参数错误"); - $id = $_REQUEST['id']; - $data = $this->DBModel->field("count_year,count_month")->where("id='{$id}'")->find(); - $time = $data['count_year']."-".$data['count_month']; - - $this->DBModel->where("id='{$id}'")->delete(); + if(!isset($_REQUEST['type'])) $this->error("参数错误"); + $type = $_REQUEST['type']; + if($type == "recount"){ + + if(!isset($_REQUEST['id'])) $this->error("参数错误"); + $id = $_REQUEST['id']; + $data = $this->DBModel->field("count_year,count_month")->where("id='{$id}'")->find(); + $time = $data['count_year']."-".$data['count_month']; + $this->DBModel->where("id='{$id}'")->delete(); + + }elseif($type == "add"){ + $time =$_REQUEST['date']; + $m = explode("-",$time); + $where = []; + $where['count_year']=$m[0]; + $where['count_month']=$m[1]; + $count = $this->DBModel->where($where)->count(); + if($count > 0){ + $this->ajaxReturn(["status"=>"0","msg"=>"{$time}已经生成报表,请重算即可"]); + } + } $params = "php ".SUBSITE_INDEX." GameMarginSet/setFreeMonth/recount/1/count_date/{$time}"; $r = D("CmdTasks")->addTask("GameMargin",$params,true); if($r){ $this->ajaxReturn(["status"=>"1",'msg'=>"任务添加成功,大约需等待5分钟后生成"]); }else{ - $this->ajaxReturn(["error"=>"error","msg"=>'任务添加失败']); + $this->ajaxReturn(["status"=>"0","msg"=>'任务添加失败']); } } diff --git a/Application/Admin/View/GameMargin/lists.html b/Application/Admin/View/GameMargin/lists.html index 3d447e635..5d2fba01f 100644 --- a/Application/Admin/View/GameMargin/lists.html +++ b/Application/Admin/View/GameMargin/lists.html @@ -78,10 +78,12 @@ - +
- 生成毛利表 + + 生成毛利表 +
@@ -130,6 +132,33 @@
{$_page|default=''}
+ + + + + @@ -175,7 +204,7 @@ }); $(".margin_recount").click(function () { var id = $(this).data("id"); - var url = "{:U('recount')}"+"&id="+id + var url = "{:U('recount')}"+"&type=recount&id="+id $.get(url,function(data) { if (data.status == 1) { layer.msg(data.msg); @@ -189,6 +218,37 @@ }) }); + $("#addMargin").on("click",function(){ + var html = $("#addMarginTpl").html(); + layer.open({ + type: 1, + title: "生成毛利分析表", + maxWidth:720, + closeBtn: 1, + content: html, + success:function(){ + $("#addMarginSubmit").off("click"); + $("#addMarginSubmit").on("click",function() { + var date = $("#recount_date").val(); + var url = "{:U('recount')}"+"&type=add&date="+date + $.get(url,function(data) { + if (data.status == 1) { + layer.msg(data.msg); + setTimeout(function () { + window.location.reload(); + }, 1500); + } else { + layer.msg(data.msg); + return false; + } + }) + + + }); + } + }); + }) + $("#search").click(function(){ var url = $(this).attr('url');