shish 3 ani în urmă
părinte
comite
48ea8d4e1a
1 a modificat fișierele cu 45 adăugiri și 0 ștergeri
  1. 45 0
      console/controllers/ProductController.php

+ 45 - 0
console/controllers/ProductController.php

@@ -5,6 +5,7 @@ namespace console\controllers;
 use biz\item\classes\PtItemClass;
 use biz\product\classes\ProductClass;
 use biz\product\models\Product;
+use biz\shop\classes\ShopClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\models\Item;
 use yii\console\Controller;
@@ -13,6 +14,50 @@ use Yii;
 class ProductController extends Controller
 {
 
+    public function actionChangeSk()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $id = 36523;
+        //$id = 520;
+        $shop = ShopClass::getById($id, true);
+        $mainId = $shop->mainId ?? 0;
+
+        $sjId = $shop->sjId ?? 0;
+        $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
+
+        $default = $shop->default ?? 0;
+
+        $productList = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', 'id', true);
+
+        if (!empty($productList)) {
+            foreach ($productList as $product) {
+                $price = $product->price ?? 0;
+                $skMore = $product->skMore ?? 0;
+                $skPrice = bcadd($price, $skMore, 2);
+                $product->skPrice = $skPrice;
+                $product->save();
+                $ptItemId = $product->itemId ?? 0;
+                if ($default == 1) {
+                    foreach ($chainShopList as $chain) {
+                        if ($chain->id == $shop->id) {
+                            continue;
+                        }
+                        $chainMainId = $chain->mainId ?? 0;
+                        $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'ptItemId' => $ptItemId], true);
+                        if (!empty($chainProduct)) {
+                            $chainProduct->skPrice = $skPrice;
+                            $chainProduct->save();
+                        }
+                    }
+                }
+            }
+        }
+
+
+    }
+
     //修改散客比花店价格贵 ssh 20220609
     public function actionSkMore()
     {