From 5aaa01b28d555d6a1367a8aacda508a21fcff4b6 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 21 Jun 2024 11:43:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=EF=BC=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=A4=90=E8=B4=B9=E7=A7=AF=E5=88=86=E8=A7=A3=E5=86=BB=E5=8F=8A?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/event.php | 1 + .../shareholder/ShareholderListen.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/listener/shareholder/ShareholderListen.php diff --git a/app/event.php b/app/event.php index d397269..fc900b7 100644 --- a/app/event.php +++ b/app/event.php @@ -47,6 +47,7 @@ return [ \crmeb\listens\CloseUserSvipListen::class, \crmeb\listens\SendSvipCouponListen::class, \crmeb\listens\SyncMerchantMarginStatusListen::class, + \app\listener\shareholder\ShareholderListen::class, ] : [], 'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class], 'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class], diff --git a/app/listener/shareholder/ShareholderListen.php b/app/listener/shareholder/ShareholderListen.php new file mode 100644 index 0000000..4a324d0 --- /dev/null +++ b/app/listener/shareholder/ShareholderListen.php @@ -0,0 +1,31 @@ +tick(1000 * 5, function () { + // Log::info('餐费积分定时任务被触发:'); + request()->clearCache(); + try{ + // 积分解冻 预计解冻时间小于当前时间,且状态为冻结中 + MerchantShareholderIntegral::where('status',0) + ->where('expect_thaw_time','<=',time()) + ->update(['status' => 1]); + // 积分过期 预计过期时间小于当前时间,且状态为使用中 + MerchantShareholderIntegral::where('status',1) + ->where('expect_overdue_time','<=',time()) + ->update(['status' => 2]); + }catch(\Exception $e){ + Log::info('餐费积分定时任务 - 错误:' . $e->getMessage()); + } + }); + } +}