From d53fb8962298d2bf59818a63f1c787bebb20725f Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 19 Aug 2021 19:39:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E6=B8=B8=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StatementWarningSetController.class.php | 74 ++++++++++++++++++- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Controller/StatementWarningSetController.class.php b/Application/Admin/Controller/StatementWarningSetController.class.php index d0c9457f9..d928a00e4 100644 --- a/Application/Admin/Controller/StatementWarningSetController.class.php +++ b/Application/Admin/Controller/StatementWarningSetController.class.php @@ -73,7 +73,8 @@ class StatementWarningSetController extends Controller { // $this->getAllWmAmount(); // $this->cpStatement(); - $this->pcStatement(); + // $this->pcStatement(); + $this->puStatement(); echo "{$this->year}-{$this->month}生成成功".PHP_EOL; @@ -253,7 +254,7 @@ class StatementWarningSetController extends Controller { 'company_belong'=>0 ])->getField("id company_id,company_name,develop_type",true); - $company = $this->getPcGameSpend($company); + $company = $this->getPromoteCompanyGameSpend($company); $pcStatementAmount = $this->addStatementWarningInfo($company,0); $savedata = [ 'type'=>2, @@ -270,7 +271,7 @@ class StatementWarningSetController extends Controller { $this->statementWarningModel->add($savedata); } } - private function getPcGameSpend($company) + private function getPromoteCompanyGameSpend($company) { $where = [ 'tab_spend.is_check'=>1, @@ -285,6 +286,7 @@ class StatementWarningSetController extends Controller { ->where($where) ->group('tab_promote.company_id,relation_game_name') ->select(); + if(!$items) return $company; $CompanyGameRatio = D("CompanyGameRatio"); $games = M("Game",'tab_')->where(['relation_game_name' => ['in',array_column($items,'relation_game_name')]])->getField("relation_game_name,relation_game_id"); @@ -302,11 +304,75 @@ class StatementWarningSetController extends Controller { } return $company; } + + private function puStatement() + { + //获取公司 + $company = M('promote_company','tab_')->where([ + 'id'=>["NOT IN",$this->inSideCompanyIds], + 'company_type'=>1, + 'company_belong'=>['in',[1,2]] + ])->getField("id company_id,company_name,develop_type",true); + if(!$company) { + $this->addStatementWarning(2,'pu_statement',0); + return; + }; + $company = $this->getPuSpecialStatement( $this->getPromoteCompanyGameSpend($company) ); + foreach ($company as $key => $value) { + if(!array_key_exists('statement_money',$value) ) { + unset($company[$key]); + }; + } + + $puStatementAmount = $this->addStatementWarningInfo($company,0); + $this->addStatementWarning(2,'pu_statement',$puStatementAmount); + } + + private function getPuSpecialStatement($company) + { + $where = [ + "company_belong"=>["NOT IN",[0,9]], + "company_id"=>["IN",array_keys($company)], + "withdraw_type"=>3, + "_string"=>"statement_begin_time >= {$this->beginThismonth} and statement_end_time <= {$this->endThismonth}" + ]; + $res = M("company_statement", "tab_")->where($where)->group('company_id')->getField("company_id,sum(statement_money) statement_money"); + if($res){ + foreach ($res as $key => $value) { + if(array_key_exists('statement_money',$company[$key])){ + $company[$key]['statement_money'] += ($value-0); + }else{ + $company[$key]['statement_money'] = ($value-0); + } + } + } + return $company; + } + + + private function addStatementWarning($type,$name,$money) + { + $savedata = [ + 'type'=>$type, + 'name'=>$name, + 'count_month'=>$this->month, + 'count_year'=>$this->year + ]; + $hasDb = $this->statementWarningModel->where($savedata)->find(); + $savedata = array_merge(['money'=>$money,'create_time'=>time()],$savedata); + if($hasDb){ + $savedata['id'] = $hasDb['id']; + $this->statementWarningModel->save($savedata); + }else{ + $this->statementWarningModel->add($savedata); + } + } + private function addStatementWarningInfo($company,$companyBelong) { $statementAmount = 0; foreach ($company as $key => $value) { - $statementMoney = $value['statement_money']-0; + $statementMoney = array_key_exists('statement_money',$value) ? ($value['statement_money']-0) : 0; $statementAmount += $statementMoney; $company[$key]['is_wm'] = $this->getCompanyIsWm($key,$companyBelong); $company[$key]['company_belong'] = $companyBelong;