rank_id = $array['rank_id']; $this->openid = $array['openid']; if (array_key_exists('invite_openid', $array)) { $this->invite_openid = $array['invite_openid']; } } /** * Execute the job. * * @return void */ public function handle() { $rank = Rank::find($this->rank_id); if (empty($rank)) { return; } $param['rank_name'] = $rank->name.'会员'; $param['openid'] = $this->openid; $param['privilege'] = $rank->content; if ($this->invite_openid) { $param['openid'] = $this->invite_openid; $wechat = Wechat::with('user')->where('openid', $this->openid)->first(); if ($wechat) { if ($wechat->user) { $name = $wechat->user->name; }else{ $name = $wechat->nickname; } $param['rank_name'] = $name.'的'.$rank->name.'会员'; } } $form_id = $this->formId($param['openid']); if(!empty($form_id)){ $form_id->status = 1; $form_id->save(); $param['form_id'] = $form_id->form_id; \WechatService::rankNotice($param); } } /** * 获取对应的formid */ public function formId($openid) { $now_time = time(); $end_time = $now_time - 7 * 24 * 60 * 60; $time = date('Y-m-d H:i:s', $end_time); $form_id = FormId::where('openid', $openid)->where('status', 0)->where('form_id', '<>','the formId is a mock one')->where('created_at', '>', $time)->orderBy('id', 'asc')->first(); return $form_id; } }