From eacdea6f9b62e102b8b6d0aa655f0624a5d96483 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Mon, 4 Nov 2019 15:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpendCountSetController.class.php | 259 +++++++++--------- 1 file changed, 131 insertions(+), 128 deletions(-) diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php index 7ff62955c..e9ce825d8 100644 --- a/Application/Admin/Controller/SpendCountSetController.class.php +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -104,145 +104,148 @@ class SpendCountSetController extends \Think\Controller //获取游戏现金流水 protected function getCashData() { - if(!$this->continue){ - die("api error"); - } - $map = array( - "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), - "spend.pay_status"=>1, - "pay_way"=>array("GT",0) - ); - $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, - spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, - IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) cash_count, - '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; - //获取现金 - $cashRes = M() - ->table("tab_spend spend") - ->field($field) - ->where($map) - ->join("tab_promote promote ON spend.promote_id = promote.id","left") - ->join("tab_game game ON spend.game_id = game.id","left") - ->join("tab_partner partner ON partner.id = game.partner_id","left") - ->group('spend.promote_id,spend.game_id') - ->select(); - if(!empty($cashRes)){ - $dbres = $this->model->addAll($cashRes); - if(!$dbres){ - $this->model->rollback(); - die("error"); - } - } + $this->createGameCount("cash_count"); + // if(!$this->continue){ + // die("api error"); + // } + // $map = array( + // "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + // "spend.pay_status"=>1, + // "pay_way"=>array("GT",0) + // ); + // $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, + // spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, + // IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) cash_count, + // '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; + // //获取现金 + // $cashRes = M() + // ->table("tab_spend spend") + // ->field($field) + // ->where($map) + // ->join("tab_promote promote ON spend.promote_id = promote.id","left") + // ->join("tab_game game ON spend.game_id = game.id","left") + // ->join("tab_partner partner ON partner.id = game.partner_id","left") + // ->group('spend.promote_id,spend.game_id') + // ->select(); + // if(!empty($cashRes)){ + // $dbres = $this->model->addAll($cashRes); + // if(!$dbres){ + // $this->model->rollback(); + // die("error"); + // } + // } # code... } //获取平台币聚合 protected function getBalanceData() { - if(!$this->continue){ - die("api error"); - } - $map = array( - "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), - "spend.pay_status"=>1, - "pay_way"=> array("EQ",0) - ); - $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, - spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, - IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) balance_coin_count, - '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; - $balanceRes = M() - ->table("tab_spend spend") - ->field($field) - ->where($map) - ->join("tab_promote promote ON spend.promote_id = promote.id","left") - ->join("tab_game game ON spend.game_id = game.id","left") - ->join("tab_partner partner ON partner.id = game.partner_id","left") - ->group('spend.promote_id,spend.game_id') - ->select(); - //集中两个表 - if(!empty($balanceRes)){ + $this->createGameCount("balance_coin_count"); + // if(!$this->continue){ + // die("api error"); + // } + // $map = array( + // "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + // "spend.pay_status"=>1, + // "pay_way"=> array("EQ",0) + // ); + // $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, + // spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, + // IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) balance_coin_count, + // '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; + // $balanceRes = M() + // ->table("tab_spend spend") + // ->field($field) + // ->where($map) + // ->join("tab_promote promote ON spend.promote_id = promote.id","left") + // ->join("tab_game game ON spend.game_id = game.id","left") + // ->join("tab_partner partner ON partner.id = game.partner_id","left") + // ->group('spend.promote_id,spend.game_id') + // ->select(); + // //集中两个表 + // if(!empty($balanceRes)){ - for ($i=0; $i < count($balanceRes); $i++) { - # code... - $tempmap = array( - "game_id"=>$balanceRes[$i]['game_id'], - "promote_id"=>$balanceRes[$i]['promote_id'], - "count_date"=>$this->date - ); - $dbres = $this->model->where($tempmap)->find(); - if(!$dbres){ - //不存在 - $tempdbres = $this->model->add($balanceRes[$i]); - if(!$tempdbres){ - $this->model->rollback(); - die("error"); - } - }else{ - $dbres["balance_coin_count"] = $balanceRes[$i]['balance_coin_count']; - $tempdbres = $this->model->save($dbres); - if(!$tempdbres){ - $this->model->rollback(); - die("error"); - } - } - } - } + // for ($i=0; $i < count($balanceRes); $i++) { + // # code... + // $tempmap = array( + // "game_id"=>$balanceRes[$i]['game_id'], + // "promote_id"=>$balanceRes[$i]['promote_id'], + // "count_date"=>$this->date + // ); + // $dbres = $this->model->where($tempmap)->find(); + // if(!$dbres){ + // //不存在 + // $tempdbres = $this->model->add($balanceRes[$i]); + // if(!$tempdbres){ + // $this->model->rollback(); + // die("error"); + // } + // }else{ + // $dbres["balance_coin_count"] = $balanceRes[$i]['balance_coin_count']; + // $tempdbres = $this->model->save($dbres); + // if(!$tempdbres){ + // $this->model->rollback(); + // die("error"); + // } + // } + // } + // } # code... } //获取绑定币充值 protected function getInsideData() { - if(!$this->continue){ - die("api error"); - } - $map = array( - "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), - "spend.pay_status"=>1, - "pay_way"=> array("LT",0) - ); - $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, - spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, - IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) inside_cash_count, - '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; - $balanceRes = M() - ->table("tab_spend spend") - ->field($field) - ->where($map) - ->join("tab_promote promote ON spend.promote_id = promote.id","left") - ->join("tab_game game ON spend.game_id = game.id","left") - ->join("tab_partner partner ON partner.id = game.partner_id","left") - ->group('spend.promote_id,spend.game_id') - ->select(); - //集中两个表 - if(!empty($balanceRes)){ + $this->createGameCount("inside_cash_count"); + // if(!$this->continue){ + // die("api error"); + // } + // $map = array( + // "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + // "spend.pay_status"=>1, + // "pay_way"=> array("LT",0) + // ); + // $field = "IFNULL(game.partner_id,0) partner_id,partner.partner partner_name, + // spend.promote_id,spend.promote_account,spend.game_id,spend.game_name, + // IFNULL(promote.parent_id,0) parent_id,promote.parent_name,sum(pay_amount) inside_cash_count, + // '{$this->date}' as count_date,'{$this->nowdata}' as create_time"; + // $balanceRes = M() + // ->table("tab_spend spend") + // ->field($field) + // ->where($map) + // ->join("tab_promote promote ON spend.promote_id = promote.id","left") + // ->join("tab_game game ON spend.game_id = game.id","left") + // ->join("tab_partner partner ON partner.id = game.partner_id","left") + // ->group('spend.promote_id,spend.game_id') + // ->select(); + // //集中两个表 + // if(!empty($balanceRes)){ - for ($i=0; $i < count($balanceRes); $i++) { - # code... - $tempmap = array( - "game_id"=>$balanceRes[$i]['game_id'], - "promote_id"=>$balanceRes[$i]['promote_id'], - "count_date"=>$this->date - ); - $dbres = $this->model->where($tempmap)->find(); - if(!$dbres){ - //不存在 - $tempdbres = $this->model->add($balanceRes[$i]); - if(!$tempdbres){ - $this->model->rollback(); - die("error"); - } - }else{ - $dbres["inside_cash_count"] = $balanceRes[$i]['inside_cash_count']; - $tempdbres = $this->model->save($dbres); - if(!$tempdbres){ - $this->model->rollback(); - die("error"); - } - } - } - } + // for ($i=0; $i < count($balanceRes); $i++) { + // # code... + // $tempmap = array( + // "game_id"=>$balanceRes[$i]['game_id'], + // "promote_id"=>$balanceRes[$i]['promote_id'], + // "count_date"=>$this->date + // ); + // $dbres = $this->model->where($tempmap)->find(); + // if(!$dbres){ + // //不存在 + // $tempdbres = $this->model->add($balanceRes[$i]); + // if(!$tempdbres){ + // $this->model->rollback(); + // die("error"); + // } + // }else{ + // $dbres["inside_cash_count"] = $balanceRes[$i]['inside_cash_count']; + // $tempdbres = $this->model->save($dbres); + // if(!$tempdbres){ + // $this->model->rollback(); + // die("error"); + // } + // } + // } + // } } - public function createGameCount($type) + protected function createGameCount($type) { $map = array( "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), @@ -294,8 +297,8 @@ class SpendCountSetController extends \Think\Controller die("error"); } }else{ - $dbres["inside_cash_count"] = $balanceRes[$i]['inside_cash_count']; - $tempdbres = $this->model->save($dbres); + $dbres[$type] = $balanceRes[$i][$type]; + $tempdbres = $this->gamemodel->save($dbres); if(!$tempdbres){ $this->model->rollback(); die("error");