Przeglądaj źródła

供货商零售上添加花材功能

林琦海 5 lat temu
rodzic
commit
7aa687e9a3

+ 2 - 1
app/shop/controllers/ItemController.php

@@ -50,7 +50,8 @@ class ItemController extends BaseController
         if(empty($data)){
             util::fail('参数错误');
         }
-        //循环修改
+        //循环修改排序值
+        // todo
 
 
     }

+ 1 - 1
biz-ghs/item/services/ItemService.php

@@ -9,7 +9,7 @@ namespace bizGhs\item\services;
 use bizGhs\base\services\BaseService;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
-use bizGhs\merchant\services\ShopService;
+use bizTy\shop\services\ShopService;
 use bizGhs\product\classes\ProductClass;
 use Yii;
 use common\components\util;

+ 0 - 10
biz-ghs/merchant/services/ShopService.php

@@ -55,14 +55,4 @@ class ShopService extends BaseService
 		return ShopClass::generateGatheringCode($merchantId, $shopId);
 	}
 
-	//根据商家ID,获取所有门店 shopIds  linqh 2021.3.4
-    public static function getShopIds($merchantId)
-    {
-        $shops = ShopClass::getAllShop($merchantId);
-        $shopIds = [];
-        if($shops){
-            $shopIds = array_column($shops,'id');
-        }
-        return $shopIds;
-    }
 }

+ 21 - 10
biz-ty/shop/services/ShopService.php

@@ -10,9 +10,9 @@ use Yii;
 
 class ShopService extends BaseService
 {
-	
+
 	public static $baseFile = '\bizTy\shop\classes\ShopClass';
-	
+
 	//计算运费 shish 2019.12.4
 	public static function getSendCost($lat, $lng, $jsStatDistance, $shopInfo)
 	{
@@ -34,44 +34,44 @@ class ShopService extends BaseService
 		$sendCost = ceil($remainDistance * 1000 / 1000 / 1000) * $addPrice;
 		return $sendCost;
 	}
-	
+
 	//获取默认门店信息 shish 2019.12.6
 	public static function getDefaultShop($merchant)
 	{
 		$defaultShopId = $merchant['defaultShopId'];
 		return ShopClass::getById($defaultShopId);
 	}
-	
+
 	//验证门店
 	public static function valid($shopInfo, $merchantId)
 	{
 		ShopClass::valid($shopInfo, $merchantId);
 	}
-	
+
 	public static function getShopList($where)
 	{
 		$list = ShopClass::getShopList($where);
 		return $list;
 	}
-	
+
 	//获取默认门店 shish 2020.1.19
 	public static function getDefaultShopId($merchant)
 	{
 		return ShopClass::getDefaultShopId($merchant);
 	}
-	
+
 	//添加门店 shish 2020.2.29
 	public static function addShop($data)
 	{
 		return ShopClass::addShop($data);
 	}
-	
+
 	//更新门店 shish 2020.2.29
 	public static function updateShop($id, $data)
 	{
 		return ShopClass::updateShop($id, $data);
 	}
-	
+
 	//删除门店 shish 2020.3.1
 	public static function deleteShop($shop)
 	{
@@ -84,4 +84,15 @@ class ShopService extends BaseService
 		return ShopClass::generateGatheringCode($merchantId, $shopId);
 	}
 
-}
+
+    //根据商家ID,获取所有门店 shopIds  linqh 2021.3.4
+    public static function getShopIds($merchantId)
+    {
+        $shops = ShopClass::getAllShop($merchantId);
+        $shopIds = [];
+        if($shops){
+            $shopIds = array_column($shops,'id');
+        }
+        return $shopIds;
+    }
+}

+ 11 - 1
biz/item/services/ItemService.php

@@ -6,6 +6,7 @@ use biz\base\services\BaseService;
 use biz\item\classes\ItemClass;
 use biz\item\classes\ItemClassClass;
 use biz\product\classes\ProductClass;
+use bizTy\shop\services\ShopService;
 use Yii;
 use common\components\util;
 use yii\db\Exception;
@@ -45,7 +46,16 @@ class ItemService extends BaseService
         try{
             //写入一条item,同时写入一条itemInfo(初始化库存)
             ItemClass::add($data);
-            ProductClass::add($data);
+            //所有门店一起添加
+            $shopIds = ShopService::getShopIds($sjId);
+            if(empty($shopIds)){
+                $transaction->rollBack();
+                util::fail("无门店");
+            }
+            foreach ($shopIds as $shopId){
+                $data['shopId'] = $shopId;
+                ProductClass::add($data);
+            }
             $transaction->commit();
         }catch (Exception $exception){
             $transaction->rollBack();