spliceIntoPosition(1, '*/20'); //每20分钟执行一次 } /** * 执行任务 * @return mixed */ protected function execute() { try{ $this->push(); }catch (\Exception $e){ trace($e->getMessage()); } } public function push(){ $list= Db::name('orders') ->alias('a') ->join('todo b','a.id = b.order_id') ->where('a.del',0) ->where('b.del',0) ->where('order_mode',4) ->where('todo_mode','in',[1,2]) ->field('b.create_time,b.to_user_id') ->select(); $ids = []; foreach ($list as $k=>$v){ $time = time(); $cTime = strtotime($v['create_time']); $diff = $time - $cTime; if ($diff > 60*60*3){ $ids[] = $v['to_user_id']; } } $ids = array_unique($ids); if(!empty($ids)){ send_jpush($ids,AppMsg::PUSH_WORKER_ORDER_SEND,'您的订单未完成,请及时处理'); } } }