From a3a350589468802d60ade706ffc48b4424b336a3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 27 Aug 2020 20:44:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=98=E6=96=B9?= =?UTF-8?q?=E6=B8=A0=E9=81=93=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index b9a727586..b80e1df40 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -132,6 +132,7 @@ class CompanyStatementSetController extends Controller { if($company == "pu"){ $this->promoteUserPool(1,$stime); $this->promoteUserPool(2,$stime); + $this->officeCompanyStatement($stime); //官方结算 echo "∟----推广个人月结&补点统计ok".PHP_EOL; } } @@ -477,6 +478,82 @@ class CompanyStatementSetController extends Controller { } return $cplList; } + //官方结算 + public function officeCompanyStatement($stime,$recount=false) + { + $t = $this->setBeginAndEndTime($type,$stime); + $begintime = $t[0]; + $endtime = $t[1]; + + //获取官方信息 + $pc_map = [ + "id"=>["IN",$pc_id], + "_string"=>"(validity_start_time > 0 AND validity_end_time = 0 ) OR validity_end_time >= {$endtime}", + "company_type"=>1 + ]; + //获取pc公司 + $company = M("CompanyInfo","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("partner = '海南万盟天下科技有限公司'")->find(); + $add_data=[ + "first_party_info"=>json_encode($company,JSON_UNESCAPED_UNICODE), + "second_party_info"=>json_encode($company,JSON_UNESCAPED_UNICODE), + "pay_type"=>1, + "withdraw_type"=>1, + "statement_begin_time"=>$begintime, + "statement_end_time"=>$endtime, + "statement_money"=>0, + "pay_amount"=>0, + "platform_amount"=>0, + "verify_log"=>json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]), + "op_time"=>time(), + "is_payment"=>2, + "statement_info"=>[], + "company_belong"=>0, + "company_name"=>'海南万盟天下科技有限公司', + "company_id"=>0, + "company_type"=>1 + ]; + + //获取渠道及发票税率 + $fax_ratio = 0; //税费费率 + $company_belong = 0; + + + + $Promote = M("Promote","tab_"); + $Spend = M("Spend","tab_"); + $spenMap = [ + "s.pay_status"=>1, + "s.payed_time"=>['between', [$begintime,$endtime]], + "s.promote_id"=>0 + ]; + $list = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('game_id') + ->join("left join tab_game g on s.game_id = g.id") + ->select(); + if(empty($list)){return;} + $statement_begin_time = date("Y.m.d",$begintime); + $statement_end_time = date("Y.m.d",$endtime); + + foreach ($list as $k => $v) { + $v['fax_ratio'] = 0; + $v['statement_begin_time']=$statement_begin_time; + $v['statement_end_time']=$statement_end_time; + $v['ratio']=0; + $v['sum_money'] = 0; + $v['statement_type']=0; + + $add_data['platform_amount'] += $v['pay_amount']; + $add_data['pay_amount'] += $v['pay_amount']; + $add_data['statement_info'][] = $v; + } + $add_data['statement_info'] = json_encode($add_data['statement_info'],JSON_UNESCAPED_UNICODE); + if($recount){ + //非重算 + return $add_data; + } + M("CompanyStatement","tab_")->add($add_data); + } + + /** * 下游结算 */ @@ -1480,11 +1557,16 @@ class CompanyStatementSetController extends Controller { //获取时间 $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); + + if($company_id == 0){ + $savedata = $this->officeCompanyStatement($stime,true); }else{ - $savedata = $this->promoteCompanyStatement($dbres['withdraw_type'],$stime,$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")]); From 927c5b859520d9d9bc1ecb08644e96aee961e8db Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 27 Aug 2020 20:54:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=B7=E5=8D=97?= =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CompanyStatementSetController.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index b80e1df40..1531c99e6 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -113,6 +113,7 @@ class CompanyStatementSetController extends Controller { $this->promoteCompanyStatement(1,$stime); $this->promoteCompanyStatement(2,$stime); + $this->officeCompanyStatement($stime); //官方结算 echo "∟----推广公司月结&补点统计ok".PHP_EOL; $this->promoteUserPool(1,$stime); @@ -127,12 +128,12 @@ class CompanyStatementSetController extends Controller { if($company == "pc"){ $this->promoteCompanyStatement(1,$stime); $this->promoteCompanyStatement(2,$stime); + $this->officeCompanyStatement($stime); //官方结算 echo "∟----推广公司月结&补点统计ok".PHP_EOL; } if($company == "pu"){ $this->promoteUserPool(1,$stime); $this->promoteUserPool(2,$stime); - $this->officeCompanyStatement($stime); //官方结算 echo "∟----推广个人月结&补点统计ok".PHP_EOL; } } @@ -481,10 +482,10 @@ class CompanyStatementSetController extends Controller { //官方结算 public function officeCompanyStatement($stime,$recount=false) { - $t = $this->setBeginAndEndTime($type,$stime); + + $t = $this->setBeginAndEndTime(1,$stime); $begintime = $t[0]; $endtime = $t[1]; - //获取官方信息 $pc_map = [ "id"=>["IN",$pc_id], @@ -526,7 +527,7 @@ class CompanyStatementSetController extends Controller { "s.payed_time"=>['between', [$begintime,$endtime]], "s.promote_id"=>0 ]; - $list = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('game_id') + $list = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('relation_game_id') ->join("left join tab_game g on s.game_id = g.id") ->select(); if(empty($list)){return;} @@ -553,7 +554,6 @@ class CompanyStatementSetController extends Controller { M("CompanyStatement","tab_")->add($add_data); } - /** * 下游结算 */