From 53b951393595badd1bb101b01a2e9e735154f253 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 22 Jun 2020 10:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementController.class.php | 45 ++++++++++++++----- .../Admin/View/CompanyStatement/lists.html | 2 +- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 3546bf558..bd80d32d8 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -715,18 +715,30 @@ class CompanyStatementController extends ThinkController } $relation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($where)->select(); - $company_id = []; + $up_company_id = []; + $dowm_company_id= []; foreach($relation as $k=>$v){ if($v['first_company_type'] == 0){ - $company_id[]=$v['second_company_id']; + if($v['second_company_type'] == 1){ + $up_company_id[] = $v['second_company_id']; + }else{ + $dowm_company_id = $v['second_company_id']; + } }else{ - $company_id[]=$v['first_company_id']; + if($v['first_company_type'] == 1){ + $up_company_id[] = $v['first_company_id']; + }else{ + $dowm_company_id[]=$v['first_company_id']; + } } } - if(count($company_id) < 1){ + if(count($up_company_id) < 1 && count($dowm_company_id) < 1){ $this->ajaxReturn(["error"=>'无新增关系,无需重算']); } - $senddata['company_id'] = implode(",",$company_id); + + $senddata['up_company_id'] = implode(",",$up_company_id); + $senddata['dowm_company_id'] = implode(",",$dowm_company_id); + //获取要结算的日期 $start = strtotime('-1 month'); $end = time(); @@ -747,7 +759,8 @@ class CompanyStatementController extends ThinkController } public function updateNewStatement() { - $company_id = $_REQUEST['company_id']; + $up_company_id = $_REQUEST['up_company_id']; + $dowm_company_id = $_REQUEST['dowm_company_id']; $date = $_REQUEST['date']; $CompanyStatementSet = A("CompanyStatementSet"); // dd($CompanyStatementSet); @@ -755,14 +768,22 @@ class CompanyStatementController extends ThinkController $w = (int)date("w",strtotime($date)); $d = (int)date("d",strtotime($date)); if($w == 1){ - $CompanyStatementSet->cpStatement(0,$stime,$company_id,false); - $CompanyStatementSet->promoteCompanyStatement(0,$stime,$company_id,false); + if(!empty($up_company_id)){ + $CompanyStatementSet->cpStatement(0,$stime,$up_company_id,false); + } + if(!empty($dowm_company_id)){ + $CompanyStatementSet->promoteCompanyStatement(0,$stime,$dowm_company_id,false); + } } if($d == 1){ - $CompanyStatementSet->cpStatement(1,$stime,$company_id,false); - $CompanyStatementSet->cpStatement(2,$stime,$company_id,false); - $CompanyStatementSet->promoteCompanyStatement(1,$stime,$company_id,false); - $CompanyStatementSet->promoteCompanyStatement(2,$stime,$company_id,false); + if(!empty($up_company_id)){ + $CompanyStatementSet->cpStatement(1,$stime,$up_company_id,false); + $CompanyStatementSet->cpStatement(2,$stime,$up_company_id,false); + } + if(!empty($dowm_company_id)){ + $CompanyStatementSet->promoteCompanyStatement(1,$stime,$dowm_company_id,false); + $CompanyStatementSet->promoteCompanyStatement(2,$stime,$dowm_company_id,false); + } } $this->ajaxReturn(array("success"=>"ok","data"=>[])); diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index dd34b52a4..52b7d75be 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -333,7 +333,7 @@ }, //开始统计 updateNewStatement:function(callback){ - var senddata = {date:DATA.datelist[(DATA.now-1)],company_id:DATA.company_id}; + var senddata = {date:DATA.datelist[(DATA.now-1)],up_company_id:DATA.up_company_id,dowm_company_id:DATA.dowm_company_id}; console.log(senddata); COMPARE.publiucAjax("{:U('updateNewStatement')}",senddata,function(){ MSG.showmsg("开始统计 ["+DATA.now+"/"+DATA.count+"] ......");