public function webhook(Request $request){$updates=$request->all();Log::info($updates);if(!empty($updates)){$latestUpdate=end($updates);$message=$latestUpdate;if(($message&&isset($message['chat'])&&$message['chat']['id']==$this->checkChatId)||$message&&isset($message['message'])&&$message['message']['chat']['id']==$this->checkChatId){$this->checkBillChat($updates)}}}function checkBillChat($updates){if(isset($updates['message'])){$message=$updates['message']}if(isset($message)&&isset($message['chat'])&&isset($message['text'])&&$message['chat']['id']==$this->checkChatId){return $this->checkOrder($message['text'],$message['message_id'])}if(isset($message['text'])&&strpos($message['text'],'@')!==false){if(preg_match('/(?<=验证码)\d{6}/',$message['text'],$matches)){return $this->checkVfCode($matches)}if(preg_match('/获取群组id/',$message['text'],$matches)){if(!$matches)return;sendTgMsg('当前群组id：'.$message['chat']['id'],$message['chat']['id'])}}else if(isset($message['text'])){sendTgMsg('有人在访问机器人，他说：'.$message['text'])}if(isset($updates['callback_query'])){$callback_query=$updates['callback_query'];$callbackData=$updates['callback_query']['data'];$callbackDataSplit=explode("#",$callbackData);if($callbackDataSplit[0]==='balance'){$this->checkPhoneBalance($callbackDataSplit[1],$callback_query['message']['message_id']);return}else if($callbackDataSplit[0]==='callBill'){$callInfo=$this->callbackOrder($callbackDataSplit[1],$callback_query['message']['message_id']);$status=$callInfo?2:1;$conditions=['business_order'=>$callbackDataSplit[1]];$data=['business_order'=>$callbackDataSplit[1],'status_order'=>$status,'created_at'=>date("Y-m-d H:i:s",time()),'remark'=>'商户已回调',];$this->creadRecord($conditions,$data);return}else if($callbackDataSplit[0]==='callCard'){$flag=DB::table('telegram_phone_bd')->where('business_order',$callbackDataSplit[1])->where('status_card',2)->first();if($flag){sendTgMsg('该订单已回调卡单',$this->checkChatId,'',$callback_query['message']['message_id']);return}$callInfo=$this->callbackCard($callbackDataSplit[1],$callbackDataSplit[2],$callback_query['message']['message_id']);$callInfo=json_decode($callInfo);$conditions=['business_order'=>$callbackDataSplit[1]];if($callInfo->status==='2'){$data=['business_order'=>$callbackDataSplit[1],'status_card'=>$callInfo->status,'is_split_bill'=>$callInfo->is_split,'remark'=>$callInfo->resultString,'hf_orderid_split'=>$callInfo->hf_orderid_split,'hf_orderid'=>$callInfo->hf_orderid,'phone'=>$callbackDataSplit[2],'created_at'=>date("Y-m-d H:i:s",time())]}else{$data=['business_order'=>$callbackDataSplit[1],'status_card'=>$callInfo->status,'remark'=>$callInfo->resultString,'created_at'=>date("Y-m-d H:i:s",time())]}$this->creadRecord($conditions,$data);return}else if($callbackDataSplit[0]==='userOverTime'){$conditions=['business_order'=>$callbackDataSplit[1]];$data=['business_order'=>$callbackDataSplit[1],'status_order'=>1,'remark'=>'超时或修改支付','created_at'=>date("Y-m-d H:i:s",time())];$this->creadRecord($conditions,$data);$message=$callbackDataSplit[1]."\r\n已确认超时";sendTgMsg($message,$this->checkChatId,'',$callback_query['message']['message_id']);return}else if($callbackDataSplit[0]==='selfFinish'){$conditions=['business_order'=>$callbackDataSplit[1]];$data=['business_order'=>$callbackDataSplit[1],'status_card'=>2,'remark'=>'已在后台处理','created_at'=>date("Y-m-d H:i:s",time())];$this->creadRecord($conditions,$data);$message=$callbackDataSplit[1]."\r\n已确认卡单回调";sendTgMsg($message,$this->checkChatId,'',$callback_query['message']['message_id']);return}}}
请优化我的代码