feat(tests): 添加结算相关功能的测试用例,增强代码覆盖率
This commit is contained in:
@@ -27,26 +27,25 @@ final class AgentSettlementPeriodCloseService
|
||||
{
|
||||
AgentSettlementProductionGuard::assertProductionCloseAllowed();
|
||||
|
||||
$period = DB::table('settlement_periods')->where('id', $periodId)->first();
|
||||
if ($period === null) {
|
||||
throw ValidationException::withMessages([
|
||||
'period' => ['period_not_found'],
|
||||
]);
|
||||
}
|
||||
return DB::transaction(function () use ($periodId): array {
|
||||
$period = DB::table('settlement_periods')->where('id', $periodId)->lockForUpdate()->first();
|
||||
if ($period === null) {
|
||||
throw ValidationException::withMessages([
|
||||
'period' => ['period_not_found'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ((string) $period->status === 'closed' || (string) $period->status === 'completed') {
|
||||
throw ValidationException::withMessages([
|
||||
'period' => ['period_already_closed'],
|
||||
]);
|
||||
}
|
||||
if ((string) $period->status === 'closed' || (string) $period->status === 'completed') {
|
||||
throw ValidationException::withMessages([
|
||||
'period' => ['period_already_closed'],
|
||||
]);
|
||||
}
|
||||
|
||||
$adminSiteId = (int) $period->admin_site_id;
|
||||
[$periodStart, $periodEnd] = AgentSettlementPeriodWindow::boundStrings(
|
||||
(string) $period->period_start,
|
||||
(string) $period->period_end,
|
||||
);
|
||||
|
||||
return DB::transaction(function () use ($periodId, $period, $adminSiteId, $periodStart, $periodEnd): array {
|
||||
$adminSiteId = (int) $period->admin_site_id;
|
||||
[$periodStart, $periodEnd] = AgentSettlementPeriodWindow::boundStrings(
|
||||
(string) $period->period_start,
|
||||
(string) $period->period_end,
|
||||
);
|
||||
try {
|
||||
$aggregate = $this->aggregator->aggregate($adminSiteId, $periodStart, $periodEnd);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
|
||||
Reference in New Issue
Block a user