|
|
@@ -7,6 +7,7 @@
|
|
|
namespace common\components\rabbitmq;
|
|
|
|
|
|
use bizGhs\order\classes\OrderItemClass;
|
|
|
+use bizGhs\product\classes\ProductClass;
|
|
|
use common\components\noticeUtil;
|
|
|
use mikemadisonweb\rabbitmq\components\ConsumerInterface;
|
|
|
use PhpAmqpLib\Message\AMQPMessage;
|
|
|
@@ -71,11 +72,26 @@ class stockConsumer implements ConsumerInterface
|
|
|
{
|
|
|
$productId = intval($data['productId'] ?? 0);
|
|
|
if ($productId <= 0) {
|
|
|
- noticeUtil::push('库存的消费者报错:limit_buy_clear 缺少 productId', '15280215347');
|
|
|
- return false;
|
|
|
+ noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 productId', '15280215347');
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- return OrderItemClass::clearLimitBuyByProductId($productId);
|
|
|
+ $clearAt = intval($data['clearAt'] ?? 0);
|
|
|
+ if ($clearAt <= 0) {
|
|
|
+ noticeUtil::push('取消限购的消费者报错:limit_buy_clear 缺少 clearAt', '15280215347');
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 旧消息直接忽略,避免“先到期的旧消息”提前清空
|
|
|
+ if (!ProductClass::checkLimitBuyClearMessage($productId, $clearAt)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = OrderItemClass::clearLimitBuyByProductId($productId);
|
|
|
+ if ($result) {
|
|
|
+ ProductClass::clearLimitBuyClearMark($productId);
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
}
|