shish 4 лет назад
Родитель
Сommit
17e1f2f01b
1 измененных файлов с 24 добавлено и 0 удалено
  1. 24 0
      console/controllers/ProductController.php

+ 24 - 0
console/controllers/ProductController.php

@@ -36,4 +36,28 @@ class ProductController extends Controller
         }
     }
 
+    // ./yii product/sk-price
+    public function actionSkPrice()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $list = ProductClass::getAllByCondition([], null, '*', null, true);
+        if (empty($list)) {
+            return false;
+        }
+        foreach ($list as $key => $item) {
+            $price = $item->price ?? 0;
+            $skAddPrice = $item->skAddPrice ?? 0;
+            $addPrice = $item->addPrice ?? 0;
+            $diff = bcsub($skAddPrice, $addPrice, 2);
+            $currentPrice = $price;
+            if ($diff > 0) {
+                $currentPrice = bcadd($price, $diff, 2);
+            }
+            $item->skPrice = $currentPrice;
+            $item->save();
+        }
+    }
+
 }