改进 汇率分离
This commit is contained in:
parent
2dfb3ca1c8
commit
5fc9774557
@ -39,32 +39,36 @@ public function __construct()
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
$moduleController = new ModuleController();
|
$moduleController = new ModuleController();
|
||||||
|
$rate = config('drops.module_rate');
|
||||||
|
|
||||||
$modules = Module::get();
|
|
||||||
|
|
||||||
// 当前时间
|
|
||||||
$now = now();
|
|
||||||
|
|
||||||
$this->warn('开始计算集成模块收益。');
|
$this->warn('开始计算集成模块收益。');
|
||||||
$this->warn('当前时间: ' . $now);
|
$this->warn('当前时间: ' . now());
|
||||||
|
$this->warn('比例: 1:' . $rate . ' (1 元 = ' . $rate . ' Drops)');
|
||||||
foreach ($modules as $module) {
|
|
||||||
$report = $moduleController->calcModule($module);
|
|
||||||
|
|
||||||
|
|
||||||
$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 位
|
$this->warn('计算模块收益完成。');
|
||||||
$income = round($income, 2);
|
$this->warn('完成时间: ' . now());
|
||||||
|
$this->warn('比例: 1:' . $rate . ' (1 元 = ' . $rate . ' Drops)');
|
||||||
$text = $module->name . " 收益 {$income} 元 ";
|
|
||||||
$this->info($text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ public function index()
|
|||||||
$calc = $this->calcModule($module);
|
$calc = $this->calcModule($module);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'module' => $module
|
'module' => $module,
|
||||||
|
'rate' => (int) config('drops.module_rate'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// merge
|
// merge
|
||||||
@ -99,16 +100,10 @@ public function calcModule(Module $module)
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$rate = (int)config('drops.rate') - 10;
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'transactions' => [
|
'transactions' => [
|
||||||
'this_month' => $this_month_balance_and_drops,
|
'this_month' => $this_month_balance_and_drops,
|
||||||
'last_month' => $last_month_balance_and_drops,
|
'last_month' => $last_month_balance_and_drops,
|
||||||
],
|
|
||||||
'balance' => [
|
|
||||||
'rate' => $rate,
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
return [
|
return [
|
||||||
'rate' => 1000,
|
'rate' => 1000,
|
||||||
'decimal' => 100000,
|
'decimal' => 100000,
|
||||||
|
'module_rate' => 990,
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user