data=$data; } /** * Execute the job. * * @return void */ public function handle() { try { $data=$this->data; $arr=[]; foreach ($data as $k=>$v){ $order=Ordertest::where('order_num',$v['order_num'])->first(); if (!isset($arr[$order->user_id])){ $user=User::find($order->user_id); $arr[$order->user_id]['express_com']=$v['express_com']; $arr[$order->user_id]['express_code']=$v['express_code']; if ($user){ $arr[$order->user_id]['openid']=$user->openid; }else{ $arr[$order->user_id]['openid']=null; } } } foreach ($arr as $k=>$v){ $a=[]; if ($v['openid']){ $a=$v; $a['data']=[ 'first'=>'您有新的订单发货了,请及时登录系统查看,并注意查收。', 'delivername' => $v['express_com'], 'ordername' => $v['express_code'], 'remark' => '点击链接进入系统,查看详情', ]; event(new SendMessageOrderSendEvent($a)); } } }catch (\Exception $exception){ } } }