fix(chat): 修复消息事务中的 null 取下标(PHP 7.4 抛出 ErrorException)
企微入口 processMessages 在事务中捕获到 Trying to access array offset on value of type null:消息"打包视频+单号"走 dabaoVideo -> getOrderInfoByPostnum 时,Express 表查不到该单号,find() 返回 null,随后直接取 ["TRADEORDER"]。 PHP 7.4 起该 notice 被抛成异常,导致整条消息事务回滚、无回复。 - getOrderInfoByPostnum:先取 TRADEORDER 到变量并用 ?? 兜底,4 处引用统一 - fastruku:仓库未取到时 ["operatorID"] 加 ?? 0 - createOrder:群未登记时 ['isOrder'] 用 ?? 0 兜底 - createPostnum:3 处 Wsdl::webservice 的仓库参数补 ?? 兜底 - grabnum(): 为空时改用 empty() 判断,避免 notice - qiwe processMessages 事务失败日志补充出错文件与行号,便于定位 以上均为等价语义,仅消除 PHP 7.4 下的 notice/异常。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a73f3b1c2a
commit
c4aa873bea
@ -115,7 +115,7 @@ class Index extends Frontend
|
|||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
\think\Log::error('消息处理事务失败: ' . $e->getMessage());
|
\think\Log::error('消息处理事务失败: ' . $e->getMessage() . ' @ ' . $e->getFile() . ':' . $e->getLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -756,7 +756,7 @@ class Chat extends Frontend
|
|||||||
$this->redis->set("kdksjdksaj1",json_encode($results));
|
$this->redis->set("kdksjdksaj1",json_encode($results));
|
||||||
$WAREHOUSE = $WarehouseModel->field("kjrkSpaceId,operatorID")->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
|
$WAREHOUSE = $WarehouseModel->field("kjrkSpaceId,operatorID")->where(["WAREHOUSEID"=>$WAREHOUSEID])->find();
|
||||||
$kjrkSpaceId = $WAREHOUSE['kjrkSpaceId']??0;
|
$kjrkSpaceId = $WAREHOUSE['kjrkSpaceId']??0;
|
||||||
$userid = $WAREHOUSE["operatorID"];
|
$userid = $WAREHOUSE["operatorID"] ?? 0;
|
||||||
if(!$kjrkSpaceId){
|
if(!$kjrkSpaceId){
|
||||||
$backMsg = $this->backMsg($from,"仓库未设置快捷入库库位");
|
$backMsg = $this->backMsg($from,"仓库未设置快捷入库库位");
|
||||||
$msgs = array_merge($msgs,$backMsg);
|
$msgs = array_merge($msgs,$backMsg);
|
||||||
@ -984,7 +984,7 @@ _________________________________________________________
|
|||||||
$addr_info = $this->getAddress($result['address']);
|
$addr_info = $this->getAddress($result['address']);
|
||||||
$RoomsModel = $this->SOURCE == "wx" ? $this->RoomsModel : $this->qiweRoomsModel;
|
$RoomsModel = $this->SOURCE == "wx" ? $this->RoomsModel : $this->qiweRoomsModel;
|
||||||
$roominfo = $RoomsModel->where(["room_id"=>$from['fromid']])->find();//货主群聊
|
$roominfo = $RoomsModel->where(["room_id"=>$from['fromid']])->find();//货主群聊
|
||||||
if(!$roominfo['isOrder']){
|
if(!($roominfo['isOrder'] ?? 0)){
|
||||||
$text = "群未开启自动抓取建单,如有需要,联系客服开启\n";
|
$text = "群未开启自动抓取建单,如有需要,联系客服开启\n";
|
||||||
}else{
|
}else{
|
||||||
if(!isset($addr_info->result->address)){
|
if(!isset($addr_info->result->address)){
|
||||||
@ -2636,7 +2636,7 @@ _________________________________________________________
|
|||||||
}else{
|
}else{
|
||||||
$text.="执行回传任务...\n";
|
$text.="执行回传任务...\n";
|
||||||
try {
|
try {
|
||||||
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"],intval($WAREHOUSE["operatorID"]),$ids],'synOrder');
|
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"] ?? null,intval($WAREHOUSE["operatorID"] ?? 0),$ids],'synOrder');
|
||||||
$text.="回传任务结束,正在检查...\n";
|
$text.="回传任务结束,正在检查...\n";
|
||||||
$order = $this->getOrderInfoBySourceOrderCode($postnum,$from);
|
$order = $this->getOrderInfoBySourceOrderCode($postnum,$from);
|
||||||
if($order["SYNFLAG"]){
|
if($order["SYNFLAG"]){
|
||||||
@ -2651,7 +2651,7 @@ _________________________________________________________
|
|||||||
}else{
|
}else{
|
||||||
$text.="平台单号:".$postnum." 未分配快递单号,开始分配...\n";
|
$text.="平台单号:".$postnum." 未分配快递单号,开始分配...\n";
|
||||||
try {
|
try {
|
||||||
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"],intval($WAREHOUSE["operatorID"]),$ids],'createPostNum');
|
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"] ?? null,intval($WAREHOUSE["operatorID"] ?? 0),$ids],'createPostNum');
|
||||||
} catch (Exception $e ) {
|
} catch (Exception $e ) {
|
||||||
}
|
}
|
||||||
$text.="分配任务结束,正在检查单号...\n";
|
$text.="分配任务结束,正在检查单号...\n";
|
||||||
@ -2659,7 +2659,7 @@ _________________________________________________________
|
|||||||
if($order["POSTNUM"] && $order["POSTFLAG"]){
|
if($order["POSTNUM"] && $order["POSTFLAG"]){
|
||||||
$text.="分配运单号成功,运单号:{$order["POSTNUM"]},执行回传任务...\n";
|
$text.="分配运单号成功,运单号:{$order["POSTNUM"]},执行回传任务...\n";
|
||||||
try {
|
try {
|
||||||
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"],intval($WAREHOUSE["operatorID"]),$ids],'synOrder');
|
$data = Wsdl::webservice([$WAREHOUSE["WAREHOUSEID"] ?? null,intval($WAREHOUSE["operatorID"] ?? 0),$ids],'synOrder');
|
||||||
$text.="回传任务结束,正在检查...\n";
|
$text.="回传任务结束,正在检查...\n";
|
||||||
$order = $this->getOrderInfoBySourceOrderCode($postnum,$from);
|
$order = $this->getOrderInfoBySourceOrderCode($postnum,$from);
|
||||||
if($order["SYNFLAG"]){
|
if($order["SYNFLAG"]){
|
||||||
@ -3022,17 +3022,18 @@ _________________________________________________________
|
|||||||
private function getOrderInfoByPostnum($postnum,$from){
|
private function getOrderInfoByPostnum($postnum,$from){
|
||||||
$status = 0;
|
$status = 0;
|
||||||
$expressRow = $this->ExpressModel->where(["POSTNUM"=>$postnum])->find();
|
$expressRow = $this->ExpressModel->where(["POSTNUM"=>$postnum])->find();
|
||||||
|
$tradeOrder = $expressRow['TRADEORDER'] ?? '';
|
||||||
if(isset($from["isMe"])){
|
if(isset($from["isMe"])){
|
||||||
if(!$expressRow["TRADEORDER"]){
|
if(!$tradeOrder){
|
||||||
$where = '(POSTNUM = "'.$postnum.'")';
|
$where = '(POSTNUM = "'.$postnum.'")';
|
||||||
}else{
|
}else{
|
||||||
$where = '(SOURCEID="'.$expressRow["TRADEORDER"].'" or POSTNUM = "'.$postnum.'")';
|
$where = '(SOURCEID="'.$tradeOrder.'" or POSTNUM = "'.$postnum.'")';
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(!$expressRow["TRADEORDER"]){
|
if(!$tradeOrder){
|
||||||
$where = '(POSTNUM = "'.$postnum.'") and STOREID='.$from["storeid"];
|
$where = '(POSTNUM = "'.$postnum.'") and STOREID='.$from["storeid"];
|
||||||
}else{
|
}else{
|
||||||
$where = '(SOURCEID="'.$expressRow["TRADEORDER"].'" or POSTNUM = "'.$postnum.'") and STOREID='.$from["storeid"];
|
$where = '(SOURCEID="'.$tradeOrder.'" or POSTNUM = "'.$postnum.'") and STOREID='.$from["storeid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -242,7 +242,7 @@ class Order extends Frontend
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return json(["grabnum"=>$last['grabnum']?$last['grabnum']:null,"count"=>$count,"hour_sum"=>$hour_sum]);
|
return json(["grabnum"=>!empty($last['grabnum'])?$last['grabnum']:null,"count"=>$count,"hour_sum"=>$hour_sum]);
|
||||||
}
|
}
|
||||||
public function closeall(){
|
public function closeall(){
|
||||||
$first = $Gongzuomodel->where(["endtime"=>0])->select();
|
$first = $Gongzuomodel->where(["endtime"=>0])->select();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user