where('jg_type',1)->where('jg_status',0)->limit(0,50)->order('id')->select(); foreach ($list as $v) { UserMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]); Jpush($v['user_id'],$v['content']); } } /** * @title 标签推送[根据标签id] * @desc 标签推送 * @author qc * @url /api/Task/taskLabelMessage */ //按照标签推送 public function taskLabelMessage() { $list = LabelMessage::where('jg_status',0)->where('is_deleted',0)->select()->toArray(); foreach ($list as $v) { LabelMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]); if($v['type'] == 1) { $user_list = User::field('id') ->where('label','like','%|'.$v['label_id'].'|%') ->where('status','=',1) ->where('is_deleted','=',0)->select()->toArray();; foreach ($user_list as $user_info) { $res = Jpush($user_info['id'],$v['content']); } }else{ if(!$v['label']) continue; $label_arr = explode(',',$v['label']); $where_str = ''; $search_arr=[]; foreach ($label_arr as $t){ $search_arr[] = " title like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $user_arr = UserSearch::where($where_str)->column('user_id'); foreach (array_unique($user_arr) as $user_id) { $res = Jpush($user_id,$v['content']); } } } } /** * @title 半年清理一次设备号 * @desc * @author qc * @url /api/Task/removeFacility */ public function removeFacility(){ UserFacility::where(['set_time','> time',date('Y-m-d H:i:s',strtotime('-180 days'))])->update(['facility'=>'','set_time'=>date('Y-m-d H:i:s')]); } }