Pārlūkot izejas kodu

登录时长统计

cyzhao 3 gadi atpakaļ
vecāks
revīzija
0eff36fa38

+ 1 - 1
Gameserver/Amfphp/Services/AppServer.php

@@ -79,7 +79,7 @@ class AppServer {
                 JsonUtil::encode($resp->result)); #                             # resp->result
         daoInst()->exec($sql);                                                  # 执行sql
     }
-
+     
     /**
      * 路由方法
      */

+ 3 - 0
Gameserver/Amfphp/util/JsonUtil.php

@@ -46,6 +46,9 @@ class JsonUtil {
      */
     public static function encode($obj) {
         $json = is_string($obj) ? $obj : json_encode($obj);                     # 防止对字符串二次编码
+        if(!isset($GLOBALS['OS'])){
+            $GLOBALS['OS']="win32";
+        }
         if ($GLOBALS['OS'] == "linux") {                                        # 还原中文字符串
             return preg_replace_callback('#\\\u([0-9a-f]{4})#i', function ($matches) {
                 return iconv('UCS-2LE', 'UTF-8', pack('H4', $matches[1]));

+ 6 - 0
Gameserver/Public/gamesys/app/main.php

@@ -74,3 +74,9 @@ function getPageUrl($tag) {
         return ROOT_URL . "home/pages/" . $tag . "/" . $tag . ".html";
     }
 }
+/**
+ * @return \loyalsoft\Req 全局访问
+ */
+function req() {
+    return null;
+}

+ 47 - 0
Gameserver/Public/gamesys/app/providers/GameContinuedTs.php

@@ -0,0 +1,47 @@
+<?php
+include_once dirname(__FILE__) . '/../main.php';
+
+$params = query_paras();
+
+//$params = $_POST['date'];
+$date = $params['date']['ts'];
+$uid = $params['date']['uid'];
+$zoneid = $params['date']['zoneid'];
+
+$sqlName = "tab_op_log".$date;
+
+$arr = daoInst()->select("*")->from($sqlName)
+                ->where('cmd')->eq(6901)
+                ->andWhere('zoneid')->eq($zoneid)
+                ->andWhere('uid')->eq($uid)
+                ->fetchAll();
+$lastItem = null;
+
+$dic = new stdClass();
+$list = array();
+$index = 1;
+
+foreach ($arr as $item) {
+    if($lastItem != null){
+        $list[] = $lastItem;
+        
+        if(strtotime($item->ts) - strtotime($lastItem->ts) > 20*60){                               
+            $timeDic = new stdClass();
+            $timeDic->startTs = strtotime($list[0]->ts);
+            $timeDic->endTs = strtotime($list[count($list)-1]->ts);
+            $timeDic->durationTs = strtotime($list[count($list)-1]->ts) - strtotime($list[0]->ts);
+            
+            $dic->$index = $timeDic;
+            $index += 1;
+            
+            $list = array();
+        }      
+    }
+
+    $lastItem = $item;
+}
+
+$result = new stdClass();
+$result->data = $dic;
+
+echo json_encode($result);

+ 24 - 0
Gameserver/Public/gamesys/home/js/index.js

@@ -421,6 +421,30 @@
                         "F_ModifyUserId": "System",
                         "F_ModifyUserName": "超级管理员"
                     },
+                    {
+                        "F_ModuleId": "7ae94059-9aa5-48eb-8330-4e2a6565b193",
+                        "F_ParentId": "1",
+                        "F_EnCode": "AreaManage",
+                        "F_FullName": "游戏登录时长",
+                        "F_Icon": "fa fa-leaf",
+                        "F_UrlAddress": "pages/GameContinuedTs/GameContinuedTs.html",
+                        "F_Target": "iframe",
+                        "F_IsMenu": 1,
+                        "F_AllowExpand": 1,
+                        "F_IsPublic": 0,
+                        "F_AllowEdit": null,
+                        "F_AllowDelete": null,
+                        "F_SortCode": 1,
+                        "F_DeleteMark": 0,
+                        "F_EnabledMark": 1,
+                        "F_Description": "游戏登录时长",
+                        "F_CreateDate": "2021-09-13 11:21:20",
+                        "F_CreateUserId": "System",
+                        "F_CreateUserName": "超级管理员",
+                        "F_ModifyDate": "2021-09-13 11:21:20",
+                        "F_ModifyUserId": "System",
+                        "F_ModifyUserName": "超级管理员"
+                    },                    
                     {
                         "F_ModuleId": "99",
                         "F_ParentId": "0",

+ 21 - 0
Gameserver/Public/gamesys/home/pages/GameContinuedTs/GameContinuedTs.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<!--
+To change this license header, choose License Headers in Project Properties.
+To change this template file, choose Tools | Templates
+and open the template in the editor.
+-->
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <script src="../../js/jquery/jQuery-2.2.0.min.js"></script>
+        <script src="../api.js"></script>
+        <script src="GameContinuedTs.js"></script>
+    </head>
+    <body>
+
+        <div>TODO write content</div>
+        <button class="btn" style="display:block;margin:auto;background-color: #3c8dbc;color: #FFFFFF;" onclick="sendMail()">发送邮件</button>
+    </body>
+</html>

+ 26 - 0
Gameserver/Public/gamesys/home/pages/GameContinuedTs/GameContinuedTs.js

@@ -0,0 +1,26 @@
+function sendMail() {
+    console.log("发送请求");
+
+    var zoneid = 1;
+    var uid = "D51D63CA040982E406BDE9898AD757AE";
+    var ts = "20201119";
+   
+//    var titleTxt = $("#title-text").val();
+//    var fromTxt = $("#from-text").val();
+
+    var data = {
+        zoneid: zoneid,
+        uid: uid,
+        ts: ts,     
+    };
+
+    post(
+            getProviderUrl("GameContinuedTs"),
+            {date: data},
+            function (data) {
+                console.log(data);
+//                Canvas(data.data1, data.data2);
+                window.alert("成功okokokokok");
+            }
+    , 'json');
+}