Browse Source

商品管理 商品详情 分类商品 包括失效商品

master
Lemon 5 years ago
parent
commit
9c8c167f3e
  1. 7
      app/Controller/v3/GoodsController.php
  2. 10
      app/Service/v3/Implementations/GoodsService.php
  3. 28
      app/Service/v3/Implementations/UserCenterBlockService.php
  4. 4
      app/Service/v3/Implementations/UserInfoService.php
  5. 2
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  6. 1
      config/routes.php

7
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);
}
}

10
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;
}
}

28
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'
]
]

4
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;
}

2
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);
}

1
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]]);
// 微信支付回调

Loading…
Cancel
Save