feat: nạp tiền thủ công mã 30 phút, gia hạn trừ số dư, đồng bộ domain từ Plesk
- Nạp tiền: mã thanh toán sống 30 phút (ManualDepositDraft), khôi phục/huỷ mã, lệnh dọn mã hết hạn; total_pending chỉ tính giao dịch đã nộp chứng từ, admin duyệt/từ chối/xoá giao dịch - Gia hạn dịch vụ: phát hành invoice gia hạn trên order gốc và trừ số dư ngay - Đồng bộ domain từ Plesk theo server, ServiceOrderRecorder tạo order/invoice cho dịch vụ admin dựng - Danh sách dịch vụ trả field theo loại (service_plan, dns_records_count), đếm dịch vụ theo loại Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10af41c5cf
commit
c5115b52dd
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Enums\TransactionStatus;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ManualDepositDraft
|
||||
{
|
||||
public const TTL_MINUTES = 30;
|
||||
|
||||
public static function query(): Builder
|
||||
{
|
||||
return Transaction::query()
|
||||
->where('type', 'manual')
|
||||
->where('status', TransactionStatus::PENDING->value)
|
||||
->whereNull('proof_image');
|
||||
}
|
||||
|
||||
public static function expiresAt(Transaction $draft): CarbonInterface
|
||||
{
|
||||
return $draft->created_at->copy()->addMinutes(self::TTL_MINUTES);
|
||||
}
|
||||
|
||||
public static function isExpired(Transaction $draft): bool
|
||||
{
|
||||
return self::expiresAt($draft)->isPast();
|
||||
}
|
||||
|
||||
public static function expiredQuery(): Builder
|
||||
{
|
||||
return self::query()->where('created_at', '<=', now()->subMinutes(self::TTL_MINUTES));
|
||||
}
|
||||
|
||||
public static function discard(Transaction $draft): bool
|
||||
{
|
||||
return DB::transaction(function () use ($draft) {
|
||||
$locked = self::query()->whereKey($draft->getKey())->lockForUpdate()->first();
|
||||
|
||||
return $locked ? (bool) $locked->forceDelete() : false;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user