<?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 TechOnline\Utils\TimeUtil; use TechSoft\Laravel\Member\MemberUtil; use TechSoft\Laravel\MemberMoney\MemberMoneyUtil; use TechSoft\Laravel\MemberVip\MemberVipUtil; use TechSoft\Laravel\Pay\Events\OrderPayedEvent; use TechSoft\Laravel\Shop\Types\OrderStatus; class PayListener { public function onOrderPayed(OrderPayedEvent $event) { $biz = $event->biz; $bizId = $event->bizId; switch ($biz) { case PayConstant::MEMBER_VIP: $order = ModelUtil::get('member_vip_order', $bizId); if (empty($order)) { return; } $memberUser = MemberUtil::get($order['memberUserId']); $memberVip = MemberVipUtil::get($order['vipId']); ModelUtil::update('member_vip_order', ['id' => $bizId], ['status' => OrderStatus::COMPLETED]); $update = []; $update['vipId'] = $order['vipId']; $update['vipExpire'] = $order['expire']; MemberUtil::update($order['memberUserId'], $update); break; case PayConstant::VIP_ARTICLE: $order = ModelUtil::get('vip_article_order', $bizId); if (empty($order)) { return; } ModelUtil::update('vip_article_order', ['id' => $bizId], ['status' => OrderStatus::COMPLETED]); ModelUtil::insert('vip_article_pay', ['memberUserId' => $order['memberUserId'], 'articleId' => $order['articleId']]); break; } } public function subscribe($events) { $events->listen( OrderPayedEvent::class, '\App\Listeners\PayListener@onOrderPayed' ); } }