新增重算功能

master
chenzhi 4 years ago
parent 7caaf75647
commit 365faa99a7

@ -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"=>'任务添加失败']);
}
}

@ -81,7 +81,9 @@
<div class="butnbox" >
<div class="butnlist jscheckbutn" style="margin-left: 2px">
<a class="butn" id="upstream">生成毛利表</a>
<if condition = "$isCanRecount">
<a class="butn" id="addMargin">生成毛利表</a>
</if>
</div>
</div>
@ -130,6 +132,33 @@
<div class="page">
{$_page|default=''}
</div>
<script type="text/html" id="addMarginTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
按月份对生成毛利分析表,请确保该月已完成结算。<br/>任务提交成功后大约需等待3-5分钟才会完成计算。
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:80px;">月份:</td>
<td class="r table_radio">
<select id="recount_date" name="recount_date" class="select_gallery" style="width:150px;">
<option value="">请选择月份</option>
<volist name=":getOpenCompanyMonthsList()" id="vo">
<option value="{$vo}">{$vo}</option>
</volist>
</select>
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="addMarginSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
</block>
<block name="script">
@ -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');

Loading…
Cancel
Save