From ae9ebf102b90ff78b01fc0656e4b04ebac8eee5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Fri, 7 May 2021 19:13:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/controller/shop/Goods.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/data/controller/shop/Goods.php b/app/data/controller/shop/Goods.php index 29b53f6a6..d46f92538 100644 --- a/app/data/controller/shop/Goods.php +++ b/app/data/controller/shop/Goods.php @@ -169,13 +169,16 @@ class Goods extends Controller if (empty($data['slider'])) $this->error('轮播图片不能为空!'); if (empty($data['payment'])) $this->error('支付方式不能为空!'); // 商品规格保存 + [$data['price_market'], $data['price_selling']] = [0, 0]; [$count, $items] = [0, array_column(json_decode($data['data_items'], true), 0)]; - foreach ($items as $item) $count += intval($item['status']); + foreach ($items as $item) if ($item['status'] > 0) { + if ($data['price_market'] > $item['market']) $data['price_market'] = $item['market']; + if ($data['price_selling'] > $item['selling']) $data['price_selling'] = $item['selling']; + $count++; + } if (empty($count)) $this->error('无效的的商品价格信息!'); $data['marks'] = arr2str($data['marks'] ?? []); $data['payment'] = arr2str($data['payment'] ?? []); - if (empty($data['price_market'])) $data['price_market'] = min(array_column($items, 'market')); - if (empty($data['price_selling'])) $data['price_selling'] = min(array_column($items, 'selling')); $this->app->db->name('ShopGoodsItem')->where(['goods_code' => $data['code']])->update(['status' => 0]); foreach ($items as $item) data_save('ShopGoodsItem', [ 'goods_sku' => $item['sku'],