Sfoglia il codice sorgente

批量修改更多

shish 4 anni fa
parent
commit
444b6e50ac
1 ha cambiato i file con 28 aggiunte e 0 eliminazioni
  1. 28 0
      app-ghs/controllers/ProductController.php

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

@@ -307,6 +307,34 @@ class ProductController extends BaseController
         util::complete();
     }
 
+    //批量修改更多,包括排序、重量和保质期 shish 20211211
+    public function actionBatchChangeMore()
+    {
+        $addData = Yii::$app->request->post('addData', '');
+        if (empty($addData)) {
+            util::fail('没有花材');
+        }
+        $itemData = json_decode($addData, true);
+        if (is_array($itemData) == false) {
+            util::fail('没有花材...');
+        }
+        $ids = array_column($itemData, 'id');
+        $infoList = ProductClass::getByIds($ids);
+        if (empty($infoList)) {
+            util::fail('没有花材');
+        }
+        foreach ($infoList as $info) {
+            if (isset($info['shopId']) == false || $info['shopId'] != $this->shopId) {
+                util::fail('非常访问,不是你的花材不能修改');
+            }
+        }
+        foreach ($itemData as $key => $data) {
+            $id = $data['id'] ?? 0;
+            ProductClass::updateById($id, $data);
+        }
+        util::complete('修改成功');
+    }
+
     //批量修改加价 shish 20211211
     public function actionBatchChangeAddPrice()
     {