Timer.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\index\controller;
  3. use think\Db;
  4. use tools\Qxsms;
  5. class Timer
  6. {
  7. public function apply(){ // 流程超时提醒
  8. $apps = Db::name('approval')->where('max_day','>',0)->field('id,max_day')->select();
  9. $curDate = date('Y-m-d');
  10. $cts = strtotime($curDate.' 00:00:00');
  11. $cte = strtotime($curDate.' 00:00:00')+24*60*60;
  12. if($apps){
  13. $allphones = [];
  14. foreach ($apps as $v){
  15. $st = date('Y-m-d H:i:s',$cts - $v['max_day']*24*60*60);
  16. $et = date('Y-m-d H:i:s',$cte - $v['max_day']*24*60*60);
  17. $phones = Db::name('apply_record')
  18. ->alias('ar')
  19. ->join('apply a','a.id = ar.apply_id')
  20. ->join('user u','ar.user_id = u.id')
  21. ->where('ar.status',0)
  22. ->where('ar.del',0)
  23. ->where('ar.type','in','2,8')
  24. ->where('a.status',1)
  25. ->where('a.approval_id',$v['id'])
  26. ->where('a.create_time','>=',$st)
  27. ->where('a.create_time','<',$et)
  28. ->column('u.phone');
  29. if($phones){
  30. $allphones = array_merge($allphones,$phones);
  31. }
  32. }
  33. if($allphones){
  34. $allphones = array_unique($allphones);
  35. $phonestr = implode(',',$allphones);
  36. $smsconfig = config('app.sms_config');
  37. $qxsms = new Qxsms($smsconfig);
  38. $content = "【基建物业管理中心】您有审批单未处理,请及时处理。";
  39. $ret = $qxsms->send($phonestr,$content);
  40. trace($phonestr);
  41. }
  42. }
  43. }
  44. public function tt(){
  45. halt(request()->domain(true));
  46. }
  47. }