<?php
 namespace App\Listeners; use App\Constant\PayConstant; use App\Events\NoteHasNewTipEvent; use App\Types\NoteTipStatus; use Illuminate\Support\Facades\Event; use TechOnline\Laravel\Dao\ModelUtil; use TechSoft\Laravel\MemberMoney\MemberMoneyUtil; use TechSoft\Laravel\Pay\Events\OrderPayedEvent; class PayListener { public function onOrderPayed(OrderPayedEvent $event) { $biz = $event->biz; $bizId = $event->bizId; switch ($biz) { case PayConstant::NOTE_TIP: $noteTip = ModelUtil::get('note_tip', ['id' => $bizId]); if (empty($noteTip)) { return; } MemberMoneyUtil::change($noteTip['memberUserId'], $noteTip['money'], '打赏收入'); ModelUtil::update('note_tip', ['id' => $bizId], ['status' => NoteTipStatus::SUCCESS]); Event::fire(new NoteHasNewTipEvent($noteTip['noteId'], $noteTip['id'])); break; } } public function subscribe($events) { $events->listen( OrderPayedEvent::class, '\App\Listeners\PayListener@onOrderPayed' ); } }