stanley-king 6 роки тому
батько
коміт
41bb65b087

+ 1 - 4
core/framework/db/mysqli.php

@@ -132,7 +132,7 @@ class Db
 
             if ($query === false)
             {
-                $eno = mysqli_errno(self::$link[$host]);
+                $eno  = mysqli_errno(self::$link[$host]);
                 $emsg = mysqli_error(self::$link[$host]);
                 $error = "Db Error eno={$eno} msg={$emsg}";
                 Log::record("{$error} \r\n sql={$sql}",Log::ERR);
@@ -162,9 +162,6 @@ class Db
             else
             {
                 Log::record($sql . " [ RunTime:" . $staer->elapsed(6) . "s ]", Log::SQL);
-//                if(strpos($sql,"SELECT") === false) {
-//                    Log::record($sql . " [ RunTime:" . $staer->elapsed(6) . "s ]", Log::SQL);
-//                }
                 return $query;
             }
         }

+ 1 - 1
core/framework/libraries/model.php

@@ -1239,7 +1239,7 @@ class ModelDb
                 }
             }
 
-            $order   =  implode(',',$array);
+            $order = implode(',',$array);
         }
         return !empty($order)?  ' ORDER BY '.$order:'';
     }

+ 5 - 5
crontab/control/queue.php

@@ -19,10 +19,10 @@ class queueControl extends BaseCronControl
     {
         if (ob_get_level()) ob_end_clean();
 
-        pcntl_signal(SIGINT,  array($this,'sig_handler'));
-        pcntl_signal(SIGHUP,  array($this,'sig_handler'));
-        pcntl_signal(SIGQUIT, array($this,'sig_handler'));
-        pcntl_signal(SIGTERM, array($this,'sig_handler'));
+        pcntl_signal(SIGINT,  [$this,'sig_handler']);
+        pcntl_signal(SIGHUP,  [$this,'sig_handler']);
+        pcntl_signal(SIGQUIT, [$this,'sig_handler']);
+        pcntl_signal(SIGTERM, [$this,'sig_handler']);
 
         $logic_queue = Logic('queue');
 
@@ -46,8 +46,8 @@ class queueControl extends BaseCronControl
                     $arg = current($content);
 
                     $argx = json_encode($arg,JSON_UNESCAPED_UNICODE);
+                    $trace = new scope_trace(__METHOD__ . "  {$method}");
                     Log::record("method={$method} args={$argx}",Log::DEBUG);
-
                     $result = $logic_queue->$method($arg);
                     if (!$result['state']) {
                         $this->log($result['msg'],false);

+ 6 - 2
data/model/room.model.php

@@ -26,6 +26,10 @@ class roomModel extends Model
         $ret = $this->table('room_participant')->where($cond)->update($updata);
         return $ret;
     }
+    public function countParts($cond) {
+        $ret = $this->table('room_participant')->where($cond)->count();
+        return $ret;
+    }
     public function invite($room_id,$user,$inviter) {
         $ret = $this->table('room_participant')->insert(['room_id' => $room_id,'member_id' => $user,'inviter' => $inviter,'invite_time' => time(),'join_time' => 0,'jointimes' => 0,'state' => 0],true);
         return $ret;
@@ -44,9 +48,9 @@ class roomModel extends Model
         $params = ['type' => $type,'room_name' => $name,'room_creator' => $creator,'room_owner' => $owner,'owner_name' => $owner_name,'max_user' => $max_user,'add_time' => time()];
         return $this->table('room')->insert($params);
     }
-    public function editRoom($cond,$update)
+    public function editRoom($cond, $updata)
     {
-        return $this->table('room')->where($cond)->update($update);
+        return $this->table('room')->where($cond)->update($updata);
     }
     public function edit($condition,$data) {
         return $this->table('room')->where($condition)->update($data);

+ 2 - 0
helper/room/factory_processor.php

@@ -13,6 +13,7 @@ use process_looper;
 use errcode;
 use uniquer;
 use Log;
+use scope_trace;
 
 class factory_processor implements IProcessor
 {
@@ -75,6 +76,7 @@ class factory_processor implements IProcessor
 
     public function onRequest($bufid, $body)
     {
+        $trace = new scope_trace(__METHOD__);
         $input = json_decode($body,true);
         if($input == false) {
             return false;

+ 6 - 0
helper/room/room_parts.php

@@ -59,6 +59,12 @@ class room_parts
         return $result;
     }
 
+    public function users()
+    {
+        $count = $this->mModRoom->countParts(['room_id' => $this->mRoomID]);
+        return intval($count);
+    }
+
     public function allparts($filter=[])
     {
         $uids = [];

+ 3 - 1
helper/room/room_processor.php

@@ -13,6 +13,7 @@ use process_looper;
 use errcode;
 use algorithm;
 use QueueClient;
+use scope_trace;
 
 class room_processor implements IProcessor
 {
@@ -41,6 +42,7 @@ class room_processor implements IProcessor
     }
     public function onRequest($bufid, $body)
     {
+        $trace = new scope_trace(__METHOD__);
         $input = json_decode($body,true);
         if($input == false) {
             process_looper::instance()->close($bufid);
@@ -167,7 +169,7 @@ class room_processor implements IProcessor
                             QueueClient::push("OnUpdateRoom",['room_id' => $roomid]);
                         } else {
                             $count = count($newusers);
-                            Model('room')->editRoom(['room_id' => $roomid],['users' => ['users',"users+{$count}"]]);
+                            Model('room')->editRoom(['room_id' => $roomid],['users' => ['exp',"users+{$count}"]]);
                         }
                     }
                     return $this->success($result);

+ 2 - 0
helper/room_helper.php

@@ -36,6 +36,7 @@ class room_helper
 
         $parts = new room\room_parts($room);
         $partinfos = $parts->top_users(20);
+        $users = $parts->users();
 
         $uids = [];
         foreach ($partinfos as $part) {
@@ -67,6 +68,7 @@ class room_helper
                 $updata['tmp_name'] = $tmp_name;
             }
         }
+        $updata['users'] = $users;
 
         if(!empty($updata)) {
             $mod_room->editRoom(['room_id' => $room],$updata);

+ 3 - 5
helper/url_helper.php

@@ -77,9 +77,8 @@ class url_helper
         $url = BASE_SITE_URL . "/mobile/index.php?act=bargain&op=open&client_type=wap&bargain_id={$bargain_id}&relay_id={$relay_id}";
         return $url;
     }
-    public static function room_invite_url($room_id,$inviter)
+    public static function room_invite_url($room_id,$relay_id)
     {
-        $relay_id = session_helper::share_id();
         $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_invite&client_type=ajax&room_id={$room_id}&inviter={$inviter}&relay_id={$relay_id}";
         return $url;
     }
@@ -148,10 +147,9 @@ class author_url
         $url = BASE_SITE_URL . "/mobile/index.php?act=bargain&op=open&client_type=wap&bargain_id={$bargain_id}&relay_id={$relay_id}";
         return $url;
     }
-    public static function room_invite_url($room_id,$inviter)
+    public static function room_invite_url($room_id,$relay_id)
     {
-        $relay_id = session_helper::share_id();
-        $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_invite&client_type=ajax&room_id={$room_id}&inviter={$inviter}&relay_id={$relay_id}";
+        $url = BASE_SITE_URL . "/mobile/index.php?act=index&op=room_invite&client_type=ajax&room_id={$room_id}&relay_id={$relay_id}";
         return $url;
     }
 }

+ 3 - 6
mobile/control/control.php

@@ -15,7 +15,7 @@ require_once (BASE_ROOT_PATH . "/helper/statistics_helper.php");
 class mobileControl
 {
     //客户端类型
-    private static $stClienTypes = array('android', 'wap', 'wechat', 'ios', 'ajax', 'web','mini');
+    private static $stClienTypes = ['android', 'wap', 'wechat', 'ios', 'ajax', 'web','mini'];
 
     //列表默认分页数
     protected $page_size;
@@ -46,7 +46,6 @@ class mobileControl
 
         $param = $_GET;
         $param['client_type'] = $_SESSION['client_type'];
-        Log::record("client_type = {$param['client_type']}",Log::DEBUG);
 
         $this->set_relay();
         statistics_helper::instance()->add_call($param);
@@ -109,8 +108,6 @@ class mobileControl
         $client = strtolower(trim($_SERVER['HTTP_CLIENT_TYPE']));
         $version = trim($_SERVER['HTTP_CLIENT_VERSION']);
 
-        Log::record("client_type = {$client}",Log::DEBUG);
-
         if (empty($client)) {
             $client = $_POST['client_type'];
         } else {
@@ -155,7 +152,7 @@ class mobileControl
 
     static public function outerr($code, $msg = '', $page = '',$type = NULL)
     {
-        static $json_clients = array('android', 'ios','mini');
+        static $json_clients = ['android', 'ios','mini'];
 
         if(!empty($type)) {
             $show_type = $type;
@@ -210,7 +207,7 @@ class mobileControl
 
     static public function outsuccess($data, $page = '',$type = NULL)
     {
-        static $json_clients = array('android', 'ios','mini');
+        static $json_clients = ['android', 'ios','mini'];
 
         if(!empty($type)) {
             $show_type = $type;

+ 16 - 22
mobile/control/index.php

@@ -111,38 +111,32 @@ class indexControl extends specialControl
     public function room_inviteOp()
     {
         $room_id = intval($_GET['room_id']);
-        $inviter = intval($_GET["inviter"]);
+        $relay_id = intval($_GET["relay_id"]);
 
-//        if(session_helper::need_wechat_author())
-//        {
-//            $_SESSION['client_type'] = 'wap';
-////            define('SERVER_TYPE','panda');
-//            $author = new thrid_author\wxauthor();
-//            $url = author_url::room_invite_url($room_id,$inviter);
-//            $url = $author->enter($url);
-//            Log::record("url:$url",Log::DEBUG);
-//            return self::outsuccess(['direct_uri' => $url],"redirect");
-//        }
-
-//        $invitee = [session_helper::memberid()];
-        $invitee = [39682];
-
-        $result = room\factory_client::instance()->invite($room_id,$inviter,$invitee);
+        if(session_helper::need_wechat_author())
+        {
+            $_SESSION['client_type'] = 'wap';
+            $author = new thrid_author\wxauthor();
+            $url = author_url::room_invite_url($room_id,$relay_id);
+            $url = $author->enter($url);
+            Log::record("url:$url",Log::DEBUG);
+            return self::outsuccess(['direct_uri' => $url],"redirect");
+        }
 
-        if(util::from_wechat() == false){
+        $result = room\factory_client::instance()->invite($room_id,$relay_id,[session_helper::memberid()]);
+        if(session_helper::isapp())
+        {
             $_SESSION['client_type'] = 'ajax';
             if($result === false) {
                 return self::outerr(errcode::ErrRoom,"进入失败");
-            }
-            else
-            {
+            } else {
                 $members = member_info::get_members($result['newusers']);
                 $result['invitees'] = $members;
                 $result["url"] = BASE_SITE_URL.'/mobile/index.php?act=member_talk&op=room_detail&talk_type=room&talk_id='.$result['room'];
                 return self::outsuccess($result);
             }
-        }else{
-            //todo 修改成同时兼容APP请求返回打开回话和微信返回打开小程序
+        }
+        else {
             $_SESSION['client_type'] = 'wap';
             return self::outsuccess(null,"talk/share_bonus");
         }

+ 0 - 2
mobile/control/member_fcode.php

@@ -30,8 +30,6 @@ class member_fcodeControl extends mbMemberControl
         $items = $mod_fcode->getFcodeList(array('mobile' => session_helper::mobile()),'*','fc_state asc,usable_time desc,fc_id asc',$this->page_size());
         $page_count = $mod_fcode->gettotalpage();
 
-        Log::record("pages={$page_count},pagesize={$this->page_size()},pageno={$this->page_no()} curpage={$_GET['curpage']}");
-
         if($this->page_no() == 1)
         {
             if(isset($_SESSION['fcodes'])) {