- 在多个控制器中引入 SettlementPartyEnrichment 服务,以优化代理结算和账单的处理逻辑。 - 更新 AgentSettlementBillIndexController 和 AgentSettlementBillShowController,支持根据账单 ID 和关键字进行查询。 - 在 AgentSettlementPeriodCloseController 中添加对站点管理权限的验证,确保只有具备相应权限的管理员能够关闭账期。 - 在 AgentSettlementPeriodIndexController 中更新账期数据的返回格式,提升数据的完整性和可用性。 - 引入对相对占成比例的支持,增强代理资料的管理能力,确保数据一致性。
44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
||
|
||
namespace App\Services\AgentSettlement;
|
||
|
||
use App\Support\AgentSettlementPeriodWindow;
|
||
use Illuminate\Support\Facades\DB;
|
||
|
||
final class UnsettledTicketPeriodWarning
|
||
{
|
||
/**
|
||
* 未结算注单:优先按游戏结算落账时间(settled_at)归属账期;未开奖仍按下注时间(created_at)。
|
||
*
|
||
* @return array{count: int, ticket_item_ids: list<int>}
|
||
*/
|
||
public function countForSite(int $adminSiteId, string $periodStart, string $periodEnd): array
|
||
{
|
||
$siteCode = (string) DB::table('admin_sites')->where('id', $adminSiteId)->value('code');
|
||
[$start, $end] = AgentSettlementPeriodWindow::boundStrings($periodStart, $periodEnd);
|
||
|
||
$rows = DB::table('ticket_items as ti')
|
||
->join('players as p', 'p.id', '=', 'ti.player_id')
|
||
->where('p.site_code', $siteCode)
|
||
->whereIn('ti.status', ['pending_draw', 'pending_confirm', 'pending_payout'])
|
||
->whereNull('ti.agent_settled_at')
|
||
->where(function ($query) use ($start, $end): void {
|
||
$query->where(function ($settled) use ($start, $end): void {
|
||
$settled->whereNotNull('ti.settled_at')
|
||
->whereBetween('ti.settled_at', [$start, $end]);
|
||
})->orWhere(function ($pending) use ($start, $end): void {
|
||
$pending->whereNull('ti.settled_at')
|
||
->whereBetween('ti.created_at', [$start, $end]);
|
||
});
|
||
})
|
||
->pluck('ti.id')
|
||
->map(fn ($id): int => (int) $id)
|
||
->all();
|
||
|
||
return [
|
||
'count' => count($rows),
|
||
'ticket_item_ids' => array_slice($rows, 0, 20),
|
||
];
|
||
}
|
||
}
|