Meeting.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\cron;
  3. use app\common\util\AppMsg;
  4. use think\Db;
  5. use yunwuxin\cron\Task;
  6. // 会议室预定提醒
  7. class Meeting extends Task
  8. {
  9. public function configure()
  10. {
  11. $this->everyMinute(); //每分钟执行一次
  12. }
  13. /**
  14. * 执行任务
  15. * @return mixed
  16. */
  17. protected function execute()
  18. {
  19. try {
  20. $this->remind();
  21. } catch (\Exception $e) {
  22. trace($e->getMessage());
  23. }
  24. }
  25. public function remind(){
  26. $curTime = time() - 30*60;
  27. $lists = Db::name('meeting_apply')
  28. ->where('status',1)
  29. ->where('del',0)
  30. ->where('start_time',date('Y-m-d H:i:00',$curTime))
  31. ->field('id,org_id,user_ids')
  32. ->select();
  33. foreach ($lists as $k=>$v){
  34. $uids = $v['user_ids']?explode(',',$v['user_ids']):[];
  35. if($uids){
  36. send_jpush($uids,AppMsg::PUSH_CUSTOM,'您有会议将要开始,请做好准备!');
  37. // $uinfo = Db::name('user')->where('del',0)->whereIn('id',$uids)->field('mobile,real_name')->select();
  38. // if($uinfo){
  39. // // 添加短信队列
  40. // $content = AppMsg::getSmsMsg(AppMsg::SMS_MEETING,[
  41. // 'name' => $v['real_name'],
  42. // ]);
  43. // send_sms([$v['mobile']],$content,$v['org_id'],$v['id']);
  44. // }
  45. }
  46. }
  47. }
  48. }