ensureDbConnection(); $data = unserialize($msg->body); if (!is_array($data)) { noticeUtil::push("生日赠礼消费者报错:Invalid message format"); return ConsumerInterface::MSG_REJECT; } $type = $data['type'] ?? null; $result = false; if ($type == 'birthday_gift_expire') { $giftId = intval($data['giftId'] ?? 0); $result = $this->runWithDbReconnect(function () use ($giftId) { return BirthdayGiftClass::expireById($giftId); }); } else { noticeUtil::push("生日赠礼消费者未知 type: {$type}"); $result = true; } return $result ? ConsumerInterface::MSG_ACK : ConsumerInterface::MSG_ACK; } catch (\Exception $e) { noticeUtil::push("生日赠礼消费者报错:" . $e->getMessage()); return ConsumerInterface::MSG_ACK; } } }