shish 4 лет назад
Родитель
Сommit
ffebd98bbd
1 измененных файлов с 37 добавлено и 6 удалено
  1. 37 6
      app-ghs/controllers/ProductController.php

+ 37 - 6
app-ghs/controllers/ProductController.php

@@ -221,7 +221,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('请在店操作');
+            util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -384,7 +384,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('请在店操作');
+            util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -424,7 +424,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('请在店操作');
+            util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -488,7 +488,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            //util::fail('请在店操作');
+            //util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -533,6 +533,13 @@ class ProductController extends BaseController
     {
         $post = Yii::$app->request->post();
 
+        $shop = $this->shop;
+        $join = $shop->join ?? 0;
+        $default = $shop->default ?? 0;
+        if ($join == 0 && $default == 0) {
+            util::fail('请在首店操作');
+        }
+
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
@@ -549,6 +556,30 @@ class ProductController extends BaseController
         }
         $product->delStatus = $delStatus;
         $product->save();
+
+        $ptItemId = $product->itemId ?? 0;
+        if (isset($shop->default) && $shop->default == 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;
+                    $chainProduct->save();
+                }
+            }
+        }
+
+
         util::complete();
     }
 
@@ -572,7 +603,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('请在店操作');
+            util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -612,7 +643,7 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('请在店操作');
+            util::fail('请在店操作');
         }
 
         $shopAdmin = $this->shopAdmin;