From 1d92fdb1db1b7d24dec2e066ee63fea081cde5de Mon Sep 17 00:00:00 2001 From: chenzhi Date: Mon, 1 Jun 2020 10:36:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=8D=E7=AE=97=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 82 ++++++++++++++++--- 1 file changed, 71 insertions(+), 11 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 827a077fd..b5d9bd4c8 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -87,23 +87,32 @@ class CompanyStatementSetController extends Controller { } } /** - * TODO:渠道费未进行计算 * 上游结算 * @param [string] $type 0:周结 1:月结 2:周结补点 */ - public function cpStatement($type,$stime) + public function cpStatement($type,$stime,$company_id=false) { $t = $this->setBeginAndEndTime($type,$stime);; $begintime = $t[0]; $endtime = $t[1]; - + if($company_id === false){ + //非重算 + $where = [ + "_string"=>"first_company_type = '1' OR second_company_type = '1'" + ]; + }else{ + $where = [ + "_string"=>"(first_company_type = '1' AND first_company_id = '{$company_id}') OR (second_company_type = '1' AND second_company_id = '{$company_id}')" + ]; + } //获取哪些要结算 if($type == 1){ - $cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 2 AND (first_company_type = '1' OR second_company_type = '1')")->select(); + $where['settlement_type']=2; + $cpDbRes = M("CompanyRelation","tab_")->where($where)->select(); }else{ - $cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 1 AND (first_company_type = '1' OR second_company_type = '1')")->select(); + $where['settlement_type']=1; + $cpDbRes = M("CompanyRelation","tab_")->where($where)->select(); } - $cpList=[]; $js_id = [];//己方公司 @@ -318,7 +327,13 @@ class CompanyStatementSetController extends Controller { continue; } //添加 - $StatementDb->add($add_data); + if($company_id === false){ + //非重算 + $StatementDb->add($add_data); + }else{ + return $add_data; + } + } } @@ -374,17 +389,30 @@ class CompanyStatementSetController extends Controller { /** * 下游结算 */ - public function promoteCompanyStatement($type,$stime) + public function promoteCompanyStatement($type,$stime,$company_id=false) { $t = $this->setBeginAndEndTime($type,$stime); $begintime = $t[0]; $endtime = $t[1]; + + if($company_id === false){ + //非重算 + $where = [ + "_string"=>"first_company_type = '2' OR second_company_type = '2'" + ]; + }else{ + $where = [ + "_string"=>"(first_company_type = '2' AND first_company_id = '{$company_id}') OR (second_company_type = '2' AND second_company_id = '{$company_id}')" + ]; + } //获取哪些要结算 if($type == 1){ - $pcDbRes = M("CompanyRelation","tab_")->where("settlement_type = 2 AND (first_company_type = '2' OR second_company_type = '2')")->select(); + $where['settlement_type']=2; + $pcDbRes = M("CompanyRelation","tab_")->where($where)->select(); }else{ - $pcDbRes = M("CompanyRelation","tab_")->where("settlement_type = 1 AND (first_company_type = '2' OR second_company_type = '2')")->select(); + $where['settlement_type']=1; + $pcDbRes = M("CompanyRelation","tab_")->where($where)->select(); } $pcList=[]; @@ -550,7 +578,12 @@ class CompanyStatementSetController extends Controller { continue; } //添加 - $StatementDb->add($add_data); + if($company_id === false){ + //非重算 + $StatementDb->add($add_data); + }else{ + return $add_data; + } } } //设定开始结束时间 @@ -610,4 +643,31 @@ class CompanyStatementSetController extends Controller { $pcList[$k]['list'] = $v; } } + + /** + * 重算接口 + * 不进行结算方式重算 + * @param [type] $id 原数据id + * @param string $admin_user 操作用户 + * @return void bool + */ + public function updateCompanyStatementData($id,$admin_user='system') + { + //获取数据 + $StatementDb = M("CompanyStatement","tab_"); + $dbres = $StatementDb->where("id='{$id}'")->find(); + //获取时间 + $stime = $dbres['statement_end_time']-0+1; + $company_id = $dbres['company_id']; + if($dbres['company_belong'] == 9){ + //上游 + $savedata = $this->cpStatement($dbres['withdraw_type'],$stime,$company_id); + }else{ + $savedata = $this->promoteCompanyStatement($dbres['withdraw_type'],$stime,$company_id); + } + //重写用户 + $savedata['verify_log'] = json_encode(["create_user"=>$admin_user,"create_time"=>date("Y-m-d H:i:s")]); + $savedata['id'] = $dbres['id']; + return $StatementDb->save($savedata); + } }