"/pages/video/index?video_id={$videoId}&sequence={$sequence}"]; } /** * 微信消息推送处理 * name: handleMessage * @param $app * @param $wechatInfoId 公众号授权信息id * @param $appid 公众号APPID * @param $message * @return string|void * date 2023/07/10 16:04 */ public static function handleMessage($app,$wechatInfoId,$appid, $message) { switch ($message['MsgType']) { case 'event': return '收到事件消息'; break; case 'text': // 更新用户活跃时间 self::updateUserActivityTime($app,$appid,$message['FromUserName']); return self::handleTextMessage($wechatInfoId,$message); case 'image': return '收到图片消息'; break; case 'voice': return '收到语音消息'; break; case 'video': return '收到视频消息'; break; case 'location': return '收到坐标消息'; break; case 'link': return '收到链接消息'; break; case 'file': return '收到文件消息'; default: return '收到其它消息'; break; } return ""; } /** * 文本纤细处理 * name: handleTextMessage * @param $appid * @param $content * date 2023/07/10 15:03 */ private static function handleTextMessage($wechatAppId, $msg) { $content = $msg['Content']; if ($content == "pk"){ return $msg['FromUserName'] ; } $back = WechatKeywordsService::getKeywordsByWords($content,$wechatAppId); $back = $back ?: ""; return $back; } private static function updateUserActivityTime($app,$appid,$opendId) { $info = WechatOfficialUserInfo::query()->where('mp_openid',$opendId)->where('gzh_appid',$appid)->first(); $data = [ 'mp_openid' => $opendId, 'gzh_appid' => $appid, 'active_at' => time(), ]; if (is_empty($info)){ $user = $app->user->get(); $data = [ 'mp_openid' => $opendId, 'gzh_appid' => $appid, 'unionid' => $user['unionid'], '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')), ]; } WechatOfficialUserInfo::updateOrCreate(['mp_openid' => $data['mp_openid'],'gzh_appid' => $data['gzh_appid']],$data); } }