feat: add idempotency support for settlement adjustments and payments, fix rebate handling
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

- Added idempotency_key parameter to settlement bill adjustment and payment endpoints to prevent duplicate operations
- Fixed player rebate profile updates to preserve existing values when only one field is modified
- Moved wallet player validation earlier in AdminPlayerStoreController to prevent unnecessary processing
- Enhanced extra rebate calculation to include 'in_bill' and 'settled' statuses in AgentP
This commit is contained in:
2026-06-23 16:49:57 +08:00
parent 9a7522e928
commit 3c57941895
20 changed files with 734 additions and 127 deletions

View File

@@ -15,10 +15,11 @@ final class PeriodCloseRebateService
*/
public function dispatchAndAllocate(
int $periodId,
int $adminSiteId,
string $periodStart,
string $periodEnd,
): array {
$rebateIds = $this->dispatchAccruedToPeriod($periodId, $periodStart, $periodEnd);
$rebateIds = $this->dispatchAccruedToPeriod($periodId, $adminSiteId, $periodStart, $periodEnd);
$allocationCount = $this->buildAllocations($periodId, $rebateIds);
return [
@@ -30,14 +31,18 @@ final class PeriodCloseRebateService
/**
* @return list<int>
*/
private function dispatchAccruedToPeriod(int $periodId, string $periodStart, string $periodEnd): array
private function dispatchAccruedToPeriod(int $periodId, int $adminSiteId, string $periodStart, string $periodEnd): array
{
$siteCode = (string) DB::table('admin_sites')->where('id', $adminSiteId)->value('code');
$ids = DB::table('rebate_records as rr')
->join('ticket_items as ti', 'ti.id', '=', 'rr.ticket_item_id')
->join('share_ledger as sl', function ($join): void {
$join->on('sl.ticket_item_id', '=', 'ti.id')
->whereNull('sl.reversal_of_id');
})
->join('players as p', 'p.id', '=', 'rr.player_id')
->where('p.site_code', $siteCode)
->where('rr.status', 'accrued')
->whereBetween('sl.settled_at', [$periodStart, $periodEnd])
->pluck('rr.id')