From 5fc97745576c4f6ab375e86faa33143f5c296cd8 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Fri, 16 Sep 2022 20:03:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E6=B1=87=E7=8E=87?= =?UTF-8?q?=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/CalcModule.php | 40 ++++++++++--------- .../Controllers/Remote/ModuleController.php | 9 +---- config/drops.php | 1 + 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/Console/Commands/CalcModule.php b/app/Console/Commands/CalcModule.php index 66aa5e8..ee8fdea 100644 --- a/app/Console/Commands/CalcModule.php +++ b/app/Console/Commands/CalcModule.php @@ -39,32 +39,36 @@ public function __construct() */ public function handle() { - // $moduleController = new ModuleController(); + $rate = config('drops.module_rate'); - $modules = Module::get(); - - // 当前时间 - $now = now(); $this->warn('开始计算集成模块收益。'); - $this->warn('当前时间: ' . $now); - - foreach ($modules as $module) { - $report = $moduleController->calcModule($module); + $this->warn('当前时间: ' . now()); + $this->warn('比例: 1:' . $rate . ' (1 元 = ' . $rate . ' Drops)'); - $income = $report['transactions']['this_month']['drops'] / $report['balance']['rate']; + Module::chunk(100, function ($modules) use ($rate, $moduleController) { + foreach ($modules as $module) { + $report = $moduleController->calcModule($module); - if ($income < 0) { - $income = 0; + + $income = $report['transactions']['this_month']['drops'] / $rate; + + if ($income < 0) { + $income = 0; + } + + // 取 2 位 + $income = round($income, 2); + + $text = $module->name . " 收益 {$income} 元 "; + $this->info($text); } + }); - // 取 2 位 - $income = round($income, 2); - - $text = $module->name . " 收益 {$income} 元 "; - $this->info($text); - } + $this->warn('计算模块收益完成。'); + $this->warn('完成时间: ' . now()); + $this->warn('比例: 1:' . $rate . ' (1 元 = ' . $rate . ' Drops)'); } } diff --git a/app/Http/Controllers/Remote/ModuleController.php b/app/Http/Controllers/Remote/ModuleController.php index 6736a3f..a125a3e 100644 --- a/app/Http/Controllers/Remote/ModuleController.php +++ b/app/Http/Controllers/Remote/ModuleController.php @@ -18,7 +18,8 @@ public function index() $calc = $this->calcModule($module); $data = [ - 'module' => $module + 'module' => $module, + 'rate' => (int) config('drops.module_rate'), ]; // merge @@ -99,16 +100,10 @@ public function calcModule(Module $module) ]; }); - - $rate = (int)config('drops.rate') - 10; - $data = [ 'transactions' => [ 'this_month' => $this_month_balance_and_drops, 'last_month' => $last_month_balance_and_drops, - ], - 'balance' => [ - 'rate' => $rate, ] ]; diff --git a/config/drops.php b/config/drops.php index fa0d585..cc47dc7 100644 --- a/config/drops.php +++ b/config/drops.php @@ -3,4 +3,5 @@ return [ 'rate' => 1000, 'decimal' => 100000, + 'module_rate' => 990, ];