From 50efce9315da6300884b3e5d3804276428c36133 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 29 Oct 2019 10:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0spen=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpendCountSetController.class.php | 42 ++++++++++++++++--- Data/update.sql | 2 + 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php index d112cff45..4fb11e70e 100644 --- a/Application/Admin/Controller/SpendCountSetController.class.php +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -19,7 +19,7 @@ class SpendCountSetController extends \Think\Controller $this->endThismonth = mktime(0,0,0,date('m')-1,date('t'),date('Y'))-1; $this->date = date('Y')."-".((date('m')-1) > 9 ? (date('m')-1) : "0".(date('m')-1)); $this->nowdata =time(); - $this->model =M("spend",'tab_'); + $this->model =M("spend_count",'tab_'); } public function initCount() { @@ -27,8 +27,8 @@ class SpendCountSetController extends \Think\Controller if($countRes > 0){ die("init error"); } - $nowdate = date('Y')."-".(date('m') > 9 ? date('m') : "0".date('m')); - // $nowdate = "2017-10"; + // $nowdate = date('Y')."-".(date('m') > 9 ? date('m') : "0".date('m')); + $nowdate = "2017-10"; //获取所有的月份 pay_time $res = M("spend",'tab_')->field("FROM_UNIXTIME(pay_time,'%Y-%m') AS pay_time")->buildSql(); $res = M()->table($res.' a')->group('pay_time')->select(); @@ -48,7 +48,8 @@ class SpendCountSetController extends \Think\Controller $this->getBalanceData(); $this->getBingData(); $this->getInsideData(); - + $this->setRoot(); + $this->model->commit(); } } @@ -69,7 +70,7 @@ class SpendCountSetController extends \Think\Controller $this->getBalanceData(); $this->getBingData(); $this->getInsideData(); - + $this->setRoot(); $this->model->commit(); die("success"); } @@ -254,6 +255,37 @@ class SpendCountSetController extends \Think\Controller } // return true; } + public function setRoot() + { + if(!$this->continue){ + die("api error"); + } + $map = array( + "parent_id"=>array("GT",0), + "count_date"=>$this->date + ); + $user = $this->model->field("parent_id,promote_id")->where($map)->group("promote_id")->select(); + $Promote=M("promote","tab_"); + for ($i=0; $i < count($user); $i++) { + # code... + $map['id']=$user[$i]['parent_id']; + $root=$Promote->field('IFNULL(parent_id,0) root_id,parent_name root_name')->where($map)->find(); + if(!$root){ + $root['root_id']=0; + $root['root_name']='官方渠道'; + } + //保存 + $where = array( + "promote_id"=>$user[$i]['promote_id'], + "count_date"=>$this->date + ); + $tempdbres = $this->model->where($where)->save($root); + if(!$tempdbres){ + $this->model->rollback(); + die("setRoot error"); + } + } + } diff --git a/Data/update.sql b/Data/update.sql index 4e476a510..731cd306b 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -197,6 +197,8 @@ CREATE TABLE `tab_spend_count` ( `promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号', `parent_id` int(11) DEFAULT '0' COMMENT '父类ID', `parent_name` varchar(30) DEFAULT NULL COMMENT '父类名称', + `root_id` int(11) DEFAULT 0 COMMENT '根ID', + `root_name` varchar(30) DEFAULT NULL COMMENT '根名称', `game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id', `game_name` varchar(30) DEFAULT '' COMMENT '游戏名称', `partner_id` int(11) DEFAULT '0' COMMENT '合作方id',