新增结算

master
chenzhi 5 years ago
parent 53004adf5d
commit 53b9513935

@ -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"=>[]));

@ -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+"] ......");

Loading…
Cancel
Save