From 276a6ef37dcfaa15fd75c50d6de96d9622cc4863 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Thu, 22 Oct 2026 14:23:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=E4=BF=AE=E5=A4=8D=20PHP=207.4=20?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=BC=95=E5=8F=91=E7=9A=84=E5=85=B6=E4=BD=99?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=EF=BC=88implode=20=E5=BC=83=E7=94=A8?= =?UTF-8?q?=E3=80=81null=20=E5=8F=96=E4=B8=8B=E6=A0=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全量检查 chat 相关代码(Chat.php / qiwe/Index.php / library/chat/Orders.php / library/qiwe / new_wms/Forward.php),补齐升级后才暴露的问题: 1. implode 参数反序(4 处,PHP 7.4 起 E_DEPRECATED,TP5 会抛成异常): Chat.php 群列表/指令/门店查询里 implode(\," and ") -> implode(" and ", \),输出 SQL 完全一致 2. carriage 查运费:getOrderInfoByPostnum 未命中返回 false, if(\["ID"]) 在 7.4 会抛 bool 取下标 -> 改为 if(\ && \["ID"]) 3. kdroomMessageExplpde2 队列消费:json_decode 失败时 \ 为 null, 补 is_array 判断跳过脏数据 4. qiwe/Index.php 5 处接口返回 json_decode 后直接用 \["code"]: 补 \ && 前置判断(getRoomList/batchGetRoomDetails/ batchGetUserinfo/sendImage/sendFile),避免空返回时抛 notice 5. chat/Orders.php createOrderToWms:订单回查为 null 时取 POSTNUM/ID/ ERRORRECORDS 的兜底,改为 empty() 与 ?? 以上均为 7.4 兼容性修复,业务行为保持不变。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- application/index/controller/qiwe/Index.php | 10 +++++----- application/index/controller/wms/Chat.php | 13 ++++++++----- application/index/library/chat/Orders.php | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/application/index/controller/qiwe/Index.php b/application/index/controller/qiwe/Index.php index 23af098..e965841 100644 --- a/application/index/controller/qiwe/Index.php +++ b/application/index/controller/qiwe/Index.php @@ -942,7 +942,7 @@ class Index extends Frontend $result = $this->query->query("getRoomList", [$this->guid, $index]); $result = json_decode($result, true); - if ($result["code"] == 0) { + if ($result && $result["code"] == 0) { $data = $result["data"]; $roomList = $data["roomList"]; $insertDatas = []; @@ -992,7 +992,7 @@ class Index extends Frontend $result = json_decode($result, true); $insertDatas = []; - if ($result['code'] == 0) { + if ($result && $result['code'] == 0) { \think\Log::error('返回结果正常: '); $roomList = $result["data"]["roomList"]; @@ -1057,7 +1057,7 @@ class Index extends Frontend $result = json_decode($result, true); $insertDatas = []; - if ($result['code'] == 0) { + if ($result && $result['code'] == 0) { \think\Log::error('返回结果正常: '); $contactList = $result["data"]["contactList"]; \think\Log::error('返回结果正常: '.json_encode($contactList)); @@ -1161,7 +1161,7 @@ class Index extends Frontend //先通过URL上传文件获取fileId $result = $this->query->query("cdnBigUploadByUrl", [$this->guid, "照片.png",$imgUrl,1]); $result = json_decode($result, true); - if($result["code"] == 0){ + if($result && $result["code"] == 0){ $fileAesKey = $result["data"]["fileAesKey"]; $fileId = $result["data"]["fileId"]; $fileKey = $result["data"]["fileKey"]; @@ -1181,7 +1181,7 @@ class Index extends Frontend $filename = basename($fileUrl); $result = $this->query->query("cdnBigUploadByUrl", [$this->guid, $filename,$fileUrl,5]); $result = json_decode($result, true); - if($result["code"] == 0){ + if($result && $result["code"] == 0){ $fileAesKey = $result["data"]["fileAesKey"]; $fileId = $result["data"]["fileId"]; $fileKey = $result["data"]["fileKey"]; diff --git a/application/index/controller/wms/Chat.php b/application/index/controller/wms/Chat.php index 760c1d4..269cc58 100644 --- a/application/index/controller/wms/Chat.php +++ b/application/index/controller/wms/Chat.php @@ -1356,6 +1356,9 @@ _________________________________________________________ }else{ $count --; $msg = json_decode($msg,true); + if(!is_array($msg)){ + continue; + } $room = $RoomsModel->where(["STOREID"=>$msg["STOREID"],"auto_feedback_active"=>1])->find(); $Model = new \app\common\model\wms\Exceptionwmsorder; $Exceptionwmsorder_row = $Model->where(["POSTNUM"=>$msg["POSTNUM"]])->find(); @@ -1396,7 +1399,7 @@ _________________________________________________________ if($keyword){ array_push($wheres,'NAME like "%'.$keyword.'%"'); } - $where = implode($wheres," and "); + $where = implode(" and ", $wheres); $list = $this->RoomsModel->where($where)->limit(($page-1)*$pagesize,$pagesize)->order('id','desc')->select(); $count = $this->RoomsModel->where($where)->count(); return json(["rows"=>$list,"count"=>$count]); @@ -1413,7 +1416,7 @@ _________________________________________________________ if($keyword){ array_push($wheres,'NAME like "%'.$keyword.'%"'); } - $where = implode($wheres," and "); + $where = implode(" and ", $wheres); $list = $this->chatMethodsModel->where($where)->limit(($page-1)*$pagesize,$pagesize)->order('id','desc')->select(); $count = $this->chatMethodsModel->where($where)->count(); return json(["rows"=>$list,"count"=>$count]); @@ -1432,7 +1435,7 @@ _________________________________________________________ if($keyword){ array_push($wheres,'NAME like "%'.$keyword.'%"'); } - $where = implode($wheres," and "); + $where = implode(" and ", $wheres); $list = $this->RoomsModel->where($where)->limit(($page-1)*$pagesize,$pagesize)->select(); $count = $this->RoomsModel->where($where)->count(); return json(["rows"=>$list,"count"=>$count]); @@ -1593,7 +1596,7 @@ _________________________________________________________ if($keyword){ array_push($wheres,'TITLE like "%'.$keyword.'%"'); } - $where = implode($wheres," and "); + $where = implode(" and ", $wheres); $RoomsModel = $this->SOURCE == "wx" ? $this->RoomsModel : $this->qiweRoomsModel; $list = $this->StoreModel->where($where)->limit(($page-1)*$pagesize,$pagesize)->select(); $storeids = []; @@ -2910,7 +2913,7 @@ _________________________________________________________ foreach($postnums as $postnum){ try{ $order = $this->getOrderInfoByPostnum($postnum,$from); - if($order["ID"]){ + if($order && $order["ID"]){ $text = "{$postnum}\n"; $STOREID = $order["STOREID"]; $WAREHOUSEID = $order["WAREHOUSEID"]; diff --git a/application/index/library/chat/Orders.php b/application/index/library/chat/Orders.php index db0ed9a..4af5e33 100644 --- a/application/index/library/chat/Orders.php +++ b/application/index/library/chat/Orders.php @@ -427,11 +427,11 @@ class Orders $data = Wsdl::webservice([$order["warehouseid"],106300,$wmsorder->ID],'createPostNum'); $wmsorder = $orderModel->where(["SOURCEID"=>$order['ordercode']])->find(); - if(!$wmsorder["POSTNUM"]){ + if(empty($wmsorder["POSTNUM"])){ if($type==0){ - Wsdl::webservice([106300,$wmsorder["ID"]],"cancelOrderByIds"); + Wsdl::webservice([106300,($wmsorder["ID"] ?? null)],"cancelOrderByIds"); } - return [$type==0?2:4,"分配快递号失败,错误信息:\n".$wmsorder["ERRORRECORDS"],[]]; + return [$type==0?2:4,"分配快递号失败,错误信息:\n".($wmsorder["ERRORRECORDS"] ?? ''),[]]; }else{ if($type==1 && $order["postnum"]!=$wmsorder['POSTNUM']){ return [4,"新旧单号不一致,已通知快递拦截新单号,找吴菁处理,参数为(".json_encode($order_data).")",[]];