新增子站结算

master
chenzhi 4 years ago
parent 8d871290f2
commit c21b9f619e

@ -229,6 +229,13 @@ class CompanyStatementController extends ThinkController
}
$this->assign("IS_SUBSITE",IS_SUBSITE);
if(IS_SUBSITE){
$SubKvModel = M("Kv","sub_",SUBSITE_DB);//指定子库
$LastSynTime = $SubKvModel->where("`key` = 'sub_spend_syn_time'")->getField("value");
$LastStatementTime = $SubKvModel->where("`key` = 'sub_company_statement'")->getField("value");
$this->assign('lastSynTime',date('Y-m-d',$LastSynTime));
$this->assign('lastStatementTime',date('Y-m-d',$LastStatementTime));
}
$this->assign('data',$data);
$this->assign('count',$count);
@ -1734,6 +1741,24 @@ class CompanyStatementController extends ThinkController
$this->ajaxReturn(array("success"=>"ok","data"=>[]));
}
//子站新增结算
public function subAddStatement(){
if(!isset($_REQUEST['statement_time'])) $this->error("参数错误");
$statement_time = $_REQUEST['statement_time'];
$end = date("Y-m-d",strtotime($statement_time)+ 86400);
$utime = strtotime($statement_time)+86399;
$LastStatementTime = M("Kv","sub_",SUBSITE_DB)->where("`key` = 'sub_company_statement'")->getField("value");
$begin = date("Y-m-d",$LastStatementTime-0+1);
$params = "php ".SUBSITE_INDEX." SubCompanyStatementSet/setFreeDateCount/begin/{$begin}/end/{$end}/utime/{$utime}";
$r = D("CmdTasks")->addTask("SubCompanyStatementSet",$params);
if($r){
$this->ajaxReturn(["status"=>1,"info"=>"任务登记成功,请等待五分分钟后查看结果"]);
}else{
$this->ajaxReturn(["status"=>0,"info"=>"任务登记错误"]);
}
}
public function viewSpecialComplement() {
@ -2448,6 +2473,13 @@ class CompanyStatementController extends ThinkController
"viewSpecialComplement"=>"<a class='butn' id='viewSpecialComplement'>特殊补点</a>",
"delStatement"=>"<a class='butn' id='delStatement' style='background-color: red;'>批量删除</a>"
];
if(IS_SUBSITE){
unset($mentBtn['updateNewStatement']);
$is_can_add = D("CmdTasks")->isCanAddTask("SubCompanyStatementSet");
if($is_can_add){
$mentBtn['subAddStatement'] = "<a class='butn' id='subAddStatement' style='background-color: green;'>新增结算</a>";
}
}
$resarr = [];
foreach ($mentBtn as $k => $v) {
if(IS_ROOT){

@ -33,7 +33,7 @@ class SubCompanyStatementSetController extends Controller {
* @param string $company all/pc/cp/pu 全部 下游公司 上游 下游个人
* @return void
*/
public function setFreeDateCount($begin,$end='',$company='all')
public function setFreeDateCount($begin,$end='',$utime=false,$company='all')
{
if($end == '') $end = $begin;
//判断日期格式
@ -58,6 +58,9 @@ class SubCompanyStatementSetController extends Controller {
for($i=0;$i<$countdate;$i++){
$this->setDailyCount($datelist[$i],$company);
}
if($utime){
M("Kv","sub_",SUBSITE_DB)->where("`key` = 'sub_company_statement'")->save(["value"=>$utime]);
}
}
public function setDailyCount($stime="now",$company='all')
{
@ -74,14 +77,14 @@ class SubCompanyStatementSetController extends Controller {
$w = (int)date("w",$stime);
if($w == 1){
if($company == "all"){
echo $nowdate.":".PHP_EOL;
echo "--周结begin".PHP_EOL;
// echo $nowdate.":".PHP_EOL;
// echo "--周结begin".PHP_EOL;
$this->cpStatement(0,$stime);
echo "∟----CP周结统计ok".PHP_EOL;
// echo "∟----CP周结统计ok".PHP_EOL;
$this->promoteCompanyStatement(0,$stime);
echo "∟----推广公司周结统计ok".PHP_EOL;
// echo "∟----推广公司周结统计ok".PHP_EOL;
}
if($company == "cp"){
$this->cpStatement(0,$stime);
@ -94,19 +97,18 @@ class SubCompanyStatementSetController extends Controller {
}
if($d == 1){
if($company == "all"){
echo $nowdate.":".PHP_EOL;
echo "--月结&补点begin".PHP_EOL;
// echo $nowdate.":".PHP_EOL;
// echo "--月结&补点begin".PHP_EOL;
$this->cpStatement(1,$stime);
echo "∟----CP月结&补点统计ok".PHP_EOL;
// echo "∟----CP月结&补点统计ok".PHP_EOL;
$this->promoteCompanyStatement(1,$stime);
$this->officeCompanyStatement($stime); //官方结算
echo "∟----官方/推广公司月结统计ok".PHP_EOL;
// echo "∟----官方/推广公司月结统计ok".PHP_EOL;
$this->promoteUserPool(1,$stime);
echo "∟----推广个人月结统计ok".PHP_EOL;
// echo "∟----推广个人月结统计ok".PHP_EOL;
}
if($company == "cp"){
$this->cpStatement(1,$stime);
@ -122,9 +124,9 @@ class SubCompanyStatementSetController extends Controller {
echo "∟----推广个人月结&补点统计ok".PHP_EOL;
}
}
if($w != 1 && $d != 1){
echo $nowdate."非月初,无需任何处理".PHP_EOL;
}
// if($w != 1 && $d != 1){
// echo $nowdate."非月初,无需任何处理".PHP_EOL;
// }
}
/**
* 上游结算

@ -289,6 +289,28 @@
<span class="layui-layer-setwin"></span>
</div>
</div>
<script type="text/html" id="addSubStatementTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
最后结算时间:【{$lastStatementTime|default=''}】/ 订单最后固定时间:【{$lastSynTime|default=''}】<br/>
结算数据仅在周一及月初有结算所以结算日期应选择比需要结算的日期多一日。例需要结算2019-10-01~2019-10-31的数据需要选择结算日期为2019-11-01
</spend>
<input id="lastStatementTime" type="hidden" name="lastStatementTime" value="{$lastStatementTime|default=''}">
<input id="lastSynTime" type="hidden" name="lastSynTime" value="{$lastSynTime|default=''}">
<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="addSubStatementTime" name="addSubStatementTime" autocomplete="off" class="date" placeholder="结算日期" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="addSubStatementSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
</block>
<block name="script">
@ -743,6 +765,74 @@
}
});
})
//子站新增结算单
$("#subAddStatement").click(function(){
var html = $("#addSubStatementTpl").html();
layer.open({
type: 1,
title: "新增结算单",
maxWidth:720,
closeBtn: 1,
shadeClose: false,
content: html,
success:function(){
$("#addSubStatementSubmit").off("click");
$("#addSubStatementTime").datetimepicker({
format: 'yyyy-mm-dd',
language: "zh-CN",
showMeridian:true,
pickDate:true,
minView: 2,
autoclose: true,
pickTime:true,
todayBtn:true,
});
$("#addSubStatementSubmit").on("click",function(){
var subtime= $("#addSubStatementTime").val();
if(subtime == '') {
layer.msg('请先选择要结算的时间');
return false;
}
var lastSynTime = Date.parse($("#lastSynTime").val())+86400000;
var lastStatementTime = Date.parse($("#lastStatementTime").val());
var subtimenum = Date.parse(subtime);
if(subtimenum > lastSynTime) {
layer.msg('新增结算时间必须小于固定订单时间');
return false;
}
if(subtimenum <= lastStatementTime) {
layer.msg('所选时间已结算');
return false;
}
$.ajax({
type: "POST",
url: "{:U('subAddStatement')}",
dataType: 'json',
async: true,
data: {statement_time:subtime},
success:function(data){
if(data.status==1){
layer.msg("<font style='color:white'>" + data.info + "</font>");
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.alert(data.info)
}
}
});
})
}
});
})
//查看批注
$(".viewRemark").click(function () {
var remark = $(this).data("remark");

Loading…
Cancel
Save