Bladeren bron

去掉接口

shish 4 jaren geleden
bovenliggende
commit
1f2863127b
1 gewijzigde bestanden met toevoegingen van 0 en 133 verwijderingen
  1. 0 133
      app-ghs/controllers/ProductController.php

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

@@ -381,139 +381,6 @@ class ProductController extends BaseController
         util::complete('修改成功');
     }
 
-    //批量修改product 排序,成本价,加价
-    public function actionBatchUpdate()
-    {
-        $shopAdmin = $this->shopAdmin;
-        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
-            util::fail('超管才能修改');
-        }
-
-        $data = Yii::$app->request->post('data', '');
-        $type = Yii::$app->request->post('type', '');
-        if (empty($data) || empty($type)) {
-            util::fail("参数错误");
-        }
-        if (in_array($type, ['inTurn', 'addPrice', 'skAddPrice', 'hjAddPrice', 'zsAddPrice', 'cost', 'weight', 'ratio', 'ratio', 'price', 'stockWarning', 'shelfLife']) == false) {
-            util::fail('非法数据修改');
-        }
-        $data = json_decode($data, true);
-        foreach ($data as $v) {
-            if ($type == 'status') {
-                $val = $v[$type] ?? '';
-                if (!in_array($val, [1, 2])) {
-                    util::fail("参数错误");
-                }
-            }
-        }
-        foreach ($data as $v) {
-            $id = $v['id'];
-            $val = $v[$type] ?? '';
-
-            //ssh 20210703
-            if ($type == 'ratio') {
-                if (preg_match("/^[1-9][0-9]*$/", $val) == false || $val <= 0) {
-                    util::fail('单位比请填写整数,并且要大于0');
-                }
-            }
-
-            //修改售价 ssh 20210703
-            if ($type == 'price') {
-                $product = ProductClass::getLockById($id);
-                $currentName = $product->name ?? '';
-                if (empty($product)) {
-                    continue;
-                }
-                if ($product->mainId != $this->mainId) {
-                    util::fail("不是您的产品");
-                }
-                if (empty($val)) {
-                    util::fail("没有填写价格:" . $currentName);
-                }
-                if (is_numeric($val) == false) {
-                    util::fail("价格不是数值:" . $currentName);
-                }
-                $currentItemId = $product->itemId ?? 0;
-                if (empty($currentItemId)) {
-                    continue;
-                }
-                if (empty($val)) {
-                    continue;
-                }
-
-                //成本价需要修改的花材id
-                $costChangeIds = Yii::$app->request->post('costChangeIds', []);
-                if (!empty($costChangeIds)) {
-                    $arrIds = json_decode($costChangeIds, true);
-                    $costIds = is_array($arrIds) ? $arrIds : [];
-                    if (!empty($costIds) && in_array($id, $costIds)) {
-                        $currentAddPrice = bcsub($val, $product->cost, 2);
-
-                        $skDiff = bcsub($product->skAddPrice, $product->addPrice, 2);
-                        //大众会员价比标准会员价高,所以是相加
-                        $newSkAddPrice = bcadd($currentAddPrice, $skDiff, 2);
-
-                        $hjDiff = bcsub($product->addPrice, $product->hjAddPrice, 2);
-                        $newHjAddPrice = bcsub($currentAddPrice, $hjDiff, 2);
-
-                        $zsDiff = bcsub($product->addPrice, $product->zsAddPrice, 2);
-                        $newZsAddPrice = bcsub($currentAddPrice, $zsDiff, 2);
-
-                        $params = [];
-                        $params['skAddPrice'] = $newSkAddPrice;
-                        $params['addPrice'] = $currentAddPrice;
-                        $params['hjAddPrice'] = $newHjAddPrice;
-                        $params['zsAddPrice'] = $newZsAddPrice;
-
-                        $sjId = $product->sjId ?? 0;
-                        $shopAll = ShopClass::getAllShop($sjId);
-                        if ($shopAll) {
-                            foreach ($shopAll as $shop) {
-                                $currentId = $shop['mainId'] ?? 0;
-                                $itemId = $product->itemId ?? 0;
-                                ProductClass::updateByCondition(['mainId' => $currentId, 'itemId' => $itemId], $params);
-                            }
-                        }
-
-                    }
-                }
-                ProductClass::changeSinglePrice($product, $val, ProductClass::PRICE_LABEL_CHANGE);
-                continue;
-            }
-
-            $data = [$type => $val];
-
-            $currentProduct = ProductClass::getById($id, true);
-            if ($currentProduct->mainId != $this->mainId) {
-                util::fail('非常操作');
-            }
-            $currentProduct->$type = $val;
-            if ($type == 'addPrice') {
-                $skAddPrice = $currentProduct->skAddPrice;
-                if ($skAddPrice <= 0) {
-                    $currentProduct->skAddPrice = $val - 1 > 0 ? $val - 1 : 1;
-                    $data['skAddPrice'] = $currentProduct->skAddPrice;
-                }
-                $hjAddPrice = $currentProduct->hjAddPrice;
-                if ($hjAddPrice <= 0) {
-                    $currentProduct->hjAddPrice = $val - 3 > 0 ? $val - 3 : 1;
-                    $data['hjAddPrice'] = $currentProduct->hjAddPrice;
-                }
-                $zsAddPrice = $currentProduct->zsAddPrice;
-                if ($zsAddPrice <= 0) {
-                    $currentProduct->zsAddPrice = $val - 4 > 0 ? $val - 4 : 1;
-                    $data['zsAddPrice'] = $currentProduct->zsAddPrice;
-                }
-            }
-            $currentProduct->save();
-
-            //2021.7.6 lqh 如果是首店,则更新全部分店
-            ProductClass::updateSyncChainShop($id, $this->shopId, $data);
-
-        }
-        util::complete();
-    }
-
     public function actionUpdate()
     {
         $shopAdmin = $this->shopAdmin;