Bläddra i källkod

更新用户互动时间规则

zqwang 1 år sedan
förälder
incheckning
ce300b1730

+ 12 - 12
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -127,15 +127,16 @@ class WechatOpenPlatformController extends CatchController
 
         $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
         $openPlatform = WechatOpenPlatformService::buildApplication($componentInfo);
-        myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
+
         $server = $openPlatform->server;
         $message = $server->getMessage();
-        myLog("wx-xiaoxi")->info([
-            'authorizer_appid' => $authorizer_appid,
-            'component_appid' => $component_appid,
-            'param' => $request->all(),
-            'msg' => $message,
-        ]);
+        // myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
+        // myLog("wx-xiaoxi")->info([
+        //     'authorizer_appid' => $authorizer_appid,
+        //     'component_appid' => $component_appid,
+        //     'param' => $request->all(),
+        //     'msg' => $message,
+        // ]);
         $appInfo = WechatOpenPlatformService::getRefreshToken($authorizer_appid,$component_appid);
         $wechatAppId = getProp($appInfo,'id');
 
@@ -143,13 +144,12 @@ class WechatOpenPlatformController extends CatchController
         unset($appInfo);
 
         $app->server->push(function ($message) use($app,$authorizer_appid,$wechatAppId) {
-            myLog("wx-xiaoxi")->info("----文本消息---");
-            myLog("wx-xiaoxi")->info("体消息:");
-            myLog("wx-xiaoxi")->info($message);
+            // myLog("wx-xiaoxi")->info("----文本消息---");
+            // myLog("wx-xiaoxi")->info("体消息:");
+            // myLog("wx-xiaoxi")->info($message);
             return WechatCommonService::handleMessage($app,$wechatAppId ,$authorizer_appid,$message);
         });
-
-        myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
+        // myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
         return $app->server->serve()->send();
     }
 }

+ 14 - 14
modules/WechatPlatform/Services/WechatCommonService.php

@@ -48,19 +48,20 @@ class WechatCommonService extends BaseService
                 // 更新用户活跃时间
                 self::updateUserActivityTime($app, $appid, $message['FromUserName']);
                 return self::handleTextMessage($wechatInfoId, $message);
-            case 'image':
-                return '收到图片消息';
-            case 'voice':
-                return '收到语音消息';
-            case 'video':
-                return '收到视频消息';
-            case 'location':
-                return '收到坐标消息';
-            case 'link':
-                return '收到链接消息';
-            case 'file':
-                return '收到文件消息';
+            // case 'image':
+            //     return '收到图片消息';
+            // case 'voice':
+            //     return '收到语音消息';
+            // case 'video':
+            //     return '收到视频消息';
+            // case 'location':
+            //     return '收到坐标消息';
+            // case 'link':
+            //     return '收到链接消息';
+            // case 'file':
+            //     return '收到文件消息';
             default:
+                self::updateUserActivityTime($app, $appid, $message['FromUserName']);
                 return '收到其它消息';
         }
         return "";
@@ -102,6 +103,7 @@ class WechatCommonService extends BaseService
         ];
         if (is_empty($info)) {
             $data = self::getUserInfo($app,$appid,$openId);
+            $data['active_at'] = time();
         }else{
             if ($info->uid == 0){
                 $data['uid'] = intval(DB::table('wechat_miniprogram_users')->where('unionid', $info->unionid)->value('id'));
@@ -145,7 +147,6 @@ class WechatCommonService extends BaseService
             $data = self::getUserInfo($app,$appid,$openId);
             WechatOfficialUserInfo::updateOrCreate(['mp_openid' => $data['mp_openid'], 'gzh_appid' => $data['gzh_appid']], $data);
         }else{
-
             if (!is_empty($info)){
                 if ($info->uid == 0){
                     $data['uid'] = intval(DB::table('wechat_miniprogram_users')->where('unionid', $info->unionid)->value('id'));
@@ -172,7 +173,6 @@ class WechatCommonService extends BaseService
             'is_subscribe' => $user['subscribe'],
             'subscribe_time' => $user['subscribe_time'],
             'subscribe_time_str' => get_date($user['subscribe_time']),
-            'active_at' => time(),
             'uid' => intval(DB::table('wechat_miniprogram_users')->where('unionid', $user['unionid'])->value('id')),
         ];
     }