From e9fd94c921d87db1ccc13fbebf627c9fb0037d4b Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Tue, 20 Aug 2024 22:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=83=AD=E9=94=80=E6=A6=9C=E5=8D=95=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=9A=84=E5=95=86=E5=AE=B6=E5=A6=82=E6=9E=9C=E6=98=AF?= =?UTF-8?q?=E9=9D=9E=E8=90=A5=E4=B8=9A=E7=8A=B6=E6=80=81=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B9=9F=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/GoodsLogic.php | 7 +++++++ app/api/logic/IndexLogic.php | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/app/api/logic/GoodsLogic.php b/app/api/logic/GoodsLogic.php index 143b58ec..a7ab0b5d 100755 --- a/app/api/logic/GoodsLogic.php +++ b/app/api/logic/GoodsLogic.php @@ -917,6 +917,12 @@ class GoodsLogic extends Logic } } + $shopWhere = []; + if (!empty(self::filterShopsIds())) { + // 过滤已删除、已冻结、已暂停营业、已到期的店铺 + $shopWhere[] = ['og.shop_id', 'not in', self::filterShopsIds()]; + } + $onSaleWhere = [ 'del' => GoodsEnum::DEL_NORMAL, // 未删除 'status' => GoodsEnum::STATUS_SHELVES, // 上架中 @@ -927,6 +933,7 @@ class GoodsLogic extends Logic ->alias('og') ->join('goods g', 'og.goods_id = g.id') ->where($onSaleWhere) + ->where($shopWhere) ->field('og.goods_id, og.create_time, count(*) as count, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price') ->group('og.goods_id') ->order('og.create_time desc, count desc') diff --git a/app/api/logic/IndexLogic.php b/app/api/logic/IndexLogic.php index 586884c8..edd9ac12 100755 --- a/app/api/logic/IndexLogic.php +++ b/app/api/logic/IndexLogic.php @@ -1021,11 +1021,19 @@ class IndexLogic extends Logic $where[] = ['og.create_time', '>=', strtotime("today")]; $where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1]; + $shopWhere = []; + if (!empty(GoodsLogic::filterShopsIds())) { + // 过滤已删除、已冻结、已暂停营业、已到期的店铺 + $shopWhere[] = ['og.shop_id', 'not in', GoodsLogic::filterShopsIds()]; + } + $order_goods = Db::name('order_goods') ->alias('og') ->join('goods g', 'og.goods_id = g.id') ->field('og.goods_id, og.create_time, count(*) as count, g.id as gid, g.name, g.image, g.issuing_price, g.market_price, g.min_price, g.purchase_price, g.wholesale_price') ->group('og.goods_id') + ->where($shopWhere) + ->where($onSaleWhere) ->limit(6 - $count) ->order('og.create_time desc, count desc') ->select()