shish před 1 rokem
rodič
revize
158a982e95

+ 1 - 1
app-ghs/controllers/LiveOrderController.php

@@ -23,7 +23,7 @@ class LiveOrderController extends BaseController
         if (!empty($has)) {
             util::fail('已经在转换了');
         }
-        $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+        $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId,'switchOrder'=>0], null, '*', null, true);
         if (empty($list)) {
             util::fail('没有记录需要转换');
         }

+ 0 - 2
console/controllers/LiveController.php

@@ -10,8 +10,6 @@ use Yii;
 class LiveController extends Controller
 {
 
-    public $sjId, $shopId, $sj;
-
     public function actionSeat()
     {
         if (getenv('YII_ENV') == 'production') {

+ 65 - 0
console/controllers/LiveOrderController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace console\controllers;
+
+use biz\shop\classes\ShopClass;
+use bizGhs\live\classes\LiveOrderClass;
+use common\components\noticeUtil;
+use yii\console\Controller;
+use Yii;
+
+class LiveOrderController extends Controller
+{
+
+    //每二分钟执行一次 ssh 20241006
+    public function actionSeat()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $shopList = ShopClass::getAllByCondition(['ptStyle'=>2],null,'id,ptStyle,shopName',null,true);
+        if(empty($shopList)){
+            return false;
+        }
+        foreach($shopList as $shop){
+            $mainId = $shop->mainId;
+            $shopName = $shop->shopName??'';
+            $sjName = $shop->merchantName??'';
+            $name = $sjName.' '.$shopName;
+            $cacheKey = 'live_order_' . $mainId;
+            $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+            if(empty($has)){
+                continue;
+            }
+            $connection = Yii::$app->db;
+            $transaction = $connection->beginTransaction();
+            try {
+
+                $list = LiveOrderClass::getAllByCondition(['mainId' => $mainId,'switchOrder'=>0], null, '*', null, true);
+                if(empty($list)){
+                    continue;
+                }
+                $arr = [];
+                foreach ($list as $live) {
+                    $addTime = $live->addTime;
+                    $date = date("Y-m-d", strtotime($addTime));
+                    $arr[$date] = 1;
+                }
+                if (count($arr) > 1) {
+                    noticeUtil::push($name." mainId:{$mainId} live order 有记录不是同一天的", '15280215347');
+                    continue;
+                }
+
+                //转换完了之后要清货位号!!!!!!!!!
+
+                $transaction->commit();
+                Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
+
+            } catch (\Exception $e) {
+                $transaction->rollBack();
+                $msg = $e->getMessage();
+                noticeUtil::push($name." mainId:{$mainId} live order 报错了:".$msg, '15280215347');
+            }
+        }
+    }
+
+}