Kaynağa Gözat

通知信息

shish 8 ay önce
ebeveyn
işleme
aceb587a89

+ 3 - 2
common/components/rabbitmq/notifyConsumer.php

@@ -8,6 +8,7 @@ namespace common\components\rabbitmq;
 
 use biz\wx\classes\WxMessageClass;
 use bizGhs\order\classes\OrderClass;
+use bizHd\device\classes\HdDeviceClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\shop\classes\ShopClass;
 use common\components\noticeUtil;
@@ -37,7 +38,7 @@ class notifyConsumer implements ConsumerInterface
                 noticeUtil::push("通知的消费者报错:Invalid notify message format: {$msg->body}", '15280215347');
                 return ConsumerInterface::MSG_REJECT;
             }
-            //print_r($data);
+            print_r($data);
             // 根据通知类型分发处理
             $type = $data['type'] ?? null;
             switch ($type) {
@@ -106,7 +107,7 @@ class notifyConsumer implements ConsumerInterface
         $cg = PurchaseClass::getById($cgId, true);
         $shopId = $cg->shopId ?? 0;
         $shop = ShopClass::getById($shopId, true);
-        $allDevices = \bizHd\device\classes\HdDeviceClass::getAllByCondition(['shopId' => $shopId]);
+        $allDevices = HdDeviceClass::getAllByCondition(['shopId' => $shopId]);
         $cids = array_column($allDevices, 'clientId');
         $title = '买花成功';
         $shopName = $shop->merchantName . ($shop->shopName != '首店' ? '(' . $shop->shopName . ')' : '');

+ 8 - 59
common/components/rabbitmq/stockConsumer.php

@@ -32,78 +32,27 @@ class stockConsumer implements ConsumerInterface
                 noticeUtil::push("库存的消费者报错:Invalid notify message format: {$msg->body}", '15280215347');
                 return ConsumerInterface::MSG_REJECT;
             }
-            //print_r($data);
+            print_r($data);
             // 根据操作类型分发处理
-            $action = $data['action'] ?? null;
-            switch ($action) {
+            $type = $data['type'] ?? null;
+            switch ($type) {
                 case 'add':
-                    $result = $this->handleAddStock($data);
-                    break;
-                case 'reduce':
-                    $result = $this->handleReduceStock($data);
-                    break;
-                case 'adjust':
-                    $result = $this->handleAdjustStock($data);
+                    $result = true;
                     break;
                 default:
-                    Yii::warning("Unknown stock action: {$action}", 'rabbitmq.stock');
+                    noticeUtil::push("库存的消费者报错,未知 type: {$type}");
                     $result = false;
             }
-            
             if ($result) {
-                Yii::info("Stock message processed successfully", 'rabbitmq.stock');
                 return ConsumerInterface::MSG_ACK;
             } else {
-                Yii::error("Stock message processing failed", 'rabbitmq.stock');
+                noticeUtil::push("库存的消费者报错:Stock message processing failed");
                 return ConsumerInterface::MSG_REQUEUE;
             }
-            
         } catch (\Exception $e) {
-            Yii::error("Stock consumer exception: " . $e->getMessage(), 'rabbitmq.stock');
+            noticeUtil::push("库存的消费者报错:" . $e->getMessage());
             return ConsumerInterface::MSG_REQUEUE;
         }
     }
-    
-    /**
-     * 处理库存补充(增加)
-     * 
-     * @param array $data 消息数据,包含 material_id, quantity 等
-     * @return bool 处理结果
-     */
-    private function handleAddStock($data)
-    {
-        // TODO: 实现库存增加业务逻辑
-        // 调用对应的 Service 或 Class 层处理
-        // 例如: StockClass::addStock($data);
-        return true;
-    }
-    
-    /**
-     * 处理库存扣减
-     * 
-     * @param array $data 消息数据,包含 material_id, quantity 等
-     * @return bool 处理结果
-     */
-    private function handleReduceStock($data)
-    {
-        // TODO: 实现库存扣减业务逻辑
-        // 调用对应的 Service 或 Class 层处理
-        // 例如: StockClass::reduceStock($data);
-        return true;
-    }
-    
-    /**
-     * 处理库存调整
-     * 
-     * @param array $data 消息数据,包含 material_id, quantity, type 等
-     * @return bool 处理结果
-     */
-    private function handleAdjustStock($data)
-    {
-        // TODO: 实现库存调整业务逻辑
-        // 调用对应的 Service 或 Class 层处理
-        // 例如: StockClass::adjustStock($data);
-        return true;
-    }
-}
 
+}