shish 2 лет назад
Родитель
Сommit
437f4222e8
1 измененных файлов с 18 добавлено и 3 удалено
  1. 18 3
      app-ghs/controllers/ItemController.php

+ 18 - 3
app-ghs/controllers/ItemController.php

@@ -23,9 +23,24 @@ class ItemController extends BaseController
     public function actionGetNewInfo()
     {
         $post = Yii::$app->request->post();
-        print_r($post);
-        die;
-        util::success([]);
+        $str = $post['data'] ?? '';
+        if (empty($str)) {
+            util::fail('请传花材信息');
+        }
+        $arr = json_decode($str, true);
+        if (empty($arr)) {
+            util::fail('请传花材信息哈');
+        }
+        $ids = array_column($arr, 'productId');
+        $list = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,stock,mainId', 'id', true);
+        if (!empty($list)) {
+            foreach ($list as $item) {
+                if ($item->mainId != $this->mainId) {
+                    util::fail('不是你的花材');
+                }
+            }
+        }
+        util::success(['list' => $list]);
     }
 
     //列出所有花材 ssh 20240222