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

+ 18 - 5
app-hd/controllers/ProductController.php

@@ -115,16 +115,29 @@ class ProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
-        $ghs = GhsClass::getGhsInfo($id);
-        if (empty($ghs)) {
-            util::fail('没有找到供应商');
+        if (!empty($id)) {
+            $ghs = GhsClass::getGhsInfo($id);
+            if (empty($ghs)) {
+                util::fail('没有找到供应商');
+            }
+            $sjId = $ghs['sjId'] ?? 0;
+            $shopId = $ghs['shopId'] ?? 0;
+        } else {
+            $shopId = $get['shopId'] ?? 0;
+            if (empty($shopId)) {
+                util::fail('没有供货商信息');
+            }
+            $shop = ShopClass::getShopInfo($shopId);
+            if (empty($shop)) {
+                util::fail('没有供货商门店');
+            }
+            $sjId = $shop['merchantId'] ?? 0;
         }
+
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {
 
-            $sjId = $ghs['sjId'] ?? 0;
-            $shopId = $ghs['shopId'] ?? 0;
 
             //获取所有当前供应商的分类 (全部、常用)
             //根据分类组装分类下的花材信息