Browse Source

店铺排序筛选重复数据

master
Lemon 5 years ago
parent
commit
a34c38907a
  1. 3
      app/Controller/v3/StoreController.php
  2. 15
      app/Service/v3/Implementations/StoreService.php
  3. 2
      app/Service/v3/Interfaces/StoreServiceInterface.php

3
app/Controller/v3/StoreController.php

@ -110,6 +110,7 @@ class StoreController extends BaseController
$userId = $this->request->input('user_id');
$page = $this->request->input('page',1);
$pagesize = $this->request->input('pagesize',10);
$ids = $this->request->input('ids','');
$employees = Employees::query()
->where('user_id',$userId)
->whereJsonContains('position', '30')
@ -117,7 +118,7 @@ class StoreController extends BaseController
if(empty($employees)){
return $this->success(['personnel' => false]);
}
$res = $this->storeService->getList($employees->market_id,$page,$pagesize);
$res = $this->storeService->getList($employees->market_id,$ids,$page,$pagesize);
return $this->success($res);
}

15
app/Service/v3/Implementations/StoreService.php

@ -58,14 +58,21 @@ class StoreService implements StoreServiceInterface
->first();
}
public function getList($marketId, $page=1, $pagesize=10)
public function getList($marketId,$ids, $page=1, $pagesize=10)
{
$market = Market::query()->withoutGlobalScope('normal')->find($marketId);
$builder = Store::query();
$paginate = $builder->where('market_id',$marketId)->orderBy('is_rest', 'asc')->paginate($pagesize);
$builder = Store::query()->where('market_id',$marketId);
if(!is_null($ids)){
$ids = explode(',',$ids);
$builder->whereNotIn('id',$ids);
}
$paginate = $builder->orderBy('is_rest', 'asc')->paginate($pagesize);
$stores = $paginate->toArray();
$market->stores = $stores['data'];
return ['has_more_pages' => $paginate->hasMorePages(), 'market' => $market];
$newIds = array_values(array_column($stores['data'], 'id'));
$ids = array_merge($ids,$newIds);
$ids = implode(',',$ids);
return ['has_more_pages' => $paginate->hasMorePages(), 'market' => $market,'ids' => $ids];
}
public function getListByMarketId($marketId, $page=1, $pagesize=10)

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

@ -8,7 +8,7 @@ interface StoreServiceInterface
public function check($storeId);
public function undo();
public function detail($storeId);
public function getList($marketId ,$page=1, $pagesize=10);
public function getList($marketId ,$ids,$page=1, $pagesize=10);
public function getListByMarketId($marketId ,$page=1, $pagesize=10);
public function updateIsRest($storeId);
}
Loading…
Cancel
Save