123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /*
- * 留存1
- */
- include_once dirname(__FILE__) . '/../main.php';
- $params = query_paras();
- $date = $params['date'];
- /*---old
- $numbers = array(1, 3, 5, 7, 15, 30); # 留存天数
- $array = array();
- $array2 = array();
- // 计算新增人数
- $tabName = "tab_rolename";
- $new = daoInst()->select('*')->from($tabName)
- ->where('ts')->ge($date . " 00:00:00")
- ->andWhere('ts')->le($date . " 23:59:59")
- ->count();
- $array[] = intval($new);
- // 遍历 留存天数数组, 计算相应留存/率
- array_map(function ($n)use($date, $tabName, $new, &$array, &$array2) {
- $iday = strtotime("$date +$n day");
- $day = date("Y-m-d", $iday);
- $total = daoInst()->select('*')->from($tabName)
- ->where('ts')->ge($date . " 00:00:00")
- ->andWhere('ts')->le($date . " 23:59:59")
- ->andWhere('lastlogin')->ge($day . " 00:00:00")
- ->count();
- $array[] = $total; # 输出
- $array2[] = (int) ($total / $new * 100); # 输出
- }, $numbers);
- //
- */
- //------new----
- $zoneid = 1;//先默认是1,其他区还没有
- $curLoginUidArr = gMem()->hgetall($key);
- $numbersArr = array(1, 2, 3, 4, 5, 6,7);
- $day = intval(strtotime($date)/24/60/60);
- foreach ($numbersArr as $type) {
- $typeDay = intval(strtotime("$day +$type day")/24/60/60);
- $memKey = "gamerun-loginUser-byUid-zone".$zoneid."-day_".$typeDay;
-
- $typeArr = gMem()->hgetall($memKey);
- $retainArr = array();
- foreach ($curLoginUidArr as $uid=>$val) {
- if(in_array($uid, $typeArr)){
- $retainArr[]=$uid;
- }
- }
-
- }
- $result = new stdClass();
- $result->data1 = $array;
- $result->data2 = $array2;
- echo json_encode($result);
|