From 8dd20100ad2460b51153d8058e693b2afa79da13 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Fri, 9 Aug 2024 03:27:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=9F=8E=E5=BF=AB?= =?UTF-8?q?=E8=AE=AF=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/IndexLogic.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/api/logic/IndexLogic.php b/app/api/logic/IndexLogic.php index a8411d1b..43732a2b 100755 --- a/app/api/logic/IndexLogic.php +++ b/app/api/logic/IndexLogic.php @@ -22,7 +22,7 @@ use app\common\model\activity_area\ActivityArea; use think\facade\Event; use app\common\model\MallNews; use app\common\model\MallNewsShop; - +use app\common\model\MallNewsFile; class IndexLogic extends Logic { @@ -220,6 +220,7 @@ class IndexLogic extends Logic // 商城快讯 $mall_news = MallNews::where('delete_time', 0)->order('sort desc, create_time desc')->limit(3)->select(); + $arr = []; foreach ($mall_news as &$v) { if ($v['mall_type'] == 0) { if (isset($v['files'])) { @@ -232,11 +233,17 @@ class IndexLogic extends Logic } } } else if ($v['mall_type'] == 1) { - $v['shop'] = MallNewsShop::alias('mns') - ->join('goods g', 'mns.shop_id = g.id') - ->join('mall_news_file mnf', 'mns.id = mnf.mall_news_shop_id') - ->field('mns.id, g.id as gid, g.name, mnf.src') - ->where(['mns.delete_time' => 0])->whereIn('mns.id', $v['mall_news_goods_id'])->select()->toArray(); + // $v['shop'] = MallNewsShop::alias('mns') + // ->join('goods g', 'mns.shop_id = g.id') + // ->join('mall_news_file mnf', 'mns.id = mnf.mall_news_shop_id') + // ->field('mns.id, g.id as gid, g.name, mnf.src') + // ->where(['mns.delete_time' => 0])->whereIn('mns.id', $v['mall_news_goods_id'])->group('mns.id')->select()->toArray(); + $ids = explode(',', $v['mall_news_goods_id']); + foreach ($ids as $k => &$v2) { + $arr[$k] = MallNewsFile::where('mall_news_shop_id', $v2)->select()->toArray(); + } + + $v['shop'] = $arr; } }