From 9aed64f46d4bcac6f4066e98f161827be89e475b Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 15 Jun 2020 15:06:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98=E5=85=85?= =?UTF-8?q?=E5=80=BC=E6=B1=87=E6=80=BB=E4=BC=98=E5=8C=96=EF=BC=8C=E8=A1=A5?= =?UTF-8?q?=E5=8D=95=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/function.php | 34 ++++ .../Controller/PlatformController.class.php | 27 ++- .../Controller/RepairController.class.php | 7 +- .../Controller/TimingController.class.php | 188 ++++++++++++++++++ 4 files changed, 246 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index cc7e5adef..2f99f79c4 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -964,3 +964,37 @@ function checkEncryptionAuth(&$value,$string){ } } +function PromoteStatistics($orderNo) { + + $spend = M("spend","tab_") + ->field("promote_id,promote_account,pay_time,pay_amount") + ->where(array('pay_order_number'=>$orderNo)) + ->find(); + + $start = strtotime(date("Ymd",$spend['pay_time'])); + + $statisticsData = M("promote_statistics","tab_") + ->where(['promote_id'=>$spend['promote_id'],'time'=>$start]) + ->find(); + + $statisticsData['count']?$statisticsData['count']:$statisticsData['count']=0; + + $insert['promote_id'] = $spend['promote_id']; + $insert['promote_account'] = $spend['promote_account']; + $insert['count'] = $spend['pay_amount']?(($spend['pay_amount']*100)+$statisticsData['count']):0; + $insert['time'] = $start; + + if ($statisticsData) { + + M("promote_statistics","tab_") + ->where(['promote_id'=>$spend['promote_id'],'time'=>$start]) + ->save($insert); + + } else { + + M("promote_statistics","tab_")->add($insert); + + } + +} + diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index f6b3fcfd7..c76d4d573 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -665,16 +665,25 @@ class PlatformController extends ThinkController $map['s.server_id'] = $_REQUEST['server_id']; unset($_REQUEST['server_id']); } - } - $data = M('promote', 'tab_')->alias('tp1') - ->field('tp1.account as promote_account,tp1.id, + } + + if (isset($_REQUEST['game_name'])||isset($_REQUEST['promote_id'])) { + $data = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id, floor(sum(pay_amount)*100) as count') - ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') - ->join("tab_spend as s on tp2.id = s.promote_id", 'left') - ->where($map) - ->group('tp1.id') - ->order('count desc') - ->select(); + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left') + ->where($map) + ->group('tp1.id') + ->order('count desc') + ->select(); + } else { + $statisticsMap['time'] =$map['pay_time']; + $data = M('promote_statistics', 'tab_')->field("promote_account,promote_id as id,sum(count) count")->where($statisticsMap)->group("promote_id")->select(); + } + + +// var_dump($data);die(); //今日/本周/本月不变 $tmap = $map; if(isset($map['pay_time'])){ diff --git a/Application/Admin/Controller/RepairController.class.php b/Application/Admin/Controller/RepairController.class.php index f6eb96244..87df477e9 100644 --- a/Application/Admin/Controller/RepairController.class.php +++ b/Application/Admin/Controller/RepairController.class.php @@ -123,7 +123,7 @@ class RepairController extends ThinkController { */ public function noticePayed($orderNo, $second, $type) { $auth = session('user_auth'); - + if (IS_AJAX) { if ($type != 'spend' && $type != 'deposit') { $this->ajaxReturn(['status'=>0,'msg'=>'参数有误']); @@ -161,8 +161,12 @@ class RepairController extends ThinkController { $game = new GameApi(); $result=$game->game_pay_notify($param,1); $spend = M($tab, "tab_"); + if($result == "success"){ $rr = $spend->where(array('pay_order_number'=>$orderNo))->save(array('pay_game_status'=>1)); + + PromoteStatistics($orderNo); + if ($rr !== false) { $cpFlag = 1; M($tab, 'tab_')->commit(); @@ -171,6 +175,7 @@ class RepairController extends ThinkController { $this->ajaxReturn(array('status'=>1,'msg'=>'补单失败.')); } }else{ + PromoteStatistics($orderNo); M($tab, 'tab_')->commit(); } } else { // deposit diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 9a800890b..540ced5e8 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -9,6 +9,7 @@ namespace Admin\Controller; use User\Api\UserApi as UserApi; +use function GuzzleHttp\Psr7\str; /** * 后台首页控制器 @@ -343,4 +344,191 @@ class TimingController extends AdminController { } + public function setPromoteStatistics() { + + echo "-------------------------------------------------------------\n"; + + $startTime = strtotime("20190829"); + $endTime = time(); + + if (I("start_time")) { + $startTime = strtotime(I("start_time")); + } + + if (I("end_time")) { + $endTime = strtotime(I("end_time")); + } + + if ($endTime < $startTime) { + echo "错误,开始时间不得大于结束时间";die(); + } + + for($start = $startTime;$start<$endTime;$start=$start+86400) { + + $map['pay_time'] = ['between', array($start, $start+86399)]; + $map['tp1.chain'] = '/'; + $map['pay_status'] = 1; + $map['promote_id'] = array('egt', 0); + + $data = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id as promote_id,floor(sum(pay_amount)*100) as count') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_spend as s on tp2.id = s.promote_id", 'left') + ->where($map) + ->group('tp1.id') + ->order('count desc') + ->select(); + foreach($data as $key => $value) { + $insert['promote_id'] = $value['promote_id']; + $insert['promote_account'] = $value['promote_account']; + $insert['count'] = $value['count']?$value['count']:0; + $insert['time'] = $start; + + $statisticsData = M("promote_statistics","tab_") + ->where(['promote_id'=>$value['promote_id'],'time'=>$start]) + ->find(); + + $date = date("Y-m-d",$start); + + if ($statisticsData) { + + M("promote_statistics","tab_") + ->where(['promote_id'=>$value['promote_id'],'time'=>$start]) + ->save($insert); + echo "更新{$value['promote_account']}在{$date}充值:{$value['count']}\n"; + } else { + + M("promote_statistics","tab_")->add($insert); + echo "新增{$value['promote_account']}在{$date}充值:{$value['count']}\n"; + } + } + + + + } + + echo "-------------------------------------------------------------\n"; + + } + + + public function shiftPromoteStatistics() { + + $data = M("shift_task")->where(['status'=>0,'type'=>2])->select(); + + $promote_data = []; + + foreach ($data as $key => $value) { + + $promote_data[] = $value['from_promote_id']; + $promote_data[] = $value['to_promote_id']; + + } + $promote_data=array_unique($promote_data); + sort($promote_data); + + $chain_data = M("promote","tab_") + ->field("id") + ->where(['chain'=>'/','id'=>['in',$promote_data]]) + ->select(); + $chain_data = array_column($chain_data,'id'); + + $chain_data_secord = M("promote","tab_") + ->field("substring_index(chain, '/', 2) as id") + ->where(['id'=>['in',$promote_data]]) + ->select(); + $chain_data_secord = array_column($chain_data_secord,'id'); + foreach($chain_data_secord as $k=>$v){ + if($v == '/'){ + unset($chain_data_secord[$k]); + } + + $chain_data_secord[$k] = substr($chain_data_secord[$k],1,strlen($v)); + if ($chain_data_secord[$k] == false) { + unset($chain_data_secord[$k]); + } +// var_dump(strlen($chain_data_secord[$k])); + + } + $data = []; + $data = array_merge(array_unique($chain_data),array_unique($chain_data_secord)); + + + $this->PromoteStatistics($data); +// dump($data); +// dump(array_unique($chain_data_secord)); + + } + + public function PromoteStatistics($promote) { + + echo "-------------------------------------------------------------\n"; + + $startTime = strtotime("20190829"); + $endTime = time(); + + if (I("start_time")) { + $startTime = strtotime(I("start_time")); + } + + if ($promote) { + $map['tp2.id'] = ['in',$promote]; + } + + if (I("end_time")) { + $endTime = strtotime(I("end_time")); + } + + if ($endTime < $startTime) { + echo "错误,开始时间不得大于结束时间";die(); + } + + for($start = $startTime;$start<$endTime;$start=$start+86400) { + + $map['pay_time'] = ['between', array($start, $start+86399)]; + $map['tp1.chain'] = '/'; + $map['pay_status'] = 1; + $map['promote_id'] = array('egt', 0); + + $data = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id as promote_id,floor(sum(pay_amount)*100) as count') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_spend as s on tp2.id = s.promote_id", 'left') + ->where($map) + ->group('tp1.id') + ->order('count desc') + ->select(); + foreach($data as $key => $value) { + $insert['promote_id'] = $value['promote_id']; + $insert['promote_account'] = $value['promote_account']; + $insert['count'] = $value['count']?$value['count']:0; + $insert['time'] = $start; + + $statisticsData = M("promote_statistics","tab_") + ->where(['promote_id'=>$value['promote_id'],'time'=>$start]) + ->find(); + + $date = date("Y-m-d",$start); + + if ($statisticsData) { + + M("promote_statistics","tab_") + ->where(['promote_id'=>$value['promote_id'],'time'=>$start]) + ->save($insert); + echo "更新{$value['promote_account']}在{$date}充值:{$value['count']}\n"; + } else { + + M("promote_statistics","tab_")->add($insert); + echo "新增{$value['promote_account']}在{$date}充值:{$value['count']}\n"; + } + } + + + + } + + echo "-------------------------------------------------------------\n"; + + } + } From 39e2bce6dde66716ff07c4411909ac9bd1737cc8 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 29 Jun 2020 16:32:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98=E5=85=85?= =?UTF-8?q?=E5=80=BC=E7=BB=9F=E8=AE=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/TimingController.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 540ced5e8..14d431bde 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -349,6 +349,11 @@ class TimingController extends AdminController { echo "-------------------------------------------------------------\n"; $startTime = strtotime("20190829"); + + if (I("start_time")=="yesterday") { + $startTime = strtotime(date("Y-m-d",strtotime("-1 day"))); + } + $endTime = time(); if (I("start_time")) {