ensureDbConnection(); // 反序列化消息体 $data = unserialize($msg->body); if (!is_array($data)) { noticeUtil::push("跑腿发单的消费者报错:Invalid notify message format: {$msg->body}", '15280215347'); return ConsumerInterface::MSG_REJECT; } //print_r($data); // 根据操作类型分发处理 $type = $data['type'] ?? null; $result = $this->runWithDbReconnect(function () use ($type, $data) { switch ($type) { case 'hd_pt_create_order': //花店跑腿开始下单 return \bizHd\express\classes\HdDeliveryOrderClass::beginCreateOrder($data); case 'ghs_pt_create_order': //供货商跑腿开始下单 return \bizGhs\express\classes\GhsDeliveryOrderClass::beginCreateOrder($data); default: noticeUtil::push("跑腿发单的消费者报错,不存在的类型: {$type}"); return false; } }); if ($result == ConsumerInterface::MSG_ACK) { return ConsumerInterface::MSG_ACK; } elseif ($result == ConsumerInterface::MSG_REJECT){ return ConsumerInterface::MSG_REJECT; } else { noticeUtil::push("跑腿发单的消费者报错:Notify message processing failed", '15280215347'); return ConsumerInterface::MSG_REQUEUE; } } catch (\Exception $e) { noticeUtil::push("跑腿发单的消费者报错:" . $e->getMessage()); return ConsumerInterface::MSG_REJECT; } } }