From d562b003fd701a1befb18f252ad339e7bf22a810 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Mon, 21 Oct 2019 17:18:32 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E9=80=82=E9=85=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mobile/Controller/SsgController.class.php | 19 ------------------- Public/Mobile/js/ssg/flexible.min.js | 4 ++-- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/Application/Mobile/Controller/SsgController.class.php b/Application/Mobile/Controller/SsgController.class.php index dcb4958bf..bf8486ae7 100644 --- a/Application/Mobile/Controller/SsgController.class.php +++ b/Application/Mobile/Controller/SsgController.class.php @@ -430,23 +430,4 @@ class SsgController extends BaseController { } } - /** - * 领取激活码 - * @param $token - * @param $gift_id - * author: xmy 280564871@qq.com - */ - public function get_novice($user_id,$gift_id){ - - $model = D("Giftbag"); - $exist = $model->checkAccountGiftExist($logininfo['user_id'],$gift_id); - if($exist){ - $this->error("您已经领取过该礼包!"); - } - $novice = $model->getNovice($logininfo['user_id'],$logininfo['account'],$gift_id); - if(empty($novice)){ - $this->error("暂无激活码"); - } - $this->success("领取成功",$novice); - } } diff --git a/Public/Mobile/js/ssg/flexible.min.js b/Public/Mobile/js/ssg/flexible.min.js index 0e8f568ad..64e088904 100644 --- a/Public/Mobile/js/ssg/flexible.min.js +++ b/Public/Mobile/js/ssg/flexible.min.js @@ -13,8 +13,8 @@ docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / 1536), 22.5), 17.5) * 5 + 'px'; }else{ - /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 */ - docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 5 + 'px'; + /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 ,17.2 大于667不再放大*/ + docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 17.2), 8.55) * 5 + 'px'; } return refreshRem; })(); From 02151093af3fd52983904c6ef49f0f6c529f687e Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Fri, 25 Oct 2019 17:10:35 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mobile/Controller/SsgController.class.php | 383 ------------------ Public/Mobile/js/ssg/flexible.min.js | 4 +- 2 files changed, 2 insertions(+), 385 deletions(-) diff --git a/Application/Mobile/Controller/SsgController.class.php b/Application/Mobile/Controller/SsgController.class.php index fffe86220..42ad4a54d 100644 --- a/Application/Mobile/Controller/SsgController.class.php +++ b/Application/Mobile/Controller/SsgController.class.php @@ -426,387 +426,4 @@ class SsgController extends BaseController { } } - - /** - *支付中心 - */ - public function pay(){ - $user = session("user_auth"); - $gameId = I("game_id", 0); - //$price = self::signprice; - if (!$user) { - redirect("/mobile.php/ssg/login"); - // $this->error("请登入", "/mobile.php/ssg/login"); - } - $userId = $user['user_id']; - $gameInfo = M('game', 'tab_')->field('game_name,supersign_token')->where(array( - 'id' => $gameId, - ))->find(); - - - $payLog = M('game_supersign', 'tab_')->where(array( - 'user_id' => $userId, - 'game_id' => $gameId - ))->find(); - - if($payLog && $payLog['pay_status']==1){ - //$this->assign("error","亲~您已购买过了~
请到【订单查询】查看订单信息哟~"); - //$this->display('blank'); - redirect("/mobile.php/Ssg/install_show/user_id/$userId/game_id/$gameId/order_id/".$payLog['order_id']); - }else{ - if (!$gameInfo['supersign_token']) { - //$this->error("超级签token未填写!"); - $this->assign("error","超级签token未配置~"); - $this->display('blank'); - exit(); - } - - $this->assign("price", self::signprice); - //$this->assign("order_id", $orderId); - $this->assign("game_id",$gameId); - $this->assign("game_name",$gameInfo['game_name']); - $this->display('pay'); - } - } - - - - /* - * 发起支付 - */ - public function dopay() { - $user = session("user_auth"); - if (!$user ) { - //redirect("/mobile.php/ssg/login"); - redirect(U("ssg/login")); - } - $gameId = I("game_id", 0); - $paytype = I("pay_type", 'ali'); - $price = self::signprice; - $userId = $user['user_id']; - if (!$userId || !$gameId) { - //$this->error("参数有误!"); - $this->assign("error","参数有误~"); - $this->display('blank'); - exit(); - } - - $payLog = M('game_supersign', 'tab_')->where(array( - 'user_id' => $userId, - 'game_id' => $gameId - ))->find(); - - $gameInfo = M('game', 'tab_')->field('game_name,supersign_token')->where(array( - 'id' => $gameId, - ))->find(); - - if ($payLog && $payLog['pay_status']==0) { - $orderId = $payLog['order_id']; - }elseif ($payLog && $payLog['pay_status']==1){ - /*$orderId = $payLog['order_id']; - if(stripos($_SERVER['HTTP_HOST'], '.wmtxkj.cn') || $_SERVER['HTTP_HOST']=='127.0.0.1' || stripos($_SERVER['HTTP_HOST'], '.free.idcfengye.com')){ - redirect("http://".$_SERVER['HTTP_HOST']."/mobile.php/Ssg/install_show/user_id/$userId/game_id/$gameId/order_id/$orderId"); - }else{ - redirect("https://".$_SERVER['HTTP_HOST']."/mobile.php/Ssg/install_show/user_id/$userId/game_id/$gameId/order_id/$orderId"); - }*/ - $this->assign("error","亲~您已购买过了~
请到【订单查询】查看订单信息哟~"); - $this->display('blank'); - //$this->error("亲~您已购买过了~请到【订单查询】查看订单信息哟~"); - exit(); - } else { - $orderId = "SS_" . date('Ymd') . date('His') . sp_random_string(4); // 超级签 - if (!$gameInfo['supersign_token']) { - //$this->error("超级签token未填写!"); - $this->assign("error","超级签token未配置~"); - $this->display('blank'); - exit(); - } - - $r = M('game_supersign', 'tab_')->add(array( - 'udid' => '', - 'user_id' => $userId, - 'game_id' => $gameId, - 'order_id' => $orderId, - 'pay_price' => $price, - 'pay_status' => 0, - 'ticket' => '', // 调用安装的时候分配 - 'token' => $gameInfo['supersign_token'], - 'create_time' => time() - )); - if (!$r) return -1; - } - if($paytype=='ali'){ - $param['price'] = $price; - $param['sdk_version'] = '2'; - $param['user_id'] = $userId; - $param['game_id'] = $gameId; - $param['order_id'] = $orderId; - $param['apitype'] = "alipay"; - $param['config'] = "alipay"; - $param['signtype']= "MD5"; - $param['server'] = "alipay.wap.create.direct.pay.by.user"; - $param['payway'] = 1; - $param['title'] = $price; - $param['body'] = $price; - //$param['callback'] = "https://m.wmtxkj.com/mobile.php/Ssg/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}"; - //$param['notifyurl'] = "https://m.wmtxkj.com/callback.php/Notify/notify/apitype/alipay"; - if(stripos($_SERVER['HTTP_HOST'], '.wmtxkj.cn') || $_SERVER['HTTP_HOST']=='127.0.0.1' || stripos($_SERVER['HTTP_HOST'], '.free.idcfengye.com')){ - $param['callback'] = "http://".$_SERVER['HTTP_HOST']."/mobile.php/Ssg/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}"; - $param['notifyurl'] = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/notify/apitype/alipay"; - }else{ - $param['callback'] = "https://".$_SERVER['HTTP_HOST']."/mobile.php/Ssg/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}"; - $param['notifyurl'] = "https://".$_SERVER['HTTP_HOST']."/callback.php/Notify/notify/apitype/alipay"; - } - - $ali_pay = $this->alipay($param); - redirect($ali_pay['url']); - }else{ - $weixn = new Weixin(); - $wx_pay = json_decode($weixn->weixin_pay('超级签消费', $orderId, $price, 'MWEB', 4), true); - if($wx_pay['status']==1){ - //$redirect_url = $_SERVER['HTTP_HOST']."/mobile.php/Ssg/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}"; - redirect($wx_pay['mweb_url']); - }else{ - $this->assign("error",$wx_pay['return_msg']); - $this->display('blank'); - } - } - } - - // alipay - public function alipay($param) { - $pay = new \Think\Pay($param['apitype'],C($param['config'])); - $vo = new \Think\Pay\PayVo(); - $vo->setBody("超级签消费") - ->setFee($param['price'])//支付金额 - ->setTitle($param['title']) - ->setOrderNo($param['order_id']) - ->setService($param['server']) - ->setSignType($param['signtype']) - ->setPayMethod("wap") - ->setTable("supersign") - ->setPayWay($param['payway']) - ->setCallback($param['callback']) - ->setNotifyUrl($param['notifyurl']) - ->setGameName(get_game_name($param['game_id'])) - ->setServerId(0) - ->setUserId($param['user_id']) - ->setSdkVersion($param['sdk_version']); - $pay_['url']= $pay->buildRequestForm($vo); - //$pay_['out_trade_no']= $out_trade_no; - return $pay_; - - } - - - /** - * 用户点击安装 - */ - public function install() { - $user = session("user_auth"); - if (!$user ) { - //$this->error("请登入", "/mobile.php/ssg/login"); - redirect(U("ssg/login")); - } - $userId = $user['user_id']; - $gameId = I('game_id', 0); - $orderId = I('order_id', 0); - if (!$userId || !$gameId || !$orderId) { - //$this->error("参数有误!"); - $this->assign("error","参数有误~"); - $this->display('blank'); - exit(); - } - M()->startTrans(); - // 获取支付记录 - $gamesign = M('game_supersign', 'tab_')->where(array( - 'order_id' => $orderId, - 'user_id' => $userId, - 'game_id' => $gameId, - 'pay_status' => 1, - ))->find(); - if (!$gamesign) { - //$this->error("支付记录不存在"); - $this->assign("error","支付记录不存在~"); - $this->display('blank'); - exit(); - } - if ($gamesign['url']) { - redirect($gamesign['url']); - } - - $token = $gamesign['token']; - $ipa365 = new Ipa365(); - - $i = 1; - while (1) { - // 获取授权码 - $list = $ipa365->ticketList(array( - 'token' => $token, - 'limit' => $i, - )); // @todo: 并发授权码已分配的情况 - $code = $list['data']['list'][$i-1]['code']; - $codeExists = M('game_supersign', 'tab_')->field('id')->where(array( - 'ticket' => $code, - ))->find(); - if (!$codeExists) { - break; - } - $i ++; - } - - $game = M('game', 'tab_')->where(array( - 'id' => $gameId, - ))->find(); - $url = $game['supersign_url']."?code={$code}"; - $r = M('game_supersign', 'tab_')->where(array( - 'user_id' => $userId, - 'game_id' => $gameId, - 'pay_status' => 1 - ))->save(array( - 'ticket' => $code, // 调用安装的时候分配 - 'url' => $url, - )); - if (!$r) { - pp(M('game_supersign', 'tab_')->_sql()); - M()->rollback(); - return -1; - } - M()->commit(); - redirect($url); - } - - /** - * 下载页面 判断订单是否支付成功 - */ - public function install_show() { - $orderId = I('order_id', 0); - $gameId = I('game_id', 0); - - $user = session("user_auth"); - if (!$user ) { - //$this->error("请登入", "/mobile.php/ssg/login"); - redirect(U("ssg/login")); - } - - $userId = $user['user_id']; - if (!$userId ) { - //$this->error("请登入", "/mobile.php/ssg/login"); - redirect(U("ssg/login")); - } - if (!$orderId || !$gameId || !$userId) { - //$this->error("参数校验失败,请重试"); - $this->assign("error","参数校验失败,请重试~"); - $this->display('blank'); - exit(); - } - - $supersign = M('game_supersign', 'tab_')->where(array('order_id' => $orderId,"game_id"=>$gameId))->find(); - if (!$supersign) { - //$this->error("订单不存在"); - $this->assign("error","订单不存在"); - $this->display('blank'); - exit(); - } - if ($supersign['pay_status'] != 1) { - //$this->error("订单未支付"); - $this->assign("error","订单未支付"); - $this->display('blank'); - exit(); - } - $game = M('game', 'tab_')->where(array('id' => $gameId))->find(); - - $this->assign('game', $game); - $this->assign('url', U('Ssg/install', array( - 'order_id' => $orderId, - 'user_id' => $userId, - 'game_id' => $gameId - ))); - //获取礼包码 - $giftbag = M('giftbag', 'tab_')->field("*")->where(array("game_id"=>$gameId,"giftbag_version"=>3))->find(); - if(empty($giftbag)){ - $giftbag = false; - }else{ - $desribe = $giftbag['desribe']; - $mygif = $this->checkAccountGiftExist($userId,$giftbag['id']); - if(!empty($mygif)){ - //已经领取 - $giftbag =$mygif; - }else{ - if($giftbag['novice_num']>0){ - //领取 - $giftbag = $this->getNovice($userId,$user['account'],$giftbag['id']); - } - } - $giftbag['desribe'] = $desribe; - - } - //验证是否领取 - $this->assign('giftbag', $giftbag); - $this->display(); - } - - /* - * 打包列表 - */ - public function pay_list() { - $user = session("user_auth"); - if (!$user ) { - //$this->error("请登入", "/mobile.php/ssg/login"); - redirect(U("ssg/login")); - } - $userId = $user['user_id']; - $list = M('game_supersion', 'tab_')->where(array( - 'user_id' => $userId, - ))->select(); - $this->assign("list", $list); - $this->display(); - } - - //领取礼包码 - public function getNovice($user_id,$account,$gift_id){ - $data =M("giftbag",'tab_')->find($gift_id); - $novice_str = $data['novice']; - $novice_arr = str2arr($novice_str,","); - if (empty($novice_arr)){ - return ""; - } - $novice_arr = array_filter($novice_arr); - $novice = array_pop($novice_arr); - $data['novice_num'] = count($novice_arr); - $data['novice'] = arr2str($novice_arr,","); - M("giftbag",'tab_')->startTrans(); - $novice_result = M("giftbag",'tab_')->save($data); - if(!empty($novice)){ - //记录领取 - $record['game_id'] = $data['game_id']; - $record['game_name'] = $data['game_name'];//get_game_name($data['game_id']); - $record['gift_id'] = $gift_id; - $record['gift_name'] = $data['giftbag_name']; - $record['status'] = 0; - $record['novice'] = $novice; - $record['user_id'] = $user_id; - $record['user_account'] = $account; - $record['create_time'] = time(); - $record['start_time'] = $data['start_time']; - $record['end_time'] = $data['end_time']; - $record_result = M("gift_record",'tab_')->add($record); - }else{ - $novice_result = false; - } - - if($novice_result === false || $record_result === false){ - M("giftbag",'tab_')->rollback(); - return ""; - }else{ - M("giftbag",'tab_')->commit(); - return $record; - } - } - - public function checkAccountGiftExist($user_id,$gift_id){ - $map['user_id'] = $user_id; - $map['gift_id'] = $gift_id; - return M("gift_record",'tab_')->field('*')->where($map)->find(); - } } diff --git a/Public/Mobile/js/ssg/flexible.min.js b/Public/Mobile/js/ssg/flexible.min.js index 0e8f568ad..64e088904 100644 --- a/Public/Mobile/js/ssg/flexible.min.js +++ b/Public/Mobile/js/ssg/flexible.min.js @@ -13,8 +13,8 @@ docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / 1536), 22.5), 17.5) * 5 + 'px'; }else{ - /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 */ - docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 5 + 'px'; + /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 ,17.2 大于667不再放大*/ + docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 17.2), 8.55) * 5 + 'px'; } return refreshRem; })(); From b968702009b5d9de55976b5564f79dac581235ed Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Mon, 28 Oct 2019 15:22:30 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PublicController.class.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 7254d0541..858f2c816 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -238,5 +238,88 @@ class PublicController extends \Think\Controller cookie('think_language', 'en-us'); $this->ajaxReturn(['status' => 1]); } + //流水聚合接口 + public function setSpendCount() + { + //获取上个月的时间挫 + $beginThismonth=mktime(0,0,0,date('m')-1,1,date('Y')); + $endThismonth=mktime(0,0,0,date('m')-1,date('t'),date('Y'))-1; + $date = date('Y')."-".((date('m')-1) > 9 ? (date('m')-1) : "0".(date('m')-1)); + + dump($date); + //获取各推广员的现金数据 + $map = array( + "pay_time"=> array('BETWEEN',array($beginThismonth, $endThismonth)), + "pay_status"=>1, + "pay_way"=>array("GT",0) + ); + $field = "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,'{$date}' as count_date"; + //获取现金 + $model = M(); + $model->startTrans(); + + $cashRes = M() + ->table("tab_spend spend") + ->field($field) + ->where($map) + ->join("tab_promote promote ON spend.promote_id = promote.id","left") + ->group('spend.promote_id,spend.game_id') + ->select(); + dump($cashRes); + if(!empty($cashRes)){ + $dbres = M("spend_count",'tab_')->addAll($cashRes); + if(!$dbres){ + $model->rollback(); + die("error"); + } + } + //添加数据库 + //获取平台币聚合 + $map['pay_way'] = array("LT",1); + $balanceRes = M() + ->table("tab_spend spend") + ->field($field) + ->where($map) + ->join("tab_promote promote ON spend.promote_id = promote.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'] + ); + $dbres = M("spend_count","tab_")->where($tempmap)->find(); + if(!$dbres){ + //不存在 + // $balanceRes[$i]['all_cash_count'] = $balanceRes[$i]['cash_count']; + $balanceRes[$i]['balance_coin_count'] = $balanceRes[$i]['cash_count']; + unset($balanceRes[$i]['cash_count']); + $tempdbres = M("spend_count","tab_")->add($balanceRes[$i]); + if(!$tempdbres){ + $model->rollback(); + die("1error"); + } + }else{ + $dbres["balance_coin_count"] = $balanceRes[$i]['cash_count']; + // $dbres['all_cash_count'] = $dbres["cash_count"]-0+ $balanceRes[$i]['cash_count']; + dump( $dbres); + $tempdbres = M("spend_count","tab_")->save($dbres); + if(!$tempdbres){ + $model->rollback(); + die("2error"); + } + } + } + } + //获取绑定币充值 + + + $model->commit(); + die("success"); + } + } From 39a593b7204a035a76d3505caf11e03c82bacb13 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Mon, 28 Oct 2019 17:08:59 +0800 Subject: [PATCH 04/12] =?UTF-8?q?spend=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PublicController.class.php | 84 ------ .../SpendCountSetController.class.php | 245 ++++++++++++++++++ 2 files changed, 245 insertions(+), 84 deletions(-) create mode 100644 Application/Admin/Controller/SpendCountSetController.class.php diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 858f2c816..0dda9d160 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -238,88 +238,4 @@ class PublicController extends \Think\Controller cookie('think_language', 'en-us'); $this->ajaxReturn(['status' => 1]); } - //流水聚合接口 - public function setSpendCount() - { - //获取上个月的时间挫 - $beginThismonth=mktime(0,0,0,date('m')-1,1,date('Y')); - $endThismonth=mktime(0,0,0,date('m')-1,date('t'),date('Y'))-1; - $date = date('Y')."-".((date('m')-1) > 9 ? (date('m')-1) : "0".(date('m')-1)); - - dump($date); - //获取各推广员的现金数据 - $map = array( - "pay_time"=> array('BETWEEN',array($beginThismonth, $endThismonth)), - "pay_status"=>1, - "pay_way"=>array("GT",0) - ); - $field = "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,'{$date}' as count_date"; - //获取现金 - $model = M(); - $model->startTrans(); - - $cashRes = M() - ->table("tab_spend spend") - ->field($field) - ->where($map) - ->join("tab_promote promote ON spend.promote_id = promote.id","left") - ->group('spend.promote_id,spend.game_id') - ->select(); - dump($cashRes); - if(!empty($cashRes)){ - $dbres = M("spend_count",'tab_')->addAll($cashRes); - if(!$dbres){ - $model->rollback(); - die("error"); - } - } - //添加数据库 - //获取平台币聚合 - $map['pay_way'] = array("LT",1); - $balanceRes = M() - ->table("tab_spend spend") - ->field($field) - ->where($map) - ->join("tab_promote promote ON spend.promote_id = promote.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'] - ); - $dbres = M("spend_count","tab_")->where($tempmap)->find(); - if(!$dbres){ - //不存在 - // $balanceRes[$i]['all_cash_count'] = $balanceRes[$i]['cash_count']; - $balanceRes[$i]['balance_coin_count'] = $balanceRes[$i]['cash_count']; - unset($balanceRes[$i]['cash_count']); - $tempdbres = M("spend_count","tab_")->add($balanceRes[$i]); - if(!$tempdbres){ - $model->rollback(); - die("1error"); - } - }else{ - $dbres["balance_coin_count"] = $balanceRes[$i]['cash_count']; - // $dbres['all_cash_count'] = $dbres["cash_count"]-0+ $balanceRes[$i]['cash_count']; - dump( $dbres); - $tempdbres = M("spend_count","tab_")->save($dbres); - if(!$tempdbres){ - $model->rollback(); - die("2error"); - } - } - } - } - //获取绑定币充值 - - - $model->commit(); - die("success"); - } - - } diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php new file mode 100644 index 000000000..9b4d7bff2 --- /dev/null +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -0,0 +1,245 @@ + + */ +class SpendCountSetController extends \Think\Controller +{ + public $beginThismonth; + public $endThismonth; + public $date; + public $nowdata; + public $model; + public $continue=false; + public function _initialize(){ + //初始化 + $this->beginThismonth = mktime(0,0,0,date('m')-1,1,date('Y')); + $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(); + } + public function initCount() + { + $countRes = M("spend_count","tab_")->field("count(*) date_count")->find()['date_count']; + if($countRes > 0){ + die("init error"); + } + $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(); + //执行数据统计 + for ($i=0; $i < count($res); $i++) { + # code... + if($res[$i]['pay_time'] != $nowdate){ + $month = $res[$i]['pay_time']; + $this->date = $month; + $tarry = explode('-',$month); + $this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]); + $this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1; + //执行 + $this->model->startTrans(); + $this->continue =true; + $this->getCashData(); + $this->getBalanceData(); + $this->getBingData(); + $this->getInsideData(); + + $this->model->commit(); + } + } + die("success"); + + } + //流水聚合接口 + public function setSpendCount() + { + //判断是否已经聚合 + $countRes = M("spend_count","tab_")->field("count(*) date_count")->where("count_date = '{$this->date}'")->find()['date_count']; + if($countRes > 0){ + die("Repeated statistics"); + } + $this->model->startTrans(); + $this->continue =true; + $this->getCashData(); + $this->getBalanceData(); + $this->getBingData(); + $this->getInsideData(); + + $this->model->commit(); + die("success"); + } + //获取游戏现金流水 + public function getCashData() + { + if(!$this->continue){ + die("api error"); + } + $map = array( + "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "pay_status"=>1, + "pay_way"=>array("GT",0) + ); + $field = "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") + ->group('spend.promote_id,spend.game_id') + ->select(); + if(!empty($cashRes)){ + $dbres = M("spend_count",'tab_')->addAll($cashRes); + if(!$dbres){ + $this->model->rollback(); + die("error"); + } + } + # code... + } + //获取平台币聚合 + public function getBalanceData() + { + if(!$this->continue){ + die("api error"); + } + $map = array( + "pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "pay_status"=>1, + "pay_way"=> array("LT",1) + ); + $field = "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") + ->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 = M("spend_count","tab_")->where($tempmap)->find(); + if(!$dbres){ + //不存在 + $tempdbres = M("spend_count","tab_")->add($balanceRes[$i]); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + }else{ + $dbres["balance_coin_count"] = $balanceRes[$i]['balance_coin_count']; + $tempdbres = M("spend_count","tab_")->save($dbres); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + } + } + } + # code... + } + //获取绑定币充值 + public function getBingData() + { + if(!$this->continue){ + die("api error"); + } + $bindRes = M() + ->table("tab_bind_recharge bind") + ->field("game_id,game_name,promote_id,promote_account,IFNULL(promote.parent_id,0) parent_id,parent_name,sum(real_amount) bind_coin_count,'{$this->date}' as count_date,'{$this->nowdata}' as create_time") + ->where(array( + "bind.create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "pay_status"=>1 + )) + ->join("tab_promote promote ON bind.promote_id = promote.id","left") + ->group('bind.promote_id,bind.game_id') + ->select(); + //聚合表 + if(!empty($bindRes)){ + for ($i=0; $i < count($bindRes); $i++) { + # code... + $tempmap = array( + "game_id"=>$balanceRes[$i]['game_id'], + "promote_id"=>$balanceRes[$i]['promote_id'], + "count_date"=>$this->date + ); + $dbres = M("spend_count","tab_")->where($tempmap)->find(); + if(!$dbres){ + //不存在 + $tempdbres = M("spend_count","tab_")->add($bindRes[$i]); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + }else{ + $dbres["bind_coin_count"] = $bindRes[$i]['bind_coin_count']; + $tempdbres = M("spend_count","tab_")->save($dbres); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + } + } + } + } + //获取内充流水 + public function getInsideData() + { + if(!$this->continue){ + die("api error"); + } + $insideRes = M() + ->table("tab_deposit deposit") + ->field("promote_id,promote_account,IFNULL(promote.parent_id,0) parent_id,parent_name,sum(pay_amount) inside_cash_count,'{$this->date}' as count_date,'{$this->nowdata}' as create_time") + ->where(array( + "deposit.create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)), + "pay_status"=>1 + )) + ->join("tab_promote promote ON deposit.promote_id = promote.id","left") + ->group('promote_id') + ->select(); + //聚合表 + if(!empty($insideRes)){ + for ($i=0; $i < count($insideRes); $i++) { + # code... + $tempmap = array( + "promote_id"=>$balanceRes[$i]['promote_id'], + "count_date"=>$this->date + ); + $dbres = M("spend_count","tab_")->where($tempmap)->find(); + if(!$dbres){ + //不存在 + $tempdbres = M("spend_count","tab_")->add($insideRes[$i]); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + }else{ + $dbres["inside_cash_count"] = $insideRes[$i]['inside_cash_count']; + $tempdbres = M("spend_count","tab_")->save($dbres); + if(!$tempdbres){ + $this->model->rollback(); + die("error"); + } + } + } + } + // return true; + } + + + +} From 18c9182b34e4cc47e1d9e6c309e5f1539da526c6 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Fri, 1 Nov 2019 10:41:47 +0800 Subject: [PATCH 05/12] 123 --- .vscode/launch.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..ae0aa1f71 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for XDebug", + "type": "php", + "request": "launch", + "port": 9000 + }, + { + "name": "Launch currently open script", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "port": 9000 + } + ] +} \ No newline at end of file From 02535dee012470029874c7b3e9c6c28b62c1abd4 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Fri, 1 Nov 2019 10:44:54 +0800 Subject: [PATCH 06/12] dev --- Application/Admin/Controller/SpendCountSetController.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php index a7d157770..881c9f03c 100644 --- a/Application/Admin/Controller/SpendCountSetController.class.php +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -155,8 +155,7 @@ class SpendCountSetController extends \Think\Controller ->field($field) ->where($map) ->join("tab_promote promote ON spend.promote_id = promote.id","left") - ->jo - in("tab_game game ON spend.game_id = game.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(); From 521a343fc342cadb5bc389c6983ea46ffc50e9f4 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 11:08:20 +0800 Subject: [PATCH 07/12] 123 --- .../IndexChartSetController.class.php | 292 ++++++++++++++++++ .../Controller/IndexController.class.php | 21 +- 2 files changed, 308 insertions(+), 5 deletions(-) create mode 100644 Application/Admin/Controller/IndexChartSetController.class.php diff --git a/Application/Admin/Controller/IndexChartSetController.class.php b/Application/Admin/Controller/IndexChartSetController.class.php new file mode 100644 index 000000000..353f7cd0a --- /dev/null +++ b/Application/Admin/Controller/IndexChartSetController.class.php @@ -0,0 +1,292 @@ + +// +---------------------------------------------------------------------- + +namespace Admin\Controller; +use User\Api\UserApi as UserApi; + +/** + * 后台首页控制器 + * @author 麦当苗儿 + */ +class IndexChartSetController extends AdminController { + + public $beginTime; + public $endTime; + public $date; + public $nowdata; + public $UserModel; + public $ChartModel; + public $LoginModel; + public $SpendModel; + public $PromoteModel; + public $addid; + public $adddata; + public $continue=false; + + public function _initialize(){ + //初始化 + + $this->UserModel =M("User","tab_"); + $this->ChartModel =M("IndexChart","tab_"); + $this->LoginModel =M("user_login_record","tab_"); + $this->SpendModel =M("spend","tab_"); + $this->PromoteModel =M("promote","tab_"); + $this->nowdata =time(); + + } + /** + * 更新某月数据 + */ + public function setChartCount() + { + // $month = I("count_date"); + // if(empty($month)) die("参数错误"); + $date = I("date"); + $this->date = $date; + $tarry = explode('-',$date); + $this->beginTime=mktime(0,0,0,$tarry[1],$tarry[2],$tarry[0]); + $this->endTime=mktime(0,0,0,$tarry[1],$tarry[2]-0+1,$tarry[0])-1; + + set_time_limit(0); + $t1 = microtime(true); + + $this->newUser(); + $this->activeUser(); + $this->payUser(); + $this->payMoney(); + $this->promoteNew(); + $this->allCount(); + $this->createDb(); + + $t2 = microtime(true); + die("success runtime:".round($t2-$t1,3).'s'); + } + + public function setMonth($month) + { + if($month == 11){ + $j = date("d"); + }else{ + $j = date("t",strtotime("2019-{$month}-1")); + } + + $start_time = strtotime(date("Y-{$month}-01")); + for($i=0;$i<$j;$i++){ + $date = date('Y-m-d',$start_time+$i*86400); + $this->setMonthCount($date); + } + } + // + public function setMonthCount($date) + { + $this->date = $date; + $tarry = explode('-',$date); + $this->beginTime=mktime(0,0,0,$tarry[1],$tarry[2],$tarry[0]); + $this->endTime=mktime(0,0,0,$tarry[1],$tarry[2]-0+1,$tarry[0])-1; + + set_time_limit(0); + $t1 = microtime(true); + + $this->newUser(); + $this->activeUser(); + $this->payUser(); + $this->payMoney(); + $this->promoteNew(); + $this->allCount(); + $this->createDb(); + + $t2 = microtime(true); + echo ("{$this->date} success runtime:".round($t2-$t1,3).'s\n'); + # code... + } + //获取每日的增长用户 + public function newUser() + { + //获取当天的数据 + // $userdata =array( + // "date"=>$this->beginTime, + // "create_time"=>$this->nowdata + // ); + + $map = ['register_time'=>['between',[$this->beginTime,$this->endTime]],"puid"=>0];//0不是小号 + $hoursnews = $this->UserModel->field('FROM_UNIXTIME(register_time, "%H") as time,COUNT(1) AS news') + ->where($map) + ->group("time") + ->select(); + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + $user_hours = array(); + foreach($hours as $v) { + $user_hours[$v] = 0; + } + foreach($hoursnews as $h) { + $user_hours[$h['time']] = (integer)$h['news']; + } + $this->adddata["new_user_hours"] = serialize($user_hours); + unset($user_hours); + //获取当日所有的注册用户 + $userList = $this->UserModel->field('count(1) count') + ->where($map) + ->find(); + $this->adddata["new_user_count"] = $userList['count']; + } + + /** + * 活跃用户计算 + */ + public function activeUser() + { + $map = ['login_time'=>['between',[$this->beginTime,$this->endTime]]];//0不是小号 + $hoursnews = $this->LoginModel->field('FROM_UNIXTIME(login_time, "%H") as time,COUNT(DISTINCT user_id) AS active') + ->where($map) + ->group("time") + ->select(); + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + $user_hours = array(); + foreach($hours as $v) { + $user_hours[$v] = 0; + } + foreach($hoursnews as $h) { + $user_hours[$h['time']] = (integer)$h['active']; + } + $this->adddata["active_user_hours"] = serialize($user_hours); + unset($user_hours); + + // $activeCount = $this->LoginModel->field('count(DISTINCT user_id) count') + // ->where($map) + // ->find(); + //$this->adddata["active_user_count"] = $activeCount['count']; + //获取活跃用户列表 + $activeCount = $this->LoginModel->field('user_id') + ->where($map) + ->group('user_id') + ->select(); + + $this->adddata["active_user_count"] = count($activeCount); + $this->adddata["active_user_list"] = serialize(array_column($activeCount,'user_id')); + unset($activeCount); + } + /** + * 计算充值用户 + */ + public function payUser() + { + $map = ['pay_time'=>['between',[$this->beginTime,$this->endTime]],'pay_status'=>1];//1支付成功 + $hoursnews = $this->SpendModel->field('FROM_UNIXTIME(pay_time, "%H") as time,COUNT(DISTINCT user_id) AS payuser') + ->where($map) + ->group("time") + ->select(); + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + $user_hours = array(); + foreach($hours as $v) { + $user_hours[$v] = 0; + } + foreach($hoursnews as $h) { + $user_hours[$h['time']] = (integer)$h['payuser']; + } + $this->adddata["pay_user_hours"] = serialize($user_hours); + unset($user_hours); + // $activeCount = $this->LoginModel->field('count(DISTINCT user_id) payuser') + // ->where($map) + // ->find(); + // $this->adddata["pay_user_count"] = $activeCount['payuser']; + $activeCount = $this->SpendModel->field('user_id') + ->where($map) + ->group('user_id') + ->select(); + + $this->adddata["pay_user_count"] = count($activeCount); + $this->adddata["pay_user_list"] = serialize(array_column($activeCount,'user_id')); + unset($activeCount); + // $res = $this->ChartModel->save($savedata); + } + /** + * 充值金额计算 + */ + public function payMoney() + { + $map = ['pay_time'=>['between',[$this->beginTime,$this->endTime]],"pay_status"=>1];//1支付成功 + $hoursnews = $this->SpendModel->field('FROM_UNIXTIME(pay_time, "%H") as time,sum(pay_amount) AS money') + ->where($map) + ->group("time") + ->select(); + + + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + $user_hours = array(); + foreach($hours as $v) { + $user_hours[$v] = 0; + } + foreach($hoursnews as $h) { + $user_hours[$h['time']] = (integer)$h['money']; + } + $this->adddata["pay_money_hours"] = serialize($user_hours); + unset($user_hours); + + $activeCount = $this->SpendModel->field('sum(pay_amount) AS money') + ->where($map) + ->find(); + $this->adddata["pay_money_count"] = $activeCount['money']?:0; + } + /** + * 新增推广 + */ + public function promoteNew() + { + $map = ['create_time'=>['between',[$this->beginTime,$this->endTime]]]; + $hoursnews = $this->PromoteModel->field('FROM_UNIXTIME(create_time, "%H") as time,COUNT(1) AS news') + ->where($map) + ->group("time") + ->select(); + + + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + $user_hours = array(); + foreach($hours as $v) { + $user_hours[$v] = 0; + } + foreach($hoursnews as $h) { + $user_hours[$h['time']] = (integer)$h['news']; + } + $this->adddata["promote_new_hours"] = serialize($user_hours);//promote_new_hours + unset($user_hours); + + $activeCount = $this->PromoteModel->field('COUNT(1) AS news') + ->where($map) + ->find(); + $this->adddata["promote_new_count"] = $activeCount['news']; + } + + /** + * 统计其他综合信息 + * 1. 7天活跃 + * 2. 平台累计用户 + * 3. 累计付费用户 + */ + public function allCount() + { + $user = D('User'); + $spend = D('Spend'); + $promote = D('Promote'); + $allcount = array(); + $allcount['user_count'] = $user->old(); + $allcount['active_count'] =$user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]]); + $allcount['player_count'] =$spend->player(); + $allcount['money_sum'] =$spend->totalAmount(); + $allcount['promote_sum'] =$promote->total(); + $this->adddata["all_count"] = serialize($allcount); + } + public function createDb() + { + $this->adddata['date']=$this->beginTime; + $this->adddata['create_time']=$this->nowdata; + // dump($this->adddata); + $this->ChartModel->add($this->adddata); + } + +} diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index f0508f406..869416cf5 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -23,12 +23,23 @@ class IndexController extends AdminController { $request=json_decode(think_decrypt($content),true); var_dump($request); } + + /** + * 后台首页 + * @author cz + * + */ + public function index(Type $var = null) + { + # code... + } + /** * 后台首页 * @author 麦当苗儿 */ - public function index(){ + public function indexBack(){ if(session('user_auth.uid')){ $data=M('Member') ->field('uid,nickname,username,us.last_login_time,us.last_login_ip,login') @@ -53,8 +64,8 @@ class IndexController extends AdminController { // 折线图 $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); - $userRepository = new UserRepository(); - $activeCount = $userRepository->getActiveUserCountRecently(7); + // $userRepository = new UserRepository(); + // $activeCount = $userRepository->getActiveUserCountRecently(7); // 累计数据 @@ -62,8 +73,8 @@ class IndexController extends AdminController { $spend = D('Spend'); $promote = D('Promote'); $this->assign('user_count', $user->old()); - // $this->assign('active_count', $user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]])); - $this->assign('active_count', $activeCount); + $this->assign('active_count', $user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]])); + // $this->assign('active_count', $activeCount); $this->assign('player_count', $spend->player()); $this->assign('money_sum', $spend->totalAmount()); $this->assign('promote_sum', $promote->total()); From e1739209e38d5ff2034f74d384433105b892874f Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 11:27:10 +0800 Subject: [PATCH 08/12] 1 --- .../Controller/IndexController.class.php | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index 869416cf5..30f0498e5 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -29,8 +29,36 @@ class IndexController extends AdminController { * @author cz * */ - public function index(Type $var = null) + public function index() { + if(session('user_auth.uid')){ + $data=M('Member') + ->field('uid,nickname,username,us.last_login_time,us.last_login_ip,login') + ->join('sys_ucenter_member as us on sys_member.uid = us.id') + ->where(array('uid'=>session('user_auth.uid'))) + ->find(); + header("Content-type: text/html; charset=utf-8"); + if(is_administrator()){ + $data['group']='超级管理员'; + }else{ + $data['group'] = get_auth_group_name($data['uid']); + } + } + $this->assign('data',$data); + $this->indextt(); + + $this->meta_title = '管理首页'; + + // 日历 + $this->calendar(); + + $tm = strtotime("-1 day"); + dump(); + $allcount = M("IndexChart","tab_")->field("all_count")->where("`date` = '{$tm}'")->find(); + dump($allcount); + + //累计统计 + # code... } From 37d8f72c6d549d88c1190fde9936a8247a555e67 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 14:43:51 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndexChartSetController.class.php | 2 +- .../Controller/IndexController.class.php | 212 +++++++++++++++++- Application/Admin/View/Index/index.html | 2 +- 3 files changed, 210 insertions(+), 6 deletions(-) diff --git a/Application/Admin/Controller/IndexChartSetController.class.php b/Application/Admin/Controller/IndexChartSetController.class.php index 353f7cd0a..b5452196b 100644 --- a/Application/Admin/Controller/IndexChartSetController.class.php +++ b/Application/Admin/Controller/IndexChartSetController.class.php @@ -102,7 +102,7 @@ class IndexChartSetController extends AdminController { $this->createDb(); $t2 = microtime(true); - echo ("{$this->date} success runtime:".round($t2-$t1,3).'s\n'); + echo ("{$this->date} success runtime:".round($t2-$t1,3).'s'.PHP_EOL); # code... } //获取每日的增长用户 diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index 30f0498e5..60402d71c 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -51,18 +51,222 @@ class IndexController extends AdminController { // 日历 $this->calendar(); + $this->foldLineDiagramNew($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); - $tm = strtotime("-1 day"); - dump(); + $tm =strtotime(date("Y-m-d",strtotime("-1 day"))); $allcount = M("IndexChart","tab_")->field("all_count")->where("`date` = '{$tm}'")->find(); - dump($allcount); + $allcount = unserialize($allcount['all_count']); + $this->assign('user_count',$allcount['user_count']); + $this->assign('active_count', $allcount['active_count']); + $this->assign('player_count', $allcount['player_count']); + $this->assign('money_sum', $allcount['money_sum']); + $this->assign('promote_sum',$allcount['promote_sum']); //累计统计 - + $this->display(); # code... } + //获取一天信息 + + + public function foldLineDiagramNew($start='',$end='',$num='',$flag=false) + { + $starttime = $start?strtotime($start):mktime(0,0,0,date('m'),date('d')-1,date('Y')); + + $endtime = $end?strtotime($end)+86399:$starttime+86399; + + $start = date('Y-m-d',$starttime); + $end = date('Y-m-d',$endtime); + + $user = D('User'); + $spend = D('Spend'); + $promote = D('Promote'); + + if ($start == $end) { // 单天 + + if ($start == date('Y-m-d',strtotime('-1 day'))) {$num = 2;} + $data['date'] = [$start]; + $data['hours'] = 1; + $tm = strtotime($start); + $dbdata = M("IndexChart","tab_")->field("new_user_count,new_user_hours,active_user_count,active_user_hours,pay_user_count,pay_user_hours,pay_money_count,pay_money_hours,promote_new_count")->where("`date` = '{$tm}'")->find(); + $data['news'] = unserialize($dbdata["new_user_hours"]); + $data['active'] = unserialize($dbdata["active_user_hours"]); + $data['player']=unserialize($dbdata["pay_user_hours"]); + $data['money']=unserialize($dbdata["pay_money_hours"]); + + //获取昨天 + $ytm = $starttime-86400; + $ydbdata = M("IndexChart","tab_")->field("new_user_count,active_user_count,pay_user_count,pay_money_count,promote_new_count")->where("`date` = '{$ytm}'")->find(); + //计算 + $cnews['count'] = $dbdata['new_user_count']; + $cnews['rate'] = $this->setRate($dbdata['new_user_count'],$ydbdata['new_user_count']); + + $cactive['count'] = $dbdata['active_user_count']; + $cactive['rate'] = $this->setRate($dbdata['active_user_count'],$ydbdata['active_user_count']); + + $cplayer['count'] = $dbdata['pay_user_count']; + $cplayer['rate'] = $this->setRate($dbdata['pay_user_count'],$ydbdata['pay_user_count']); + + $cmoney['count'] = $dbdata['pay_money_count']; + $cmoney['rate'] = $this->setRate($dbdata['pay_money_count'],$ydbdata['pay_money_count']); + + $cpromote['count'] = $dbdata['promote_new_count']; + $cpromote['rate'] = $this->setRate($dbdata['promote_new_count'],$ydbdata['promote_new_count']); + + } else { + + $datelist = get_date_list($starttime,$endtime,$num==7?4:1); + dump($datelist); + $data['date'] = $datelist; + $data['hours'] = 0; + $map = array( + "date"=>['between',[$starttime,$endtime]] + ); + //获取记录 + $count1 = array(); + $active_user_list = []; + $pay_user_list = []; + $dbdata = M("IndexChart","tab_")->field("new_user_count,active_user_count,active_user_list,pay_user_count,pay_user_list,pay_money_count,promote_new_count") + ->where($map)->select(); + foreach($dbdata as $k => $v) { + $data['news'][$k] = $v['new_user_count']; + $data['active'][$k] = $v['active_user_count']; + $data['player'][$k] = $v['pay_user_count']; + $data['money'][$k] = $v['pay_money_count']; + $active_user_list += unserialize($v['active_user_list']); + unset($v['active_user_list']); + unset($dbdata[$k]['active_user_list']); + $pay_user_list += unserialize($v['pay_user_list']); + unset($v['pay_user_list']); + unset($dbdata[$k]['pay_user_list']); + $count1['new_user_count'] += $v['new_user_count']; + $count1['pay_money_count'] += $v['pay_money_count']; + $count1['promote_new_count'] += $v['promote_new_count']; + } + unset($dbdata); + $count1['active_user_count'] = count(array_flip(array_flip($active_user_list))); + unset($active_user_list); + $count1['pay_user_count'] = count(array_flip(array_flip($pay_user_list))); + unset($active_user_list); + //获取前num的日志 + switch($num) { + case 3:{ + $between = ['between',[strtotime('-7 day',$starttime),strtotime('-7 day',$endtime)]]; + };break; + case 4:{ + $temp = strtotime('-1 month',$starttime); + $between = ['between',[$temp,mktime(0,0,0,date('m',$temp)+1,1,date('Y',$temp))-1]]; + + };break; + case 5:{ + $between = ['between',[strtotime('-7 day',$starttime),strtotime('-7 day',$endtime)]]; + + };break; + case 6:{ + $between = ['between',[strtotime('-30 day',$starttime),strtotime('-30 day',$endtime)]]; + };break; + case 7:{ + $between = ['between',[strtotime('-365 day',$starttime),strtotime('-365 day',$endtime)]]; + };break; + default:{ + $day_num = count($datelist); + $between = ['between',[strtotime('-'.$day_num.' day',$starttime),strtotime('-'.$day_num.' day',$endtime)]]; + }; + } + //获取前几天记录 + $map1 = array( + "date"=>$between + ); + $ydbdata = M("IndexChart","tab_")->field("new_user_count,active_user_count,active_user_list,pay_user_count,pay_user_list,pay_money_count,promote_new_count") + ->where($map1)->select(); + $active_user_list = []; + $pay_user_list = []; + $count2 = array(); + foreach($ydbdata as $k => $v) { + $active_user_list += unserialize($v['active_user_list']); + unset($v['active_user_list']); + unset($dbdata[$k]['active_user_list']); + $pay_user_list += unserialize($v['pay_user_list']); + unset($v['pay_user_list']); + unset($dbdata[$k]['pay_user_list']); + $count2['new_user_count'] += $v['new_user_count']; + $count2['pay_money_count'] += $v['pay_money_count']; + $count2['promote_new_count'] += $v['promote_new_count']; + } + unset($ydbdata); + $count2['active_user_count'] = count(array_flip(array_flip($active_user_list))); + unset($active_user_list); + $count2['pay_user_count'] = count(array_flip(array_flip($pay_user_list))); + unset($active_user_list); + //比较 + $cnews['count'] = $count1['new_user_count']; + $cnews['rate'] = $this->setRate($count1['new_user_count'],$count2['new_user_count']); + + $cactive['count'] =$count1['active_user_count']; + $cactive['rate'] = $this->setRate($count1['active_user_count'],$count2['active_user_count']); + + $cplayer['count'] =$count1['pay_user_count']; + $cplayer['rate'] = $this->setRate($count1['pay_user_count'],$count2['pay_user_count']); + + $cmoney['count'] = $count1['pay_money_count']; + $cmoney['rate'] = $this->setRate($count1['pay_money_count'],$count2['pay_money_count']); + + $cpromote['count'] = $count1['promote_new_count']; + $cpromote['rate'] = $this->setRate($count1['promote_new_count'],$count2['promote_new_count']); + + } + + + + foreach($data as $k => $v) { + // dump($k); + if (is_array($v)) { + if ($k == 'date') + $data[$k] = '"'.implode('","',$v).'"'; + else + $data[$k] = implode(',',$v); + + } + } + + $data['compare']['news'] = $cnews; + $data['compare']['active'] = $cactive; + $data['compare']['player'] = $cplayer; + $data['compare']['money'] = $cmoney; + $data['compare']['promote'] = $cpromote; + if ($flag) { + + echo json_encode($data); + + } else { + + $this->assign('foldline',$data); + + $this->assign('num',$num); + + } + # code... + } + public function setRate($d1,$d2) + { + $rate = 0; + if($d1>0){ + if($d2 > 0){ + $rate = round(($d1/$d2-1)*100,2); + }else{ + $rate = 100; + } + }else if($d1 == 0 && $d2 == 0){ + $rate = 0; + }else{ + $rate = -100; + } + return $rate; + } + + /** * 后台首页 * @author 麦当苗儿 diff --git a/Application/Admin/View/Index/index.html b/Application/Admin/View/Index/index.html index d7d94c443..d6aed5c01 100644 --- a/Application/Admin/View/Index/index.html +++ b/Application/Admin/View/Index/index.html @@ -45,7 +45,7 @@
  • 过去整月
  • 过去7天
  • 过去30天
  • -
  • 过去一年
  • +
    From 04c5f17790a091eb10030f6982a88e6409a5cd2c Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 16:08:51 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IndexChartSetController.class.php | 100 ++-- .../Controller/IndexController.class.php | 487 +++--------------- Application/Admin/View/Index/index.html | 7 +- 3 files changed, 127 insertions(+), 467 deletions(-) diff --git a/Application/Admin/Controller/IndexChartSetController.class.php b/Application/Admin/Controller/IndexChartSetController.class.php index b5452196b..691eff18f 100644 --- a/Application/Admin/Controller/IndexChartSetController.class.php +++ b/Application/Admin/Controller/IndexChartSetController.class.php @@ -27,7 +27,7 @@ class IndexChartSetController extends AdminController { public $PromoteModel; public $addid; public $adddata; - public $continue=false; + public $reset=false; public function _initialize(){ //初始化 @@ -37,53 +37,51 @@ class IndexChartSetController extends AdminController { $this->LoginModel =M("user_login_record","tab_"); $this->SpendModel =M("spend","tab_"); $this->PromoteModel =M("promote","tab_"); - $this->nowdata =time(); + $this->nowdata =time(); + if(I("reset")) $this->reset = true; } /** - * 更新某月数据 + * 每日更新接口 */ public function setChartCount() { - // $month = I("count_date"); - // if(empty($month)) die("参数错误"); - $date = I("date"); - $this->date = $date; - $tarry = explode('-',$date); - $this->beginTime=mktime(0,0,0,$tarry[1],$tarry[2],$tarry[0]); - $this->endTime=mktime(0,0,0,$tarry[1],$tarry[2]-0+1,$tarry[0])-1; - - set_time_limit(0); - $t1 = microtime(true); - - $this->newUser(); - $this->activeUser(); - $this->payUser(); - $this->payMoney(); - $this->promoteNew(); - $this->allCount(); - $this->createDb(); - - $t2 = microtime(true); - die("success runtime:".round($t2-$t1,3).'s'); + $begin = date("Y-m-d",strtotime("-1 day")); + $this->setDateCount($begin); } - public function setMonth($month) + public function setFreeDateCount($begin,$end='') { - if($month == 11){ - $j = date("d"); + if($end == '') $end = $begin; + //判断日期格式 + $patten = "/^\d{4}[\-](0?[1-9]|1[012])[\-](0?[1-9]|[12][0-9]|3[01])$/"; + if (!preg_match($patten, $begin)) { + die("开始时间格式错误"); + } + if (!preg_match($patten, $end)) { + die("结束时间格式错误"); + } + if(strtotime($end) < strtotime($begin)){ + die("结束时间不能比开始时间小"); + } + if(strtotime($end)+86399 > time()){ + die("结束时间不能包含今日"); + } + if($begin == $end){ + $this->setDateCount($begin); }else{ - $j = date("t",strtotime("2019-{$month}-1")); + $starttime = $begin?strtotime($begin):mktime(0,0,0,date('m'),date('d')-1,date('Y')); + $endtime = $end?strtotime($end)+86399:$starttime+86399; + $datelist = get_date_list($starttime,$endtime,1); + $countdate = count($datelist); + for($i=0;$i<$countdate;$i++){ + $this->setDateCount($datelist[$i]); + } } - $start_time = strtotime(date("Y-{$month}-01")); - for($i=0;$i<$j;$i++){ - $date = date('Y-m-d',$start_time+$i*86400); - $this->setMonthCount($date); - } } // - public function setMonthCount($date) + public function setDateCount($date) { $this->date = $date; $tarry = explode('-',$date); @@ -92,7 +90,20 @@ class IndexChartSetController extends AdminController { set_time_limit(0); $t1 = microtime(true); - + //判断是否存在 + $res = $this->ChartModel->where("date = '{$this->beginTime}'")->find(); + $reset=''; + if(!empty($res)){ + if($this->reset){ + $this->ChartModel->where("date = '{$this->beginTime}'")->delete(); + $reset = "reset and creat "; + }else{ + echo ("{$this->date} 已统计,请勿重复 ".PHP_EOL); + return; + } + + } + $this->newUser(); $this->activeUser(); $this->payUser(); @@ -102,18 +113,12 @@ class IndexChartSetController extends AdminController { $this->createDb(); $t2 = microtime(true); - echo ("{$this->date} success runtime:".round($t2-$t1,3).'s'.PHP_EOL); + echo ("{$this->date} {$reset}success runtime:".round($t2-$t1,3).'s'.PHP_EOL); # code... } //获取每日的增长用户 public function newUser() { - //获取当天的数据 - // $userdata =array( - // "date"=>$this->beginTime, - // "create_time"=>$this->nowdata - // ); - $map = ['register_time'=>['between',[$this->beginTime,$this->endTime]],"puid"=>0];//0不是小号 $hoursnews = $this->UserModel->field('FROM_UNIXTIME(register_time, "%H") as time,COUNT(1) AS news') ->where($map) @@ -156,11 +161,6 @@ class IndexChartSetController extends AdminController { } $this->adddata["active_user_hours"] = serialize($user_hours); unset($user_hours); - - // $activeCount = $this->LoginModel->field('count(DISTINCT user_id) count') - // ->where($map) - // ->find(); - //$this->adddata["active_user_count"] = $activeCount['count']; //获取活跃用户列表 $activeCount = $this->LoginModel->field('user_id') ->where($map) @@ -191,10 +191,6 @@ class IndexChartSetController extends AdminController { } $this->adddata["pay_user_hours"] = serialize($user_hours); unset($user_hours); - // $activeCount = $this->LoginModel->field('count(DISTINCT user_id) payuser') - // ->where($map) - // ->find(); - // $this->adddata["pay_user_count"] = $activeCount['payuser']; $activeCount = $this->SpendModel->field('user_id') ->where($map) ->group('user_id') @@ -203,7 +199,6 @@ class IndexChartSetController extends AdminController { $this->adddata["pay_user_count"] = count($activeCount); $this->adddata["pay_user_list"] = serialize(array_column($activeCount,'user_id')); unset($activeCount); - // $res = $this->ChartModel->save($savedata); } /** * 充值金额计算 @@ -285,7 +280,6 @@ class IndexChartSetController extends AdminController { { $this->adddata['date']=$this->beginTime; $this->adddata['create_time']=$this->nowdata; - // dump($this->adddata); $this->ChartModel->add($this->adddata); } diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index 60402d71c..1532a9075 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -16,18 +16,9 @@ use Base\Repository\UserRepository; * @author 麦当苗儿 */ class IndexController extends AdminController { - - public function test() - { - $content = 'MDAwMDAwMDAwMJndsKKZZYuXeqCgy324cpebidDdi6mplZy2vKCFdqeagKewp5CKas6JaJ3Nec6fnYWvzM59qK2im5OfZZGrq2d9zqeig3aD0IqNYs6IlnarmnzR0HrP0puGt7B2hqysdoLe0n-FeIKUfnqCl33edZ2DeK_VlJacnJvPvJycebiXlpewpJGLg9eVjWLOk815aoCfqs59qK2skrqwZpKKrJeW0aytkYaCmHqfetV50oaukY2vy5K8tJuHy69nhXWrpH3StKSYZHKUi4573JG7aamAn9TOfs6spYHQuKScedqdfc7VopBlctZ9pJnSipeGrpF82NqVrbmlmpSbopGfqKeOq6yvj2Sxk3-NhtqKqqhlha-ymYrR22OG3L9ohnjaYoKWvKKFZLGTf32Gln-3mJebiczei8_PlZy2v2eHibCUmLjJsoV3oNJ6n6jLiZZpn5GIrpt6z6ibhKWwq5ufzpuOt69vhHZt2X6JqMuJ0oKpkGee2JOYrJuHy6-thYmrqY67r6KDdoPcimiZzpK7hZ2Gnq-Zi5ilpZG6uKGaZayll5a4q4CcsMuLaHfWirppq5l8q5qLva2Yms-sqJKFq2d9za-sgKBqzX-MatyRu5SpgJ_Uzn-svZyRz79phpyknI64p2mRnZyXio2G3H2onKGRn8nQgLy8qYXPv6uGrKeagKewpZx7i86To4LLf816rpGNr5eLva18kqaWrp56uKuOvLCDkXdp2n56dtqT3n6rhZ-mmYC5vWqbqrCqknq4m5ip0qSHh37bfoqGlH7ehWiFr77dgKispYHPrJ6RZJtiltK3ooacg5KLjn-Sfbh5roV5upd6ztqbkpSsqJKIm6aNu5elgJ2oy4l-hpOKuHafj326mH7fy5uQqrtnhpzJYYysu2yRioKViX6Gkoq4l2mCe92WgKmtn4e43mWGnMVmjZXeaoWtgpKAeZzLfKd6pJlos8uV0rmrm5TSqpqbq2d9zquuhHZt2XqfqMuTq3Zpj2ee3ousuauQlJtlmomsnZfNr2-An4ezibB62X24m6uGiaaVfrnGqYWmq2iPnLB3jt2vrIChe8qWjGrclKt2ZJuNss6Az6SlgdConJ2Im2SNvNGihp2c1Xqkf9mKu2Wfj2fR3HrP0puGttGphoa7poG4p66FrYrLl4dunw'; - $request=json_decode(think_decrypt($content),true); - var_dump($request); - } - /** * 后台首页 * @author cz - * */ public function index() { @@ -51,7 +42,7 @@ class IndexController extends AdminController { // 日历 $this->calendar(); - $this->foldLineDiagramNew($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); + $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); $tm =strtotime(date("Y-m-d",strtotime("-1 day"))); $allcount = M("IndexChart","tab_")->field("all_count")->where("`date` = '{$tm}'")->find(); @@ -64,12 +55,16 @@ class IndexController extends AdminController { $this->assign('promote_sum',$allcount['promote_sum']); //累计统计 $this->display(); - # code... } - //获取一天信息 - - public function foldLineDiagramNew($start='',$end='',$num='',$flag=false) + /* + * 折线图 + * @param integer $start 开始时间 + * @param integer $end 结束时间 + * @param boolean $flag 是否ajax返回 + * @author 鹿文学 + */ + public function foldLineDiagram($start='',$end='',$num='',$flag=false) { $starttime = $start?strtotime($start):mktime(0,0,0,date('m'),date('d')-1,date('Y')); @@ -116,7 +111,6 @@ class IndexController extends AdminController { } else { $datelist = get_date_list($starttime,$endtime,$num==7?4:1); - dump($datelist); $data['date'] = $datelist; $data['hours'] = 0; $map = array( @@ -186,10 +180,10 @@ class IndexController extends AdminController { foreach($ydbdata as $k => $v) { $active_user_list += unserialize($v['active_user_list']); unset($v['active_user_list']); - unset($dbdata[$k]['active_user_list']); + unset($ydbdata[$k]['active_user_list']); $pay_user_list += unserialize($v['pay_user_list']); unset($v['pay_user_list']); - unset($dbdata[$k]['pay_user_list']); + unset($ydbdata[$k]['pay_user_list']); $count2['new_user_count'] += $v['new_user_count']; $count2['pay_money_count'] += $v['pay_money_count']; $count2['promote_new_count'] += $v['promote_new_count']; @@ -266,419 +260,88 @@ class IndexController extends AdminController { return $rate; } - - /** - * 后台首页 - * @author 麦当苗儿 - */ - public function indexBack(){ - if(session('user_auth.uid')){ - $data=M('Member') - ->field('uid,nickname,username,us.last_login_time,us.last_login_ip,login') - ->join('sys_ucenter_member as us on sys_member.uid = us.id') - ->where(array('uid'=>session('user_auth.uid'))) - ->find(); - header("Content-type: text/html; charset=utf-8"); - if(is_administrator()){ - $data['group']='超级管理员'; - }else{ - $data['group'] = get_auth_group_name($data['uid']); - } - } - $this->assign('data',$data); - $this->indextt(); + /* + * 日历 + * @param integer $start 开始时间(2018-04) + * @param integer $end 结束时间(2018-05) + * @param boolean $flag 是否ajax返回 + * @author 鹿文学 + */ + public function calendar($start='',$end='',$flag=false) { - $this->meta_title = '管理首页'; - - // 日历 - $this->calendar(); - - // 折线图 - $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); + $start = $start?$start:date('Y-m',strtotime('-1 month')); + $end = $end?$end:date('Y-m'); - // $userRepository = new UserRepository(); - // $activeCount = $userRepository->getActiveUserCountRecently(7); + if ($start == $end) {$start = date('Y-m',strtotime('-1 month',$end));} + if (strtotime($start)>strtotime($end)) {$temp = $end;$end = $start;$start = $temp;} + if (strtotime($end) > strtotime(date('Y-m'))) {$end = date('Y-m');$start = date('Y-m',strtotime('-1 month'));} + $iscurrent = $end != date('Y-m')?1:0; // 默认是当前月,不可进入下一个月 - // 累计数据 - $user = D('User'); - $spend = D('Spend'); - $promote = D('Promote'); - $this->assign('user_count', $user->old()); - $this->assign('active_count', $user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]])); - // $this->assign('active_count', $activeCount); - $this->assign('player_count', $spend->player()); - $this->assign('money_sum', $spend->totalAmount()); - $this->assign('promote_sum', $promote->total()); - - $this->display(); - } + $stime = strtotime($start); + $etime = strtotime($end); - /* - * 日历 - * @param integer $start 开始时间(2018-04) - * @param integer $end 结束时间(2018-05) - * @param boolean $flag 是否ajax返回 - * @author 鹿文学 - */ - public function calendar($start='',$end='',$flag=false) { - - $start = $start?$start:date('Y-m',strtotime('-1 month')); - $end = $end?$end:date('Y-m'); - - if ($start == $end) {$start = date('Y-m',strtotime('-1 month',$end));} - if (strtotime($start)>strtotime($end)) {$temp = $end;$end = $start;$start = $temp;} - if (strtotime($end) > strtotime(date('Y-m'))) {$end = date('Y-m');$start = date('Y-m',strtotime('-1 month'));} - - $iscurrent = $end != date('Y-m')?1:0; // 默认是当前月,不可进入下一个月 - - $stime = strtotime($start); - $etime = strtotime($end); - - $sw = date('w',$stime); // 周几 - $ew = date('w',$etime); - $sw = $sw == 0? 6:(integer)$sw-1; - $ew = $ew == 0? 6:(integer)$ew-1; - - $st = date('t',$stime); // 天数 - $et = date('t',$etime); - - $sf = $ef = $sr = $er = 1; // 行数 ,日期起始值 - - for($i=0;$i<7;$i++) { - if ($i<$sw) - $first[$sr][$i] = ['value'=>'']; - else { - $first[$sr][$i] = ['value'=>set_date_day_format($sf),'full'=>$start.'-'.set_date_day_format($sf)];$sf++; - } + $sw = date('w',$stime); // 周几 + $ew = date('w',$etime); + $sw = $sw == 0? 6:(integer)$sw-1; + $ew = $ew == 0? 6:(integer)$ew-1; + + $st = date('t',$stime); // 天数 + $et = date('t',$etime); + + $sf = $ef = $sr = $er = 1; // 行数 ,日期起始值 + + for($i=0;$i<7;$i++) { + if ($i<$sw) + $first[$sr][$i] = ['value'=>'']; + else { + $first[$sr][$i] = ['value'=>set_date_day_format($sf),'full'=>$start.'-'.set_date_day_format($sf)];$sf++; } - for($i=0;$i<7;$i++) { - if ($i<$ew) - $last[$er][$i] = ['value'=>'']; - else { - $eday = set_date_day_format($ef); - if (strtotime($end.'-'.$eday)>strtotime(date('Y-m-d'))){ - $last[$er][$i] = ['value'=>$eday,'full'=>$end.'-'.$eday,'no'=>1];$ef++; - }else{ - $last[$er][$i] = ['value'=>$eday,'full'=>$end.'-'.$eday];$ef++; - } + } + for($i=0;$i<7;$i++) { + if ($i<$ew) + $last[$er][$i] = ['value'=>'']; + else { + $eday = set_date_day_format($ef); + if (strtotime($end.'-'.$eday)>strtotime(date('Y-m-d'))){ + $last[$er][$i] = ['value'=>$eday,'full'=>$end.'-'.$eday,'no'=>1];$ef++; + }else{ + $last[$er][$i] = ['value'=>$eday,'full'=>$end.'-'.$eday];$ef++; } } + } + + $sn = $en = 0; // 列数 + for ($i=$sf;$i<=$st;$i++) { + if (count($first[$sr])==7){$sr++;$sn=0;} + $sday = set_date_day_format($i); + $first[$sr][$sn] = ['value'=>$sday,'full'=>$start.'-'.$sday]; + $sn++; + } + for ($i=$ef;$i<=$et;$i++) { + if (count($last[$er])==7){$er++;$en=0;} + $eday = set_date_day_format($i); + if (strtotime($end.'-'.$eday)>strtotime(date('Y-m-d'))){$last[$er][$en] = ['value'=>$eday,'full'=>$end.'-'.$eday,'no'=>1];} else{$last[$er][$en] = ['value'=>$eday,'full'=>$end.'-'.$eday];} - $sn = $en = 0; // 列数 - for ($i=$sf;$i<=$st;$i++) { - if (count($first[$sr])==7){$sr++;$sn=0;} - $sday = set_date_day_format($i); - $first[$sr][$sn] = ['value'=>$sday,'full'=>$start.'-'.$sday]; - $sn++; - } - for ($i=$ef;$i<=$et;$i++) { - if (count($last[$er])==7){$er++;$en=0;} - $eday = set_date_day_format($i); - if (strtotime($end.'-'.$eday)>strtotime(date('Y-m-d'))){$last[$er][$en] = ['value'=>$eday,'full'=>$end.'-'.$eday,'no'=>1];} else{$last[$er][$en] = ['value'=>$eday,'full'=>$end.'-'.$eday];} - - $en++; - } - - $prev = date('Y-m',strtotime('-1 month',$stime)).','.$start; - $next = $end.','.date('Y-m',strtotime('+1 month',$etime)); - - $calendar = ['first'=>$first,'last'=>$last,'prev'=>$prev,'next'=>$next,'iscurrent'=>$iscurrent,'ftitle'=>date('Y年m月',$stime),'ltitle'=>date('Y年m月',$etime),'today'=>date('Y-m-d')]; - - if ($flag) { - - echo json_encode($calendar); - - } else { - - $this->assign('calendar',$calendar); - - } - + $en++; } + $prev = date('Y-m',strtotime('-1 month',$stime)).','.$start; + $next = $end.','.date('Y-m',strtotime('+1 month',$etime)); - /* - * 折线图 - * @param integer $start 开始时间 - * @param integer $end 结束时间 - * @param boolean $flag 是否ajax返回 - * @author 鹿文学 - */ - public function foldLineDiagram($start='',$end='',$num='',$flag=false) { - - $starttime = $start?strtotime($start):mktime(0,0,0,date('m'),date('d')-1,date('Y')); - - $endtime = $end?strtotime($end)+86399:$starttime+86399; - - $start = date('Y-m-d',$starttime); - $end = date('Y-m-d',$endtime); - - $user = D('User'); - $spend = D('Spend'); - $promote = D('Promote'); - - if ($start == $end) { - - if ($start == date('Y-m-d',strtotime('-1 day'))) {$num = 2;} - - $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; - - $data['date'] = [$start]; - - $data['hours'] = 1; - - foreach($hours as $v) { - $data['news'][$v] = 0; - $data['active'][$v] = 0; - $data['player'][$v] = 0; - $data['money'][$v] = 0; - } - - // 新增用户 - $hoursnews = $user->newsAdd(['register_time'=>['between',[$starttime,$endtime]]],'news','time',5); - - // 活跃用户 - $hoursactive = $user->totalPlayerByGroup($hours,['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]],'active','time',5); - - // 付费用户 - $hoursplayer = $spend->totalPlayerByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'player','time',5); - - // 充值金额 - $hoursmoney = $spend->totalAmountByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'money','time',5); - - foreach($hours as $v) { - foreach($hoursnews as $h) { - $time = explode(' ',$h['time']); - if ($time[1] == $v){ - $data['news'][$v] = (integer)$h['news'];break; - } - } - - foreach($hoursactive as $h) { - - if ($h['time'] == $v){ - $data['active'][$v] = (integer)$h['active'];break; - } - } - - foreach($hoursplayer as $h) { - $time = explode(' ',$h['time']); - if ($time[1] == $v){ - $data['player'][$v] = (integer)$h['player'];break; - } - } - - foreach($hoursmoney as $h) { - $time = explode(' ',$h['time']); - if ($time[1] == $v){ - $data['money'][$v] = $h['money'];break; - } - } - - } - - // 新 - $between = ['between',[$starttime-86400,$endtime]]; - - $cnewslist = $user->newsAdd(['register_time'=>$between],'count','time',1,'time desc'); - $cnews['count'] = $cnewslist[0]['count']?$cnewslist[0]['count']:0; - $cnews['rate'] = $cnewslist[0] && $cnewslist[1]? round(($cnewslist[0]['count']/$cnewslist[1]['count']-1)*100,2):($cnewslist[0]&&!$cnewslist[1]?(100):(!$cnewslist[0]&&$cnewslist[1]?(-100):0)); - - // 活 - $cactivelist = $user->totalPlayerByGroup([date('Y-m-d',$starttime-86400),$end],['tab_user_login_record.login_time'=>$between],'count','time',1,'time desc'); - $cactive['count'] = $cactivelist[0]['count']?$cactivelist[0]['count']:0; - $cactive['rate'] = $cactivelist[0] && $cactivelist[1]? round(($cactivelist[0]['count']/$cactivelist[1]['count']-1)*100,2):($cactivelist[0]&&!$cactivelist[1]?(100):(!$cactivelist[0]&&$cactivelist[1]?(-100):0)); - - // 付 - $cplayerlist = $spend->totalPlayerByGroup(['pay_time'=>$between],'count','time',1,'time desc'); - $cplayer['count'] = $cplayerlist[0]['count']?$cplayerlist[0]['count']:0; - $cplayer['rate'] = $cplayerlist[0] && $cplayerlist[1]? round(($cplayerlist[0]['count']/$cplayerlist[1]['count']-1)*100,2):($cplayerlist[0]&&!$cplayerlist[1]?(100):(!$cplayerlist[0]&&$cplayerlist[1]?(-100):0)); - - // 充 - $cmoneylist = $spend->totalAmountByGroup(['pay_time'=>$between],'count','time',1,'time desc'); - $cmoney['count'] = $cmoneylist[0]['count']?$cmoneylist[0]['count']:0; - $cmoney['rate'] = $cmoneylist[0] && $cmoneylist[1]? round(($cmoneylist[0]['count']/$cmoneylist[1]['count']-1)*100,2):($cmoneylist[0]&&!$cmoneylist[1]?(100):(!$cmoneylist[0]&&$cmoneylist[1]?(-100):0)); - - // 渠 - $cpromotelist = $promote->newsAdd(['create_time'=>$between],'count','time',1,'time desc'); - $cpromote['count'] = $cpromotelist[0]['count']?$cpromotelist[0]['count']:0; - $cpromote['rate'] = $cpromotelist[0] && $cpromotelist[1]? round(($cpromotelist[0]['count']/$cpromotelist[1]['count']-1)*100,2):($cpromotelist[0]&&!$cpromotelist[1]?(100):(!$cpromotelist[0]&&$cpromotelist[1]?(-100):0)); - - } else { - - $datelist = get_date_list($starttime,$endtime,$num==7?4:1); - - $data['date'] = $datelist; - - $data['hours'] = 0; - foreach($datelist as $k => $v) { - $data['news'][$v] = 0; - $data['active'][$v] = 0; - $data['player'][$v] = 0; - $data['money'][$v] = 0; - } - - // 新增用户 - $news = $user->newsAdd(['register_time'=>['between',[$starttime,$endtime]]],'news','time',$num==7?2:1); - - // 活跃用户 - $active = $user->totalPlayerByGroup($datelist,['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]],'active','time',$num==7?2:1); - - // 付费用户 - $player = $spend->totalPlayerByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'player','time',$num==7?2:1); - - // 充值金额 - $money = $spend->totalAmountByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'money','time',$num==7?2:1); - - foreach($datelist as $v) { - foreach($news as $h) { - if ($v == $h['time']) { - $data['news'][$v] = (integer)$h['news'];break; - } - } - - foreach($active as $h) { - if ($v == $h['time']) { - $data['active'][$v] = (integer)$h['active'];break; - } - } - - foreach($player as $h) { - if ($v == $h['time']) { - $data['player'][$v] = (integer)$h['player'];break; - } - } - - foreach($money as $h) { - if ($v == $h['time']) { - $data['money'][$v] = $h['money'];break; - } - } - - } - - - // 新 - $cnewslist1 = $user->old(['register_time'=>['between',[$starttime,$endtime]]]); - // 活 - $cactivelist1 = $user->active(['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]]); - // 付 - $cplayerlist1 = $spend->player(['pay_time'=>['between',[$starttime,$endtime]]]); - // 充 - $cmoneylist1 = $spend->totalAmount(['pay_time'=>['between',[$starttime,$endtime]]]); - // 渠 - $cpromotelist1 = $promote->total(['create_time'=>['between',[$starttime,$endtime]]]); - switch($num) { - case 3:{ - $between = ['between',[strtotime('-7 day',$starttime),strtotime('-7 day',$endtime)]]; - - $cnewslist2 = $user->old(['register_time'=>$between]); - - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - - $cpromotelist2 = $promote->total(['create_time'=>$between]); - };break; - case 4:{ - $temp = strtotime('-1 month',$starttime); - $between = ['between',[$temp,mktime(0,0,0,date('m',$temp)+1,1,date('Y',$temp))-1]]; - $cnewslist2 = $user->old(['register_time'=>$between]); - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - $cpromotelist2 = $promote->total(['create_time'=>$between]); - };break; - case 5:{ - $between = ['between',[strtotime('-7 day',$starttime),strtotime('-7 day',$endtime)]]; - $cnewslist2 = $user->old(['register_time'=>$between]); - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - $cpromotelist2 = $promote->total(['create_time'=>$between]); - };break; - case 6:{ - $between = ['between',[strtotime('-30 day',$starttime),strtotime('-30 day',$endtime)]]; - $cnewslist2 = $user->old(['register_time'=>$between]); - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - $cpromotelist2 = $promote->total(['create_time'=>$between]); - };break; - case 7:{ - $between = ['between',[strtotime('-365 day',$starttime),strtotime('-365 day',$endtime)]]; - $cnewslist2 = $user->old(['register_time'=>$between]); - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - $cpromotelist2 = $promote->total(['create_time'=>$between]); - };break; - default:{ - $day_num = count($datelist); - $between = ['between',[strtotime('-'.$day_num.' day',$starttime),strtotime('-'.$day_num.' day',$endtime)]]; - $cnewslist2 = $user->old(['register_time'=>$between]); - $cactivelist2 = $user->active(['tab_user_login_record.login_time'=>$between]); - $cplayerlist2 = $spend->player(['pay_time'=>$between]); - $cmoneylist2 = $spend->totalAmount(['pay_time'=>$between]); - $cpromotelist2 = $promote->total(['create_time'=>$between]); - }; - - } - - - $cnews['count'] = $cnewslist1?$cnewslist1:0; - $cnews['rate'] = $cnewslist1 && $cnewslist2? round(($cnewslist1/$cnewslist2-1)*100,2):($cnewslist1&&!$cnewslist2?(100):(!$cnewslist1&&$cnewslist2?(-100):0)); - - $cactive['count'] = $cactivelist1?$cactivelist1:0; - $cactive['rate'] = $cactivelist1 && $cactivelist2? round(($cactivelist1/$cactivelist2-1)*100,2):($cactivelist1&&!$cactivelist2?(100):(!$cactivelist1&&$cactivelist2?(-100):0)); - - $cplayer['count'] = $cplayerlist1?$cplayerlist1:0; - $cplayer['rate'] = $cplayerlist1 && $cplayerlist2? round(($cplayerlist1/$cplayerlist2-1)*100,2):($cplayerlist1&&!$cplayerlist2?(100):(!$cplayerlist1&&$cplayerlist2?(-100):0)); - - $cmoney['count'] = $cmoneylist1?$cmoneylist1:0; - $cmoney['rate'] = $cmoneylist1 && $cmoneylist2? round(($cmoneylist1/$cmoneylist2-1)*100,2):($cmoneylist1&&!$cmoneylist2?(100):(!$cmoneylist1&&$cmoneylist2?(-100):0)); - - $cpromote['count'] = $cpromotelist1?$cpromotelist1:0; - $cpromote['rate'] = $cpromotelist1 && $cpromotelist2? round(($cpromotelist1/$cpromotelist2-1)*100,2):($cpromotelist1&&!$cpromotelist2?(100):(!$cpromotelist1&&$cpromotelist2?(-100):0)); - - } - - + $calendar = ['first'=>$first,'last'=>$last,'prev'=>$prev,'next'=>$next,'iscurrent'=>$iscurrent,'ftitle'=>date('Y年m月',$stime),'ltitle'=>date('Y年m月',$etime),'today'=>date('Y-m-d')]; + + if ($flag) { - foreach($data as $k => $v) { - - if (is_array($v)) { - if ($k == 'date') - $data[$k] = '"'.implode('","',$v).'"'; - else - $data[$k] = implode(',',$v); - - } - } + echo json_encode($calendar); - $data['compare']['news'] = $cnews; - $data['compare']['active'] = $cactive; - $data['compare']['player'] = $cplayer; - $data['compare']['money'] = $cmoney; - $data['compare']['promote'] = $cpromote; + } else { - if ($flag) { - - echo json_encode($data); - - } else { - - $this->assign('foldline',$data); - - $this->assign('num',$num); - - } + $this->assign('calendar',$calendar); } + } public function indextt(){ $user = M("User","tab_"); diff --git a/Application/Admin/View/Index/index.html b/Application/Admin/View/Index/index.html index d6aed5c01..595a26b29 100644 --- a/Application/Admin/View/Index/index.html +++ b/Application/Admin/View/Index/index.html @@ -386,9 +386,12 @@ }); } } - + //执行日期的选择 function chartdata(start,end,parent) { - + var index = layer.load(1, { + shade: [0.3,'#000'] //0.1透明度的白色背景 + }); + // var index = layer.load(2, {shade: false}); var href = '{:U("index")}'; end = end?end:start; var tb = $.trim($('.tab_head a.current').attr('href')).replace('#',''); From 360cf3f3ba5f5276a2f67907e88186112318e97a Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 16:38:29 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/IndexController.class.php | 144 +++++++++++++++++- Application/Admin/View/Index/index.html | 23 ++- 2 files changed, 164 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index 1532a9075..1cbe5477d 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -42,8 +42,12 @@ class IndexController extends AdminController { // 日历 $this->calendar(); - $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); - + if(strtotime($_REQUEST['start']) == mktime(0,0,0,date('m'),date('d'),date('Y'))){ + //今日时时 + $this->nowday($_REQUEST['num']); + }else{ + $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); + } $tm =strtotime(date("Y-m-d",strtotime("-1 day"))); $allcount = M("IndexChart","tab_")->field("all_count")->where("`date` = '{$tm}'")->find(); $allcount = unserialize($allcount['all_count']); @@ -56,6 +60,142 @@ class IndexController extends AdminController { //累计统计 $this->display(); } + /* + * 今日折线图 + */ + public function nowday($num) + { + $starttime = mktime(0,0,0,date('m'),date('d'),date('Y')); + + $endtime = $starttime+86399; + + $start = date('Y-m-d',$starttime); + $end = date('Y-m-d',$endtime); + + $user = D('User'); + $spend = D('Spend'); + $promote = D('Promote'); + + + if ($start == date('Y-m-d',strtotime('-1 day'))) {$num = 2;} + + $hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']; + + $data['date'] = [$start]; + + $data['hours'] = 1; + + foreach($hours as $v) { + $data['news'][$v] = 0; + $data['active'][$v] = 0; + $data['player'][$v] = 0; + $data['money'][$v] = 0; + } + + // 新增用户 + $hoursnews = $user->newsAdd(['register_time'=>['between',[$starttime,$endtime]]],'news','time',5); + + // 活跃用户 + $hoursactive = $user->totalPlayerByGroup($hours,['tab_user_login_record.login_time'=>['between',[$starttime,$endtime]]],'active','time',5); + + // 付费用户 + $hoursplayer = $spend->totalPlayerByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'player','time',5); + + // 充值金额 + $hoursmoney = $spend->totalAmountByGroup(['pay_time'=>['between',[$starttime,$endtime]]],'money','time',5); + + foreach($hours as $v) { + foreach($hoursnews as $h) { + $time = explode(' ',$h['time']); + if ($time[1] == $v){ + $data['news'][$v] = (integer)$h['news'];break; + } + } + + foreach($hoursactive as $h) { + + if ($h['time'] == $v){ + $data['active'][$v] = (integer)$h['active'];break; + } + } + + foreach($hoursplayer as $h) { + $time = explode(' ',$h['time']); + if ($time[1] == $v){ + $data['player'][$v] = (integer)$h['player'];break; + } + } + + foreach($hoursmoney as $h) { + $time = explode(' ',$h['time']); + if ($time[1] == $v){ + $data['money'][$v] = $h['money'];break; + } + } + + } + + // 新 + $between = ['between',[$starttime-86400,$endtime]]; + + $cnewslist = $user->newsAdd(['register_time'=>$between],'count','time',1,'time desc'); + $cnews['count'] = $cnewslist[0]['count']?$cnewslist[0]['count']:0; + $cnews['rate'] = $cnewslist[0] && $cnewslist[1]? round(($cnewslist[0]['count']/$cnewslist[1]['count']-1)*100,2):($cnewslist[0]&&!$cnewslist[1]?(100):(!$cnewslist[0]&&$cnewslist[1]?(-100):0)); + + // 活 + $cactivelist = $user->totalPlayerByGroup([date('Y-m-d',$starttime-86400),$end],['tab_user_login_record.login_time'=>$between],'count','time',1,'time desc'); + $cactive['count'] = $cactivelist[0]['count']?$cactivelist[0]['count']:0; + $cactive['rate'] = $cactivelist[0] && $cactivelist[1]? round(($cactivelist[0]['count']/$cactivelist[1]['count']-1)*100,2):($cactivelist[0]&&!$cactivelist[1]?(100):(!$cactivelist[0]&&$cactivelist[1]?(-100):0)); + + // 付 + $cplayerlist = $spend->totalPlayerByGroup(['pay_time'=>$between],'count','time',1,'time desc'); + $cplayer['count'] = $cplayerlist[0]['count']?$cplayerlist[0]['count']:0; + $cplayer['rate'] = $cplayerlist[0] && $cplayerlist[1]? round(($cplayerlist[0]['count']/$cplayerlist[1]['count']-1)*100,2):($cplayerlist[0]&&!$cplayerlist[1]?(100):(!$cplayerlist[0]&&$cplayerlist[1]?(-100):0)); + + // 充 + $cmoneylist = $spend->totalAmountByGroup(['pay_time'=>$between],'count','time',1,'time desc'); + $cmoney['count'] = $cmoneylist[0]['count']?$cmoneylist[0]['count']:0; + $cmoney['rate'] = $cmoneylist[0] && $cmoneylist[1]? round(($cmoneylist[0]['count']/$cmoneylist[1]['count']-1)*100,2):($cmoneylist[0]&&!$cmoneylist[1]?(100):(!$cmoneylist[0]&&$cmoneylist[1]?(-100):0)); + + // 渠 + $cpromotelist = $promote->newsAdd(['create_time'=>$between],'count','time',1,'time desc'); + $cpromote['count'] = $cpromotelist[0]['count']?$cpromotelist[0]['count']:0; + $cpromote['rate'] = $cpromotelist[0] && $cpromotelist[1]? round(($cpromotelist[0]['count']/$cpromotelist[1]['count']-1)*100,2):($cpromotelist[0]&&!$cpromotelist[1]?(100):(!$cpromotelist[0]&&$cpromotelist[1]?(-100):0)); + + + + + + foreach($data as $k => $v) { + + if (is_array($v)) { + if ($k == 'date') + $data[$k] = '"'.implode('","',$v).'"'; + else + $data[$k] = implode(',',$v); + + } + } + + $data['compare']['news'] = $cnews; + $data['compare']['active'] = $cactive; + $data['compare']['player'] = $cplayer; + $data['compare']['money'] = $cmoney; + $data['compare']['promote'] = $cpromote; + + if ($flag) { + + echo json_encode($data); + + } else { + + $this->assign('foldline',$data); + + $this->assign('num',$num); + + } + # code... + } /* * 折线图 diff --git a/Application/Admin/View/Index/index.html b/Application/Admin/View/Index/index.html index 595a26b29..936a4e2e4 100644 --- a/Application/Admin/View/Index/index.html +++ b/Application/Admin/View/Index/index.html @@ -388,10 +388,31 @@ } //执行日期的选择 function chartdata(start,end,parent) { + var starttime = new Date(start).getTime(); + if(end){ + var endtime = new Date(end).getTime(); + }else{ + var endtime = new Date(start).getTime(); + } + if(starttime > endtime){ + var temp = start; + start = end; + end = temp; + } + + if(end && (start != end)){ + var endtime = (new Date(end).getTime()) + 86399000; + var now = new Date().getTime(); + if(endtime > now){ + layer.msg('历史时间选择不能包含今日'); + return false; + } + }; + var index = layer.load(1, { shade: [0.3,'#000'] //0.1透明度的白色背景 }); - // var index = layer.load(2, {shade: false}); + var href = '{:U("index")}'; end = end?end:start; var tb = $.trim($('.tab_head a.current').attr('href')).replace('#',''); From a29227c2cd2692e1c6ff672712f82ec462f3337b Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Tue, 19 Nov 2019 16:40:23 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93data=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/update.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Data/update.sql b/Data/update.sql index 63465cfb3..8812820ac 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -428,3 +428,26 @@ CREATE TABLE `tab_notice_read` ( ALTER TABLE `tab_user_play_info` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `create_time`); ALTER TABLE `tab_user_login_record` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `login_time`); ALTER TABLE `tab_spend` ADD INDEX `search`(`promote_id`, `game_id`, `server_id`, `pay_way`, `pay_status`, `pay_time`); + + +--2019-11-19 chenzhi +CREATE TABLE `tab_index_chart` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键自增', + `date` int(11) NOT NULL DEFAULT '0' COMMENT '日期时间戳', + `new_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '新增用户聚合', + `new_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日新增总计', + `active_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '活跃用户聚合', + `active_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日活跃总计', + `active_user_list` longtext NOT NULL DEFAULT '' COMMENT '单日活跃用户的id序列', + `pay_user_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '付费用户聚合', + `pay_user_count` int(11) NOT NULL DEFAULT '0' COMMENT '单日付费用户总计', + `pay_user_list` longtext NOT NULL DEFAULT '' COMMENT '单日付费用户的id序列', + `pay_money_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '付费金额聚合', + `pay_money_count` decimal(10,2) DEFAULT '0.00' COMMENT '单日付费金额总计', + `promote_new_hours` varchar(500) NOT NULL DEFAULT '' COMMENT '小时新增渠道', + `promote_new_count` int(11) NOT NULL DEFAULT '0' COMMENT '新增合作渠道总计', + `all_count` varchar(500) NOT NULL DEFAULT '' COMMENT '累计的统计数据', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '统计日期', + PRIMARY KEY (`id`), + KEY `date` (`date`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='首页折线图静态数据'; \ No newline at end of file