request->get(); $limit = $this->request->get('size', config('apiadmin.ADMIN_LIST_DEFAULT')); $start = $this->request->get('page', 1); $where = [['status', '=', 3]]; if (isset($param['expire_time']) && !empty($param['expire_time'])) { $where = ['expire_time', '=', strtotime($param['expire_time'])]; } $list = Db::table('invoice_issuance') ->where($where) ->field('expire_time, sum(amount) as amount_sum') ->order('expire_time asc') ->group('expire_time') ->page($start, $limit) ->select() ->toArray(); $select = Db::table('invoice_issuance')->where('status', 3)->field('count(expire_time)')->group('expire_time')->select(); $total = count($select); foreach ($list as &$item) { $count = (new InvoiceFinalReportModel())->where('report_time', $item['expire_time'])->count(); $item['status'] = $count ? 1 : 0; $item['status_str'] = $item['status'] == 1 ? '已结报' : '未结报'; $item['expire_time'] = date("Y-m", $item['expire_time']); } return $this->buildSuccess([ 'list' => $list, 'total' => $total ]); } public function report(): Response { try { $param = $this->request->get(); validate()->rule(['report_time|结报日期' => 'require|date'])->check($param); $report_time = $param['report_time']; $InvoiceIssuanceService = new InvoiceIssuanceService(); $result = $InvoiceIssuanceService->summaryReport(strtotime($report_time)); if ($result !== true) throw new \Exception($result); return $this->buildSuccess(); } catch (\Exception $e) { return $this->buildFailed(ReturnCode::EMPTY_PARAMS, $e->getMessage()); } } }