Browse Source

价格变化

shish 4 years ago
parent
commit
765fff1741
1 changed files with 21 additions and 3 deletions
  1. 21 3
      biz-ghs/product/classes/ProductClass.php

+ 21 - 3
biz-ghs/product/classes/ProductClass.php

@@ -843,10 +843,21 @@ class ProductClass extends BaseClass
         $paramsBack = $upData;
         $ptItemId = $product->itemId ?? 0;
 
-        //修改价格
+        $currentSkPrice = null;
+        if (isset($data['skMore']) && is_numeric($data['skMore'])) {
+            $currentSkPrice = bcadd($price, $data['skMore'], 2);
+        }
+
         if ($price != $product->price) {
-            self::changeSinglePrice($shop, $ptItemId, $price);
+            //花店价有变化
+            self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice);
             unset($upData['price']);
+        } else {
+            //花店价没有变化,但散客价比花店价贵多少有修改时,也要改价
+            if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $product->skMore) {
+                self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice);
+                unset($upData['price']);
+            }
         }
         self::updateById($id, $upData);
         //不影响其它直营店花材的上下架
@@ -875,8 +886,15 @@ class ProductClass extends BaseClass
                     continue;
                 }
                 if ($price != $chainProduct->price) {
-                    self::changeSinglePrice($chainShop, $ptItemId, $price);
+                    //花店价有变化
+                    self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice);
                     unset($params['price']);
+                } else {
+                    //花店价没有变化,但散客价比花店价贵多少有修改时,也要改价
+                    if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $chainProduct->skMore) {
+                        self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice);
+                        unset($params['price']);
+                    }
                 }
                 self::updateById($chainProduct->id, $params);
             }