getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->paginate($kvPairs['paginateParams']['paginate'] ?? 50); $totalFee = $this->getSql($kvPairs['owner_id'], $kvPairs['counting_month'])->sum('expenditure_total_cost'); return array($details, $totalFee); } public function getSql($owner_id, $counting_month): \Illuminate\Database\Eloquent\Builder { list($start, $end) = $this->getStartAndEnd($counting_month); return DischargeTask::query() ->where('owner_id', $owner_id) ->whereBetween('income_at', [$start, $end]); } public function switchType($type) { // TODO: Implement switchType() method. } public function buildExport($details): array { $result = []; foreach ($details as $detail) { $result[] = [ $detail->income_at, $detail->type, $detail->numbers, $detail->expenditure_amount, $detail->expenditure_unit, $detail->expenditure_unit_price, $detail->expenditure_total_cost, $detail->income_remark, $detail->expenditure_remark, ]; } return $result; } public function add(array $model) { // TODO: Implement add() method. } public function getTotalFee($owner_id, $counting_month) { return $this->getSql($owner_id, $counting_month)->sum('expenditure_total_cost'); } /** * @param null $counting_month * @param array $ownerIds */ public function recordReport($counting_month = null, array $ownerIds = []) { // TODO: Implement recordReport() method. } }