From a12f7599a2ad24ccade4f7df4c3fa28ecbbeaa9a Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 12 Jul 2022 10:51:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E8=B0=83=E7=94=A8app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/data/sys.php | 17 ++++++++--------- app/wechat/sys.php | 5 +++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/data/sys.php b/app/data/sys.php index 8eb2bb573..5b60f894d 100644 --- a/app/data/sys.php +++ b/app/data/sys.php @@ -9,11 +9,10 @@ use app\data\service\OrderService; use app\data\service\RebateService; use app\data\service\UserBalanceService; use app\data\service\UserRebateService; +use think\admin\Library; use think\Console; -$app = app(); - -if ($app->request->isCli()) { +if (Library::$sapp->request->isCli()) { // 动态注册操作指令 Console::starting(function (Console $console) { $console->addCommand(OrderClean::class); @@ -24,21 +23,21 @@ if ($app->request->isCli()) { }); } else { // 注册订单支付处理事件 - $app->event->listen('ShopOrderPayment', function ($orderNo) use ($app) { + Library::$sapp->event->listen('ShopOrderPayment', function ($orderNo) { - $app->log->notice("订单 {$orderNo} 支付事件,执行用户返利行为"); + Library::$sapp->log->notice("订单 {$orderNo} 支付事件,执行用户返利行为"); RebateService::instance()->execute($orderNo); - $app->log->notice("订单 {$orderNo} 支付事件,执行发放余额行为"); + Library::$sapp->log->notice("订单 {$orderNo} 支付事件,执行发放余额行为"); UserBalanceService::confirm($orderNo); - $app->log->notice("订单 {$orderNo} 支付事件,执行用户升级行为"); + Library::$sapp->log->notice("订单 {$orderNo} 支付事件,执行用户升级行为"); OrderService::upgrade($orderNo); }); // 注册订单确认支付事件 - $app->event->listen('ShopOrderConfirm', function ($orderNo) use ($app) { - $app->log->notice("订单 {$orderNo} 确认事件,执行返利确认行为"); + Library::$sapp->event->listen('ShopOrderConfirm', function ($orderNo) { + Library::$sapp->log->notice("订单 {$orderNo} 确认事件,执行返利确认行为"); UserRebateService::confirm($orderNo); }); } diff --git a/app/wechat/sys.php b/app/wechat/sys.php index 03f210076..e7e95a114 100644 --- a/app/wechat/sys.php +++ b/app/wechat/sys.php @@ -17,14 +17,15 @@ use app\wechat\command\Auto; use app\wechat\command\Fans; use app\wechat\service\AutoService; +use think\admin\Library; use think\Console; -if (app()->request->isCli()) { +if (Library::$sapp->request->isCli()) { Console::starting(function (Console $console) { $console->addCommands([Fans::class, Auto::class]); }); } else { - app()->event->listen('WechatFansSubscribe', function ($openid) { + Library::$sapp->event->listen('WechatFansSubscribe', function ($openid) { AutoService::register($openid); }); } \ No newline at end of file