diff --git a/Application/Admin/Controller/GameMarginController.class.php b/Application/Admin/Controller/GameMarginController.class.php index 143c3c850..d89fa154c 100644 --- a/Application/Admin/Controller/GameMarginController.class.php +++ b/Application/Admin/Controller/GameMarginController.class.php @@ -141,6 +141,9 @@ class GameMarginController extends AdminController $item["jh_margin_amount"] = round( $item["jh_statement_amount"]-$item["jh_pay_amount"]*(1-$item['cp_promote_ratio']/100)*($item["cp_ratio"]+$item['cp_rebate_ratio'])/100 ,2); $item["jh_margin_ratio"] = round($item["jh_margin_amount"]/$item['jh_pay_amount'],4)*100; } + $item['margin_amount'] = round( ($item['pay_amount']-$item['cp_statement_amount']-$item['cp_rebate_amount']-$item['cp_other_amount']-$item['pc_statement_amount']-$item['pu_statement_amount']+$item['jh_statement_amount']),2); + $item['margin_ratio'] = round($item['margin_amount']/$item['pay_amount'],4)*100; + $margin_amount = 0; //总计 foreach ($marginInfo as &$v) { @@ -156,7 +159,23 @@ class GameMarginController extends AdminController $this->DBModel->where("id='{$params['id']}'")->save($save); $this->ajaxReturn(['status'=>1,'msg'=>"修改成功,刷新。。。"]); } + 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(); + + $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"=>'任务添加失败']); + } + } } \ No newline at end of file diff --git a/Application/Admin/View/GameMargin/lists.html b/Application/Admin/View/GameMargin/lists.html index 5218b864d..3d447e635 100644 --- a/Application/Admin/View/GameMargin/lists.html +++ b/Application/Admin/View/GameMargin/lists.html @@ -117,7 +117,7 @@ 查看/编辑 - 重算 + 重算 @@ -173,6 +173,21 @@ content: url }); }); + $(".margin_recount").click(function () { + var id = $(this).data("id"); + var url = "{:U('recount')}"+"&id="+id + $.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(){ diff --git a/Application/Admin/View/GameMargin/marginView.html b/Application/Admin/View/GameMargin/marginView.html index 01709dfd1..775a3e27e 100644 --- a/Application/Admin/View/GameMargin/marginView.html +++ b/Application/Admin/View/GameMargin/marginView.html @@ -216,7 +216,7 @@ {$count["jh_margin_amount"]} {$count["jh_margin_ratio"]}% {$count["margin_ratio"]}% - {$count["margin_amount"]}% + {$count["margin_amount"]}