EngineerBillController.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\master_worker;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\master_worker\EngineerBillLists;
  17. use app\adminapi\logic\export\ExportLogic;
  18. use app\common\service\ExcelExportService;
  19. use excel\ExcelWriter;
  20. use phpseclib3\Common\Functions\Strings;
  21. use think\facade\Db;
  22. /**
  23. * EngineerSettlement控制器
  24. * Class EngineerSettlementController
  25. * @package app\adminapi\controller
  26. */
  27. class EngineerBillController extends BaseAdminController
  28. {
  29. public array $notNeedLogin = ['download'];
  30. /**
  31. * @notes 获取列表
  32. * @return \think\response\Json
  33. * @author likeadmin
  34. * @date 2024/11/15 17:21
  35. */
  36. public function lists()
  37. {
  38. return $this->dataLists(new EngineerBillLists());
  39. }
  40. public function download()
  41. {
  42. $firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
  43. $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
  44. $filename = date('Y-m-d',strtotime($firstDay))."-至-".date('Y-m-d',strtotime($lastDay))."最后结算余额";
  45. $result = ExportLogic::add([
  46. 'download_type' => 1,
  47. 'download_fun' => 'EngineerBillDownload',
  48. 'params' => ['firstDay'=>$firstDay,'lastDay'=>$lastDay],
  49. 'name' => $filename,
  50. 'admin_id' => $this->adminId,
  51. ]);
  52. if (false === $result) {
  53. return $this->fail(ExportLogic::getError());
  54. }
  55. // 暂时 - 立即生成导出文件
  56. (new ExcelExportService)->download($result);
  57. return $this->success('添加成功-'.$result, [], 1, 1);
  58. }
  59. }