buildSuccess([ 'fileName' => $new_name, 'fileUrl' => $this->request->domain() . $path . $new_name ]); } else { return $this->buildFailed(ReturnCode::FILE_SAVE_ERROR, '文件上传失败'); } } /** * * @return Response */ public function statistics(): Response { try { $data = []; $wechatUserTotal = (new WechatUser)->where('delete_time', 0)->count('id'); $data['wechat_user_total'] = $wechatUserTotal; $data['invoice_head_data'] = [['type' => '机构', 'count' => 0], ['type' => '个人', 'count' => 0]]; $invoice_head_field = "type, count(id) as `count`"; $invoice_head_data = (new InvoiceHead)->field($invoice_head_field)->group('type')->select()->toArray(); if ($invoice_head_data) { foreach ($invoice_head_data as $invoice_head_value) { if ($invoice_head_value['type'] > 0) { $data['invoice_head_data'][1]['count'] += $invoice_head_value['count']; } else { $data['invoice_head_data'][0]['count'] += $invoice_head_value['count']; } } } $finalReportArr = ['type' => '当月结报金额', 'count' => 0]; $finalReportArr['count'] = (new FinalReportDate())->getSumAmount(date("Y-m")); $data['invoice_head_data'][] = $finalReportArr; return $this->buildSuccess($data); } catch (\Exception $e) { return $this->buildFailed(ReturnCode::RECORD_NOT_FOUND, '记录未找到'); } } /** * 结报金额统计-月 * @return Response */ public function getFinalReportData(): Response { $dateArr = []; $amountArr = []; $nowDate = date('Y-m'); for ($i = 5; $i >= 1; $i--) { $dateArr[] = date('Y-m', strtotime('-' . $i . ' month', strtotime($nowDate))); $amountArr[] = 0; } $dateArr[] = $nowDate; foreach ($dateArr as $key => $monthDate) { $amountArr[$key] = (new FinalReportDate())->getSumAmount($monthDate, 2); } return $this->buildSuccess([ 'date' => $dateArr, 'data' => $amountArr ]); } }