调整品类推荐的价格从低到高排序

This commit is contained in:
wangxiaowei 2024-08-03 15:24:02 +08:00
parent b984b12824
commit cd775fc7aa

@ -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);