Sfoglia il codice sorgente

首店改价,暂时同步到各个分店

林琦海 5 anni fa
parent
commit
2b6e77df30
1 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. 19 0
      biz-ghs/product/classes/ProductClass.php

+ 19 - 0
biz-ghs/product/classes/ProductClass.php

@@ -10,6 +10,7 @@ use biz\shop\services\ShopService;
 use bizGhs\base\classes\BaseClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
+use bizGhs\merchant\classes\ShopClass;
 use bizGhs\order\traits\OrderTrait;
 use common\components\imgUtil;
 use common\components\stringUtil;
@@ -499,7 +500,25 @@ class ProductClass extends BaseClass
     //修改价格 linqh 2021.1.28
     public static function changePrice($id, $shopId, $price, $priceLabel)
     {
+        //2021.7.6 linqh 首店改价,暂时同步到各个分店
+        //判断是否首店
+        $shopInfo = ShopClass::getById($shopId);
         $res = ProductClass::updateByCondition(['id' => $id, 'shopId' => $shopId], ['price' => $price, 'priceLabel' => $priceLabel]);
+        $productData = ProductClass::getById($id);
+        $itemId = $productData['itemId'];
+        if($shopInfo['default']==1){
+            //首店
+            $sjId = $shopInfo['sjId'];
+            $shopAll = ShopClass::getAllShop($sjId);
+            if($shopAll){
+                foreach ($shopAll as $s){
+                    if($s['id'] != $shopId){
+                        ProductClass::updateByCondition(['itemId' => $itemId, 'shopId' => $s['id']], ['price' => $price, 'priceLabel' => $priceLabel]);
+                    }
+                }
+            }
+
+        }
         return $res;
     }