|
|
@@ -30,7 +30,7 @@ class stockConsumer implements ConsumerInterface
|
|
|
// 反序列化消息体
|
|
|
$data = unserialize($msg->body);
|
|
|
if (!is_array($data)) {
|
|
|
- noticeUtil::push("库存的消费者报错:Invalid notify message format: {$msg->body}", '15280215347');
|
|
|
+ noticeUtil::push("库存的消费者报错:Invalid notify message format: {$msg->body}");
|
|
|
return ConsumerInterface::MSG_REJECT;
|
|
|
}
|
|
|
print_r($data);
|
|
|
@@ -44,11 +44,9 @@ class stockConsumer implements ConsumerInterface
|
|
|
case 'add':
|
|
|
$result = true;
|
|
|
echo '持久化OK---';
|
|
|
- print_r($data);
|
|
|
break;
|
|
|
case 'limit_buy_clear':
|
|
|
echo 'limit_buy_clear---';
|
|
|
- print_r($data);
|
|
|
$result = $this->clearOrderItemLimitBuy($data);
|
|
|
break;
|
|
|
default:
|
|
|
@@ -56,16 +54,8 @@ class stockConsumer implements ConsumerInterface
|
|
|
$result = false;
|
|
|
}
|
|
|
if ($result) {
|
|
|
- if ($type == 'limit_buy_clear') {
|
|
|
- Yii::info('限购延迟消息消费成功(ACK): ' . json_encode($data, JSON_UNESCAPED_UNICODE), __METHOD__);
|
|
|
- Yii::getLogger()->flush(true);
|
|
|
- }
|
|
|
return ConsumerInterface::MSG_ACK;
|
|
|
} else {
|
|
|
- if ($type == 'limit_buy_clear') {
|
|
|
- Yii::warning('限购延迟消息消费失败,准备重入队: ' . json_encode($data, JSON_UNESCAPED_UNICODE), __METHOD__);
|
|
|
- Yii::getLogger()->flush(true);
|
|
|
- }
|
|
|
noticeUtil::push("库存的消费者报错:Stock message processing failed");
|
|
|
//return ConsumerInterface::MSG_REQUEUE;
|
|
|
return ConsumerInterface::MSG_ACK;
|
|
|
@@ -87,40 +77,29 @@ class stockConsumer implements ConsumerInterface
|
|
|
{
|
|
|
$productId = intval($data['productId'] ?? 0);
|
|
|
if ($productId <= 0) {
|
|
|
- noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 productId', '15280215347');
|
|
|
+ noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 productId');
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$clearAt = intval($data['clearAt'] ?? 0);
|
|
|
if ($clearAt <= 0) {
|
|
|
- noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 clearAt', '15280215347');
|
|
|
+ noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 clearAt');
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// 旧消息直接忽略,避免“先到期的旧消息”提前清空
|
|
|
if (!ProductClass::checkLimitBuyClearMessage($productId, $clearAt)) {
|
|
|
- Yii::info('限购延迟消息已忽略(旧消息): ' . json_encode([
|
|
|
- 'productId' => $productId,
|
|
|
- 'clearAt' => $clearAt,
|
|
|
- ], JSON_UNESCAPED_UNICODE), __METHOD__);
|
|
|
- Yii::getLogger()->flush(true);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$result = ProductClass::clearLimitBuyByProductId($productId);
|
|
|
if ($result) {
|
|
|
ProductClass::clearLimitBuyClearMark($productId);
|
|
|
- Yii::info('限购字段清理完成: ' . json_encode([
|
|
|
- 'productId' => $productId,
|
|
|
- 'clearAt' => $clearAt,
|
|
|
- ], JSON_UNESCAPED_UNICODE), __METHOD__);
|
|
|
- Yii::getLogger()->flush(true);
|
|
|
} else {
|
|
|
- Yii::warning('限购字段清理失败: ' . json_encode([
|
|
|
+ noticeUtil::push('限购字段清理失败: ' . json_encode([
|
|
|
'productId' => $productId,
|
|
|
'clearAt' => $clearAt,
|
|
|
- ], JSON_UNESCAPED_UNICODE), __METHOD__);
|
|
|
- Yii::getLogger()->flush(true);
|
|
|
+ ], JSON_UNESCAPED_UNICODE));
|
|
|
}
|
|
|
return $result;
|
|
|
}
|