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]; $where = [ ['report_time', '>=', strtotime(date("Y-m"))], ['report_time', '<', strtotime('+1 month', strtotime(date("Y-m")))] ]; $finalReportArr['count'] = (new InvoiceFinalReport())->getSumAmount($where); $data['invoice_head_data'][] = $finalReportArr; return $this->buildSuccess($data); } catch (\Exception $e) { return $this->buildFailed(ReturnCode::RECORD_NOT_FOUND, '记录未找到'); } } /** * 结报金额统计-月 * @return Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getFinalReportData() { $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) { $start_time = strtotime($monthDate); $end_time = strtotime('+1 month', $start_time); $where = [ ['report_time', '>=', $start_time], ['report_time', '<', $end_time] ]; $amountArr[$key] = (new InvoiceFinalReport())->getSumAmount($where); } return $this->buildSuccess([ 'date' => $dateArr, 'data' => $amountArr ]); } }