From a4734f7415933e8becf922de8900677e9b57e232 Mon Sep 17 00:00:00 2001 From: "674780036@qq.com" <674780036@qq.com> Date: Mon, 26 Feb 2024 23:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E8=AE=A2=E5=8D=95-=E5=88=86?= =?UTF-8?q?=E9=94=80=E6=97=B6=E9=97=B4=E5=88=B0=E6=9C=9F=E6=94=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/CalDealerTime.php | 60 +++++++++++++++++++++++++++++++++++ config/console.php | 1 + 2 files changed, 61 insertions(+) create mode 100644 app/command/CalDealerTime.php diff --git a/app/command/CalDealerTime.php b/app/command/CalDealerTime.php new file mode 100644 index 00000000..b345a5b8 --- /dev/null +++ b/app/command/CalDealerTime.php @@ -0,0 +1,60 @@ +setName('CalDealerTime') + ->setDescription('自动计算分销时间'); + } + + protected function execute(Input $input, Output $output) + { + //todo wmc这边代码需要优化 + //$list = User::where('status', 1) + $list = User::where('user_type', 'in', [UserTypeEnum::MEMBER,UserTypeEnum::DEALER]) + ->where('is_delete', '=', 0) + //->where('store_id',10001) + ->select(); + // print '
'; + // print_r($list->toArray()); + // print ''; + // die; + foreach ($list as $item) { + //如果分销商到期,改成会员 + if(strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d'))){ + User::where('user_id',$item['user_id'])->update([ + 'user_type'=>UserTypeEnum::MEMBER + ]); + } + //如果会员到期,但是分销商没到期,还是分销商;分销商到期了,改成普通用户 + if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && (strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d')))){ + User::where('user_id',$item['user_id'])->update([ + 'user_type'=>UserTypeEnum::NORMAL + ]); + } + + } + + + } + + +} diff --git a/config/console.php b/config/console.php index dbaa6db4..ff096871 100644 --- a/config/console.php +++ b/config/console.php @@ -9,5 +9,6 @@ return [ 'timer' => \app\timer\command\Timer::class, //test脚本 'test' => 'app\command\test', + 'CalDealerTime' => 'app\command\CalDealerTime', ], ];