$v){ $season[$v->keys]=$v->value; } $code=Code::where('season',$season['season'])->where('type',$season['type'])->with(['get_user'])->get(); if ($code){ foreach ($code as $k=>$v){ $re=Code::find($v->id); if ($v->mini_message_num==0){ $easySms=new EasySms(config('easysms')); $year=date('Y',$season['time_start']); $month=date('m',$season['time_start']); $day=date('d',$season['time_start']); if ($v->type==0){ $mean='实战营'; }elseif ($v->type==1){ $mean='密训营'; } try{ $data=AuthManage::where('season',$v->season)->where('type',$v->type)->pluck('phone')->toArray(); $phone=User::where('id',$v->user_id)->value('phone'); $client=new Client(); $url='http://api.admin.app.jiuweiyun.cn/api/sign_message'; $array=[ 'form_params'=>[ 'data'=>$data, 'mobile'=>$phone, 'season'=>$v->season, 'type'=>$v->type, 'appids'=>'daweiboshi_szy', 'secret'=>'daweiboshi_szy_secret' ] ]; $client->request('post',$url,$array); }catch (\Exception $exception){ Log::error($exception); } } if ($v->account_message_num==0){ try{ $data=[ 'template_id'=>'BTmiw1Lr630I5ADYVX8Pzy75e4M7OmtgUBcCPVj7CKo', 'touser'=>$v->get_user->openid, 'page'=>'', 'data'=>[ 'thing5'=>[ 'value'=>'第'.$v->season.'届大卫博士创业'.$mean, ], 'thing7'=>[ 'value'=>$season['province'].'-'.$season['city'] ], 'time6'=>[ 'value'=>date('Y年m月d日',$season['time_start']) ], 'thing4'=>[ 'value'=>'请提前一天前往举办地签到' ] ] ]; event(new SuccessSignMessageEvent($data)); }catch (\Exception $exception){ Log::error('订阅消息发送失败'.$exception); } } if ($v->sms_message_num==0){ try { $content="【大卫博士】恭喜你,成功报名第".$v->season.'届大卫博士创业'.$mean.'。活动将于'.$year.'年'.$month.'月'.$day.'日开始,请提前一天前往举办地签到。'; $easySms->send($v->get_user->phone, ['content' =>$content]); } catch (\Overtrue\EasySms\Exceptions\NoGatewayAvailableException $exception) { $message = $exception->getException('qcloud')->getMessage(); Log::error($message); } } $re->sms_message_num=1; $re->account_message_num=1; $re->mini_message_num=1; $re->save(); } } } }