Browse Source

修改加价,触发自动调价

林琦海 5 years ago
parent
commit
236750c265

+ 1 - 0
app-ghs/controllers/ProductController.php

@@ -211,6 +211,7 @@ class ProductController extends BaseController
                 $type => $val
             ];
             ProductClass::updateByCondition($where, $data);
+            ProductClass::autoPriceById($id);
         }
         util::complete();
     }

+ 2 - 0
biz-ghs/item/services/ItemService.php

@@ -228,6 +228,8 @@ class ItemService extends BaseService
                     $productData['itemId'] = $v['id'];
                     unset($productData['id']);
                     $productData['rank'] = 'A';
+                    //计算价格
+                    $productData['price'] = bcadd($v['cost'],$v['addPrice'],2);
                     ProductClass::add($productData);
                 }
             }

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

@@ -603,4 +603,14 @@ class ProductClass extends BaseClass
         }
         self::updateById($id, $upData);
     }
+
+    //自动改价 2021.4.14
+    public static function autoPriceById($productId)
+    {
+        $product = self::getById($productId);
+        if($product && $product['priceLabel']==self::PRICE_LABEL_AUTO){
+            $price = bcadd($product['cost'],$product['addPrice'],2);
+            self::changePrice($productId,$product['shopId'],$price,self::PRICE_LABEL_AUTO);
+        }
+    }
 }