新增订单重算及固化

master
chenzhi 4 years ago
parent 1de381bccd
commit 6790ab5fd3

@ -160,16 +160,26 @@ class SubSpendController extends ThinkController
$this->OpAuthList= getModuleControllerAuth();
}
$this->assign('menubtn',$this->menuAuth());
$this->assign('menubtn',$this->menuAuth($is_sub_data));
$this->display();
}
protected function menuAuth()
protected function menuAuth($is_sub_data = false)
{
$mentBtn = [
"addStatement"=>"<a class='butn' id='addStatement'>参与结算</a>",
"removeStatement"=>"<a class='butn' id='removeStatement' style='background-color: red;'>移出结算</a>",
];
$is_can_add = D("CmdTasks")->isCanAddTask("SubSpendSet");
if($is_can_add){
$mentBtn = [
"addSubSpendSet"=>"<a class='butn' id='addSubSpendSet'>固定订单</a>",
"updateSubSpend"=>"<a class='butn' id='updateSubSpend'>重固订单</a>"
];
}else{
$mentBtn = [];
}
if($is_sub_data){
$mentBtn['changeSubSpend'] = "<a class='butn' id='changeSubSpend'>订单换绑</a>";
$mentBtn['addStatement'] = "<a class='butn' id='addStatement'>参与结算</a>";
$mentBtn['removeStatement'] = "<a class='butn' id='removeStatement' style='background-color: red;'>移出结算</a>";
}
$resarr = [];
foreach ($mentBtn as $k => $v) {
if(IS_ROOT){
@ -183,6 +193,32 @@ class SubSpendController extends ThinkController
return $resarr;
}
public function addSubSpendSet(){
if(!isset($_REQUEST['time'])) $this->error("参数错误");
$time = $_REQUEST['time'];
$params = "php ".SUBSITE_INDEX." SubSpendSet/setSubSpend/time/{$time}";
$r = D("CmdTasks")->addTask("SubSpendSet",$params);
if($r){
$this->ajaxReturn(["status"=>1,"info"=>"固化数据任务登记成功,请等待两三分钟后查看结果"]);
}else{
$this->ajaxReturn(["status"=>0,"info"=>"固化数据任务登记错误"]);
}
}
public function updateSubSpend(){
if(!isset($_REQUEST['begin']) || !isset($_REQUEST['end'])) $this->error("参数错误");
$begin = $_REQUEST['begin'];
$end = $_REQUEST['end'];
$params = "php ".SUBSITE_INDEX." SubSpendSet/recountSubSpend/begin/{$begin}/end/{$end}";
$r = D("CmdTasks")->addTask("SubSpendSet",$params);
if($r){
$this->ajaxReturn(["status"=>1,"info"=>"重算任务登记成功,请等待两三分钟后查看结果"]);
}else{
$this->ajaxReturn(["status"=>0,"info"=>"重算任务登记错误"]);
}
}
public function addStatement()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");

@ -104,6 +104,4 @@ class SubSpendSetController extends Controller
{
return $this->SubKvModel->where("`key` = 'sub_spend_syn_time'")->save(['value'=>$this->SynTime]);
}
}

@ -408,6 +408,50 @@
</form>
<a class="ajax-post add-butn <notempty name='commonset'>addSIsetted</notempty>" href="javascript:;" target-form="addShortcutIcon" url="{:U('Think/addShortcutIcon')}"><img src="__IMG__/zwmimages/icon_jia.png"><span><notempty name='commonset'>已添加<else />添加至常用设置</notempty></span></a>
</div>
<script type="text/html" id="addSubSpendTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
最后固定数据时间:【{$lastSynTime}】<br/>仅能固定最后固定数据时间之后的订单<br/>订单日期表示:最后固定的时间到所选时间(含)之间的订单数据进行固定
</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">
<input type="text" id="addSubSpendTime" name="addSubSpendTime" autocomplete="off" class="date" placeholder="订单日期" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="addSubSpendSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
<script type="text/html" id="updateSubSpendTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
已固定订单时间:【{$lastSynTime}】<br/>重新固定的数据将覆盖之前的订单数据
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:100px;">订单开始日期:</td>
<td class="r table_radio">
<input type="text" id="updateSubSpendStart" name="updateSubSpendStart" autocomplete="off" class="date" placeholder="订单开始日期" />
</td>
</tr>
<tr style="height:20px;"></tr>
<tr>
<td class="l noticeinfo" style="width:100px;">订单结束日期:</td>
<td class="r table_radio">
<input type="text" id="updateSubSpendEnd" name="updateSubSpendEnd" autocomplete="off" class="date" placeholder="订单结束日期" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="updateSubSpendSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
</block>
@ -428,10 +472,154 @@
</volist>
$(".select_gallery").select2();
</script>
<script type="text/javascript">
var SPENDOP={
lastSynTime:"{$lastSynTime}",
publiucAjax:function(url,senddata,callback){
$.ajax({
type: 'post',
url: url,
data:senddata,
success: function(data) {
console.log(data)
if(data.status == 1){
callback(data.info);
}else{
layer.alert(data.info);
return false;
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
},
initFun(){
this.mainEven();
},
closeLayer(){
layer.closeAll();
},
reload(){
setTimeout(function(){
window.location.reload();
},1000);
},
oepnHtml(title,dom,callback){
var html = $(dom).html();
layer.open({
type: 1,
title: title,
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:callback
});
},
mainEven(){
$("#addSubSpendSet").on("click",function() {
SPENDOP.oepnHtml("新增固定订单","#addSubSpendTpl",SPENDOP.addSubSpendSetEvent);
});
$("#updateSubSpend").on("click",function() {
SPENDOP.oepnHtml("重新固定订单","#updateSubSpendTpl",SPENDOP.updateSubSpendEvent);
});
},
addSubSpendSetEvent(){
$("#addSubSpendSubmit").off("click");
$("#addSubSpendTime").datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
showMeridian:true,
pickDate:true,
minView: 2,
autoclose: true,
pickTime:true,
todayBtn:true,
});
$("#addSubSpendSubmit").on("click",function() {
var subtime= $("#addSubSpendTime").val();
var day2 = new Date();
day2.setTime(day2.getTime());
var today = day2.getFullYear()+"-" + (day2.getMonth()+1) + "-" + day2.getDate();
var lastSynTime = Date.parse(SPENDOP.lastSynTime);
today = Date.parse(today);
var subtimenum = Date.parse(subtime);
if(subtimenum >= today) {
layer.msg('固化数据必须小于当日');
return false;
}
if(subtimenum <= lastSynTime) {
layer.msg('所选时间已固化');
return false;
}
//执行
SPENDOP.publiucAjax("{:U('addSubSpendSet')}",{time:subtime},function(info){
layer.alert(info);
SPENDOP.reload();
});
})
},
updateSubSpendEvent(){
$("#updateSubSpendSubmit").off("click");
$("#updateSubSpendStart").datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
showMeridian:true,
pickDate:true,
minView: 2,
autoclose: true,
pickTime:true,
todayBtn:true,
});
$("#updateSubSpendEnd").datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
showMeridian:true,
pickDate:true,
minView: 2,
autoclose: true,
pickTime:true,
todayBtn:true,
});
$("#updateSubSpendSubmit").on("click",function() {
var begin= $("#updateSubSpendStart").val();
var end= $("#updateSubSpendEnd").val();
var startNum = Date.parse(begin);
var endNum = Date.parse(end);
var lastSynTime = Date.parse(SPENDOP.lastSynTime);
if(startNum > endNum) {
layer.msg('开始时间必须小于结束时间');
return false;
}
if(endNum > lastSynTime) {
layer.msg('重算结束时间必须在最后固定时间之前');
return false;
}
//执行
SPENDOP.publiucAjax("{:U('updateSubSpend')}",{begin:begin,end:end},function(info){
layer.alert(info);
SPENDOP.reload();
});
})
}
}
</script>
<script type="text/javascript">
//导航高亮
highlight_subnav("{:U('lists')}");
$(function () {
SPENDOP.initFun();
//搜索功能
$("#search").click(function () {
var sdate = Date.parse($('#time-start').val()) / 1000;

Loading…
Cancel
Save