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) {