fail('导入失败'); } return $this->dataLists(new EngineerBillLists()); } public function download() { /*$firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month')); $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month')); $filename = date('Y-m-d',strtotime($firstDay))."-至-".date('Y-m-d',strtotime($lastDay))."最后结算余额"; $result = ExportLogic::add([ 'download_type' => 1, 'params' => ['firstDay'=>$firstDay,'lastDay'=>$lastDay], 'name' => $filename, 'admin_id' => $this->adminId, ]); if (false === $result) { return $this->fail(ExportLogic::getError()); }*/ $params = $this->request->get(); $deadline_time = strtotime($params['deadline_time'])+86400; $settlement_type = $params['settlement_type']; $allData = $this->dataLists(new EngineerBillLists())->getData()['data']['lists']; if(empty($allData)) return $this->fail('无数据'); $type = [ 1=>'周(7天)', 2=>'半月', 3=>'整月' ]; $filename = "截止到".$params['deadline_time'].$type[$settlement_type].'型结算单'; $result = ExportLogic::add([ 'download_type' => 1, 'params' => ['settlement_type'=>$settlement_type,'deadline_time'=>$deadline_time], 'name' => $filename, 'admin_id' => $this->adminId, ]); if (false === $result) { return $this->fail(ExportLogic::getError()); } Log::info('导出参数:'.json_encode([$params,$result])); // 暂时 - 立即生成导出文件 (new ExcelExportService)->download($result); return $this->success('添加成功-'.$result, [], 1, 1); } public function submitForm() { $params = $this->request->post(); $params['adminId'] = $this->adminId; $result = EngineerBillLogic::submitForm($params); if ($result === false){ return $this->fail(EngineerBillLogic::getError()); } return $this->success('打款成功', [], 1, 1); } /* * 列表导出 - 不涉及任何后续批量编号逻辑 */ public function listsDownload() { $params = $this->request->get(); $filename = "财务结算工程师"; $result = ExportLogic::add([ 'download_type' => 5, 'params' => $params, 'name' => $filename, 'admin_id' => $this->adminId, ]); if (false === $result) { return $this->fail(ExportLogic::getError()); } // 暂时 - 立即生成导出文件 (new ExcelExportService)->download($result); return $this->success('添加成功-'.$result, [], 1, 1); } }