From cd775fc7aa4523adfdb8e9ad3718eb881bc849da Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Sat, 3 Aug 2024 15:24:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=93=81=E7=B1=BB=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E7=9A=84=E4=BB=B7=E6=A0=BC=E4=BB=8E=E4=BD=8E=E5=88=B0?= =?UTF-8?q?=E9=AB=98=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/IndexLogic.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/app/api/logic/IndexLogic.php b/app/api/logic/IndexLogic.php index 29562364..931d3671 100755 --- a/app/api/logic/IndexLogic.php +++ b/app/api/logic/IndexLogic.php @@ -229,11 +229,11 @@ class IndexLogic extends Logic } } } - + // 热销榜单 $hot_list = self::getIndexHotList(); - - + + return [ 'headlines' => $headlines, 'hots' => $hots, @@ -683,8 +683,7 @@ class IndexLogic extends Logic ['is_recommend', '=', 1] // 推荐商品 ]; $order = [ - 'sales_actual' => 'desc', // 实际销量倒序 - 'id' => 'desc' + 'min_price' => 'asc', // 价格排序 ]; $set = null; $where1 = []; @@ -712,7 +711,7 @@ class IndexLogic extends Logic ->where($where1) ->where($where) ->order($order) - ->limit(3) + ->limit(4) ->select() ->toArray(); $set_price_type = 0; @@ -970,7 +969,7 @@ class IndexLogic extends Logic return $result; } - + private static function getIndexHotList() { $hot_list = $order_goods = []; @@ -979,7 +978,7 @@ class IndexLogic extends Logic 'status' => GoodsEnum::STATUS_SHELVES, // 上架中 'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过 ]; - + $hot_list = Db::name('hot_list') ->alias('hl') ->join('goods g', 'hl.goods_id = g.id') @@ -992,20 +991,20 @@ class IndexLogic extends Logic ->toArray(); $count = count($hot_list); - + if ($count < 6) { $where[] = ['og.create_time', '>=', strtotime("today")]; $where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1]; $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') - ->limit(6 - $count) - ->order('og.create_time desc, count desc') - ->select() - ->toArray(); + ->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') + ->limit(6 - $count) + ->order('og.create_time desc, count desc') + ->select() + ->toArray(); } $result = array_merge($hot_list, $order_goods);