shish před 5 roky
rodič
revize
86912e7d9f

+ 12 - 9
app-hd/controllers/ProductController.php

@@ -8,12 +8,10 @@ namespace hd\controllers;
 
 use biz\ghs\classes\GhsClass;
 use bizGhs\admin\classes\AdminClass;
-use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\product\services\ProductService;
 use bizGhs\item\services\ItemService;
-use common\components\noticeUtil;
 use common\components\util;
 use Yii;
 
@@ -113,20 +111,25 @@ class ProductController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
-        $ghs = GhsClass::getGhsInfo($id);
-        if(empty($ghs)){
+        $ghsShopId = $get['shopId'] ?? 0;
+        if (empty($id)) {
+            $ghs = GhsClass::build($ghsShopId, $this->shopId, $this->sjId);
+        } else {
+            $ghs = GhsClass::getGhsInfo($id);
+        }
+        if (empty($ghs)) {
             util::fail('供货商无效');
         }
-        $shopId = $ghs['ghsShopId']??0;
-        $sjId = $ghs['ghsSjId']??0;
-        AdminClass::addRecentShop($shopId,$this->admin);
+        $shopId = $ghs['ghsShopId'] ?? 0;
+        $sjId = $ghs['ghsSjId'] ?? 0;
+        AdminClass::addRecentShop($shopId, $this->admin);
         //获取所有当前供应商的分类 (全部、常用)
         //根据分类组装分类下的花材信息
         $classIds = ItemClassClass::getGhsItemClassAll($sjId);
         $where['merchantId'] = $sjId;
         $where['shopId'] = $shopId;
 
-        $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
+        $itemInfoData = ProductClass::getAllByCondition($where, null, "*");
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
         //常用的itemIds
         $oftenItemIds = ProductClass::getOftenItemIds($shopId);
@@ -135,7 +138,7 @@ class ProductController extends BaseController
 
         //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
-        $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, '');
+        $data = ProductService::assembleData($classIds, $itemIdsInfo, $itemInfoData, $oftenItemIds, '');
 
         util::success($data);
     }

+ 26 - 0
biz/ghs/classes/GhsClass.php

@@ -2,6 +2,7 @@
 
 namespace biz\ghs\classes;
 
+use biz\shop\classes\ShopClass;
 use biz\sj\classes\MerchantAssetClass;
 use common\components\imgUtil;
 use common\components\util;
@@ -12,6 +13,31 @@ class GhsClass extends BaseClass
 
     public static $baseFile = '\biz\ghs\models\Ghs';
 
+    //新建供货商 shish 2021.4.13
+    public static function build($ghsShopId, $shopId, $sjId)
+    {
+        $shop = ShopClass::getShopInfo($ghsShopId);
+        if (empty($shop)) {
+            util::fail('没有找到供货商的门店');
+        }
+        $data = [
+            'ghsSjId' => $shop['sjId'],
+            'ghsShopId' => $ghsShopId,
+            'sjId' => $sjId,
+            'shopId' => $shopId,
+            'mobile' => $shop['mobile'] ?? '',
+            'province' => $shop['province'] ?? '',
+            'city' => $shop['city'] ?? '',
+            'dist' => $shop['dist'] ?? '',
+            'address' => $shop['address'] ?? '',
+            'floor' => $shop['floor'] ?? '',
+            'fullAddress' => $shop['fullAddress'] ?? '',
+            'lat' => $shop['lat'] ?? '',
+            'long' => $shop['long'] ?? '',
+        ];
+        return self::addGhs($data);
+    }
+
     //增加供货商 shish 2021.3.29
     public static function addGhs($data)
     {