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 @@