From 6c620c8b0936d32d6d71c1577a7c47288f31cae2 Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 9 May 2018 11:14:19 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=95=86=E5=9F=8E=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/store/service/GoodsService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/store/service/GoodsService.php b/application/store/service/GoodsService.php index 5ea113cf8..75c5c07f9 100644 --- a/application/store/service/GoodsService.php +++ b/application/store/service/GoodsService.php @@ -104,24 +104,24 @@ class GoodsService } // 统计入库信息 $stockField = 'goods_id,goods_spec,ifnull(sum(goods_stock), 0) goods_stock'; - $stockWhere = ['status' => '1', 'is_deleted' => '0', 'goods_id' => $goods_id, 'mch_id' => $mch_id]; + $stockWhere = ['status' => '1', 'is_deleted' => '0', 'goods_id' => $goods_id]; $stockList = (array)Db::name('StoreGoodsStock')->field($stockField)->where($stockWhere)->group('goods_id,goods_spec')->select(); // 统计销售信息 $saleField = 'goods_id,goods_spec,ifnull(sum(number), 0) goods_sale'; - $saleWhere = ['status' => '1', 'is_deleted' => '0', 'goods_id' => $goods_id, 'mch_id' => $mch_id]; + $saleWhere = ['status' => '1', 'is_deleted' => '0', 'goods_id' => $goods_id]; $saleList = (array)Db::name('StoreOrderList')->field($saleField)->where($saleWhere)->group('goods_id,goods_spec')->select(); // 库存置零 list($where, $total_sale) = [['goods_id' => $goods_id], 0]; - Db::name('StoreGoodsList')->where($where)->update(['goods_stock' => 0, 'goods_sale' => 0, 'mch_id' => $mch_id]); + Db::name('StoreGoodsList')->where($where)->update(['goods_stock' => 0, 'goods_sale' => 0]); // 更新商品库存 foreach ($stockList as $stock) { - $where = ['goods_id' => $goods_id, 'goods_spec' => $stock['goods_spec'], 'mch_id' => $mch_id]; + $where = ['goods_id' => $goods_id, 'goods_spec' => $stock['goods_spec']]; Db::name('StoreGoodsList')->where($where)->update(['goods_stock' => $stock['goods_stock']]); } // 更新商品销量 foreach ($saleList as $sale) { $total_sale += intval($sale['goods_sale']); - $where = ['goods_id' => $goods_id, 'goods_spec' => $sale['goods_spec'], 'mch_id' => $mch_id]; + $where = ['goods_id' => $goods_id, 'goods_spec' => $sale['goods_spec']]; Db::name('StoreGoodsList')->where($where)->update(['goods_sale' => $sale['goods_sale']]); } return ['code' => 1, 'msg' => '同步商品库存成功!'];