From 4f8f505283deb053336bc884d96cdf92c2f65e84 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Sat, 27 Jul 2024 14:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/GoodsLogic.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/api/logic/GoodsLogic.php b/app/api/logic/GoodsLogic.php index b9684e37..02511a62 100644 --- a/app/api/logic/GoodsLogic.php +++ b/app/api/logic/GoodsLogic.php @@ -907,23 +907,25 @@ class GoodsLogic extends Logic } } - $where[] = ['og.create_time', '>=', strtotime("today")]; - $where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1]; + $onSaleWhere = [ + 'del' => GoodsEnum::DEL_NORMAL, // 未删除 + 'status' => GoodsEnum::STATUS_SHELVES, // 上架中 + 'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过 + ]; $order_goods = Db::name('order_goods') ->alias('og') ->join('goods g', 'og.goods_id = g.id') - ->where($where) - ->field('og.goods_id, 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') + ->where($onSaleWhere) + ->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('count desc, og.create_time desc') + ->order('og.create_time desc, count desc') ->page($page, $size) ->select() ->toArray(); $count = Db::name('order_goods') ->alias('og') - ->where($where) ->count(); foreach ($order_goods as &$v) {