调整品类推荐的价格从低到高排序
This commit is contained in:
parent
b984b12824
commit
cd775fc7aa
@ -229,11 +229,11 @@ class IndexLogic extends Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 热销榜单
|
// 热销榜单
|
||||||
$hot_list = self::getIndexHotList();
|
$hot_list = self::getIndexHotList();
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'headlines' => $headlines,
|
'headlines' => $headlines,
|
||||||
'hots' => $hots,
|
'hots' => $hots,
|
||||||
@ -683,8 +683,7 @@ class IndexLogic extends Logic
|
|||||||
['is_recommend', '=', 1] // 推荐商品
|
['is_recommend', '=', 1] // 推荐商品
|
||||||
];
|
];
|
||||||
$order = [
|
$order = [
|
||||||
'sales_actual' => 'desc', // 实际销量倒序
|
'min_price' => 'asc', // 价格排序
|
||||||
'id' => 'desc'
|
|
||||||
];
|
];
|
||||||
$set = null;
|
$set = null;
|
||||||
$where1 = [];
|
$where1 = [];
|
||||||
@ -712,7 +711,7 @@ class IndexLogic extends Logic
|
|||||||
->where($where1)
|
->where($where1)
|
||||||
->where($where)
|
->where($where)
|
||||||
->order($order)
|
->order($order)
|
||||||
->limit(3)
|
->limit(4)
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
$set_price_type = 0;
|
$set_price_type = 0;
|
||||||
@ -970,7 +969,7 @@ class IndexLogic extends Logic
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getIndexHotList()
|
private static function getIndexHotList()
|
||||||
{
|
{
|
||||||
$hot_list = $order_goods = [];
|
$hot_list = $order_goods = [];
|
||||||
@ -979,7 +978,7 @@ class IndexLogic extends Logic
|
|||||||
'status' => GoodsEnum::STATUS_SHELVES, // 上架中
|
'status' => GoodsEnum::STATUS_SHELVES, // 上架中
|
||||||
'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过
|
'audit_status' => GoodsEnum::AUDIT_STATUS_OK, // 审核通过
|
||||||
];
|
];
|
||||||
|
|
||||||
$hot_list = Db::name('hot_list')
|
$hot_list = Db::name('hot_list')
|
||||||
->alias('hl')
|
->alias('hl')
|
||||||
->join('goods g', 'hl.goods_id = g.id')
|
->join('goods g', 'hl.goods_id = g.id')
|
||||||
@ -992,20 +991,20 @@ class IndexLogic extends Logic
|
|||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
$count = count($hot_list);
|
$count = count($hot_list);
|
||||||
|
|
||||||
if ($count < 6) {
|
if ($count < 6) {
|
||||||
$where[] = ['og.create_time', '>=', strtotime("today")];
|
$where[] = ['og.create_time', '>=', strtotime("today")];
|
||||||
$where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1];
|
$where[] = ['og.create_time', '<=', strtotime("tomorrow") - 1];
|
||||||
|
|
||||||
$order_goods = Db::name('order_goods')
|
$order_goods = Db::name('order_goods')
|
||||||
->alias('og')
|
->alias('og')
|
||||||
->join('goods g', 'og.goods_id = g.id')
|
->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')
|
->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')
|
->group('og.goods_id')
|
||||||
->limit(6 - $count)
|
->limit(6 - $count)
|
||||||
->order('og.create_time desc, count desc')
|
->order('og.create_time desc, count desc')
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array_merge($hot_list, $order_goods);
|
$result = array_merge($hot_list, $order_goods);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user