EngineerBillController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /**
  30. * @notes 获取列表
  31. * @return \think\response\Json
  32. * @author likeadmin
  33. * @date 2024/11/15 17:21
  34. */
  35. public function lists()
  36. {
  37. return $this->dataLists(new EngineerBillLists());
  38. }
  39. public function download()
  40. {
  41. /*$firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
  42. $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
  43. $filename = date('Y-m-d',strtotime($firstDay))."-至-".date('Y-m-d',strtotime($lastDay))."最后结算余额";
  44. $result = ExportLogic::add([
  45. 'download_type' => 1,
  46. 'params' => ['firstDay'=>$firstDay,'lastDay'=>$lastDay],
  47. 'name' => $filename,
  48. 'admin_id' => $this->adminId,
  49. ]);
  50. if (false === $result) {
  51. return $this->fail(ExportLogic::getError());
  52. }*/
  53. $params = $this->request->post();
  54. $deadline_time = strtotime($params['deadline_time'])+86400;
  55. $settlement_type = $params['settlement_type'];
  56. $filename = "每".$settlement_type."截止到".$params['deadline_time']."批号".$params['deadline_time']."-最后结算余额";
  57. $result = ExportLogic::add([
  58. 'download_type' => 1,
  59. 'params' => ['settlement_type'=>$settlement_type,'deadline_time'=>$deadline_time],
  60. 'name' => $filename,
  61. 'admin_id' => $this->adminId,
  62. ]);
  63. if (false === $result) {
  64. return $this->fail(ExportLogic::getError());
  65. }
  66. // 暂时 - 立即生成导出文件
  67. (new ExcelExportService)->download($result);
  68. return $this->success('添加成功-'.$result, [], 1, 1);
  69. }
  70. }