调整品类商家不存在则不显示商品

This commit is contained in:
wangxiaowei 2024-08-03 16:26:13 +08:00
parent cd775fc7aa
commit c8801c23ea

@ -16,6 +16,7 @@ use app\common\model\goods\GoodsCategory;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
use app\api\logic\SeckillGoodsLogic;
use app\api\logic\GoodsLogic;
use think\facade\Db;
use app\common\model\activity_area\ActivityArea;
use think\facade\Event;
@ -674,6 +675,12 @@ class IndexLogic extends Logic
public static function categoryRecommend($platform_category_id,$p_id,$set_id)
{
$shop_id = GoodsLogic::filterShopsIds();
$shopWhere = [];
if (!empty($shop_id)) {
$shopWhere[] = ['shop_id', 'not in', $shop_id];
}
// 销售中商品:未删除/审核通过/已上架
$where = [
['del', '=', GoodsEnum::DEL_NORMAL], // 未删除
@ -682,6 +689,7 @@ class IndexLogic extends Logic
['first_cate_id|second_cate_id|third_cate_id', '=', $platform_category_id], // 分类id
['is_recommend', '=', 1] // 推荐商品
];
$order = [
'min_price' => 'asc', // 价格排序
];
@ -710,10 +718,12 @@ class IndexLogic extends Logic
$lists = Goods::field('id,name,image,min_price,market_price,wholesale_price,purchase_price,issuing_price,sales_actual,(sales_actual + sales_virtual) as sales_total')
->where($where1)
->where($where)
->where($shopWhere)
->order($order)
->limit(4)
->select()
->toArray();
$set_price_type = 0;
if ($set != null&&$settpye!=1) {
foreach ($lists as $key => $value) {
@ -758,6 +768,7 @@ class IndexLogic extends Logic
return $lists;
}
public static function config()
{
$navigation = Db::name('dev_navigation')