1
0

EngineerBillController.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. use think\facade\Log;
  23. /**
  24. * EngineerSettlement控制器
  25. * Class EngineerSettlementController
  26. * @package app\adminapi\controller
  27. */
  28. class EngineerBillController extends BaseAdminController
  29. {
  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. 'params' => ['firstDay'=>$firstDay,'lastDay'=>$lastDay],
  48. 'name' => $filename,
  49. 'admin_id' => $this->adminId,
  50. ]);
  51. if (false === $result) {
  52. return $this->fail(ExportLogic::getError());
  53. }*/
  54. $params = $this->request->get();
  55. $deadline_time = strtotime($params['deadline_time'])+86400;
  56. $settlement_type = $params['settlement_type'];
  57. $filename = "每".$settlement_type."截止到".$params['deadline_time']."批号".$params['deadline_time']."-最后结算余额";
  58. $result = ExportLogic::add([
  59. 'download_type' => 1,
  60. 'params' => ['settlement_type'=>$settlement_type,'deadline_time'=>$deadline_time],
  61. 'name' => $filename,
  62. 'admin_id' => $this->adminId,
  63. ]);
  64. if (false === $result) {
  65. return $this->fail(ExportLogic::getError());
  66. }
  67. Log::info('导出参数:'.json_encode([$params,$result]));
  68. // 暂时 - 立即生成导出文件
  69. (new ExcelExportService)->download($result);
  70. return $this->success('添加成功-'.$result, [], 1, 1);
  71. }
  72. }