fix(chat): 修复 PHP 7.4 升级引发的其余告警(implode 弃用、null 取下标)

全量检查 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>
This commit is contained in:
liufumingren 2026-10-22 14:23:27 +08:00
parent c4aa873bea
commit 276a6ef37d
3 changed files with 16 additions and 13 deletions

View File

@ -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"];

View File

@ -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"];

View File

@ -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).")",[]];