CleanStart.php 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\cron;
  3. use app\common\model\CleanTask;
  4. use app\common\util\AppMsg;
  5. use think\Db;
  6. use yunwuxin\cron\Task;
  7. class CleanStart extends Task
  8. {
  9. public function configure()
  10. {
  11. $this->dailyAt('06:00');
  12. }
  13. /**
  14. * 执行任务
  15. * @return mixed
  16. */
  17. protected function execute()
  18. {
  19. try{
  20. // 专项保洁任务将要开始提醒 每天早上6点执行一次
  21. $curTime = date('Y-m-d');
  22. $users = Db::name('clean_task_user')
  23. ->alias('ptu')
  24. ->join('clean_task pt','pt.id = ptu.task_id')
  25. ->where('pt.del',0)
  26. ->where('pt.status',0)
  27. ->where('pt.start_time',$curTime)
  28. ->column('ptu.user_id');
  29. if($users){
  30. send_jpush($users,AppMsg::PUSH_CLEAN,'您有新的专项保洁任务将要开始,请及时执行。');
  31. }
  32. }catch (\Exception $e){
  33. trace($e->getMessage());
  34. }
  35. }
  36. }