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, ];