From 75a5ac4486c3fbe4171d03ab6c48a63197a368bf Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 4 Nov 2020 11:39:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=80=E4=B8=8B=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/ActivityService.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Service/v3/Implementations/ActivityService.php b/app/Service/v3/Implementations/ActivityService.php index dcd1043..8d90a5b 100644 --- a/app/Service/v3/Implementations/ActivityService.php +++ b/app/Service/v3/Implementations/ActivityService.php @@ -74,7 +74,9 @@ class ActivityService implements ActivityServiceInterface $redis = ApplicationContext::getContainer()->get(Redis::class); $activitySettings = $redis->hGetAll('activity_type_setting'); $activity['type'] = $type = $activitySettings['index_activity_type']; - $activity['settings'] = json_decode($activitySettings[$activitySettings['index_activity_type']], true); + $settingsStr = $activitySettings[$activity['type']] ?? ''; + $activity['settings'] = json_decode($settingsStr, true); + $activity['settings'] = !empty($activity['settings']) ? $activity['settings'] : (object)[]; $storeTable = ApplicationContext::getContainer()->get(Store::class)->getTable(); $goodsTable = ApplicationContext::getContainer()->get(GoodsActivity::class)->getTable(); @@ -107,7 +109,7 @@ class ActivityService implements ActivityServiceInterface ->orderBy(''.$goodsTable.'.expire_time', 'ASC') ->orderBy(''.$goodsTable.'.created_at', 'DESC'); - if (isset($activity['settings']['index_num_limit'])&&!empty($activity['settings']['index_num_limit'])) { + if (is_array($activity['settings'])&&isset($activity['settings']['index_num_limit'])&&!empty($activity['settings']['index_num_limit'])) { $builder = $builder->limit($activity['settings']['index_num_limit']); }