mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加会员等级升级
This commit is contained in:
parent
e1705815fe
commit
8c3b5674cf
@ -34,7 +34,7 @@ class UserBalance extends Command
|
|||||||
foreach ($this->app->db->name('DataUser')->field('id')->cursor() as $user) {
|
foreach ($this->app->db->name('DataUser')->field('id')->cursor() as $user) {
|
||||||
$this->queue->message($total, ++$count, "正在计算用户 [{$user['id']}] 的余额");
|
$this->queue->message($total, ++$count, "正在计算用户 [{$user['id']}] 的余额");
|
||||||
UserService::instance()->balance($user['id']);
|
UserService::instance()->balance($user['id']);
|
||||||
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的余额");
|
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的余额", 1);
|
||||||
}
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$this->queue->error($exception->getMessage());
|
$this->queue->error($exception->getMessage());
|
||||||
|
@ -2,12 +2,37 @@
|
|||||||
|
|
||||||
namespace app\data\command;
|
namespace app\data\command;
|
||||||
|
|
||||||
|
use app\data\service\UserService;
|
||||||
use think\admin\Command;
|
use think\admin\Command;
|
||||||
|
use think\admin\Exception;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\Output;
|
||||||
|
|
||||||
class UserLevel extends Command
|
class UserLevel extends Command
|
||||||
{
|
{
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
|
$this->setName('xdata:UserLevel');
|
||||||
|
$this->setDescription('批量重新计算用户等级');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Input $input
|
||||||
|
* @param Output $output
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
[$total, $count] = [$this->app->db->name('DataUser')->count(), 0];
|
||||||
|
foreach ($this->app->db->name('DataUser')->field('id')->cursor() as $user) {
|
||||||
|
$this->queue->message($total, ++$count, "正在计算用户 [{$user['id']}] 的等级");
|
||||||
|
UserService::instance()->syncLevel($user['id']);
|
||||||
|
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的等级", 1);
|
||||||
|
}
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->queue->error($exception->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
use app\data\command\OrderClear;
|
use app\data\command\OrderClear;
|
||||||
use app\data\command\UserBalance;
|
use app\data\command\UserBalance;
|
||||||
|
use app\data\command\UserLevel;
|
||||||
use think\Console;
|
use think\Console;
|
||||||
|
|
||||||
Console::starting(function (Console $console) {
|
Console::starting(function (Console $console) {
|
||||||
if (app()->request->isCli()) {
|
if (app()->request->isCli()) {
|
||||||
$console->addCommand(OrderClear::class);
|
$console->addCommand(OrderClear::class);
|
||||||
$console->addCommand(UserBalance::class);
|
$console->addCommand(UserBalance::class);
|
||||||
|
$console->addCommand(UserLevel::class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user