shish %!s(int64=3) %!d(string=hai) anos
pai
achega
590cae9c07
Modificáronse 1 ficheiros con 18 adicións e 0 borrados
  1. 18 0
      app-ghs/controllers/XjController.php

+ 18 - 0
app-ghs/controllers/XjController.php

@@ -76,6 +76,24 @@ class XjController extends BaseController
         if ($product->mainId != $this->mainId) {
             util::fail('不是您的花材');
         }
+        $data = $post['data'] ?? '';
+        $arr = json_decode($data, true);
+        if (empty($arr)) {
+            util::fail('没有找到花材列表');
+        }
+        foreach ($arr as $item) {
+            $id = $item['id'] ?? 0;
+            $stock = $item['stock'] ?? -1;
+            $xj = XjClass::getById($id, true);
+            if (empty($xj)) {
+                continue;
+            }
+            if ($xj->itemId != $itemId) {
+                continue;
+            }
+            $xj->stock = $stock;
+            $xj->save();
+        }
         util::complete();
     }