<?php
 namespace Module\VipArticle\Listener; use ModStart\Core\Dao\ModelUtil; use Module\PayCenter\Events\OrderPayedEvent; use Module\Vendor\Type\OrderStatus; use Module\VipArticle\Constant\PayConstant; class VipArticlePayListener { public function onOrderPayed(OrderPayedEvent $event) { $biz = $event->biz; $bizId = $event->bizId; switch ($biz) { 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, '\Module\VipArticle\Listener\VipArticlePayListener@onOrderPayed' ); } }