shish 3 lat temu
rodzic
commit
7c0a7932be
1 zmienionych plików z 13 dodań i 11 usunięć
  1. 13 11
      console/controllers/MqController.php

+ 13 - 11
console/controllers/MqController.php

@@ -15,19 +15,21 @@ class MqController extends Controller
     public function actionHdCgNoticeGhs()
     {
         $noticeKey = "hdCgNoticeGhs";
-        $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
-        if (!empty($json)) {
-            $arr = json_decode($json, true);
-            $orderId = $arr['orderId'] ?? 0;
-            if (!empty($orderId)) {
-                $order = OrderClass::getById($orderId, true);
-                $shopId = $order->shopId ?? 0;
-                $shop = ShopClass::getById($shopId, true);
-                if (!empty($shop)) {
-                    WxMessageClass::ghsHasNewOrderInform($shop, $order);
+        while ($count = Yii::$app->redis->executeCommand('LLEN', [$noticeKey])) {
+            $json = Yii::$app->redis->executeCommand('RPOP', [$noticeKey]);
+            if (!empty($json)) {
+                $arr = json_decode($json, true);
+                $orderId = $arr['orderId'] ?? 0;
+                if (!empty($orderId)) {
+                    $order = OrderClass::getById($orderId, true);
+                    $shopId = $order->shopId ?? 0;
+                    $shop = ShopClass::getById($shopId, true);
+                    if (!empty($shop)) {
+                        WxMessageClass::ghsHasNewOrderInform($shop, $order);
+                    }
                 }
+                print_r($arr);
             }
-            print_r($arr);
         }
     }