add test batches
This commit is contained in:
@@ -10,7 +10,6 @@ use Illuminate\Support\Facades\Log;
|
||||
class DiscountApplyService
|
||||
{
|
||||
private DiscountContextService $context;
|
||||
|
||||
private DiscountInvoiceService $invoiceService;
|
||||
|
||||
public function __construct(DiscountContextService $context, DiscountInvoiceService $invoiceService)
|
||||
@@ -25,7 +24,7 @@ class DiscountApplyService
|
||||
$semester = $this->context->getSemester();
|
||||
|
||||
$voucher = DiscountVoucher::query()->find($voucherId);
|
||||
if (! $voucher) {
|
||||
if (!$voucher) {
|
||||
return ['ok' => false, 'message' => 'Voucher not found.'];
|
||||
}
|
||||
|
||||
@@ -44,7 +43,7 @@ class DiscountApplyService
|
||||
return ['ok' => false, 'message' => 'This voucher has reached its maximum allowed uses.'];
|
||||
}
|
||||
|
||||
if (! $allowAdditional) {
|
||||
if (!$allowAdditional) {
|
||||
$rows = DB::table('discount_usages as du')
|
||||
->select('i.parent_id')
|
||||
->join('invoices as i', 'i.id', '=', 'du.invoice_id')
|
||||
@@ -56,7 +55,7 @@ class DiscountApplyService
|
||||
->all();
|
||||
|
||||
$blockedParentIds = array_map(static fn ($r) => (int) ($r['parent_id'] ?? 0), $rows);
|
||||
if (! empty($blockedParentIds)) {
|
||||
if (!empty($blockedParentIds)) {
|
||||
$parentIds = array_values(array_diff(array_map('intval', $parentIds), $blockedParentIds));
|
||||
}
|
||||
if (empty($parentIds)) {
|
||||
@@ -82,7 +81,6 @@ class DiscountApplyService
|
||||
'parent_id' => (int) $parentId,
|
||||
'voucher_id' => $voucherId,
|
||||
]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -101,7 +99,7 @@ class DiscountApplyService
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $allowAdditional) {
|
||||
if (!$allowAdditional) {
|
||||
$exists = DB::table('discount_usages as du')
|
||||
->join('invoices as i', 'du.invoice_id', '=', 'i.id')
|
||||
->where('du.voucher_id', $voucherId)
|
||||
@@ -199,7 +197,6 @@ class DiscountApplyService
|
||||
DB::commit();
|
||||
} catch (\Throwable $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return ['ok' => false, 'message' => 'Voucher application failed. Transaction rolled back.'];
|
||||
}
|
||||
|
||||
@@ -289,7 +286,7 @@ class DiscountApplyService
|
||||
event('paymentReceived', [$eventData, $studentData]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('paymentReceived hook failed: '.$e->getMessage());
|
||||
Log::warning('paymentReceived hook failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user