Kaynağa Gözat

显示和隐藏库存

shish 1 yıl önce
ebeveyn
işleme
e31dd288b9
1 değiştirilmiş dosya ile 18 ekleme ve 0 silme
  1. 18 0
      app-ghs/controllers/ShopController.php

+ 18 - 0
app-ghs/controllers/ShopController.php

@@ -7,6 +7,7 @@ use biz\shop\classes\ShopAdminClass;
 use biz\sj\services\MerchantExtendService;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
+use bizGhs\ghs\classes\GhsClass;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\merchant\services\ShopService;
 use bizHd\saas\services\RegionService;
@@ -154,6 +155,23 @@ class ShopController extends BaseController
             }
         }
 
+        //显示和隐藏库存,同时影响到老客户和新注册客户 ssh 20250309
+        $showStock = $post['showStock'] ?? 0;
+        $shopId = $this->shopId;
+        $customList = CustomClass::getAllByCondition(['ownShopId' => $shopId], null, '*', null, true);
+        if (!empty($customList)) {
+            foreach ($customList as $key => $custom) {
+                $ghsId = $custom->ghsId ?? 0;
+                $ghs = GhsClass::getById($ghsId, true);
+                if (!empty($custom) && !empty($ghs)) {
+                    $ghs->showStock = $showStock;
+                    $ghs->save();
+                    $custom->showStock = $showStock;
+                    $custom->save();
+                }
+            }
+        }
+
         $post['meetNum'] = isset($post['meetNum']) && !empty($post['meetNum']) ? $post['meetNum'] : 0;
         $post['meetAmount'] = isset($post['meetAmount']) && !empty($post['meetAmount']) ? $post['meetAmount'] : 0;
         $post['cutAmount'] = isset($post['cutAmount']) && !empty($post['cutAmount']) ? $post['cutAmount'] : 0;