This commit is contained in:
邓皓元 2019-05-10 18:14:52 +08:00
parent 098b6830d0
commit 1351b340a8

View File

@ -57,12 +57,13 @@ class CardService extends Service
$simArray = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->orderBy('sim')->forPage($page, $limit)->get()->pluck('sim')->toArray(); $simArray = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->orderBy('sim')->forPage($page, $limit)->get()->pluck('sim')->toArray();
$subQuery = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->currentModel(); $subQuery = $this->orderCardPartitionRepository->selectRaw('sim')->withConditions($conditions)->currentModel();
$query = DB::table(DB::raw("({$subQuery->toSql()}) as sub")) $res = DB::table(DB::raw("({$subQuery->toSql()}) as sub"))
->select(DB::raw('count(sim)')) ->select(DB::raw('count(*) as total'))
->mergeBindings($subQuery->getQuery()) ->mergeBindings($subQuery->getQuery())
->get(); ->first();
$total = $res->total;
$total = $query->count;
$cards = $this->orderCardPartitionRepository->select($select)->where('type', 0)->whereIn('sim', $simArray)->get(); $cards = $this->orderCardPartitionRepository->select($select)->where('type', 0)->whereIn('sim', $simArray)->get();
} else { } else {
$total = $this->orderCardPartitionRepository->withConditions($conditions)->count(); $total = $this->orderCardPartitionRepository->withConditions($conditions)->count();