如果时间大于 5 分钟,不满 1 小时,则按 1 小时扣费

This commit is contained in:
iVampireSP.com 2022-12-04 14:17:12 +08:00
parent b3ea002897
commit b6a87a81c4
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -48,13 +48,18 @@ public function destroy(HostRequest $request, Host $host): JsonResponse
if ($host->status == 'pending') {
// 如果上次更新时间大于 5min
if (time() - strtotime($host->updated_at) > 300) {
if ($host->updated_at->diffInMinutes(now()) > 5) {
$host->delete();
} else {
return $this->error('请等待 5 分钟后再试');
}
}
// 如果时间大于 5 分钟,不满 1 小时
if (now()->diffInMinutes($host->updated_at) > 5 && now()->diffInMinutes($host->updated_at) < 60) {
$host->cost();
}
dispatch(new \App\Jobs\Module\Host($host, 'delete'));
return $this->deleted($host);