update: statistical service

This commit is contained in:
v2board
2023-04-15 19:34:54 +08:00
parent 6dd509d73e
commit 7be6553396
10 changed files with 112 additions and 5 deletions

View File

@ -45,6 +45,7 @@ class SendRemindMail extends Command
$mailService = new MailService();
foreach ($users as $user) {
if ($user->remind_expire) $mailService->remindExpire($user);
if ($user->remind_traffic) $mailService->remindTraffic($user);
}
}
}

View File

@ -2,10 +2,13 @@
namespace App\Console\Commands;
use App\Models\StatUser;
use App\Services\StatisticalService;
use Illuminate\Console\Command;
use App\Models\Order;
use App\Models\StatOrder;
use App\Models\CommissionLog;
use Illuminate\Support\Facades\DB;
class V2boardStatistics extends Command
{
@ -44,6 +47,31 @@ class V2boardStatistics extends Command
$this->statOrder();
}
private function statUser()
{
$createdAt = time();
$recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
$statService = new StatisticalService($recordAt);
$stats = $statService->getStatUser();
DB::beginTransaction();
foreach ($stats as $stat) {
if (!StatUser::insert([
'user_id' => $stat['user_Id'],
'u' => $stat['u'],
'd' => $stat['d'],
'server_rate' => $stat['server_rate'],
'created_at' => $createdAt,
'updated_at' => $createdAt,
'record_type' => 'd',
'record_at' => $recordAt
])) {
DB::rollback();
break;
}
}
DB::commit();
}
private function statOrder()
{
$endAt = strtotime(date('Y-m-d'));