在他點(diǎn)擊確認(rèn)交付后,我試圖在 30 分鐘后向客戶應(yīng)用發(fā)送通知。我創(chuàng)建了一個事件偵聽器來發(fā)送該通知,但是如何讓偵聽器偵聽一個事件并在 30 分鐘后發(fā)送該通知?這是我在 APIController 中的確認(rèn)交付功能:public function confirm_delivery(Request $request){ $id = (int)$request->order_id; $order = Order::find($id); Order::where('user_id', $user->id)->find($id)->update(['stage' => 9]); $type = 'CUSTOMER_'; $uuid = $user->uniqid; $order_id =$id; $order_no =$order->order_no; //Todo::Event to send notfifiction for user to rate place after 30 mins event(new CustomerRatePlaceEvent($type,$uuid,$order_id,$order_no)); return ResponseHelper::customizedResponse(true, 1, 'Order delivered to customer.');}_在 CustomerRatePlaceEvent 中構(gòu)造:public $type;public $uuid;public $order_id;public $order_no;public function __construct($type,$uuid,$order_id,$order_no){ $this->type = $type; $this->uuid = $uuid; $this->order_id = $order_id; $this->order_no = $order_no;}事件服務(wù)提供者: CustomerRatePlaceEvent::class => [ CustomerRatePlaceListener::class, ],CustomerRatePlaceListener:public function handle($event){ NotificationHelper::?ratePlaceNotification($event->type,$event->uuid,$event->order_id,$event->order_no);}(通知代碼在一個輔助函數(shù)中,它工作正常:NotificationHelper::?ratePlaceNotification)
如何在 30 分鐘后向客戶發(fā)送通知?
慕無忌1623718
2022-10-14 16:31:44