Update UserAmount.php

This commit is contained in:
邹景立 2021-03-19 16:04:50 +08:00
parent d8b3768f55
commit c26ee179f2

View File

@ -30,16 +30,16 @@ class UserAmount extends Command
*/ */
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ {
try { [$total, $count, $error] = [$this->app->db->name('DataUser')->count(), 0, 0];
[$total, $count] = [$this->app->db->name('DataUser')->count(), 0]; foreach ($this->app->db->name('DataUser')->field('id')->cursor() as $user) try {
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']}] 的余额及返利"); UserRebateService::instance()->amount($user['id']);
UserRebateService::instance()->amount($user['id']); UserBalanceService::instance()->amount($user['id']);
UserBalanceService::instance()->amount($user['id']); $this->queue->message($total, $count, "刷新用户 [{$user['id']}] 余额及返利完成", 1);
$this->queue->message($total, $count, "完成计算用户 [{$user['id']}] 的余额及返利", 1);
}
} catch (\Exception $exception) { } catch (\Exception $exception) {
$this->queue->error($exception->getMessage()); $error++;
$this->queue->message($total, $count, "刷新用户 [{$user['id']}] 余额及返利失败, {$exception->getMessage()}", 1);
} }
$this->setQueueSuccess("此次共处理 {$total} 个刷新操作, 其中有 {$error} 个刷新失败。");
} }
} }