MotorRecord.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace app\api\controller\v1\taxi;
  3. use app\api\controller\ApiController;
  4. use app\api\service\JWTAuth as IAuth;
  5. use think\App;
  6. use think\Request;
  7. class MotorRecord extends ApiController
  8. {
  9. protected $model;
  10. public function __construct(App $app = null, IAuth $auth)
  11. {
  12. parent::__construct($app, $auth);
  13. $this->model = new \app\api\model\taxi\MotorRecord();
  14. }
  15. /**
  16. * 显示资源列表
  17. *
  18. * @return \think\Response
  19. * @throws \Lettered\Support\Exceptions\FailedException
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. * @throws \think\exception\DbException
  23. */
  24. public function index()
  25. {
  26. $list = [];
  27. // 按月份
  28. for($month = 1; $month <= date('m'); $month ++ ){
  29. $data = $this->model->where(['user_id' => $this->auth->user()['id']])
  30. ->field("*,FROM_UNIXTIME(created_at, '%Y-%m-%d %H:%i:%s') as created_at")
  31. ->where('type', 30)
  32. ->whereTime('created_at', 'between', $this->model->getMonthTime($month))
  33. ->order(['id' => 'desc', 'updated_at' => 'desc'])
  34. ->select();
  35. if (count($data) != 0)
  36. $list[date('Y') . $month] = $data;
  37. }
  38. return $this->ApiJson(0, '获取信息成功', $list);
  39. }
  40. /**
  41. * 显示创建资源表单页.
  42. *
  43. * @return \think\Response
  44. */
  45. public function create()
  46. {
  47. //
  48. }
  49. /**
  50. * 保存新建的资源
  51. *
  52. * @param \think\Request $request
  53. * @return \think\Response
  54. */
  55. public function save(Request $request)
  56. {
  57. //
  58. }
  59. /**
  60. * 显示指定的资源
  61. *
  62. * @param int $id
  63. * @return \think\Response
  64. */
  65. public function read($id)
  66. {
  67. //
  68. }
  69. /**
  70. * 显示编辑资源表单页.
  71. *
  72. * @param int $id
  73. * @return \think\Response
  74. */
  75. public function edit($id)
  76. {
  77. //
  78. }
  79. /**
  80. * 保存更新的资源
  81. *
  82. * @param \think\Request $request
  83. * @param int $id
  84. * @return \think\Response
  85. */
  86. public function update(Request $request, $id)
  87. {
  88. //
  89. }
  90. /**
  91. * 删除指定资源
  92. *
  93. * @param int $id
  94. * @return \think\Response
  95. */
  96. public function delete($id)
  97. {
  98. //
  99. }
  100. }