shish 1 год назад
Родитель
Сommit
3b46d2c398
1 измененных файлов с 50 добавлено и 0 удалено
  1. 50 0
      app-hd/controllers/ProductController.php

+ 50 - 0
app-hd/controllers/ProductController.php

@@ -23,6 +23,56 @@ class ProductController extends BaseController
 
     public $guestAccess = ['ghs-item', 'ghs-product-detail'];
 
+    //花材展示状态控制 ssh 20250519
+    public function actionDelStatusUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $shop = $this->shop;
+        $join = $shop->join ?? 0;
+        $default = $shop->default ?? 0;
+        if ($join == 0 && $default == 0) {
+            util::fail('请在首店操作');
+        }
+        $id = $post['id'] ?? 0;
+        $delStatus = $post['delStatus'] ?? 0;
+        $product = ProductClass::getById($id, true);
+        if ($product->mainId != $this->mainId) {
+            util::fail('不是你的花材哦!!');
+        }
+        $product->delStatus = $delStatus;
+        if ($delStatus == 1) {
+            $product->stock = 0;
+            $product->status = 2;
+        }
+        $product->save();
+        $ptItemId = $product->itemId ?? 0;
+        if (isset($shop->default) && $shop->default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
+            //总店修改同步到所有门店
+            $sjId = $shop->sjId ?? 0;
+            $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
+            foreach ($chainShopList as $chainShop) {
+                $chainShopId = $chainShop->id ?? 0;
+                if (isset($chainShop->join) && $chainShop->join == 1) {
+                    continue;
+                }
+                if ($chainShopId == $shop->id) {
+                    continue;
+                }
+                $chainMainId = $chainShop->mainId ?? 0;
+                $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'itemId' => $ptItemId], true);
+                if (!empty($chainProduct)) {
+                    $chainProduct->delStatus = $delStatus;
+                    if ($delStatus == 1) {
+                        $chainProduct->stock = 0;
+                        $chainProduct->status = 2;
+                    }
+                    $chainProduct->save();
+                }
+            }
+        }
+        util::complete();
+    }
+
     //打印花材的标签 ssh 20220602
     public function actionPrint()
     {