Răsfoiți Sursa

批量添加

shish 5 ani în urmă
părinte
comite
e43c7a135b

+ 9 - 21
app-ghs/controllers/ProductController.php

@@ -152,10 +152,16 @@ class ProductController extends BaseController
         util::success(['list' => $data]);
         util::success(['list' => $data]);
     }
     }
 
 
+    //批量改价
+    public function actionBatchChangePrice()
+    {
+        util::complete();
+    }
+
     //改价
     //改价
     public function actionChangePrice()
     public function actionChangePrice()
     {
     {
-
+        //花材价格只能在首店修改,并同步到分店
         $shop = $this->shop;
         $shop = $this->shop;
         $default = $shop->default ?? 0;
         $default = $shop->default ?? 0;
         if ($default != 1) {
         if ($default != 1) {
@@ -173,8 +179,6 @@ class ProductController extends BaseController
         $productId = Yii::$app->request->post('productId', 0);
         $productId = Yii::$app->request->post('productId', 0);
         $price = Yii::$app->request->post('price', '');
         $price = Yii::$app->request->post('price', '');
         if (is_numeric($price) && $price > 0) {
         if (is_numeric($price) && $price > 0) {
-            //改价
-
             //判断是否有效
             //判断是否有效
             $productData = ProductClass::getProductData($productId, $this->shopId);
             $productData = ProductClass::getProductData($productId, $this->shopId);
             if (!$productData) {
             if (!$productData) {
@@ -187,14 +191,6 @@ class ProductController extends BaseController
             if (!$productData) {
             if (!$productData) {
                 util::fail("花材不存在");
                 util::fail("花材不存在");
             }
             }
-            $itemId = $productData['itemId'];
-            //获取该花材的每扎成本价和每扎加价
-            //自动调价=每扎成本价+每扎加价
-            // $itemData = ItemClass::getItemData($itemId, $this->sjId);
-//            if (!$itemData) {
-//                util::fail("出错拉");
-//            }
-//            $price = bcadd($itemData['cost'], $itemData['addPrice'], 2);
             $price = bcadd($productData['cost'], $productData['addPrice'], 2);
             $price = bcadd($productData['cost'], $productData['addPrice'], 2);
             ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
             ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
         }
         }
@@ -209,13 +205,6 @@ class ProductController extends BaseController
         if (!$productData) {
         if (!$productData) {
             util::fail("花材不存在");
             util::fail("花材不存在");
         }
         }
-        //$itemId = $productData['itemId'];
-        //获取该花材的每扎成本价和每扎加价
-        //自动调价=每扎成本价+每扎加价
-//        $itemData = ItemClass::getItemData($itemId, $this->sjId);
-//        if (!$itemData) {
-//            util::fail("出错拉");
-//        }
         //2021.04.06改为用product中的成本价+加价
         //2021.04.06改为用product中的成本价+加价
         $price = bcadd($productData['cost'], $productData['addPrice'], 2);
         $price = bcadd($productData['cost'], $productData['addPrice'], 2);
         ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
         ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
@@ -432,11 +421,10 @@ class ProductController extends BaseController
     {
     {
         $id = Yii::$app->request->get('id');
         $id = Yii::$app->request->get('id');
         $productData = ProductClass::getById($id);
         $productData = ProductClass::getById($id);
-        if(!$productData){
+        if (!$productData) {
             util::fail("花材不存在");
             util::fail("花材不存在");
         }
         }
-        if($productData['shopId'] != $this->shopId){
-            //
+        if ($productData['shopId'] != $this->shopId) {
             util::fail("无效花材");
             util::fail("无效花材");
         }
         }
         //去除无用的字段
         //去除无用的字段

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

@@ -526,9 +526,7 @@ class ProductClass extends BaseClass
     //修改价格 linqh 2021.1.28
     //修改价格 linqh 2021.1.28
     public static function changePrice($id, $shopId, $price, $priceLabel)
     public static function changePrice($id, $shopId, $price, $priceLabel)
     {
     {
-        //2021.7.6 linqh 首店改价,暂时同步到各个分店
-        //判断是否首店
-        $shopInfo = ShopClass::getById($shopId);
+        //2021.7.6 linqh 首店改价,同步到各个分店
         $res = ProductClass::updateByCondition(['id' => $id, 'shopId' => $shopId], ['price' => $price, 'priceLabel' => $priceLabel]);
         $res = ProductClass::updateByCondition(['id' => $id, 'shopId' => $shopId], ['price' => $price, 'priceLabel' => $priceLabel]);
         self::updateSyncProduct($id, $shopId, ['price' => $price, 'priceLabel' => $priceLabel]);
         self::updateSyncProduct($id, $shopId, ['price' => $price, 'priceLabel' => $priceLabel]);
         return $res;
         return $res;