Browse Source

商家中心

master
Lemon 5 years ago
parent
commit
aa475ac3fd
  1. 3
      app/Controller/v3/GoodsController.php
  2. 39
      app/Controller/v3/HomeController.php
  3. 14
      app/Controller/v3/OrderListController.php
  4. 4
      app/Controller/v3/StoreLoginController.php
  5. 15
      app/Model/v3/Order.php
  6. 5
      app/Model/v3/OrderMain.php
  7. 4
      app/Service/v3/Implementations/GoodsService.php
  8. 72
      app/Service/v3/Implementations/OrderListService.php
  9. 30
      app/Service/v3/Implementations/StoreInfoService.php
  10. 4
      app/Service/v3/Implementations/StoreLoginService.php
  11. 2
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  12. 2
      app/Service/v3/Interfaces/OrderListServiceInterface.php
  13. 16
      app/Service/v3/Interfaces/StoreInfoServiceInterface.php
  14. 2
      app/Service/v3/Interfaces/StoreLoginServiceInterface.php
  15. 3
      config/autoload/dependencies.php
  16. 3
      config/routes.php

3
app/Controller/v3/GoodsController.php

@ -22,9 +22,8 @@ class GoodsController extends BaseController
public function detail() public function detail()
{ {
$params = $this->request->all(); $params = $this->request->all();
$res['detail'] = $this->goodsService->do();
$res['detail'] = $this->goodsService->do(35);
$res['banner'] = $this->goodsService->getBanner(); $res['banner'] = $this->goodsService->getBanner();
$res['store'] = $this->storeService->detail($params['store_id']);
return $this->success($res); return $this->success($res);
} }
} }

39
app/Controller/v3/HomeController.php

@ -9,6 +9,7 @@ use App\Controller\BaseController;
use App\Request\v3\UserIndexRequest; use App\Request\v3\UserIndexRequest;
use App\Service\v3\Interfaces\CollectStoreServiceInterface; use App\Service\v3\Interfaces\CollectStoreServiceInterface;
use App\Service\v3\Interfaces\CouponServiceInterface; use App\Service\v3\Interfaces\CouponServiceInterface;
use App\Service\v3\Interfaces\StoreInfoServiceInterface;
use App\Service\v3\Interfaces\UserCenterBlockServiceInterface; use App\Service\v3\Interfaces\UserCenterBlockServiceInterface;
use App\Service\v3\Interfaces\UserInfoServiceInterface; use App\Service\v3\Interfaces\UserInfoServiceInterface;
use App\TaskWorker\SSDBTask; use App\TaskWorker\SSDBTask;
@ -47,6 +48,12 @@ class HomeController extends BaseController
*/ */
protected $userCenterBlockService; protected $userCenterBlockService;
/**
* @Inject
* @var StoreInfoServiceInterface
*/
protected $storeInfoService;
/** /**
* 小程序首页,根据market_id * 小程序首页,根据market_id
* 1.banner数据 * 1.banner数据
@ -54,6 +61,7 @@ class HomeController extends BaseController
* 3.活动数据(秒杀、团购、新品、无) * 3.活动数据(秒杀、团购、新品、无)
* 4.tabs数据 * 4.tabs数据
*/ */
public function appletIndex() public function appletIndex()
{ {
$seconds = 25600; $seconds = 25600;
@ -220,4 +228,35 @@ class HomeController extends BaseController
return $this->success($data); return $this->success($data);
} }
/**
* 商家入口详情
*/
public function storeIndex()
{
$data['detail'] = $this->storeInfoService->detail();
$data['order_online'] = [
'count' => 6549,
'total' => 12654.12
];
$data['order_offline'] = [
'count' => 3639,
'total' => 89563.12
];
$data['new_user'] = [
'day' => 10,
'week' => 15,
'month' => 25,
'all' => 50
];
$data['badge'] = [
'unpaid' => 0,
'receiving' => 0,
'completed' => 0,
'refund' => 0,
];
return $this->success($data);
}
} }

14
app/Controller/v3/OrderListController.php

@ -37,4 +37,18 @@ class OrderListController extends BaseController
$list = $this->orderListService->onlineByUser($params['user_id'], $params['tab'], $params['page'], $params['pagesize']); $list = $this->orderListService->onlineByUser($params['user_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list); return $this->success($list);
} }
public function onlineForStore()
{
$params = $this->request->all();
$list = $this->orderListService->onlineByStore($params['store_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list);
}
public function offlineForStore()
{
$params = $this->request->all();
$list = $this->orderListService->offlineByStore($params['store_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list);
}
} }

4
app/Controller/v3/StoreLoginController.php

@ -5,7 +5,7 @@ namespace App\Controller\v3;
use App\Controller\BaseController; use App\Controller\BaseController;
use App\Service\v3\Interfaces\StoreLoginServicceInterface;
use App\Service\v3\Interfaces\StoreLoginServiceInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
@ -13,7 +13,7 @@ class StoreLoginController extends BaseController
{ {
/** /**
* @Inject * @Inject
* @var StoreLoginServicceInterface
* @var StoreLoginServiceInterface
*/ */
protected $storeLoginServicce; protected $storeLoginServicce;
public function login() public function login()

15
app/Model/v3/Order.php

@ -12,4 +12,19 @@ class Order extends Model
{ {
return $this->hasMany(OrderGoods::class, 'order_id', 'id'); return $this->hasMany(OrderGoods::class, 'order_id', 'id');
} }
public function market()
{
return $this->belongsTo(Market::class, 'market_id', 'id');
}
public function orderMain()
{
return $this->belongsTo(OrderMain::class, 'order_main_id', 'id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
} }

5
app/Model/v3/OrderMain.php

@ -66,4 +66,9 @@ class OrderMain extends Model
'id' 'id'
); );
} }
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
} }

4
app/Service/v3/Implementations/GoodsService.php

@ -8,9 +8,9 @@ use App\Model\v3\Goods;
class GoodsService implements GoodsServiceInterface class GoodsService implements GoodsServiceInterface
{ {
public function do()
public function do($goodsId)
{ {
$res = Goods::query()->where('id',35)->get();
$res = Goods::query()->with('store')->where('id',$goodsId)->first();
return $res; return $res;
} }

72
app/Service/v3/Implementations/OrderListService.php

@ -4,6 +4,7 @@ namespace App\Service\v3\Implementations;
use App\Constants\v3\OrderState; use App\Constants\v3\OrderState;
use App\Model\v3\OrderMain; use App\Model\v3\OrderMain;
use App\Model\v3\Order;
use App\Service\v3\Interfaces\OrderListServiceInterface; use App\Service\v3\Interfaces\OrderListServiceInterface;
use Hyperf\Paginator\Paginator; use Hyperf\Paginator\Paginator;
@ -35,7 +36,76 @@ class OrderListService implements OrderListServiceInterface
->with(['market' => function($query) { ->with(['market' => function($query) {
$query->select(['lanzu_market.id', 'lanzu_market.name', 'lanzu_market.tel']); $query->select(['lanzu_market.id', 'lanzu_market.name', 'lanzu_market.tel']);
}]) }])
->where(['user_id' => $userId]);
->where([
['user_id','=',$userId],
['type','=',1]
]);
switch ($tab) {
case 'all':
break;
case 'completed':
$builder->whereIn('state', OrderState::FINISH);
break;
case 'unpaid':
$builder->where(['state' => OrderState::UNPAID]);
break;
case 'receiving':
$builder->whereIn('state', OrderState::RECEIVING);
break;
case 'refund':
$builder->whereIn('state', OrderState::REFUND);
break;
}
$paginate = $builder->paginate($pagesize);
$orders = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
}
public function onlineByStore($storeId, $tab, $page=1, $pagesize=10)
{
$builder = OrderMain::query()
->select('id','global_order_id', 'money', 'state', 'market_id', 'created_at')
->with(['orders' => function($query) use ($storeId) {
$query->where('store_id',$storeId)->with('orderGoods');
}])
->where([
'type' => 1
]);
switch ($tab) {
case 'all':
break;
case 'completed':
$builder->whereIn('state', OrderState::FINISH);
break;
case 'unpaid':
$builder->where(['state' => OrderState::UNPAID]);
break;
case 'receiving':
$builder->whereIn('state', OrderState::RECEIVING);
break;
case 'refund':
$builder->whereIn('state', OrderState::REFUND);
break;
}
$paginate = $builder->paginate($pagesize);
$orders = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
}
public function offlineByStore($storeId, $tab, $page=1, $pagesize=10)
{
$builder = Order::query()
->with(['orderMain' => function($query) {
$query->where('lanzu_order_main.type',4);
}])
->with(['user' => function($query) {
$query->select(['lanzu_user.id', 'lanzu_user.nick_name']);
}])
->where([
'store_id' => $storeId
]);
switch ($tab) { switch ($tab) {
case 'all': case 'all':
break; break;

30
app/Service/v3/Implementations/StoreInfoService.php

@ -0,0 +1,30 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\StoreInfoServiceInterface;
use App\Model\v3\Store;
class StoreInfoService implements StoreInfoServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check()
{
}
public function undo()
{
// TODO: Implement undo() method.
}
public function detail()
{
return Store::query()->where('id',1)->first()->toArray();
}
}

4
app/Service/v3/Implementations/StoreLoginService.php

@ -4,9 +4,9 @@
namespace App\Service\v3\Implementations; namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode; use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException; use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\StoreLoginServicceInterface;
use App\Service\v3\Interfaces\StoreLoginServiceInterface;
class StoreLoginService implements StoreLoginServicceInterface
class StoreLoginService implements StoreLoginServiceInterface
{ {
public function do($account,$password) public function do($account,$password)
{ {

2
app/Service/v3/Interfaces/GoodsServiceInterface.php

@ -4,7 +4,7 @@ namespace App\Service\v3\Interfaces;
interface GoodsServiceInterface interface GoodsServiceInterface
{ {
public function do();
public function do($goodsId);
public function check($goodsId); public function check($goodsId);
public function undo(); public function undo();
public function getBanner(); public function getBanner();

2
app/Service/v3/Interfaces/OrderListServiceInterface.php

@ -8,4 +8,6 @@ interface OrderListServiceInterface
public function check(); public function check();
public function undo(); public function undo();
public function onlineByUser($userId, $tab, $page=1, $pagesize=10); public function onlineByUser($userId, $tab, $page=1, $pagesize=10);
public function onlineByStore($userId, $tab, $page, $pagesize);
public function offlineByStore($userId, $tab, $page, $pagesize);
} }

16
app/Service/v3/Interfaces/StoreInfoServiceInterface.php

@ -0,0 +1,16 @@
<?php
namespace App\Service\v3\Interfaces;
interface StoreInfoServiceInterface
{
public function do();
public function check();
public function undo();
public function detail();
}

2
app/Service/v3/Interfaces/StoreLoginServicceInterface.php → app/Service/v3/Interfaces/StoreLoginServiceInterface.php

@ -4,7 +4,7 @@
namespace App\Service\v3\Interfaces; namespace App\Service\v3\Interfaces;
interface StoreLoginServicceInterface
interface StoreLoginServiceInterface
{ {
public function do($account,$password); public function do($account,$password);
public function check(); public function check();

3
config/autoload/dependencies.php

@ -54,5 +54,6 @@ return [
\App\Service\v3\Interfaces\CouponServiceInterface::class => \App\Service\v3\Implementations\CouponService::class, \App\Service\v3\Interfaces\CouponServiceInterface::class => \App\Service\v3\Implementations\CouponService::class,
\App\Service\v3\Interfaces\OrderListServiceInterface::class => \App\Service\v3\Implementations\OrderListService::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\UserCenterBlockServiceInterface::class => \App\Service\v3\Implementations\UserCenterBlockService::class,
\App\Service\v3\Interfaces\StoreLoginServicceInterface::class => \App\Service\v3\Implementations\StoreLoginService::class,
\App\Service\v3\Interfaces\StoreLoginServiceInterface::class => \App\Service\v3\Implementations\StoreLoginService::class,
\App\Service\v3\Interfaces\StoreInfoServiceInterface::class => \App\Service\v3\Implementations\StoreInfoService::class,
]; ];

3
config/routes.php

@ -109,4 +109,7 @@ Router::addGroup('/v3/', function () {
Router::post('shopCart/detail', 'App\Controller\v3\ShopCartController@detail'); Router::post('shopCart/detail', 'App\Controller\v3\ShopCartController@detail');
Router::post('orderOnline/review', 'App\Controller\v3\OrderOnlineController@review'); Router::post('orderOnline/review', 'App\Controller\v3\OrderOnlineController@review');
Router::post('storeLogin/login', 'App\Controller\v3\StoreLoginController@login'); Router::post('storeLogin/login', 'App\Controller\v3\StoreLoginController@login');
Router::post('home/storeIndex', 'App\Controller\v3\HomeController@storeIndex');
Router::post('orderList/onlineForStore', 'App\Controller\v3\OrderListController@onlineForStore');
Router::post('orderList/offlineForStore', 'App\Controller\v3\OrderListController@offlineForStore');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save