From c7c4b52c89ca1ed1e08e419488e85f85981b829f Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 19 May 2021 17:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E4=B8=8B=E6=B8=B8=E5=A4=96?= =?UTF-8?q?=E5=9B=A2=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameMarginSetController.class.php | 67 +++++++++++++++---- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/Application/Admin/Controller/GameMarginSetController.class.php b/Application/Admin/Controller/GameMarginSetController.class.php index 38eac3ba2..e0fc6cd57 100644 --- a/Application/Admin/Controller/GameMarginSetController.class.php +++ b/Application/Admin/Controller/GameMarginSetController.class.php @@ -16,7 +16,7 @@ class GameMarginSetController extends Controller { private $month;//月份 private $year;//年份 private $adddata;//要添加的数据 - // public $taskid=false; + private $inSideCompanyIds; // public $result=''; /** * 更新某月数据 @@ -58,14 +58,27 @@ class GameMarginSetController extends Controller { private function setGameMargin() { + $this->getInsideCompanyid(); $this->getAllGameSpend(); - // $this->getJuheStatement(); - // $this->getPuStatement(); - - //上游 $this->getCpStatement(); + $this->getJuheStatement(); + $this->getPuStatement(); + $this->getPcStatement(); dd($this->adddata); - + } + /** + * 内部公司 + */ + private function getInsideCompanyid() + { + $res = M("PromoteCompany","tab_")->where("is_inside = 1")->field("id")->select(); + if($res){ + $res = array_column($res,"id"); + $res[] = 0; + }else{ + $res = [0]; + } + $this->inSideCompanyIds = implode(",",$res); } //获取期间所有有流水的游戏 private function getAllGameSpend() @@ -326,10 +339,8 @@ class GameMarginSetController extends Controller { foreach ($res as $v) { $sinfo = json_decode($v['statement_info'],true); foreach ($sinfo as $val) { - var_dump($val['game_name']); //获取真实游戏名 - $games = $this->OPName2GName($val['game_name'],$v['company_id']); - var_dump($games); + $games = $this->cpOPName2GName($val['game_name'],$v['company_id']); foreach ($games as $game) { if( !array_key_exists($game,$this->adddata) ){ continue; @@ -345,9 +356,8 @@ class GameMarginSetController extends Controller { } } } - - //原包名还原游戏名 - private function OPName2GName($OPName,$company_id) + //结算包名还原游戏名 + private function cpOPName2GName($OPName,$company_id) { $where = [ "partner_id"=>$company_id, @@ -355,11 +365,40 @@ class GameMarginSetController extends Controller { ]; $game = M("Game","tab_")->field("relation_game_name")->where($where)->group("relation_game_name")->select(); if($game){ - return array_column($game,"relation_game_name"); + return array_column($game,"relation_game_name"); }else{ return [$OPName]; } } - + //获取下游内团 + private function getPcStatement() + { + $where = [ + "company_belong"=>0, + "withdraw_type"=>1, + "statement_begin_time"=>$this->beginThismonth, + "statement_end_time"=>$this->endThismonth, + "company_id"=>["NOT IN",$this->inSideCompanyIds] + ]; + $res = M("company_statement","tab_")->where($where)->select(); + if($res){ + foreach ($res as $v) { + $sinfo = json_decode($v['statement_info'],true); + foreach ($sinfo as $val) { + //奖罚不算 + if( !array_key_exists($val['game_name'],$this->adddata) ){ + continue; + } + if( array_key_exists("pc_pay_amount",$this->adddata[$val['game_name']]) ){ + $this->adddata[$val['game_name']]['pc_pay_amount'] += $val['pay_amount']; + $this->adddata[$val['game_name']]['pc_statement_amount'] += $val['sum_money']; + }else{ + $this->adddata[$val['game_name']]['pc_pay_amount'] = $val['pay_amount']; + $this->adddata[$val['game_name']]['pc_statement_amount'] = $val['sum_money']; + } + } + } + } + } }