改进 汇率分离

This commit is contained in:
iVampireSP.com 2022-09-16 20:03:54 +08:00
parent 2dfb3ca1c8
commit 5fc9774557
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
3 changed files with 25 additions and 25 deletions

View File

@ -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)');
}
}

View File

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

View File

@ -3,4 +3,5 @@
return [
'rate' => 1000,
'decimal' => 100000,
'module_rate' => 990,
];