From a2c36ffc634e4546341434ee0daf20fdc43f609e Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 3 Apr 2019 18:55:46 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/store/controller/Goods.php | 8 +++++--- application/store/view/goods/stock.html | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/application/store/controller/Goods.php b/application/store/controller/Goods.php index 6e072a67d..dff6dbee2 100644 --- a/application/store/controller/Goods.php +++ b/application/store/controller/Goods.php @@ -83,9 +83,11 @@ class Goods extends Controller return $this->fetch('', ['vo' => $goods]); } list($post, $data) = [$this->request->post(), []]; - if (isset($post['id']) && isset($post['spec']) && is_array($post['spec'])) { - foreach ($post['spec'] as $k => $v) if ($v > 0) array_push($data, [ - 'goods_id' => $post['id'], 'goods_spec' => $k, 'number_stock' => $v, + if (isset($post['id']) && isset($post['goods_id']) && is_array($post['goods_id'])) { + foreach (array_keys($post['goods_id']) as $key) if ($post['number'][$key] > 0) array_push($data, [ + 'goods_id' => $post['goods_id'][$key], + 'goods_spec' => $post['goods_spec'][$key], + 'number_stock' => $post['number'][$key], ]); if (!empty($data)) { Db::name('StoreGoodsStock')->insertAll($data); diff --git a/application/store/view/goods/stock.html b/application/store/view/goods/stock.html index fc68cf60a..0e2d5a357 100644 --- a/application/store/view/goods/stock.html +++ b/application/store/view/goods/stock.html @@ -41,7 +41,9 @@ - + + +