total
This commit is contained in:
parent
6bc77e7e91
commit
098b6830d0
@ -39,7 +39,9 @@ class CardService extends Service
|
||||
{
|
||||
$limit = $conditions['limit'] ?? 20;
|
||||
$page = Request::get('page', 1);
|
||||
$conditions['type'] = [0];
|
||||
$conditions['type'] = isset($conditions['card_status']) ? [0, 1, 2] : 0;
|
||||
|
||||
|
||||
|
||||
$select = [
|
||||
'id',
|
||||
@ -52,8 +54,15 @@ class CardService extends Service
|
||||
|
||||
if (isset($conditions['card_status'])) {
|
||||
$conditions['type'] = [0, 1, 2];
|
||||
$total = $this->orderCardPartitionRepository->withConditions($conditions)->count();
|
||||
$simArray = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->orderBy('sim')->forPage($page, $limit)->get()->pluck('sim')->toArray();
|
||||
|
||||
$subQuery = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->currentModel();
|
||||
$query = DB::table(DB::raw("({$subQuery->toSql()}) as sub"))
|
||||
->select(DB::raw('count(sim)'))
|
||||
->mergeBindings($subQuery->getQuery())
|
||||
->get();
|
||||
|
||||
$total = $query->count;
|
||||
$cards = $this->orderCardPartitionRepository->select($select)->where('type', 0)->whereIn('sim', $simArray)->get();
|
||||
} else {
|
||||
$total = $this->orderCardPartitionRepository->withConditions($conditions)->count();
|
||||
|
Loading…
x
Reference in New Issue
Block a user