From 9c8c167f3ec1cb3b1249ee1c2d6cf9cfa9444859 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Tue, 22 Sep 2020 14:43:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86=20=20?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=20=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=95=86=E5=93=81=20=20=E5=8C=85=E6=8B=AC=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/GoodsController.php | 7 +++++ .../v3/Implementations/GoodsService.php | 10 +++++-- .../UserCenterBlockService.php | 28 ++++++++----------- .../v3/Implementations/UserInfoService.php | 4 +-- .../v3/Interfaces/GoodsServiceInterface.php | 2 ++ config/routes.php | 1 + 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 29a37d3..2d46258 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -83,4 +83,11 @@ class GoodsController extends BaseController $res = $this->goodsService->update($this->request->all()); return $this->success($res); } + + public function info() + { + $goodsId = $this->request->input('goods_id',0); + $res = $this->goodsService->info($goodsId); + return $this->success($res); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 08f0c32..c215408 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -67,13 +67,13 @@ class GoodsService implements GoodsServiceInterface public function detail($goodsId) { - $res = Goods::query()->with('store')->where('id',$goodsId)->select('*','name as goods_name')->first(); + $res = Goods::query()->with('store')->where('id',$goodsId)->first(); return $res; } public function getByType($storeId,$typeId) { - return Goods::query()->where(['store_id' => $storeId,'category_id' => $typeId])->orderByDesc('on_sale')->orderByDesc('created_at')->get()->toArray(); + return Goods::query()->withoutGlobalScope('normal')->where(['store_id' => $storeId,'category_id' => $typeId])->orderByDesc('on_sale')->orderByDesc('created_at')->get()->toArray(); } public function update($params) @@ -89,4 +89,10 @@ class GoodsService implements GoodsServiceInterface } return $goods->save(); } + + public function info($goodsId) + { + $res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->select('*','name as goods_name')->first(); + return $res; + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/UserCenterBlockService.php b/app/Service/v3/Implementations/UserCenterBlockService.php index defc9e7..376c48c 100644 --- a/app/Service/v3/Implementations/UserCenterBlockService.php +++ b/app/Service/v3/Implementations/UserCenterBlockService.php @@ -47,28 +47,22 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface 'type' => 'store_user', 'title' => '商家相关', 'items' => [ - ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter2.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'], - [ - 'name' => '商品管理', 'icon' => $img_host . 'user_icons/service2.png', - 'type' => 'webview', - 'path' => 'http://localhost:8080/#/pages/goodsManagement/goodsManagement?market_id=1&user_id=694&store_id=5', - 'command'=>'sp_login' - ] + ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter2.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'] ] ]; foreach ($roles as $key => $item) { # code... - // if($item['key'] == 'store'){ - // $blocks[] = [ - // 'type' => 'store_user', - // 'title' => '商户相关', - // 'items' => [ - // ['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login'] - // ] - // ]; - // } + if($item['key'] == 'store'){ + $goodsEditor = [ + 'name' => '商品管理', 'icon' => $img_host . 'user_icons/service2.png', + 'type' => 'webview', + 'path' => 'http://localhost:8080/#/pages/goodsManagement/goodsManagement?market_id='.$item['data']['market_id'].'&user_id='.$item['data']['user_id'].'&store_id='.$item['data']['id'], + 'command'=>'sp_login' + ]; + array_push($blocks[1]['items'],$goodsEditor); + } if($item['key'] == 'sp'){ $blocks[] = [ @@ -79,7 +73,7 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface [ 'name' => '商品管理', 'icon' => $img_host . 'user_icons/service2.png', 'type' => 'webview', - 'path' => 'http://localhost:8080/#/pages/index/index?user_id=680&personal_id=68', + 'path' => 'http://localhost:8080/#/pages/index/index?user_id='.$item['data']['user_id'].'&personal_id='.$item['data']['id'], 'command'=>'sp_login' ] ] diff --git a/app/Service/v3/Implementations/UserInfoService.php b/app/Service/v3/Implementations/UserInfoService.php index c663af9..168590a 100644 --- a/app/Service/v3/Implementations/UserInfoService.php +++ b/app/Service/v3/Implementations/UserInfoService.php @@ -79,13 +79,13 @@ class UserInfoService implements UserInfoServiceInterface public function getStoreByUID($userId) { - $store = Store::where('user_id',$userId)->select(['id','name'])->first(); + $store = Store::where('user_id',$userId)->select(['id','name','user_id','market_id'])->first(); return $store; } public function getServicePersonnelByUID($userId) { - $sp = ServicePersonnel::where('user_id',$userId)->select(['id'])->first(); + $sp = ServicePersonnel::where('user_id',$userId)->select('id','user_id')->first(); return $sp; } diff --git a/app/Service/v3/Interfaces/GoodsServiceInterface.php b/app/Service/v3/Interfaces/GoodsServiceInterface.php index 2ff7952..0ea31b3 100644 --- a/app/Service/v3/Interfaces/GoodsServiceInterface.php +++ b/app/Service/v3/Interfaces/GoodsServiceInterface.php @@ -9,7 +9,9 @@ interface GoodsServiceInterface public function do($goodsId); public function check(Goods $goods,$num = 1); public function undo(); + public function detail($goodsId); public function getBanner($goodsId); public function getByType($storeId,$typeId); public function update($params); + public function info($goodsId); } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 85acf94..767d3ad 100644 --- a/config/routes.php +++ b/config/routes.php @@ -153,6 +153,7 @@ Router::addGroup('/v3/', function () { Router::post('store/getGoodsByType', 'App\Controller\v3\StoreController@getGoodsByType'); Router::post('goods/update', 'App\Controller\v3\GoodsController@update'); Router::post('store/getList', 'App\Controller\v3\StoreController@getList'); + Router::post('goods/info', 'App\Controller\v3\GoodsController@info'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); // 微信支付回调