From 8a27cc445b23e90234a8f36143339b68d238a224 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 16:43:02 +0800 Subject: [PATCH 1/5] no message --- app/Controller/v3/HomeController.php | 4 ++++ config/routes.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index 02f3c68..e0a45ad 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -98,6 +98,7 @@ class HomeController extends BaseController 'goods' => [ [ 'id' => 1, + 'store_id' => 111, 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', 'name' => '【优质】大白菜', 'spec' => [ @@ -118,6 +119,7 @@ class HomeController extends BaseController 'seconds' => $leftSeconds, ],[ 'id' => 1, + 'store_id' => 111, 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', 'name' => '【优质】大白菜', 'spec' => [ @@ -138,6 +140,7 @@ class HomeController extends BaseController 'seconds' => $leftSeconds, ],[ 'id' => 1, + 'store_id' => 111, 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', 'name' => '【优质】大白菜', 'spec' => [ @@ -158,6 +161,7 @@ class HomeController extends BaseController 'seconds' => $leftSeconds, ],[ 'id' => 1, + 'store_id' => 111, 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', 'name' => '【优质】大白菜', 'spec' => [ diff --git a/config/routes.php b/config/routes.php index 025a0ab..fe8eed9 100644 --- a/config/routes.php +++ b/config/routes.php @@ -99,7 +99,7 @@ Router::addGroup('/v3/', function () { Router::post('user/updateInfo', 'App\Controller\v3\UserController@updateInfo'); Router::post('home/userIndex', 'App\Controller\v3\HomeController@userIndex'); Router::post('user/olOrders', 'App\Controller\v3\OrderListController@onlineForUser'); - Router::post('orderOnline/detailByUser', 'App\Controller\v3\OrderOnlineController@detailByUser'); + Router::post('user/olOrderDetail', 'App\Controller\v3\OrderOnlineController@detailByUser'); Router::post('userDeliveryAddress/update', 'App\Controller\v3\UserDeliveryAddressController@update'); Router::post('userDeliveryAddress/get', 'App\Controller\v3\UserDeliveryAddressController@get'); Router::post('userDeliveryAddress/delete', 'App\Controller\v3\UserDeliveryAddressController@delete'); From ad95008c2175ff4ecf752543fc930ccb39a0a473 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 16:44:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?BANNER=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/HomeController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index e0a45ad..47ae7d0 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -73,6 +73,7 @@ class HomeController extends BaseController 'subtitle' => '满足您的美味生活', 'redirect_type' => '', 'redirect_url' => '', + 'bg_color' => '#FF00FF', ], [ 'id' => 3, @@ -81,6 +82,7 @@ class HomeController extends BaseController 'subtitle' => '很实在', 'redirect_type' => 'page', 'redirect_url' => '/pages/index', + 'bg_color' => '#0000FF', ], ], 'categories' => [ From c350f1823acfc7330dd38d83901dfc9b7c4dae7a Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 17:19:16 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=95=86=E6=88=B7ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsRecommendController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Controller/v3/GoodsRecommendController.php b/app/Controller/v3/GoodsRecommendController.php index 22fd775..ec2a0fb 100644 --- a/app/Controller/v3/GoodsRecommendController.php +++ b/app/Controller/v3/GoodsRecommendController.php @@ -36,7 +36,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 111, 'logo' => '', 'name' => '我是一个商家'] + 'store' => ['id' => 1, 'logo' => '', 'name' => '我是一个商家'] ], [ 'goods' => [ @@ -76,7 +76,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 333, 'logo' => '', 'name' => '我是一个商家333'] + 'store' => ['id' => 2, 'logo' => '', 'name' => '我是一个商家333'] ], [ 'goods' => [ @@ -96,7 +96,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 444, 'logo' => '', 'name' => '我是一个商家444'] + 'store' => ['id' => 3, 'logo' => '', 'name' => '我是一个商家444'] ] ]; parent::__construct(); @@ -132,7 +132,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 111, 'logo' => '', 'name' => '我是一个商家'] + 'store' => ['id' => 1, 'logo' => '', 'name' => '我是一个商家'] ], ], @@ -155,7 +155,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 222, 'logo' => '', 'name' => '我是一个商家222'] + 'store' => ['id' => 2, 'logo' => '', 'name' => '我是一个商家222'] ], ], Tabs::APPLET_INDEX_FRESH => [ @@ -177,7 +177,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 333, 'logo' => '', 'name' => '我是一个商家333'] + 'store' => ['id' => 3, 'logo' => '', 'name' => '我是一个商家333'] ], ], Tabs::APPLET_INDEX_OFFICE => [ @@ -199,7 +199,7 @@ class GoodsRecommendController extends BaseController 'is_effective' => 2, 'noneffective_note' => '已卖完', ], - 'store' => ['id' => 444, 'logo' => '', 'name' => '我是一个商家444'] + 'store' => ['id' => 4, 'logo' => '', 'name' => '我是一个商家444'] ], ] ]; From 48cee0b117b77be74a0e2246608c6a3c230ae5d1 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 17:25:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/HomeController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index 47ae7d0..174f92c 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -207,6 +207,7 @@ class HomeController extends BaseController { $params = $request->validated(); $data['user'] = $this->userInfoService->detail($params['user_id']); + $data['user']['role'] = '商家'; $data['user']['collection_count'] = $this->collectStoreService->countByUser($params['user_id']); $data['user']['coupon_count'] = $this->couponService->countAvailableByUser($params['user_id']); From 2996763294ba72f6230401ae1aebb2d4808afeff Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 3 Sep 2020 20:19:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E3=80=81=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/Banner.php | 17 ++ app/Constants/v3/SsdbKeys.php | 6 + app/Constants/v3/Tabs.php | 10 ++ .../v3/GoodsRecommendController.php | 15 +- app/Controller/v3/HomeController.php | 156 ++++-------------- app/Model/v3/Banner.php | 21 +++ app/Model/v3/GoodsActivity.php | 49 ++++++ .../v3/Implementations/ActivityService.php | 110 ++++++++++++ .../v3/Implementations/BannerService.php | 14 ++ .../v3/Implementations/CategoryService.php | 18 ++ .../Interfaces/ActivityServiceInterface.php | 11 ++ .../v3/Interfaces/BannerServiceInterface.php | 8 + .../Interfaces/CategoryServiceInterface.php | 1 + config/autoload/dependencies.php | 1 + 14 files changed, 306 insertions(+), 131 deletions(-) create mode 100644 app/Constants/v3/Banner.php create mode 100644 app/Model/v3/Banner.php create mode 100644 app/Model/v3/GoodsActivity.php create mode 100644 app/Service/v3/Implementations/ActivityService.php create mode 100644 app/Service/v3/Implementations/BannerService.php create mode 100644 app/Service/v3/Interfaces/ActivityServiceInterface.php create mode 100644 app/Service/v3/Interfaces/BannerServiceInterface.php diff --git a/app/Constants/v3/Banner.php b/app/Constants/v3/Banner.php new file mode 100644 index 0000000..a333263 --- /dev/null +++ b/app/Constants/v3/Banner.php @@ -0,0 +1,17 @@ + 0, 'is_effective' => 2, 'noneffective_note' => '已卖完', + 'store' => ['id' => 1, 'logo' => '', 'name' => '我是一个商家'] ], - 'store' => ['id' => 1, 'logo' => '', 'name' => '我是一个商家'] + ], [ 'goods' => [ @@ -55,8 +57,8 @@ class GoodsRecommendController extends BaseController 'cart_num' => 0, 'is_effective' => 2, 'noneffective_note' => '已卖完', + 'store' => ['id' => 222, 'logo' => '', 'name' => '我是一个商家222'] ], - 'store' => ['id' => 222, 'logo' => '', 'name' => '我是一个商家222'] ], [ 'goods' => [ @@ -75,8 +77,9 @@ class GoodsRecommendController extends BaseController 'cart_num' => 0, 'is_effective' => 2, 'noneffective_note' => '已卖完', + 'store' => ['id' => 2, 'logo' => '', 'name' => '我是一个商家333'] ], - 'store' => ['id' => 2, 'logo' => '', 'name' => '我是一个商家333'] + ], [ 'goods' => [ @@ -221,7 +224,11 @@ class GoodsRecommendController extends BaseController */ public function getByTab() { - return $this->success(['tab_data' => $this->data]); + $goods = Goods::query() + ->with(['store']) + ->limit(6) + ->get()->toArray(); + return $this->success(['tab_data' => $goods]); } diff --git a/app/Controller/v3/HomeController.php b/app/Controller/v3/HomeController.php index 174f92c..2b4befc 100644 --- a/app/Controller/v3/HomeController.php +++ b/app/Controller/v3/HomeController.php @@ -3,10 +3,14 @@ namespace App\Controller\v3; use App\Constants\v3\ActivityType; +use App\Constants\v3\Banner; use App\Constants\v3\SsdbKeys; use App\Constants\v3\Tabs; use App\Controller\BaseController; use App\Request\v3\UserIndexRequest; +use App\Service\v3\Interfaces\ActivityServiceInterface; +use App\Service\v3\Interfaces\BannerServiceInterface; +use App\Service\v3\Interfaces\CategoryServiceInterface; use App\Service\v3\Interfaces\CollectStoreServiceInterface; use App\Service\v3\Interfaces\CouponServiceInterface; use App\Service\v3\Interfaces\UserCenterBlockServiceInterface; @@ -47,6 +51,24 @@ class HomeController extends BaseController */ protected $userCenterBlockService; + /** + * @Inject + * @var BannerServiceInterface + */ + protected $bannerService; + + /** + * @Inject + * @var CategoryServiceInterface + */ + protected $categoryService; + + /** + * @Inject + * @var ActivityServiceInterface + */ + protected $activityService; + /** * 小程序首页,根据market_id * 1.banner数据 @@ -56,135 +78,15 @@ class HomeController extends BaseController */ public function appletIndex() { - $seconds = 25600; - $days = bcdiv($seconds, 86400); - $leftSeconds = bcsub($seconds, bcmul($days,86400)); - $hours = bcdiv($leftSeconds,3600); - $leftSeconds = bcsub($leftSeconds, bcmul($hours,3600)); - $minutes = bcdiv($leftSeconds,60); - $leftSeconds = bcsub($leftSeconds, bcmul($minutes,60)); + $marketId = $this->request->input('market_id', 0); + $banners = $this->bannerService->all(Banner::TYPE_APPLET_INDEX, $marketId); + $categories = $this->categoryService->allForAppletIndex(); + $activity = $this->activityService->allForAppletIndex(ActivityType::FLASH_SALE, $marketId); return $this->success([ - 'banners' => [ - [ - 'id' => 2, - 'img' => 'https://store.lanzu.vip/attachment/images/2/2020/06/nfXxIhEgH71hcSxSz2hHnaaEaF1g3A.jpg', - 'title' => '懒族生活', - 'subtitle' => '满足您的美味生活', - 'redirect_type' => '', - 'redirect_url' => '', - 'bg_color' => '#FF00FF', - ], - [ - 'id' => 3, - 'img' => 'http://lanzutest.lanzulive.com/attachment/images/2/2020/08/PY55Y3Mz17yJo17rv1Z7vImX1V5159.jpg', - 'title' => '鲜菜有爱', - 'subtitle' => '很实在', - 'redirect_type' => 'page', - 'redirect_url' => '/pages/index', - 'bg_color' => '#0000FF', - ], - ], - 'categories' => [ - ['id' => 1, 'icon' => config('alioss.img_host').'/attachment/types/卤菜.png', 'name' => '卤菜'], - ['id' => 2, 'icon' => config('alioss.img_host').'/attachment/types/水果.png', 'name' => '水果'], - ['id' => 3, 'icon' => config('alioss.img_host').'/attachment/types/肉.png', 'name' => '肉'], - ['id' => 4, 'icon' => config('alioss.img_host').'/attachment/types/蔬菜.png', 'name' => '蔬菜'], - ['id' => 5, 'icon' => config('alioss.img_host').'/attachment/types/蔬菜.png', 'name' => '蔬菜'], - ['id' => 6, 'icon' => config('alioss.img_host').'/attachment/types/肉.png', 'name' => '肉'], - ['id' => 7, 'icon' => config('alioss.img_host').'/attachment/types/水果.png', 'name' => '水果'], - ['id' => 8, 'icon' => config('alioss.img_host').'/attachment/types/卤菜.png', 'name' => '卤菜'], - ], - 'activity' => [ - 'type' => ActivityType::FLASH_SALE, - 'goods' => [ - [ - 'id' => 1, - 'store_id' => 111, - 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', - 'name' => '【优质】大白菜', - 'spec' => [ - ['key' => '净含量', 'value' => '500g'] - ], - 'original_price' => 50.5, - 'price' => 25.25, - 'inventory' => 0, - 'month_sales' => 20, - 'total_sales' => 20, - 'cart_num' => 0, - 'is_effective' => 1, - 'noneffective_note' => '已抢光', - 'total_seconds' => $seconds, - 'days' => $days, - 'hours' => $hours, - 'minutes' => $minutes, - 'seconds' => $leftSeconds, - ],[ - 'id' => 1, - 'store_id' => 111, - 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', - 'name' => '【优质】大白菜', - 'spec' => [ - ['key' => '净含量', 'value' => '500g'] - ], - 'original_price' => 50.5, - 'price' => 25.25, - 'inventory' => 0, - 'month_sales' => 20, - 'total_sales' => 20, - 'cart_num' => 0, - 'is_effective' => 1, - 'noneffective_note' => '已抢光', - 'total_seconds' => $seconds, - 'days' => $days, - 'hours' => $hours, - 'minutes' => $minutes, - 'seconds' => $leftSeconds, - ],[ - 'id' => 1, - 'store_id' => 111, - 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', - 'name' => '【优质】大白菜', - 'spec' => [ - ['key' => '净含量', 'value' => '500g'] - ], - 'original_price' => 50.5, - 'price' => 25.25, - 'inventory' => 0, - 'month_sales' => 20, - 'total_sales' => 20, - 'cart_num' => 0, - 'is_effective' => 1, - 'noneffective_note' => '已抢光', - 'total_seconds' => $seconds, - 'days' => $days, - 'hours' => $hours, - 'minutes' => $minutes, - 'seconds' => $leftSeconds, - ],[ - 'id' => 1, - 'store_id' => 111, - 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', - 'name' => '【优质】大白菜', - 'spec' => [ - ['key' => '净含量', 'value' => '500g'] - ], - 'original_price' => 50.5, - 'price' => 25.25, - 'inventory' => 0, - 'month_sales' => 20, - 'total_sales' => 20, - 'cart_num' => 0, - 'is_effective' => 1, - 'noneffective_note' => '已抢光', - 'total_seconds' => $seconds, - 'days' => $days, - 'hours' => $hours, - 'minutes' => $minutes, - 'seconds' => $leftSeconds, - ], - ] - ], + 'banners' => $banners, + 'categories' => $categories, + 'activity' => $activity, 'tabs' => [ ['tab' => Tabs::APPLET_INDEX_RECOMMEND, 'title' => '推荐', 'subtitle' => '猜你喜欢', 'badge' => '', 'bg_color' => '#FF0000', 'font_color' => '#FFFFFF'], ['tab' => Tabs::APPLET_INDEX_NEW, 'title' => '懒族上新', 'subtitle' => '买点不一样', 'badge' => '限时', 'bg_color' => '#FF0000', 'font_color' => '#FFFFFF'], diff --git a/app/Model/v3/Banner.php b/app/Model/v3/Banner.php new file mode 100644 index 0000000..805c5cb --- /dev/null +++ b/app/Model/v3/Banner.php @@ -0,0 +1,21 @@ +where(['status' => 1]); + }); + } +} \ No newline at end of file diff --git a/app/Model/v3/GoodsActivity.php b/app/Model/v3/GoodsActivity.php new file mode 100644 index 0000000..5cf01f9 --- /dev/null +++ b/app/Model/v3/GoodsActivity.php @@ -0,0 +1,49 @@ + 'array', + 'spec' => 'array', + 'tags' => 'array', + ]; + + protected $appends = [ + 'month_sales', + 'cart_num', + ]; + + protected function boot(): void + { + parent::boot(); + self::addGlobalScope('normal', function (Builder $builder) { + $builder->where(['on_sale' => GoodsConstants::ON_SALE_YES]); + }); + } + + public function getMonthSalesAttribute() + { + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + return (integer)$ssdb->exec('get', SsdbKeys::GOODS_MONTH_SALES.date('YM').'_'.$this->id); + } + + public function getCartNumAttribute() + { + return (integer)$this->shopCartService->check($this->id); + } + + public function store() + { + return $this->belongsTo(Store::class, 'store_id', 'goods_id'); + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/ActivityService.php b/app/Service/v3/Implementations/ActivityService.php new file mode 100644 index 0000000..58788f9 --- /dev/null +++ b/app/Service/v3/Implementations/ActivityService.php @@ -0,0 +1,110 @@ +where(['type' => $type, 'market_id' => $marketId]) + ->addSelect('sales as total_sales') + ->get()->toArray(); + + return [ + 'type' => ActivityType::FLASH_SALE, + 'goods' => [ + [ + 'id' => 1, + 'store_id' => 111, + 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', + 'name' => '【优质】大白菜', + 'spec' => [ + ['key' => '净含量', 'value' => '500g'] + ], + 'original_price' => 50.5, + 'price' => 25.25, + 'inventory' => 0, + 'month_sales' => 20, + 'total_sales' => 20, + 'cart_num' => 0, + 'is_effective' => 1, + 'noneffective_note' => '已抢光', + 'total_seconds' => $seconds, + ],[ + 'id' => 1, + 'store_id' => 111, + 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', + 'name' => '【优质】大白菜', + 'spec' => [ + ['key' => '净含量', 'value' => '500g'] + ], + 'original_price' => 50.5, + 'price' => 25.25, + 'inventory' => 0, + 'month_sales' => 20, + 'total_sales' => 20, + 'cart_num' => 0, + 'is_effective' => 1, + 'noneffective_note' => '已抢光', + 'total_seconds' => $seconds, + ],[ + 'id' => 1, + 'store_id' => 111, + 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', + 'name' => '【优质】大白菜', + 'spec' => [ + ['key' => '净含量', 'value' => '500g'] + ], + 'original_price' => 50.5, + 'price' => 25.25, + 'inventory' => 0, + 'month_sales' => 20, + 'total_sales' => 20, + 'cart_num' => 0, + 'is_effective' => 1, + 'noneffective_note' => '已抢光', + 'total_seconds' => $seconds, + ],[ + 'id' => 1, + 'store_id' => 111, + 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', + 'name' => '【优质】大白菜', + 'spec' => [ + ['key' => '净含量', 'value' => '500g'] + ], + 'original_price' => 50.5, + 'price' => 25.25, + 'inventory' => 0, + 'month_sales' => 20, + 'total_sales' => 20, + 'cart_num' => 0, + 'is_effective' => 1, + 'noneffective_note' => '已抢光', + 'total_seconds' => $seconds, + ], + ] + ]; + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/BannerService.php b/app/Service/v3/Implementations/BannerService.php new file mode 100644 index 0000000..5cd4541 --- /dev/null +++ b/app/Service/v3/Implementations/BannerService.php @@ -0,0 +1,14 @@ +where(['type' => $type, 'market_id' => $marketId])->get()->toArray(); + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/CategoryService.php b/app/Service/v3/Implementations/CategoryService.php index 2a06ce7..4ecae9c 100644 --- a/app/Service/v3/Implementations/CategoryService.php +++ b/app/Service/v3/Implementations/CategoryService.php @@ -2,10 +2,13 @@ namespace App\Service\v3\Implementations; +use App\Constants\v3\SsdbKeys; use App\Model\v3\Goods; use App\Model\v3\GoodsType; use App\Model\v3\StoreType; use App\Service\v3\Interfaces\CategoryServiceInterface; +use App\TaskWorker\SSDBTask; +use Hyperf\Utils\ApplicationContext; class CategoryService implements CategoryServiceInterface { @@ -48,4 +51,19 @@ class CategoryService implements CategoryServiceInterface ->orderBy('id', 'DESC') ->get()->toArray(); } + + public function allForAppletIndex() + { + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + $categories = $ssdb->exec('hgetall', SsdbKeys::APPLET_INDEX_CATEGORY); + + // key是分类ID,value是icon和name的json + $returnData = []; + foreach ($categories as $key => &$category) { + $value = json_decode($category, true); + $returnData[] = ['id' => $key, 'icon' => config('alioss.img_host').$value['icon'], 'name' => $value['name']]; + } + + return $returnData; + } } \ No newline at end of file diff --git a/app/Service/v3/Interfaces/ActivityServiceInterface.php b/app/Service/v3/Interfaces/ActivityServiceInterface.php new file mode 100644 index 0000000..2d4c2d3 --- /dev/null +++ b/app/Service/v3/Interfaces/ActivityServiceInterface.php @@ -0,0 +1,11 @@ + \App\Service\v3\Implementations\CouponService::class, \App\Service\v3\Interfaces\OrderListServiceInterface::class => \App\Service\v3\Implementations\OrderListService::class, \App\Service\v3\Interfaces\UserCenterBlockServiceInterface::class => \App\Service\v3\Implementations\UserCenterBlockService::class, + \App\Service\v3\Interfaces\BannerServiceInterface::class => \App\Service\v3\Implementations\BannerService::class, ];