Merge remote-tracking branch 'origin/main' into fix/chenxi-product-cost-warehouse-inheritance

This commit is contained in:
chenxi 2026-10-26 20:32:57 +08:00
commit 128b1da09f
35 changed files with 2968 additions and 759 deletions

View File

@ -48,81 +48,30 @@ class SystemizationTodoWorkbookImporter
$header = $headerInfo['columns'];
$headerRow = $headerInfo['row'];
$created = 0;
$skipped = 0;
DB::transaction(function () use (
$rows = $this->workbookRows(
$reader,
$sheetIndex,
$sheetName,
$header,
$headerRow,
$companyId,
$userId,
&$created,
&$skipped
): void {
$category = '';
$section = '';
foreach ($reader->rows($sheetIndex) as $rowNumber => $cells) {
if ($rowNumber <= $headerRow) {
continue;
}
$categoryValue = $this->cell($cells, $header['category'] ?? null);
if ($categoryValue !== '') {
$category = $categoryValue;
}
$sectionValue = $this->cell($cells, $header['section'] ?? null);
if ($sectionValue !== '') {
$section = $sectionValue;
}
$title = $this->cell($cells, $header['title'] ?? null);
if ($title === '') {
continue;
}
$owner = $this->cell($cells, $header['owner'] ?? null);
$assignee = $this->cell($cells, $header['assignee'] ?? null);
$sourceKey = hash(
'sha256',
implode('|', [$companyId, $sheetName, $rowNumber, $category, $section, $title, $owner, $assignee])
);
);
$created = 0;
$skipped = 0;
DB::transaction(function () use ($rows, $companyId, $userId, &$created, &$skipped): void {
foreach ($rows as $row) {
$exists = SystemizationTodo::withoutGlobalScopes()
->where('company_id', $companyId)
->where('source_key', $sourceKey)
->where('source_key', $row['data']['source_key'])
->exists();
if ($exists) {
$skipped++;
continue;
}
$startText = $this->cell($cells, $header['start'] ?? null);
$finishText = $this->cell($cells, $header['finish'] ?? null);
[$startDate, $startNote] = $this->dateParts($startText);
[$finishDate, $finishNote] = $this->dateParts($finishText);
$progress = $this->cell($cells, $header['progress'] ?? null);
$status = $this->status($progress, $startText, $finishText);
$completedAt = $status === SystemizationTodo::STATUS_COMPLETED
? ($finishDate ?? now()->toDateString())
: null;
SystemizationTodo::withoutGlobalScopes()->create([
...$row['data'],
'company_id' => $companyId,
'category' => $category !== '' ? $category : null,
'section' => $section !== '' ? $section : null,
'title' => $title,
'owner' => $owner !== '' ? $owner : null,
'assignee' => $assignee !== '' ? $assignee : null,
'start_date' => $startDate,
'start_note' => $startNote !== '' ? $startNote : null,
'due_date' => $finishDate,
'due_note' => $finishNote !== '' ? $finishNote : null,
'status' => $status,
'completed_at' => $completedAt,
'progress' => $progress !== '' ? $progress : null,
'notes' => ($notes = $this->cell($cells, $header['notes'] ?? null)) !== '' ? $notes : null,
'sort_order' => $rowNumber,
'source_key' => $sourceKey,
'imported_at' => now(),
'created_by' => $userId,
'updated_by' => $userId,
@ -181,7 +130,17 @@ class SystemizationTodoWorkbookImporter
$matchedIds = array_values($matches);
$retained = $existing
->filter(static fn (SystemizationTodo $todo): bool => ! in_array($todo->id, $matchedIds, true))
->sortBy(static fn (SystemizationTodo $todo): string =>
sprintf('%010d-%010d', (int) $todo->sort_order, (int) $todo->id)
)
->values();
$retainedSortOrder = max(
(int) $existing->max('sort_order'),
...array_map(
static fn (array $row): int => (int) $row['data']['sort_order'],
$rows,
),
) + 1;
$oldSourceKeys = $existing->pluck('source_key', 'id')->all();
$updated = 0;
foreach ($matches as $rowIndex => $todoId) {
@ -209,6 +168,7 @@ class SystemizationTodoWorkbookImporter
$existing,
$retained,
$oldSourceKeys,
$retainedSortOrder,
$companyId,
$userId,
&$created,
@ -262,11 +222,12 @@ class SystemizationTodoWorkbookImporter
}
foreach ($retained as $todo) {
if (($oldSourceKeys[$todo->id] ?? null) !== null) {
SystemizationTodo::withoutGlobalScopes()
->whereKey($todo->id)
->update(['source_key' => $oldSourceKeys[$todo->id]]);
}
SystemizationTodo::withoutGlobalScopes()
->whereKey($todo->id)
->update([
'sort_order' => $retainedSortOrder++,
'source_key' => $oldSourceKeys[$todo->id] ?? null,
]);
}
});
@ -285,7 +246,16 @@ class SystemizationTodoWorkbookImporter
/**
* @param array<int,int> $columns
* @return array<int,array{row:int,category:string,section:string,title:string,data:array<string,mixed>}>
* @return array<int,array{
* row:int,
* title_index:int,
* title_count:int,
* source_title:string,
* category:string,
* section:string,
* title:string,
* data:array<string,mixed>
* }>
*/
private function workbookRows(
PayablesWorkbookStreamReader $reader,
@ -311,10 +281,12 @@ class SystemizationTodoWorkbookImporter
$section = $sectionValue;
}
$title = $this->cell($cells, $columns['title'] ?? null);
if ($title === '') {
$sourceTitle = $this->cell($cells, $columns['title'] ?? null);
if ($sourceTitle === '') {
continue;
}
$titles = $this->titleSegments($sourceTitle);
$titleCount = count($titles);
$owner = $this->cell($cells, $columns['owner'] ?? null);
$assignee = $this->cell($cells, $columns['assignee'] ?? null);
$startText = $this->cell($cells, $columns['start'] ?? null);
@ -325,50 +297,108 @@ class SystemizationTodoWorkbookImporter
$notes = $this->cell($cells, $columns['notes'] ?? null);
$status = $this->status($progress, $startText, $finishText);
$rows[] = [
'row' => $rowNumber,
'category' => $category,
'section' => $section,
'title' => $title,
'data' => [
'category' => $category !== '' ? $category : null,
'section' => $section !== '' ? $section : null,
foreach ($titles as $offset => $title) {
$titleIndex = $offset + 1;
$sortOrder = ($rowNumber * 100) + $titleIndex;
$rows[] = [
'row' => $rowNumber,
'title_index' => $titleIndex,
'title_count' => $titleCount,
'source_title' => $sourceTitle,
'category' => $category,
'section' => $section,
'title' => $title,
'owner' => $owner !== '' ? $owner : null,
'assignee' => $assignee !== '' ? $assignee : null,
'start_date' => $startDate,
'start_note' => $startNote !== '' ? $startNote : null,
'due_date' => $finishDate,
'due_note' => $finishNote !== '' ? $finishNote : null,
'status' => $status,
'completed_at' => $status === SystemizationTodo::STATUS_COMPLETED
? ($finishDate ?? now()->toDateString())
: null,
'progress' => $progress !== '' ? $progress : null,
'notes' => $notes !== '' ? $notes : null,
'sort_order' => $rowNumber,
'source_key' => hash(
'sha256',
implode('|', [
$companyId,
$sheetName,
$rowNumber,
$category,
$section,
$title,
$owner,
$assignee,
])
),
],
];
'data' => [
'category' => $category !== '' ? $category : null,
'section' => $section !== '' ? $section : null,
'title' => $title,
'owner' => $owner !== '' ? $owner : null,
'assignee' => $assignee !== '' ? $assignee : null,
'start_date' => $startDate,
'start_note' => $startNote !== '' ? $startNote : null,
'due_date' => $finishDate,
'due_note' => $finishNote !== '' ? $finishNote : null,
'status' => $status,
'completed_at' => $status === SystemizationTodo::STATUS_COMPLETED
? ($finishDate ?? now()->toDateString())
: null,
'progress' => $progress !== '' ? $progress : null,
'notes' => $notes !== '' ? $notes : null,
'sort_order' => $sortOrder,
'source_key' => hash(
'sha256',
implode('|', [
$companyId,
$sheetName,
$rowNumber,
$titleIndex,
$category,
$section,
$title,
$owner,
$assignee,
])
),
],
];
}
}
return $rows;
}
/**
* @param array<int,array{row:int,category:string,section:string,title:string,data:array<string,mixed>}> $rows
* Split a cell into separate tasks only when it contains multiple numbered lines.
*
* @return array<int,string>
*/
private function titleSegments(string $value): array
{
$value = trim(str_replace(["\r\n", "\r"], "\n", $value));
$marker = '/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、,,..::;;)]\s*/u';
$lines = preg_split('/\n/u', $value) ?: [];
$numberedLines = array_filter(
$lines,
static fn (string $line): bool => preg_match($marker, trim($line)) === 1,
);
if (count($numberedLines) < 2) {
return [$value];
}
$segments = [];
$current = '';
foreach ($lines as $line) {
$line = trim($line);
if ($line === '') {
continue;
}
if (preg_match($marker, $line) === 1) {
if ($current !== '') {
$segments[] = trim($current);
}
$current = trim((string) preg_replace($marker, '', $line));
continue;
}
$current = $current === '' ? $line : $current . "\n" . $line;
}
if ($current !== '') {
$segments[] = trim($current);
}
return $segments !== [] ? $segments : [$value];
}
/**
* @param array<int,array{
* row:int,
* title_index:int,
* title_count:int,
* source_title:string,
* category:string,
* section:string,
* title:string,
* data:array<string,mixed>
* }> $rows
* @return array{0:array<int,int>,1:array<int,int>}
*/
private function matchRows(array $rows, \Illuminate\Support\Collection $existing): array
@ -381,6 +411,32 @@ class SystemizationTodoWorkbookImporter
}
foreach ($rows as $rowIndex => $row) {
if ($row['title_count'] < 2 || $row['title_index'] !== 1) {
continue;
}
$sourceKey = $this->matchTitleKey($row['source_title']);
$available = array_values(array_filter(
$candidates[$sourceKey] ?? [],
fn (SystemizationTodo $todo): bool =>
! in_array($todo->id, $usedIds, true)
&& $this->matchText($todo->category) === $this->matchText($row['category'])
&& $this->matchText($todo->section) === $this->matchText($row['section']),
));
if ($available === []) {
continue;
}
usort($available, static fn (SystemizationTodo $a, SystemizationTodo $b): int =>
abs($a->sort_order - $row['data']['sort_order'])
<=> abs($b->sort_order - $row['data']['sort_order'])
);
$matches[$rowIndex] = $available[0]->id;
$usedIds[] = $available[0]->id;
}
foreach ($rows as $rowIndex => $row) {
if (isset($matches[$rowIndex])) {
continue;
}
$key = $this->matchTitleKey($row['title']);
$available = array_values(array_filter(
$candidates[$key] ?? [],
@ -390,7 +446,8 @@ class SystemizationTodoWorkbookImporter
continue;
}
usort($available, static fn (SystemizationTodo $a, SystemizationTodo $b): int =>
abs($a->sort_order - $row['row']) <=> abs($b->sort_order - $row['row'])
abs($a->sort_order - $row['data']['sort_order'])
<=> abs($b->sort_order - $row['data']['sort_order'])
);
$todo = $available[0];
$matches[$rowIndex] = $todo->id;
@ -419,7 +476,7 @@ class SystemizationTodoWorkbookImporter
$pairs[] = [
'rowIndex' => $rowIndex,
'todoId' => $todoId,
'score' => $similarity - abs($todo->sort_order - $row['row']) / 1000,
'score' => $similarity - abs($todo->sort_order - $row['data']['sort_order']) / 1000,
];
}
}
@ -445,7 +502,7 @@ class SystemizationTodoWorkbookImporter
private function matchTitleKey(?string $value): string
{
$value = preg_replace(
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、..::)]\s*/u',
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、,,..::;;)]\s*/u',
'',
(string) $value,
) ?? '';

View File

@ -547,9 +547,8 @@ SQL);
? $classificationStatus === '保留'
: $row['company_status'] === '正常';
$row['company_status'] = $retained ? '正常' : '已注销';
$row['tax_type'] = $retained
? ($this->normalizeTaxType($taxType) ?? '待维护')
: '/';
// Excel 台账明确有税务类型时始终展示;没有时再回退到上游公司资料。
$row['tax_type'] = $this->normalizeTaxType($taxType) ?? '/';
$businessType = trim((string) $businessType);
$row['business_registration_type'] = $retained
&& in_array($businessType, ['核定', '个人独资企业'], true)

View File

@ -12,6 +12,7 @@ class SyncFinanceLedgerShopData extends Command
{--from= : 提现业务日期起,默认从台账期初日}
{--to= : 提现业务日期止,最晚只同步到前一晚}
{--days= : 只同步最近 N 天}
{--rebuild : 先用最新余额快照清空并重建店铺台账}
{--no-recalculate : 只同步数据,不重算流水}';
protected $description = '同步上一晚店铺余额,并把平台账单中的提现对应到财务账户收入';
@ -29,6 +30,7 @@ class SyncFinanceLedgerShopData extends Command
$from,
$this->option('to') ?: null,
! $this->option('no-recalculate'),
(bool) $this->option('rebuild'),
);
} catch (Throwable $exception) {
$this->error($exception->getMessage());
@ -40,6 +42,7 @@ class SyncFinanceLedgerShopData extends Command
['店铺余额日期', $result['balance']['date'] ?: '-'],
['余额源记录', $result['balance']['source']],
['补充确认店铺', $result['balance']['added']],
['重建店铺台账', $result['balance']['rebuilt']],
['已更新店铺余额', $result['balance']['matched']],
['店铺余额合计', number_format((float) $result['balance']['amount'], 2)],
['提现处理笔数', $result['withdrawals']['processed']],

View File

@ -9,6 +9,7 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
@ -91,6 +92,8 @@ class SystemizationTodos extends Controller
'order' => PHP_INT_MAX,
'category_display' => '',
'section_display' => '',
'type_count' => 0,
'content_count' => 0,
];
$todo->setAttribute('type_sequence', $sequence['type_sequence']);
$todo->setAttribute('content_sequence', $sequence['content_sequence']);
@ -98,29 +101,11 @@ class SystemizationTodos extends Controller
$todo->setAttribute('hierarchy_order', $sequence['order']);
$todo->setAttribute('category_display', $sequence['category_display']);
$todo->setAttribute('section_display', $sequence['section_display']);
$todo->setAttribute('type_count', $sequence['type_count']);
$todo->setAttribute('content_count', $sequence['content_count']);
});
$items = $items->sortBy('hierarchy_order')->values();
if ($filters['type_sequence'] > 0) {
$items = $items
->filter(static fn (SystemizationTodo $todo): bool =>
(int) $todo->type_sequence === $filters['type_sequence']
)
->values();
}
if ($filters['content_sequence'] > 0) {
$items = $items
->filter(static fn (SystemizationTodo $todo): bool =>
(int) $todo->content_sequence === $filters['content_sequence']
)
->values();
}
if ($filters['item_sequence'] > 0) {
$items = $items
->filter(static fn (SystemizationTodo $todo): bool =>
(int) $todo->item_sequence === $filters['item_sequence']
)
->values();
}
$positionGroups = $this->positionGroups($sequenceMap);
$base = SystemizationTodo::query();
$categories = SystemizationTodo::query()
@ -158,8 +143,10 @@ class SystemizationTodos extends Controller
'view' => 'business.pages.systemization-todos',
'title' => '系统化待办',
'items' => $items,
'todoPositionGroups' => $positionGroups,
'todoFilters' => $filters,
'todoCategories' => $categories,
'todoContentOptions' => $this->contentOptions(),
'todoOwners' => $this->peopleOptions('owner'),
'todoAssignees' => $this->peopleOptions('assignee'),
'todoStatuses' => SystemizationTodo::STATUSES,
@ -174,6 +161,8 @@ class SystemizationTodos extends Controller
'todoRoutes' => [
'store' => route('business.systemization-todos.store'),
'update' => route('business.systemization-todos.update', ['todo' => '__TODO__']),
'category' => route('business.systemization-todos.category', ['todo' => '__TODO__']),
'section' => route('business.systemization-todos.section', ['todo' => '__TODO__']),
'destroy' => route('business.systemization-todos.destroy', ['todo' => '__TODO__']),
'attachment' => route('business.systemization-todos.attachments.show', [
'todo' => '__TODO__',
@ -241,6 +230,10 @@ class SystemizationTodos extends Controller
$sequenceMap = [];
$hierarchyOrder = 0;
foreach ($categoryKeys as $categoryIndex => $categoryKey) {
$typeCount = array_sum(array_map(
static fn (array $rows): int => count($rows),
$groupedRows[$categoryKey],
));
$contentKeys = array_keys($sectionOrder[$categoryKey]);
usort($contentKeys, function (string $left, string $right) use (
$categoryKey,
@ -269,6 +262,8 @@ class SystemizationTodos extends Controller
'order' => $hierarchyOrder++,
'category_display' => $row['category_label'],
'section_display' => $row['section_label'],
'type_count' => $typeCount,
'content_count' => count($contentRows),
];
}
}
@ -277,6 +272,30 @@ class SystemizationTodos extends Controller
return $sequenceMap;
}
private function positionGroups(array $sequenceMap): array
{
$groups = [];
$todos = SystemizationTodo::query()
->orderBy('sort_order')
->orderBy('id')
->get(['id', 'category', 'section', 'sort_order']);
foreach ($todos as $todo) {
$sequence = $sequenceMap[$todo->id] ?? null;
if ($sequence === null) {
continue;
}
$key = $sequence['type_sequence'] . ':' . $sequence['content_sequence'];
$groups[$key] ??= [
'category' => (string) ($todo->category ?? ''),
'section' => $sequence['section_display'],
'count' => 0,
];
$groups[$key]['count']++;
}
return array_values($groups);
}
private function compareHierarchyGroups(
string $left,
string $right,
@ -293,7 +312,7 @@ class SystemizationTodos extends Controller
private function hierarchyLabel(?string $value): string
{
return trim((string) preg_replace(
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、..::)]\s*/u',
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、,,..::;;)]\s*/u',
'',
(string) $value,
));
@ -314,20 +333,181 @@ class SystemizationTodos extends Controller
public function store(Request $request): RedirectResponse
{
$data = $this->validated($request);
$position = max(1, (int) ($data['position'] ?? 1));
unset($data['position']);
$data['company_id'] = (int) company_id();
$data['sort_order'] = (int) SystemizationTodo::query()->max('sort_order') + 1;
$data['created_by'] = user_id();
$data['updated_by'] = user_id();
$this->normalizeCompletionDates($data);
$todo = SystemizationTodo::query()->create($data);
$insertedSequence = $position;
$todo = DB::transaction(function () use ($data, $position, &$insertedSequence): SystemizationTodo {
$siblings = $this->contentSiblings($data['category'] ?? null, $data['section'] ?? null);
$nextOrder = (int) SystemizationTodo::query()->max('sort_order') + 1;
if ($siblings->isEmpty()) {
$insertOrder = $nextOrder;
} elseif ($position <= $siblings->count()) {
$insertOrder = (int) $siblings[$position - 1]->sort_order;
} else {
$insertOrder = (int) $siblings->max('sort_order') + 1;
}
SystemizationTodo::query()
->where('sort_order', '>=', $insertOrder)
->increment('sort_order');
$insertedSequence = $siblings->isEmpty()
? 1
: min($position, $siblings->count() + 1);
return SystemizationTodo::query()->create([
...$data,
'sort_order' => $insertOrder,
]);
});
$this->storeAttachments($request, $todo);
return $this->backToPage('待办事项已新增并定位。', 'success', $todo);
return $this->backToPage(
'待办事项已新增为当前内容第 ' . $insertedSequence . ' 条并定位。',
'success',
$todo,
);
}
public function updateCategory(Request $request, SystemizationTodo $todo): RedirectResponse
{
$data = $request->validate([
'category' => ['required', 'string', 'max:100'],
]);
$ids = [];
DB::transaction(function () use ($todo, $data, &$ids): void {
$ids = $this->groupTodoIds($todo, false);
$this->updateGroupField($ids, ['category' => trim($data['category'])]);
});
return $this->backToPage(
'类型已更新,当前类型下的 ' . count($ids) . ' 条待办已同步调整。',
'success',
$todo,
);
}
public function updateSection(Request $request, SystemizationTodo $todo): RedirectResponse
{
$data = $request->validate([
'section' => ['required', 'string', 'max:255'],
]);
$ids = [];
DB::transaction(function () use ($todo, $data, &$ids): void {
$ids = $this->groupTodoIds($todo, true);
$this->updateGroupField($ids, ['section' => trim($data['section'])]);
});
return $this->backToPage(
'内容已更新,当前内容下的 ' . count($ids) . ' 条待办已同步调整。',
'success',
$todo,
);
}
private function contentSiblings(
?string $category,
?string $section,
?int $excludeId = null,
): Collection
{
$categoryKey = $this->hierarchyGroupKey($this->hierarchyLabel($category));
$sectionKey = $this->hierarchyGroupKey($this->hierarchyLabel($section));
return SystemizationTodo::query()
->orderBy('sort_order')
->orderBy('id')
->lockForUpdate()
->get()
->filter(fn (SystemizationTodo $todo): bool =>
(int) $todo->id !== (int) $excludeId
&& $this->hierarchyGroupKey($this->hierarchyLabel($todo->category)) === $categoryKey
&& $this->hierarchyGroupKey($this->hierarchyLabel($todo->section)) === $sectionKey
)
->values();
}
private function positionForUpdate(
SystemizationTodo $todo,
int $targetPosition,
array &$data,
): void {
$currentCategoryKey = $this->hierarchyGroupKey($this->hierarchyLabel($todo->category));
$currentSectionKey = $this->hierarchyGroupKey($this->hierarchyLabel($todo->section));
$targetCategoryKey = $this->hierarchyGroupKey($this->hierarchyLabel($data['category'] ?? null));
$targetSectionKey = $this->hierarchyGroupKey($this->hierarchyLabel($data['section'] ?? null));
$sameGroup = $currentCategoryKey === $targetCategoryKey
&& $currentSectionKey === $targetSectionKey;
if ($sameGroup) {
$currentSiblings = $this->contentSiblings($todo->category, $todo->section);
$currentIndex = $currentSiblings->search(
static fn (SystemizationTodo $item): bool => (int) $item->id === (int) $todo->id
);
if ($currentIndex !== false && $targetPosition === ((int) $currentIndex + 1)) {
return;
}
}
$siblings = $this->contentSiblings(
$data['category'] ?? null,
$data['section'] ?? null,
(int) $todo->id,
);
if ($siblings->isEmpty()) {
$insertOrder = (int) SystemizationTodo::query()->max('sort_order') + 1;
} elseif ($targetPosition <= $siblings->count()) {
$insertOrder = (int) $siblings[$targetPosition - 1]->sort_order;
} else {
$insertOrder = (int) $siblings->max('sort_order') + 1;
}
SystemizationTodo::query()
->where('sort_order', '>=', $insertOrder)
->increment('sort_order');
$data['sort_order'] = $insertOrder;
}
private function groupTodoIds(SystemizationTodo $todo, bool $includeSection): array
{
$categoryKey = $this->hierarchyGroupKey($this->hierarchyLabel($todo->category));
$sectionKey = $this->hierarchyGroupKey($this->hierarchyLabel($todo->section));
return SystemizationTodo::query()
->lockForUpdate()
->get(['id', 'category', 'section'])
->filter(fn (SystemizationTodo $candidate): bool =>
$this->hierarchyGroupKey($this->hierarchyLabel($candidate->category)) === $categoryKey
&& (! $includeSection
|| $this->hierarchyGroupKey($this->hierarchyLabel($candidate->section)) === $sectionKey)
)
->pluck('id')
->map(static fn (mixed $id): int => (int) $id)
->values()
->all();
}
private function updateGroupField(array $ids, array $data): void
{
if ($ids === []) {
return;
}
SystemizationTodo::query()
->whereIn('id', $ids)
->update([
...$data,
'updated_by' => user_id(),
]);
}
public function update(Request $request, SystemizationTodo $todo): RedirectResponse
{
$data = $this->validated($request);
$targetPosition = max(0, (int) ($data['position'] ?? 0));
unset($data['position']);
$data['updated_by'] = user_id();
$this->normalizeCompletionDates($data);
@ -347,7 +527,16 @@ class SystemizationTodos extends Controller
}
}
$todo->update($data);
DB::transaction(function () use ($todo, $data, $targetPosition): void {
$lockedTodo = SystemizationTodo::query()
->lockForUpdate()
->findOrFail($todo->id);
if ($targetPosition > 0) {
$this->positionForUpdate($lockedTodo, $targetPosition, $data);
}
$lockedTodo->update($data);
$todo->setRawAttributes($lockedTodo->getAttributes(), true);
});
$this->storeAttachments($request, $todo);
return $this->backToPage('待办事项已更新并定位。', 'success', $todo);
@ -419,9 +608,6 @@ class SystemizationTodos extends Controller
'assignees' => $this->peopleFilter('assignee'),
'start_date' => $this->normalizeDateFilter(request('start_date')),
'due_date' => $this->normalizeDateFilter(request('due_date')),
'type_sequence' => max(0, (int) request('type_sequence', 0)),
'content_sequence' => max(0, (int) request('content_sequence', 0)),
'item_sequence' => max(0, (int) request('item_sequence', 0)),
'keyword' => trim((string) request('keyword', '')),
];
}
@ -451,6 +637,30 @@ class SystemizationTodos extends Controller
->values();
}
private function contentOptions(): array
{
$options = [];
$todos = SystemizationTodo::query()
->whereNotNull('section')
->where('section', '<>', '')
->get(['category', 'section']);
foreach ($todos as $todo) {
$category = $this->hierarchyLabel($todo->category);
$section = $this->hierarchyLabel($todo->section);
if ($category !== '' && $section !== '') {
$options[$category][$section] = true;
}
}
foreach ($options as $category => $sections) {
$labels = array_keys($sections);
usort($labels, 'strnatcasecmp');
$options[$category] = $labels;
}
return $options;
}
private function normalizeDateFilter(mixed $value): string
{
$value = trim((string) $value);
@ -471,6 +681,7 @@ class SystemizationTodos extends Controller
'category' => ['nullable', 'string', 'max:100'],
'section' => ['nullable', 'string', 'max:255'],
'title' => ['required', 'string', 'max:5000'],
'position' => ['nullable', 'integer', 'min:1'],
'owner' => ['nullable', 'string', 'max:255'],
'assignee' => ['nullable', 'string', 'max:255'],
'start_date' => ['nullable', 'date_format:Y-m-d'],

View File

@ -19,25 +19,25 @@ return [
['key' => 'F', 'label' => '8月应发工资', 'group' => 'original', 'kind' => 'number'],
['key' => 'G', 'label' => '原社保个人扣款', 'group' => 'original', 'kind' => 'number'],
['key' => 'H', 'label' => '原公积金个人扣款', 'group' => 'original', 'kind' => 'number'],
['key' => 'I', 'label' => '扣除额', 'group' => 'original', 'kind' => 'number'],
['key' => 'I', 'label' => '扣除额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=5000'],
['key' => 'J', 'label' => '原需报个税基数', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=F#-G#-H#-I#'],
['key' => 'K', 'label' => '原个税比列', 'group' => 'original', 'kind' => 'formula_percent', 'formula' => '=IF(J#<=0,"",IF(J#<=3000,0.03,IF(J#<=12000,0.1,IF(J#<=25000,0.2,IF(J#<=35000,0.25,IF(J#<=55000,0.3,IF(J#<=80000,0.35,0.45)))))))'],
['key' => 'L', 'label' => '原速算扣除数', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=IF(J#<=0,"",IF(J#<=3000,0,IF(J#<=12000,210,IF(J#<=25000,1410,IF(J#<=35000,2660,IF(J#<=55000,4410,IF(J#<=80000,7160,15160)))))))'],
['key' => 'M', 'label' => '原需交个税金额', 'group' => 'original', 'kind' => 'number'],
['key' => 'M', 'label' => '原需交个税金额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=J#*K#-L#'],
['key' => 'N', 'label' => '原需年交个税金额', 'group' => 'original', 'kind' => 'formula_number', 'formula' => '=M#*12'],
['key' => 'O', 'label' => '新公积金缴存基数', 'group' => 'fund', 'kind' => 'number'],
['key' => 'P', 'label' => '新单位公积金月缴存12%', 'group' => 'fund', 'kind' => 'number'],
['key' => 'Q', 'label' => '新个人公积金月缴存12%', 'group' => 'fund', 'kind' => 'number'],
['key' => 'R', 'label' => '超额代扣缴', 'group' => 'fund', 'kind' => 'number'],
['key' => 'O', 'label' => '新公积金缴存基数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(F#<=0,"",IF(F#<=8500,4952,IF(F#<=15000,8000,IF(F#<=25000,10000,12000))))'],
['key' => 'P', 'label' => '新单位公积金月缴存12%', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=O#*0.12'],
['key' => 'Q', 'label' => '新个人公积金月缴存12%', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=O#*0.12'],
['key' => 'R', 'label' => '超额代扣缴', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=Q#-H#'],
['key' => 'S', 'label' => '新月度应纳税所得额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=F#-G#-I#-P#-R#'],
['key' => 'T', 'label' => '新月度个税比列', 'group' => 'fund', 'kind' => 'formula_percent', 'formula' => '=IF(S#<=0,"",IF(S#<=3000,0.03,IF(S#<=12000,0.1,IF(S#<=25000,0.2,IF(S#<=35000,0.25,IF(S#<=55000,0.3,IF(S#<=80000,0.35,0.45)))))))'],
['key' => 'U', 'label' => '新月度新速算扣除数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(S#<=0,"",IF(S#<=3000,0,IF(S#<=12000,210,IF(S#<=25000,1410,IF(S#<=35000,2660,IF(S#<=55000,4410,IF(S#<=80000,7160,15160)))))))'],
['key' => 'V', 'label' => '新月度个税金额', 'group' => 'fund', 'kind' => 'number'],
['key' => 'V', 'label' => '新月度个税金额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=S#*T#-U#'],
['key' => 'W', 'label' => '全年应纳税所得额', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=S#*12'],
['key' => 'X', 'label' => '年度税率', 'group' => 'fund', 'kind' => 'formula_percent', 'formula' => '=IF(S#=0,"",IF(W#<=0,0,IF(W#<=36000,0.03,IF(W#<=144000,0.1,IF(W#<=300000,0.2,IF(W#<=420000,0.25,IF(W#<=660000,0.3,IF(W#<=960000,0.35,0.45))))))))'],
['key' => 'Y', 'label' => '年度速算扣除数', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=IF(W#=0,"",IF(W#<=0,0,IF(W#<=36000,0,IF(W#<=144000,2520,IF(W#<=300000,16920,IF(W#<=420000,31920,IF(W#<=660000,52920,IF(W#<=960000,85920,181920))))))))'],
['key' => 'Z', 'label' => '全年个税', 'group' => 'fund', 'kind' => 'formula_number', 'formula' => '=W#*X#-Y#'],
['key' => 'AA', 'label' => '单月应纳税所得额区间', 'group' => 'salary_parttime', 'kind' => 'number'],
['key' => 'AA', 'label' => '单月应纳税所得额区间', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=IF(T#<=0.03,0,IF(T#<=0.1,3000,12000))'],
['key' => 'AB', 'label' => '福利费', 'group' => 'salary_parttime', 'kind' => 'number'],
['key' => 'AC', 'label' => '现金', 'group' => 'salary_parttime', 'kind' => 'number'],
['key' => 'AD', 'label' => '兼职工资合计', 'group' => 'salary_parttime', 'kind' => 'formula_number', 'formula' => '=AB#+AC#'],

View File

@ -225,8 +225,8 @@ CRON_TZ=Asia/Shanghai
# 供应商管理每天北京时间 08:15 完整校准档案、合同、联系人与打款资料。
15 8 * * * root /usr/bin/flock -w 3600 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan business-mirror:sync-supplier-management --quiet >/dev/null 2>&1
*/2 * * * * root /usr/bin/flock -n /run/caiwu-esign-polling.lock /usr/bin/docker exec -u www-data caiwu_app php artisan esign:poll-signatures --quiet >/dev/null 2>&1
# 财务台账:每天 02:30 同步 AI 库动账、上一晚店铺余额和平台提现,并重算流水。
30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /bin/sh -c '/usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet && /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-shop-data --days=7 --quiet' >/dev/null 2>&1
# 财务台账:每天 02:30 同步 AI 库动账并重算流水;店铺台账默认不自动回填。
30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet >/dev/null 2>&1
# 科目映射保存后保留自动重跑队列,每分钟在受限容器内串行消费。
* * * * * root /usr/bin/flock -n /run/caiwu-account-mapping-resync.lock /bin/sh /opt/caiwuxitong/run-finance-batch.sh store-receipt:auto-resync --quiet >/dev/null 2>&1
* * * * * root /usr/bin/flock -n /run/caiwu-account-bills-export.lock /bin/sh /opt/caiwuxitong/run-finance-batch.sh account-bills:exports:run --quiet >/dev/null 2>&1

View File

@ -229,8 +229,8 @@ CRON_TZ=Asia/Shanghai
# 供应商管理每天北京时间 08:15 完整校准档案、合同、联系人与打款资料。
15 8 * * * root /usr/bin/flock -w 3600 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan business-mirror:sync-supplier-management --quiet >/dev/null 2>&1
*/2 * * * * root /usr/bin/flock -n /run/caiwu-esign-polling.lock /usr/bin/docker exec -u www-data caiwu_app php artisan esign:poll-signatures --quiet >/dev/null 2>&1
# 财务台账:每天 02:30 同步 AI 库动账、上一晚店铺余额和平台提现,并重算流水。
30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /bin/sh -c '/usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet && /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-shop-data --days=7 --quiet' >/dev/null 2>&1
# 财务台账:每天 02:30 同步 AI 库动账并重算流水;店铺台账默认不自动回填。
30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet >/dev/null 2>&1
# 科目映射保存后保留自动重跑队列,每分钟在受限容器内串行消费。
* * * * * root /usr/bin/flock -n /run/caiwu-account-mapping-resync.lock /bin/sh /opt/caiwuxitong/run-finance-batch.sh store-receipt:auto-resync --quiet >/dev/null 2>&1
* * * * * root /usr/bin/flock -n /run/caiwu-account-bills-export.lock /bin/sh /opt/caiwuxitong/run-finance-batch.sh account-bills:exports:run --quiet >/dev/null 2>&1

View File

@ -8,7 +8,7 @@ CAIWU_BATCH_CALLER_DIR="$PWD"
export CAIWU_BATCH_CALLER_DIR
case "${1:-}" in
*:import|*:import-*|*:import:*|product:monthly-weighted-average:base) is_import=1 ;;
jushuitan:sync-shipping|store-receipt:order-match:sync|store-receipt:product-cost:sync|store-receipt:auto-resync|order-data:warm-shop-candidates|business-mirror:index-work-order-waybills|business-mirror:refresh-paid-sales|account-bills:exports:run|finance-ledger:recalculate|product:monthly-weighted-average:auto|product:monthly-weighted-average:compute|product:monthly-weighted-average:report|finance:monthly-weighted-product-cost:auto) ;;
jushuitan:sync-shipping|store-receipt:order-match:sync|store-receipt:product-cost:sync|store-receipt:auto-resync|order-data:warm-shop-candidates|business-mirror:sync-tables|business-mirror:index-work-order-waybills|business-mirror:refresh-paid-sales|account-bills:exports:run|finance-ledger:recalculate|product:monthly-weighted-average:auto|product:monthly-weighted-average:compute|product:monthly-weighted-average:report|finance:monthly-weighted-product-cost:auto) ;;
*) echo 'Unsupported finance batch command' >&2; exit 64 ;;
esac
cd "$REMOTE_DIR"

View File

@ -288,6 +288,18 @@ php artisan business-mirror:sync-tables
首次全量、历史回补和镜像校准由任务 Codex 自主执行:先备份受影响的系统配置、镜像表及同步状态,再在生产同步节点内使用现有上游互斥锁,按稳定游标分批执行或续传 `--full`,直至完成并核对源表/镜像和实际页面。无需负责人另行授权或代跑命令;开发机驱动不支持时直接通过 SSH 使用生产容器,不以本机不能同步为由停止任务。后续无参数命令只执行或继续受控增量,不对无关数据集批量全量。
生产同步节点对单个数据集执行历史回补时,也通过受限批入口分批续传,避免网页容器承担重型任务。每轮使用有限批次,返回“同步进行中”后以相同命令继续,直到显示“同步完成”:
```bash
sh /opt/caiwuxitong/run-finance-batch.sh business-mirror:sync-tables <dataset-key> --full --batch=500 --max-batches=20
```
首次全量完成后的定向增量去掉 `--full`,继续保留批次上限:
```bash
sh /opt/caiwuxitong/run-finance-batch.sh business-mirror:sync-tables <dataset-key> --batch=500 --max-batches=20
```
重型发货回填、业绩明细重算、商品成本重算和店铺候选全量核对,统一从生产节点使用受限任务入口:
```bash

View File

@ -66,7 +66,7 @@ docker compose -f docker-compose.local.yml exec -u www-data app \
- 账户总表支持导出空白 Excel 录入模板,包含页面列、状态和账户类型选项及填写说明
- 账户总表编辑模式支持直接新增公司和首个账户:公司不存在时同步写入公司台账,可维护注册地、企业类型、税务类型、公司状态、基本户信息和备注;账户简称必须唯一,可同时登记期初日期与期初余额
- 写权限:账户映射、账户状态和账户类型修改仅系统管理员及配置的财务台账管理员角色;其他账号只读
- 调度:`finance-ledger:sync-rpt --days=7 --merge` 每天 02:30(Asia/Shanghai)
- 调度:`finance-ledger:sync-rpt --days=7 --merge` 每天 02:30(Asia/Shanghai);店铺台账默认不自动回填
账户状态独立保存在 `fin_account_statuses`,账户类型人工维护值独立保存在
`fin_account_type_overrides`,重新导入账户基础数据均不会覆盖;页面修改使用
@ -128,6 +128,13 @@ docker exec -u www-data caiwu_app php artisan finance-ledger:verify
30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet >/dev/null 2>&1
```
店铺台账默认保持现有数据,不随每日动账同步自动回填。需要按上游重新拉取时,
先确认已部署包含 `sync-shop-data --rebuild` 的主线镜像,再手动执行:
```bash
sh /opt/caiwuxitong/run-finance-batch.sh finance-ledger:sync-shop-data --rebuild
```
5. 在「系统设置 → 权限」把「财务台账」页面分配给财务角色;账户映射修改允许超级管理员和「财务台账管理员」角色(可用 `FINANCE_LEDGER_MAPPING_EDITOR_ROLES` 覆盖)。
生产环境不设置 `FINANCE_LEDGER_WINDOW_END` 时会同步到当天;本地为了复现 12,037 笔规格数据,在 `runtime/.env` 固定为 `2026-10-18`。

View File

@ -30,7 +30,7 @@ class ProcessDetails extends Controller
return view('business.pages.financial-operations.process-details', [
'section' => ['slug' => 'financial-operations', 'title' => '财务经营报表'],
'page' => ['slug' => 'process-details', 'title' => '流程明细'],
'rows' => new LengthAwarePaginator(
'processRows' => new LengthAwarePaginator(
$result['data'],
$result['total'],
$perPage,
@ -39,7 +39,6 @@ class ProcessDetails extends Controller
),
'filters' => $filters,
'summary' => $result['summary'],
'months' => $options['months'],
'documentTypes' => $options['document_types'],
'statuses' => $options['statuses'],
'mirrorStatus' => $result['status'],
@ -53,7 +52,7 @@ class ProcessDetails extends Controller
return view('business.pages.financial-operations.process-details', [
'section' => ['slug' => 'financial-operations', 'title' => '财务经营报表'],
'page' => ['slug' => 'process-details', 'title' => '流程明细'],
'rows' => new LengthAwarePaginator([], 0, $perPage, $page, [
'processRows' => new LengthAwarePaginator([], 0, $perPage, $page, [
'path' => $request->url(),
'query' => $request->except('page'),
]),
@ -64,7 +63,6 @@ class ProcessDetails extends Controller
'amount_total' => 0.0,
'bank_amount_total' => 0.0,
],
'months' => [],
'documentTypes' => [],
'statuses' => [],
'mirrorStatus' => 'unavailable',
@ -124,11 +122,13 @@ class ProcessDetails extends Controller
/** @return array<string,string> */
private function filters(Request $request): array
{
$month = trim((string) $request->query('month', ''));
$paidDate = trim((string) $request->query('paid_date', ''));
$status = trim((string) $request->query('status', ''));
$paidDateValid = preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $paidDate, $dateParts) === 1
&& checkdate((int) $dateParts[2], (int) $dateParts[3], (int) $dateParts[1]);
return [
'month' => preg_match('/^\d{4}-\d{2}$/', $month) === 1 ? $month : '',
'paid_date' => $paidDateValid ? $paidDate : '',
'document_type' => mb_substr(trim((string) $request->query('document_type', '')), 0, 100),
'status' => mb_substr($status, 0, 20),
'business_id' => mb_substr(trim((string) $request->query('business_id', '')), 0, 32),

View File

@ -115,31 +115,17 @@ class DingProcessDetailMirrorRepository
];
}
/** @return array{months:list<string>,document_types:list<string>,statuses:list<string>} */
/** @return array{document_types:list<string>,statuses:list<string>} */
public function filterOptions(): array
{
if (! Schema::connection($this->connection->getName())->hasTable('ding_process_detail_mirror')) {
return ['months' => [], 'document_types' => [], 'statuses' => []];
return ['document_types' => [], 'statuses' => []];
}
$base = $this->connection->table('ding_process_detail_mirror')
->where('source_scope', $this->scope());
return [
'months' => (clone $base)
->whereNotNull('business_month')
->where('business_month', '!=', '')
->distinct()
->orderByDesc('business_month')
->pluck('business_month')
->map(static function (mixed $value): string {
$month = (string) $value;
return preg_match('/^\d{6}$/', $month) === 1
? substr($month, 0, 4) . '-' . substr($month, 4, 2)
: $month;
})
->all(),
'document_types' => (clone $base)
->whereNotNull('document_type')
->where('document_type', '!=', '')
@ -191,9 +177,9 @@ class DingProcessDetailMirrorRepository
$query = $this->connection->table('ding_process_detail_mirror')
->where('source_scope', $this->scope());
$month = trim((string) ($filters['month'] ?? ''));
if (preg_match('/^\d{4}-\d{2}$/', $month) === 1) {
$query->where('business_month', str_replace('-', '', $month));
$paidDate = trim((string) ($filters['paid_date'] ?? ''));
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $paidDate) === 1) {
$query->where('paid_at', 'like', $paidDate . '%');
}
foreach ([

View File

@ -27,12 +27,12 @@ class FinanceLedgerShopDataSynchronizer
/**
* @return array{
* balance:array{date:?string,source:int,added:int,matched:int,amount:float},
* balance:array{date:?string,source:int,added:int,rebuilt:int,matched:int,amount:float},
* withdrawals:array{from:string,to:string,processed:int,written:int,upstream_duplicates:int,unmatched:int,account_missing:int,income:float,expense:float},
* recalculated:?array
* }
*/
public function sync(?string $from = null, ?string $to = null, bool $recalculate = true): array
public function sync(?string $from = null, ?string $to = null, bool $recalculate = true, bool $rebuild = false): array
{
$previousNight = now()->startOfDay()->subDay()->toDateString();
$to = $this->validDate($to) ?? $previousNight;
@ -45,7 +45,7 @@ class FinanceLedgerShopDataSynchronizer
$from = $to;
}
$balance = $this->syncShopBalances($to);
$balance = $this->syncShopBalances($to, $rebuild);
$withdrawals = $this->syncWithdrawals($from, $to);
$recalculated = $recalculate && ($balance['matched'] > 0 || $withdrawals['written'] > 0)
? app(FinanceLedgerCalculator::class)->recalculate()
@ -59,20 +59,21 @@ class FinanceLedgerShopDataSynchronizer
}
/**
* @return array{date:?string,source:int,added:int,matched:int,amount:float}
* @return array{date:?string,source:int,added:int,rebuilt:int,matched:int,amount:float}
*/
public function syncShopBalances(?string $through = null): array
public function syncShopBalances(?string $through = null, bool $rebuild = false): array
{
$through = $this->validDate($through) ?? now()->startOfDay()->subDay()->toDateString();
$balanceDate = $this->shopBalances->latestBalanceDate(CarbonImmutable::parse($through));
if ($balanceDate === null) {
return ['date' => null, 'source' => 0, 'added' => 0, 'matched' => 0, 'amount' => 0.0];
return ['date' => null, 'source' => 0, 'added' => 0, 'rebuilt' => 0, 'matched' => 0, 'amount' => 0.0];
}
$rebuilt = $rebuild ? $this->rebuildShopLedger($balanceDate) : 0;
$shops = $this->connection->table('fin_shops')
->orderBy('id')
->get(['id', 'shop_name', 'platform', 'account_short']);
$added = $this->addConfirmedMissingShops($balanceDate, $shops);
$added = $rebuilt > 0 ? 0 : $this->addConfirmedMissingShops($balanceDate, $shops);
if ($added > 0) {
$shops = $this->connection->table('fin_shops')
->orderBy('id')
@ -112,11 +113,89 @@ class FinanceLedgerShopDataSynchronizer
'date' => $balanceDate,
'source' => $this->shopBalances->countForDate($balanceDate),
'added' => $added,
'rebuilt' => $rebuilt,
'matched' => count($updates),
'amount' => round(array_sum($updates), 2),
];
}
private function rebuildShopLedger(string $balanceDate): int
{
$sourceRows = $this->connection->table(JushuitanShopBalanceRepository::TABLE)
->where('balance_date', $balanceDate)
->orderByRaw("CASE WHEN data_source = 'jushuitan' THEN 0 ELSE 1 END")
->orderBy('id')
->get(['source_platform', 'store_name']);
if ($sourceRows->isEmpty()) {
return 0;
}
$receivingByNormalized = [];
foreach (StoreReceivingAccount::withoutGlobalScopes()->whereNull('deleted_at')->get() as $account) {
$name = trim((string) ($account->erp_store_name ?? ''));
if ($name !== '') {
$receivingByNormalized[JushuitanShopBalanceRepository::normalizeStoreName($name)][] = $account;
}
}
$accountShortByShop = $this->connection->table('fin_account_map')
->where('source', 'shop')
->whereNotNull('account_short')
->where('account_short', '<>', '')
->pluck('account_short', 'source_value');
$now = now();
$seen = [];
$rows = [];
foreach ($sourceRows as $source) {
$name = trim((string) ($source->store_name ?? ''));
if ($name === '' || isset($seen[$name])) {
continue;
}
$seen[$name] = true;
$normalized = JushuitanShopBalanceRepository::normalizeStoreName($name);
$receivingMatches = $receivingByNormalized[$normalized] ?? [];
$receiving = count($receivingMatches) === 1 ? $receivingMatches[0] : null;
$accountShort = trim((string) ($accountShortByShop[$name] ?? ''));
$bankLastFour = $receiving === null ? '' : trim((string) ($receiving->bank_card_last_four ?? ''));
$payout = $receiving === null ? '' : trim((string) ($receiving->withdrawal_account_name ?? ''));
if ($payout !== '' && $bankLastFour !== '') {
$payout .= ' ' . $bankLastFour;
}
$row = [
'shop_name' => mb_substr($name, 0, 200),
'platform' => mb_substr($this->financialPlatform((string) ($source->source_platform ?? ''), $name), 0, 50),
'company_name' => $receiving === null
? null
: (mb_substr(trim((string) ($receiving->store_entity_name ?? '')), 0, 100) ?: null),
'account_short' => $accountShort === '' ? null : mb_substr($accountShort, 0, 100),
'status' => $receiving === null ? '待确认' : $this->financialShopStatus($receiving->store_status),
'payout_account' => $payout === '' ? null : mb_substr($payout, 0, 100),
'shop_balance' => 0,
'remark' => $receiving === null
? '由聚水潭店铺余额快照重新生成,待确认回款账户'
: '由店铺主数据与最新店铺余额快照重新生成',
'created_at' => $now,
'updated_at' => $now,
];
if ($this->connection->getSchemaBuilder()->hasColumn('fin_shops', 'shop_balance_date')) {
$row['shop_balance_date'] = null;
}
$rows[] = $row;
}
if ($rows === []) {
return 0;
}
return $this->connection->transaction(function () use ($rows): int {
$this->connection->table('fin_shops')->delete();
foreach (array_chunk($rows, 200) as $chunk) {
$this->connection->table('fin_shops')->insert($chunk);
}
return count($rows);
});
}
private function addConfirmedMissingShops(string $balanceDate, $existingShops): int
{
$sourceRows = $this->connection->table(JushuitanShopBalanceRepository::TABLE)
@ -450,6 +529,16 @@ class FinanceLedgerShopDataSynchronizer
return $sourcePlatform !== '' ? $sourcePlatform : '未填写';
}
private function financialShopStatus(mixed $status): string
{
return match (trim((string) $status)) {
'正常', '在营' => '在营',
'关店中', '暂停' => '暂停',
'已关店', '已注销' => '已注销',
default => trim((string) $status) ?: '待确认',
};
}
private function validDate(?string $value): ?string
{
$value = trim((string) $value);

View File

@ -0,0 +1,130 @@
<?php
namespace Modules\EcommerceFinance\Services;
use Illuminate\Database\DatabaseManager;
use Illuminate\Support\Facades\Schema;
use Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository;
use Throwable;
/**
* 财务台账店铺台账的店铺目录。
*
* 平台和 ERP 店铺名称来自店铺维度报表的店铺资料;店铺主体只取当前
* 失效时间为「存续中」的主体期间。财务台账自己的账户和余额字段按 ERP
* 店铺名称合并,避免把报表销量或其他财务字段混入店铺台账。
*/
class FinanceLedgerShopDirectory
{
public function __construct(
private readonly BusinessInformationMirrorRepository $storeInformation,
private readonly StoreReportPeriodBuilder $periods,
private readonly DatabaseManager $databases,
) {
}
/**
* 返回 null 表示店铺维度报表镜像尚未就绪,调用方应回退到财务台账原表。
*
* @return list<array{
* id:int,
* platform:?string,
* shop_name:string,
* company_name:?string,
* account_short:?string,
* status:string,
* payout_account:?string,
* shop_balance:float,
* shop_balance_date:?string,
* remark:?string
* }>|null
*/
public function rows(): ?array
{
try {
$stores = $this->storeInformation->allStores();
} catch (Throwable $exception) {
report($exception);
return null;
}
$openStores = array_values(array_filter(
$stores,
static fn (array $store): bool => in_array(
(string) ($store['store_status'] ?? ''),
['0', '正常'],
true,
) && trim((string) ($store['erp_store_name'] ?? '')) !== '',
));
if ($openStores === []) {
return [];
}
try {
$periods = $this->periods->build($openStores);
} catch (Throwable $exception) {
report($exception);
return null;
}
$financeShops = $this->financeShops();
$rows = [];
foreach ($openStores as $store) {
$erpStoreName = trim((string) ($store['erp_store_name'] ?? ''));
$companyName = null;
foreach ($periods[$erpStoreName] ?? [] as $period) {
// 报表把失效时间为空的最后一个期间显示为「存续中」。
if (($period['expires_at'] ?? null) === null) {
$companyName = $this->nullableString($period['company_name'] ?? null);
}
}
$financeShop = $financeShops[$erpStoreName] ?? null;
$rows[] = [
'id' => (int) ($store['id'] ?? 0),
'platform' => $this->nullableString($store['platform'] ?? null),
'shop_name' => $erpStoreName,
'company_name' => $companyName,
'account_short' => $this->nullableString($financeShop->account_short ?? null),
'status' => '在营',
'payout_account' => $this->nullableString(
$financeShop->payout_account ?? ($store['withdrawal_account'] ?? null),
),
'shop_balance' => round((float) ($financeShop->shop_balance ?? 0), 2),
'shop_balance_date' => $this->nullableString($financeShop->shop_balance_date ?? null),
'remark' => $this->nullableString($financeShop->remark ?? null),
];
}
return $rows;
}
/** @return array<string,object> */
private function financeShops(): array
{
$connection = $this->databases->connection(
(string) config('upstream_mirrors.connection', 'business_mirror'),
);
if (! Schema::connection($connection->getName())->hasTable('fin_shops')) {
return [];
}
return $connection->table('fin_shops')
->get()
->mapWithKeys(static function (object $row): array {
$name = trim((string) ($row->shop_name ?? ''));
return $name === '' ? [] : [$name => $row];
})
->all();
}
private function nullableString(mixed $value): ?string
{
$value = trim((string) $value);
return $value === '' ? null : $value;
}
}

View File

@ -6,10 +6,12 @@ use App\Utilities\FinanceLedgerAccountStatus;
use App\Utilities\FinanceLedgerAccountShouldKeep;
use App\Utilities\FinanceLedgerAccountType;
use App\Utilities\FinanceLedgerAccess;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Query\Builder;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Modules\EcommerceFinance\Services\FinanceLedgerShopDirectory;
use Modules\EcommerceFinance\Repositories\JushuitanShopBalanceRepository;
/**
@ -31,6 +33,11 @@ class FinanceLedgerPageData
private const ACCOUNT_FILTER_EMPTY = '__empty__';
public function __construct(
private readonly FinanceLedgerShopDirectory $shopDirectory,
) {
}
public function page(?string $tab = null): array
{
$tab = (string) (request('tab') ?: $tab);
@ -214,6 +221,91 @@ class FinanceLedgerPageData
}
private function shops(): array
{
$directoryRows = $this->shopDirectory->rows();
return $directoryRows === null
? $this->shopsFromLedgerTable()
: $this->shopsFromStoreReport($directoryRows);
}
/**
* @param list<array<string,mixed>> $rows
* @return array{rows:LengthAwarePaginator,summary:array{count:int,balance:float}}
*/
private function shopsFromStoreReport(array $rows): array
{
$keyword = trim((string) request('shops_q', ''));
$platform = trim((string) request('shops_platform', ''));
$company = trim((string) request('shops_company', ''));
$rows = array_values(array_filter(
$rows,
static function (array $row) use ($keyword, $platform, $company): bool {
if ($platform !== '' && trim((string) ($row['platform'] ?? '')) !== $platform) {
return false;
}
if ($company !== '' && mb_stripos((string) ($row['company_name'] ?? ''), $company) === false) {
return false;
}
if ($keyword === '') {
return true;
}
foreach (['shop_name', 'platform', 'company_name'] as $field) {
if (mb_stripos((string) ($row[$field] ?? ''), $keyword) !== false) {
return true;
}
}
return false;
},
));
$headerColumns = $this->shopHeaderColumns();
$rows = $this->filterAndSortHeaderRows($rows, 'shops', $headerColumns);
if (! isset($headerColumns[trim((string) request('shops_sort', ''))])) {
usort($rows, static fn (array $left, array $right): int => [
(string) ($left['company_name'] ?? ''),
(string) ($left['shop_name'] ?? ''),
] <=> [
(string) ($right['company_name'] ?? ''),
(string) ($right['shop_name'] ?? ''),
]);
}
$summary = [
'count' => count($rows),
'balance' => round(array_sum(array_map(
static fn (array $row): float => (float) ($row['shop_balance'] ?? 0),
$rows,
)), 2),
];
$perPage = 100;
$currentPage = Paginator::resolveCurrentPage('shops_page');
$items = array_map(
static fn (array $row): object => (object) $row,
array_slice($rows, ($currentPage - 1) * $perPage, $perPage),
);
return [
'rows' => (new LengthAwarePaginator(
$items,
count($rows),
$perPage,
$currentPage,
[
'path' => Paginator::resolveCurrentPath(),
'query' => request()->query(),
'pageName' => 'shops_page',
],
))->withQueryString(),
'summary' => $summary,
];
}
/** @return array{rows:LengthAwarePaginator,summary:array{count:int,balance:float}} */
private function shopsFromLedgerTable(): array
{
$query = $this->db()->table('fin_shops');
foreach (['shops_q' => ['shop_name', 'platform', 'company_name'], 'shops_platform' => ['platform'], 'shops_company' => ['company_name']] as $param => $columns) {
@ -717,8 +809,8 @@ class FinanceLedgerPageData
private function shopHeaderColumns(): array
{
return [
'shop_name' => ['sort' => 'shop_name', 'type' => 'text'],
'platform' => ['sort' => 'platform', 'type' => 'text'],
'shop_name' => ['sort' => 'shop_name', 'type' => 'text'],
'company_name' => ['sort' => 'company_name', 'type' => 'text'],
'account_short' => ['sort' => 'account_short', 'type' => 'text'],
'status' => ['sort' => 'status', 'type' => 'text'],

View File

@ -0,0 +1,86 @@
<?php
namespace Modules\EcommerceFinance\View;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Modules\EcommerceFinance\Repositories\DingProcessDetailMirrorRepository;
use Throwable;
class ProcessDetailsPageData
{
public function __construct(
private readonly DingProcessDetailMirrorRepository $repository,
) {}
/** @return array<string,mixed> */
public function page(Request $request): array
{
$filters = $this->filters($request);
$page = max((int) $request->query('page', 1), 1);
$perPage = 50;
try {
$result = $this->repository->paginate($filters, $page, $perPage);
$options = $this->repository->filterOptions();
return [
'processRows' => new LengthAwarePaginator(
$result['data'],
$result['total'],
$perPage,
$page,
['path' => $request->url(), 'query' => $request->except('page')],
),
'filters' => $filters,
'summary' => $result['summary'],
'documentTypes' => $options['document_types'],
'statuses' => $options['statuses'],
'mirrorStatus' => $result['status'],
'mirrorSyncedAt' => $result['last_synced_at'],
'scope' => $result['scope'],
'error' => null,
];
} catch (Throwable $exception) {
report($exception);
return [
'processRows' => new LengthAwarePaginator([], 0, $perPage, $page, [
'path' => $request->url(),
'query' => $request->except('page'),
]),
'filters' => $filters,
'summary' => [
'rows' => 0,
'approvals' => 0,
'amount_total' => 0.0,
'bank_amount_total' => 0.0,
],
'documentTypes' => [],
'statuses' => [],
'mirrorStatus' => 'unavailable',
'mirrorSyncedAt' => null,
'scope' => $this->repository->scope(),
'error' => '流程明细镜像尚未完成导入,请稍后重试。',
];
}
}
/** @return array<string,string> */
private function filters(Request $request): array
{
$paidDate = trim((string) $request->query('paid_date', ''));
$status = trim((string) $request->query('status', ''));
$paidDateValid = preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $paidDate, $dateParts) === 1
&& checkdate((int) $dateParts[2], (int) $dateParts[3], (int) $dateParts[1]);
return [
'paid_date' => $paidDateValid ? $paidDate : '',
'document_type' => mb_substr(trim((string) $request->query('document_type', '')), 0, 100),
'status' => mb_substr($status, 0, 20),
'business_id' => mb_substr(trim((string) $request->query('business_id', '')), 0, 32),
'originator_name' => mb_substr(trim((string) $request->query('originator_name', '')), 0, 100),
'keyword' => mb_substr(trim((string) $request->query('keyword', '')), 0, 100),
];
}
}

View File

@ -104,9 +104,9 @@
['owner', '责任人', 'text'],
],
'shops' => [
['shop_name', '店铺名称', 'text'],
['platform', '平台', 'text'],
['company_name', '所属公司', 'text'],
['shop_name', 'ERP系统店铺名称', 'text'],
['company_name', '店铺主体', 'text'],
['account_short', '账户简称', 'text'],
['status', '店铺状态', 'text'],
['payout_account', '回款账户', 'text'],
@ -742,7 +742,7 @@
])
@endforeach
</tr></thead>
<tbody>@forelse ($ledgerShops as $row)<tr><td>{{ $row->shop_name }}</td><td>{{ $row->platform }}</td><td>{{ $row->company_name }}</td><td>{{ $row->account_short }}</td><td><span class="{{ $row->status === '在营' ? 'success' : 'muted' }}">{{ $row->status }}</span></td><td>{{ $row->payout_account }}</td><td class="num" @if ($row->shop_balance_date ?? null) title="余额日期:{{ $row->shop_balance_date }}" @endif>{{ $money($row->shop_balance) }}</td><td>{{ $row->remark }}</td></tr>@empty<tr><td colspan="8"><div class="ledger-empty">没有匹配的店铺数据。</div></td></tr>@endforelse</tbody>
<tbody>@forelse ($ledgerShops as $row)<tr><td>{{ $row->platform }}</td><td>{{ $row->shop_name }}</td><td>{{ $row->company_name }}</td><td>{{ $row->account_short }}</td><td><span class="{{ $row->status === '在营' ? 'success' : 'muted' }}">{{ $row->status }}</span></td><td>{{ $row->payout_account }}</td><td class="num" @if ($row->shop_balance_date ?? null) title="余额日期:{{ $row->shop_balance_date }}" @endif>{{ $money($row->shop_balance) }}</td><td>{{ $row->remark }}</td></tr>@empty<tr><td colspan="8"><div class="ledger-empty">没有匹配的店铺数据。</div></td></tr>@endforelse</tbody>
</table>
@include('business.pages.financial-ledger.partials.pagination', [
'rows' => $ledgerShops,

View File

@ -377,7 +377,7 @@
<div class="labor-expense-head">
<div>
<strong>人工费用测算表</strong>
<p>表头与公式依据 {{ $laborExpenseTable['source_label'] ?? '工资表' }}。黄色字段用于录入,浅金列按公式实时计算;月度、年度税率及速算扣除数按对应应纳税所得额匹配税法档位,公式中的 # 表示当前行。</p>
<p>表头与公式依据 {{ $laborExpenseTable['source_label'] ?? '工资表' }}。黄色字段用于录入,浅金列按公式实时计算;月度基本减除费用为 5000 元、年度汇算为 60000 元,个税金额、税率、速算扣除数及公积金缴存基数均按对应规则自动匹配,公式中的 # 表示当前行。</p>
</div>
<span class="labor-expense-badge">{{ count($laborFields) }} 个业务列 · {{ $laborFormulaCount }} 个公式</span>
</div>
@ -526,6 +526,14 @@
return { rate: 0.45, deduction: 181920 };
};
const housingFundBase = (salary) => {
if (salary <= 0) return null;
if (salary <= 8500) return 4952;
if (salary <= 15000) return 8000;
if (salary <= 25000) return 10000;
return 12000;
};
const calculate = (row) => {
const hasNumericInput = fields.some((field) => {
if (!numericKinds.has(field.kind)) return false;
@ -539,9 +547,16 @@
}
const v = (key) => numeric(row[key]);
const originalTaxable = v('F') - v('G') - v('H') - v('I');
const originalAnnualTax = v('M') * 12;
const newMonthlyTaxable = v('F') - v('G') - v('I') - v('P') - v('R');
const monthlyBasicDeduction = 5000;
const originalTaxable = v('F') - v('G') - v('H') - monthlyBasicDeduction;
const newHousingFundBase = housingFundBase(v('F'));
const newEmployerHousingFund = newHousingFundBase === null ? null : newHousingFundBase * 0.12;
const newPersonalHousingFund = newHousingFundBase === null ? null : newHousingFundBase * 0.12;
const excessHousingFundWithholding = newPersonalHousingFund === null
? null
: newPersonalHousingFund - v('H');
const newMonthlyTaxable = v('F') - v('G') - monthlyBasicDeduction
- numeric(newEmployerHousingFund) - numeric(excessHousingFundWithholding);
const newAnnualTaxable = newMonthlyTaxable * 12;
const newAnnualBracket = annualBracket(newAnnualTaxable);
const originalRate = newMonthlyTaxable === 0 ? null : newAnnualBracket.rate;
@ -550,10 +565,21 @@
? null
: newAnnualTaxable * originalRate - originalDeduction;
const originalMonthlyBracket = monthlyWageBracket(originalTaxable);
const originalMonthlyTax = originalMonthlyBracket === null
? null
: originalTaxable * originalMonthlyBracket.rate - originalMonthlyBracket.deduction;
const originalAnnualTax = originalMonthlyTax === null ? null : originalMonthlyTax * 12;
const parttimeSalary = v('AB') + v('AC');
const newSalary = v('F') - parttimeSalary;
const salaryTaxable = newSalary - v('G') - v('I') - v('P') - v('R');
const salaryTaxable = newSalary - v('G') - monthlyBasicDeduction
- numeric(newEmployerHousingFund) - numeric(excessHousingFundWithholding);
const newMonthlyBracket = monthlyWageBracket(newMonthlyTaxable);
const newMonthlyTax = newMonthlyBracket === null
? null
: newMonthlyTaxable * newMonthlyBracket.rate - newMonthlyBracket.deduction;
const taxableRange = newMonthlyBracket === null || newMonthlyBracket.rate <= 0.03
? 0
: (newMonthlyBracket.rate <= 0.1 ? 3000 : 12000);
const salaryMonthlyBracket = monthlyWageBracket(salaryTaxable);
const salaryAnnualTaxable = salaryTaxable * 12;
const salaryBracket = annualBracket(salaryAnnualTaxable);
@ -580,9 +606,11 @@
const salaryIncome = newSalary * 12;
const parttimeIncome = monthlyParttime * 12 * 0.8;
const totalIncome = salaryIncome + parttimeIncome;
const basicDeduction = 60000;
const socialFundDeduction = (v('G') + v('P') + v('R')) * 12;
const settlementTaxable = totalIncome - basicDeduction - socialFundDeduction;
const annualBasicDeduction = 60000;
const socialFundDeduction = (
v('G') + numeric(newEmployerHousingFund) + numeric(excessHousingFundWithholding)
) * 12;
const settlementTaxable = totalIncome - annualBasicDeduction - socialFundDeduction;
const settlementBracket = annualBracket(settlementTaxable);
const settlementRate = settlementTaxable <= 0 ? null : settlementBracket.rate;
const settlementDeduction = settlementTaxable <= 0 ? null : settlementBracket.deduction;
@ -600,9 +628,17 @@
: originalAnnualTaxAmount - settlementTax;
Object.assign(result, {
I: monthlyBasicDeduction,
J: originalTaxable,
M: originalMonthlyTax,
N: originalAnnualTax,
O: newHousingFundBase,
P: newEmployerHousingFund,
Q: newPersonalHousingFund,
R: excessHousingFundWithholding,
S: newMonthlyTaxable,
V: newMonthlyTax,
AA: taxableRange,
W: newAnnualTaxable,
X: originalRate,
Y: originalDeduction,
@ -631,7 +667,7 @@
AW: salaryIncome,
AX: parttimeIncome,
AY: totalIncome,
AZ: basicDeduction,
AZ: annualBasicDeduction,
BA: socialFundDeduction,
BB: settlementTaxable,
BC: settlementRate,

View File

@ -0,0 +1,688 @@
<style>
.process-details-page {
display: flex;
flex-direction: column;
gap: 1rem;
color: var(--vip-content-ink, #171717);
font-size: .8125rem;
}
.process-details-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .4rem 1.25rem;
padding: .65rem 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .75rem;
background: #faf7f1;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
line-height: 1.6;
}
.process-details-meta span {
display: inline-flex;
align-items: center;
gap: .25rem;
}
.process-details-meta strong {
color: var(--vip-content-ink, #171717);
font-weight: 600;
}
.process-details-toolbar {
display: grid;
grid-template-columns: repeat(12, minmax(0, 1fr));
align-items: flex-end;
gap: .8rem 1rem;
padding: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .75rem;
background: var(--vip-surface, #fff);
}
.process-details-field {
display: flex;
flex-direction: column;
gap: .35rem;
min-width: 0;
grid-column: span 2;
}
.process-details-field.is-wide {
grid-column: span 3;
}
.process-details-field.is-keyword {
grid-column: span 8;
}
.process-details-field label {
color: var(--vip-content-muted, #595959);
font-size: .75rem;
font-weight: 600;
}
.process-details-field input,
.process-details-field select {
width: 100%;
height: 2.125rem;
padding: 0 .65rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
font-size: .8125rem;
}
.process-details-field input:focus,
.process-details-field select:focus {
border-color: var(--vip-content-accent-dark, #856632);
outline: none;
box-shadow: 0 0 0 3px rgba(133, 102, 50, .2);
}
.process-details-actions {
display: flex;
flex-wrap: wrap;
gap: .5rem;
grid-column: span 4;
align-self: end;
justify-content: flex-end;
}
.process-details-button {
display: inline-flex;
align-items: center;
gap: .35rem;
height: 2.125rem;
padding: 0 .85rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
font-weight: 600;
text-decoration: none;
cursor: pointer;
}
.process-details-button:hover {
border-color: var(--vip-content-accent, #B9954F);
color: var(--vip-content-accent-dark, #856632);
text-decoration: none;
}
.process-details-button.is-primary {
border-color: var(--vip-content-accent-dark, #856632);
background: var(--vip-content-accent-dark, #856632);
color: #fff;
}
.process-details-button.is-primary:hover {
background: #6A5129;
color: #fff;
}
.process-details-alert {
padding: .75rem 1rem;
margin-bottom: 1rem;
border: 1px solid var(--vip-danger, #B80000);
border-radius: .5rem;
background: #fff5f5;
color: var(--vip-danger, #B80000);
}
.process-details-summary {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
overflow: hidden;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .75rem;
background: var(--vip-content-accent-soft, #F7F0DE);
}
.process-details-summary .item {
display: flex;
flex-direction: column;
gap: .2rem;
min-width: 0;
padding: .8rem 1rem;
border-right: 1px solid rgba(185, 149, 79, .24);
}
.process-details-summary .item:last-child {
border-right: 0;
}
.process-details-summary .item span {
color: var(--vip-content-muted, #595959);
font-size: .72rem;
}
.process-details-summary .item b {
color: var(--vip-content-ink, #171717);
font-size: 1rem;
font-variant-numeric: tabular-nums;
}
.process-details-note {
margin: -.2rem .25rem 0;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
line-height: 1.6;
}
.process-details-table-card {
overflow: hidden;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .75rem;
background: #fff;
}
.process-details-table-wrap {
overflow: auto;
max-height: min(68vh, 46rem);
background: #fff;
}
.process-details-table {
width: 100%;
min-width: 112rem;
border-collapse: separate;
border-spacing: 0;
font-size: .78rem;
}
.process-details-table th,
.process-details-table td {
padding: .55rem .65rem;
border-right: 1px solid var(--vip-border, #D8D2C7);
border-bottom: 1px solid var(--vip-border, #D8D2C7);
white-space: nowrap;
vertical-align: middle;
}
.process-details-table th {
position: sticky;
top: 0;
z-index: 2;
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-ink, #171717);
font-size: .75rem;
font-weight: 700;
text-align: left;
}
.process-details-table th:first-child,
.process-details-table td:first-child {
position: sticky;
left: 0;
}
.process-details-table th:first-child {
z-index: 4;
}
.process-details-table td:first-child {
z-index: 1;
background: #fff;
}
.process-details-table tr:hover td {
background: #fcfaf4;
}
.process-details-table tr:hover td:first-child {
background: #fcfaf4;
}
.process-details-table .num {
text-align: right;
font-variant-numeric: tabular-nums;
}
.process-details-table .center {
text-align: center;
}
.process-details-table .wide {
max-width: 18rem;
overflow: hidden;
text-overflow: ellipsis;
}
.process-details-table .wide:hover {
overflow: visible;
white-space: normal;
word-break: break-all;
}
.process-details-status {
display: inline-flex;
align-items: center;
padding: .15rem .5rem;
border-radius: 999px;
font-size: .7rem;
font-weight: 600;
}
.process-details-status.is-success {
background: rgba(83, 121, 62, .12);
color: var(--vip-success, #53793E);
}
.process-details-status.is-warning {
background: rgba(147, 95, 7, .12);
color: var(--vip-warning, #935F07);
}
.process-details-status.is-danger {
background: rgba(184, 0, 0, .09);
color: var(--vip-danger, #B80000);
}
.process-details-status.is-neutral {
background: #f1f1f1;
color: var(--vip-content-muted, #595959);
}
.process-details-empty {
padding: 4rem 1rem;
text-align: center;
color: var(--vip-content-muted, #595959);
white-space: normal;
}
.process-details-footer {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: .6rem 1rem;
min-height: 3.25rem;
padding: .65rem 1rem;
border-top: 1px solid var(--vip-border, #D8D2C7);
background: #fffdf8;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
}
.process-details-footer__summary {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .35rem 1rem;
}
.process-details-footer__summary b {
color: var(--vip-content-ink, #171717);
font-variant-numeric: tabular-nums;
}
.process-details-pagination {
display: inline-flex;
align-items: center;
gap: .3rem;
margin: 0;
}
.process-details-page-link,
.process-details-page-current,
.process-details-page-link.is-disabled {
display: inline-flex;
width: 2rem;
height: 2rem;
align-items: center;
justify-content: center;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .45rem;
background: #fff;
color: var(--vip-content-accent-dark, #856632);
text-decoration: none;
}
.process-details-page-link:hover {
border-color: var(--vip-content-accent, #B9954F);
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-accent-dark, #856632);
text-decoration: none;
}
.process-details-page-link.is-disabled {
border-color: #ece7dc;
background: #faf9f6;
color: #c0b9ad;
cursor: not-allowed;
}
.process-details-page-link .material-icons-outlined {
font-size: 1.05rem;
}
.process-details-page-current {
width: auto;
min-width: 4.5rem;
padding: 0 .6rem;
border-color: var(--vip-content-accent-dark, #856632);
background: var(--vip-content-accent-dark, #856632);
color: #fff;
font-variant-numeric: tabular-nums;
}
.process-details-page-jump {
display: inline-flex;
align-items: center;
gap: .35rem;
margin-left: .25rem;
}
.process-details-page-jump input {
width: 4.25rem;
height: 2rem;
padding: 0 .45rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .45rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
font-size: .75rem;
text-align: center;
}
.process-details-page-jump button {
height: 2rem;
padding: 0 .65rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .45rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
font-size: .75rem;
cursor: pointer;
}
.process-details-page-jump button:hover {
border-color: var(--vip-content-accent, #B9954F);
color: var(--vip-content-accent-dark, #856632);
}
@media (max-width: 900px) {
.process-details-toolbar {
grid-template-columns: repeat(6, minmax(0, 1fr));
}
.process-details-field {
grid-column: span 2;
}
.process-details-field.is-wide {
grid-column: span 3;
}
.process-details-field.is-keyword,
.process-details-actions {
grid-column: span 6;
}
.process-details-actions {
justify-content: flex-start;
}
.process-details-summary {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.process-details-summary .item:nth-child(2) {
border-right: 0;
}
.process-details-summary .item:nth-child(-n+2) {
border-bottom: 1px solid rgba(185, 149, 79, .24);
}
.process-details-footer {
align-items: flex-start;
}
}
@media (max-width: 640px) {
.process-details-toolbar {
grid-template-columns: 1fr;
}
.process-details-field,
.process-details-field.is-wide,
.process-details-field.is-keyword,
.process-details-actions {
grid-column: 1;
}
.process-details-actions .process-details-button {
flex: 1 1 auto;
justify-content: center;
}
.process-details-summary {
grid-template-columns: 1fr;
}
.process-details-summary .item {
border-right: 0;
border-bottom: 1px solid rgba(185, 149, 79, .24);
}
.process-details-summary .item:last-child {
border-bottom: 0;
}
.process-details-footer,
.process-details-pagination,
.process-details-page-jump {
width: 100%;
}
.process-details-pagination {
flex-wrap: wrap;
}
.process-details-page-jump {
margin-left: 0;
}
}
</style>
<div class="process-details-page">
<div class="process-details-meta">
<span>数据范围:<strong>{{ $scopeLabel }}</strong></span>
<span>镜像状态:<strong>{{ $mirrorStatus ?? 'unknown' }}</strong></span>
@if (! empty($mirrorSyncedAt))
<span>最近同步:<strong>{{ $mirrorSyncedAt }}</strong></span>
@endif
</div>
@if ($error)
<div class="process-details-alert" role="alert">{{ $error }}</div>
@endif
<form method="GET" action="{{ $pageUrl }}" class="process-details-toolbar" aria-label="流程明细筛选">
<div class="process-details-field">
<label for="process-details-paid-date">打款日期</label>
<input id="process-details-paid-date" type="date" name="paid_date" value="{{ $filters['paid_date'] ?? '' }}">
</div>
<div class="process-details-field">
<label for="process-details-type">单据类型</label>
<select id="process-details-type" name="document_type">
<option value="">全部类型</option>
@foreach ($documentTypes as $option)
<option value="{{ $option }}" @selected(($filters['document_type'] ?? '') === $option)>{{ $option }}</option>
@endforeach
</select>
</div>
<div class="process-details-field">
<label for="process-details-status">状态</label>
<select id="process-details-status" name="status">
<option value="">全部状态</option>
@foreach ($statuses as $option)
<option value="{{ $option }}" @selected(($filters['status'] ?? '') === $option)>{{ $option }}</option>
@endforeach
</select>
</div>
<div class="process-details-field is-wide">
<label for="process-details-business-id">审批编号</label>
<input id="process-details-business-id" type="search" name="business_id" value="{{ $filters['business_id'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-field">
<label for="process-details-originator">发起人</label>
<input id="process-details-originator" type="search" name="originator_name" value="{{ $filters['originator_name'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-field is-keyword">
<label for="process-details-keyword">用途/摘要</label>
<input id="process-details-keyword" type="search" name="keyword" value="{{ $filters['keyword'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-actions">
<button class="process-details-button is-primary" type="submit">
<span class="material-icons-outlined" aria-hidden="true">search</span>查询
</button>
<a class="process-details-button" href="{{ $pageUrl }}">
<span class="material-icons-outlined" aria-hidden="true">refresh</span>重置
</a>
<a class="process-details-button" href="{{ $exportUrl }}" title="导出当前筛选结果(CSV,包含全部匹配行)">
<span class="material-icons-outlined" aria-hidden="true">download</span>导出
</a>
</div>
</form>
<div class="process-details-summary">
<div class="item"><span>明细行数</span><b>{{ number_format((int) ($summary['rows'] ?? 0)) }}</b></div>
<div class="item"><span>审批单数</span><b>{{ number_format((int) ($summary['approvals'] ?? 0)) }}</b></div>
<div class="item"><span>金额合计</span><b>{{ $money($summary['amount_total'] ?? null) }}</b></div>
<div class="item"><span>银行付款合计</span><b>{{ $money($summary['bank_amount_total'] ?? null) }}</b></div>
</div>
<p class="process-details-note">
当前展示的是当前账号权限范围内可读取的钉钉审批流程明细;审批中的金额和行项目仍可能随流程变化。
企业级全量数据待领导开通 OA 权限后切换。
</p>
<div class="process-details-table-card">
<div class="process-details-table-wrap">
<table class="process-details-table">
<thead>
<tr>
<th>序号</th>
<th>审批编号</th>
<th>发起人</th>
<th>状态</th>
<th>单据类型</th>
<th>用途/摘要</th>
<th class="center">单据内行号</th>
<th>科目编码</th>
<th>科目名称</th>
<th class="num">金额(元)</th>
<th>银行科目编码</th>
<th>银行科目名称</th>
<th class="num">银行付款金额</th>
<th>付款方式</th>
<th>打款时间</th>
</tr>
</thead>
<tbody>
@forelse ($processRows as $row)
<tr>
<td class="num">{{ ($processRows->currentPage() - 1) * $processRows->perPage() + $loop->iteration }}</td>
<td>{{ $row->business_id }}</td>
<td>{{ $text($row->originator_name) }}</td>
<td class="center">
<span class="process-details-status {{ $statusClass((string) $row->status) }}">{{ $text($row->status) }}</span>
</td>
<td>{{ $text($row->document_type) }}</td>
<td class="wide" title="{{ $row->purpose }}">{{ $text($row->purpose) }}</td>
<td class="center">{{ $row->line_no }}</td>
<td>{{ $text($row->account_code) }}</td>
<td class="wide" title="{{ $row->account_name }}">{{ $text($row->account_name) }}</td>
<td class="num">{{ $money($row->amount) }}</td>
<td>{{ $text($row->bank_account_code) }}</td>
<td class="wide" title="{{ $row->bank_account_name }}">{{ $text($row->bank_account_name) }}</td>
<td class="num">{{ $money($row->bank_amount) }}</td>
<td>{{ $text($row->payment_method) }}</td>
<td>{{ $text($row->paid_at) }}</td>
</tr>
@empty
<tr>
<td colspan="15" class="process-details-empty">
当前筛选条件没有流程明细。可以调整月份、单据类型、状态或关键词后重试。
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@php
$processDetailsLastPage = max($processRows->lastPage(), 1);
$processDetailsCurrentPage = min(max($processRows->currentPage(), 1), $processDetailsLastPage);
@endphp
<footer class="process-details-footer">
<div class="process-details-footer__summary">
<span>共 <b>{{ number_format($processRows->total()) }}</b> 行</span>
<span>第 <b>{{ number_format($processDetailsCurrentPage) }}</b> / {{ number_format($processDetailsLastPage) }} 页</span>
<span>本页 <b>{{ number_format($processRows->count()) }}</b> 行</span>
</div>
<nav class="process-details-pagination" aria-label="流程明细分页">
@if ($processRows->onFirstPage())
<span class="process-details-page-link is-disabled" aria-disabled="true" title="首页">
<span class="material-icons-outlined" aria-hidden="true">first_page</span>
</span>
<span class="process-details-page-link is-disabled" aria-disabled="true" title="上一页">
<span class="material-icons-outlined" aria-hidden="true">chevron_left</span>
</span>
@else
<a class="process-details-page-link" href="{{ $processRows->url(1) }}" title="首页" aria-label="首页">
<span class="material-icons-outlined" aria-hidden="true">first_page</span>
</a>
<a class="process-details-page-link" href="{{ $processRows->previousPageUrl() }}" title="上一页" aria-label="上一页">
<span class="material-icons-outlined" aria-hidden="true">chevron_left</span>
</a>
@endif
<span class="process-details-page-current" aria-current="page">
{{ number_format($processDetailsCurrentPage) }} / {{ number_format($processDetailsLastPage) }}
</span>
@if ($processRows->hasMorePages())
<a class="process-details-page-link" href="{{ $processRows->nextPageUrl() }}" title="下一页" aria-label="下一页">
<span class="material-icons-outlined" aria-hidden="true">chevron_right</span>
</a>
<a class="process-details-page-link" href="{{ $processRows->url($processDetailsLastPage) }}" title="末页" aria-label="末页">
<span class="material-icons-outlined" aria-hidden="true">last_page</span>
</a>
@else
<span class="process-details-page-link is-disabled" aria-disabled="true" title="下一页">
<span class="material-icons-outlined" aria-hidden="true">chevron_right</span>
</span>
<span class="process-details-page-link is-disabled" aria-disabled="true" title="末页">
<span class="material-icons-outlined" aria-hidden="true">last_page</span>
</span>
@endif
@if ($processDetailsLastPage > 1)
<form class="process-details-page-jump" method="GET" action="{{ $pageUrl }}">
@foreach ($filters as $filterName => $filterValue)
@if ($filterValue !== '')
<input type="hidden" name="{{ $filterName }}" value="{{ $filterValue }}">
@endif
@endforeach
<label for="process-details-page">跳到</label>
<input id="process-details-page" type="number" name="page" min="1" max="{{ $processDetailsLastPage }}" value="{{ $processDetailsCurrentPage }}" inputmode="numeric" aria-label="跳到第几页">
<button type="submit">确定</button>
</form>
@endif
</nav>
</footer>
</div>
</div>

View File

@ -1,8 +1,19 @@
@php
$rows = $rows ?? null;
$processRows = $processRows ?? null;
if (! $processRows instanceof \Illuminate\Contracts\Pagination\LengthAwarePaginator) {
$pageData = app(\Modules\EcommerceFinance\View\ProcessDetailsPageData::class)->page(request());
$processRows = $pageData['processRows'];
$filters = $pageData['filters'];
$summary = $pageData['summary'];
$documentTypes = $pageData['documentTypes'];
$statuses = $pageData['statuses'];
$mirrorStatus = $pageData['mirrorStatus'];
$mirrorSyncedAt = $pageData['mirrorSyncedAt'];
$scope = $pageData['scope'];
$error = $pageData['error'];
}
$filters = $filters ?? [];
$summary = $summary ?? [];
$months = $months ?? [];
$documentTypes = $documentTypes ?? [];
$statuses = $statuses ?? [];
$error = $error ?? null;
@ -24,429 +35,32 @@
'section' => 'financial-operations',
'page' => 'process-details',
]);
$exportUrl = route('business.process-details.export', array_filter(
$exportFilters = array_filter(
$filters,
static fn (mixed $value): bool => $value !== '' && $value !== null,
));
);
$exportUrl = url('/' . company_id() . '/workspace/financial-operations/process-details/export');
if ($exportFilters !== []) {
$exportUrl .= '?' . http_build_query($exportFilters);
}
@endphp
<x-layouts.admin>
<x-slot name="title">
流程明细
</x-slot>
<x-slot name="content">
<style>
.process-details-page {
color: var(--vip-content-ink, #171717);
font-size: .8125rem;
}
@php
$processDetailsRouteAction = (string) request()->route()?->getActionName();
$processDetailsEmbedded = ! str_contains($processDetailsRouteAction, 'ProcessDetails@show');
@endphp
.process-details-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .4rem .9rem;
margin-bottom: .85rem;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
line-height: 1.6;
}
@if ($processDetailsEmbedded)
@include('business.pages.financial-operations.process-details-content')
@else
<x-layouts.admin>
<x-slot name="title">
流程明细
</x-slot>
.process-details-meta strong {
color: var(--vip-content-ink, #171717);
font-weight: 600;
}
.process-details-toolbar {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: .75rem;
padding: 1rem;
margin-bottom: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: var(--vip-surface, #fff);
}
.process-details-field {
display: flex;
flex-direction: column;
gap: .35rem;
min-width: 10.5rem;
}
.process-details-field.is-wide {
min-width: 13.5rem;
}
.process-details-field label {
color: var(--vip-content-muted, #595959);
font-size: .75rem;
font-weight: 600;
}
.process-details-field input,
.process-details-field select {
height: 2.25rem;
padding: 0 .65rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
}
.process-details-field input:focus,
.process-details-field select:focus {
border-color: var(--vip-content-accent-dark, #856632);
outline: none;
box-shadow: 0 0 0 3px rgba(133, 102, 50, .2);
}
.process-details-actions {
display: flex;
flex-wrap: wrap;
gap: .5rem;
}
.process-details-button {
display: inline-flex;
align-items: center;
gap: .35rem;
height: 2.25rem;
padding: 0 .85rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
color: var(--vip-content-ink, #171717);
font: inherit;
font-weight: 600;
text-decoration: none;
cursor: pointer;
}
.process-details-button:hover {
border-color: var(--vip-content-accent, #B9954F);
color: var(--vip-content-accent-dark, #856632);
text-decoration: none;
}
.process-details-button.is-primary {
border-color: var(--vip-content-accent-dark, #856632);
background: var(--vip-content-accent-dark, #856632);
color: #fff;
}
.process-details-button.is-primary:hover {
background: #6A5129;
color: #fff;
}
.process-details-alert {
padding: .75rem 1rem;
margin-bottom: 1rem;
border: 1px solid var(--vip-danger, #B80000);
border-radius: .5rem;
background: #fff5f5;
color: var(--vip-danger, #B80000);
}
.process-details-summary {
display: flex;
flex-wrap: wrap;
gap: 1rem 2rem;
padding: .8rem 1rem;
margin-bottom: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: var(--vip-content-accent-soft, #F7F0DE);
}
.process-details-summary .item {
display: flex;
flex-direction: column;
gap: .15rem;
}
.process-details-summary .item span {
color: var(--vip-content-muted, #595959);
font-size: .7rem;
}
.process-details-summary .item b {
font-size: .95rem;
font-variant-numeric: tabular-nums;
}
.process-details-note {
margin-bottom: .75rem;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
line-height: 1.6;
}
.process-details-table-wrap {
overflow: auto;
max-height: min(68vh, 46rem);
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: .5rem;
background: #fff;
}
.process-details-table {
width: 100%;
min-width: 112rem;
border-collapse: separate;
border-spacing: 0;
font-size: .78rem;
}
.process-details-table th,
.process-details-table td {
padding: .55rem .65rem;
border-right: 1px solid var(--vip-border, #D8D2C7);
border-bottom: 1px solid var(--vip-border, #D8D2C7);
white-space: nowrap;
vertical-align: middle;
}
.process-details-table th {
position: sticky;
top: 0;
z-index: 2;
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-ink, #171717);
font-size: .75rem;
font-weight: 700;
text-align: left;
}
.process-details-table tr:hover td {
background: #fcfaf4;
}
.process-details-table .num {
text-align: right;
font-variant-numeric: tabular-nums;
}
.process-details-table .center {
text-align: center;
}
.process-details-table .wide {
max-width: 18rem;
overflow: hidden;
text-overflow: ellipsis;
}
.process-details-table .wide:hover {
overflow: visible;
white-space: normal;
word-break: break-all;
}
.process-details-status {
display: inline-flex;
align-items: center;
padding: .15rem .5rem;
border-radius: 999px;
font-size: .7rem;
font-weight: 600;
}
.process-details-status.is-success {
background: rgba(83, 121, 62, .12);
color: var(--vip-success, #53793E);
}
.process-details-status.is-warning {
background: rgba(147, 95, 7, .12);
color: var(--vip-warning, #935F07);
}
.process-details-status.is-danger {
background: rgba(184, 0, 0, .09);
color: var(--vip-danger, #B80000);
}
.process-details-status.is-neutral {
background: #f1f1f1;
color: var(--vip-content-muted, #595959);
}
.process-details-empty {
padding: 4rem 1rem;
text-align: center;
color: var(--vip-content-muted, #595959);
white-space: normal;
}
.process-details-footer {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: .75rem;
padding: .8rem 1rem;
color: var(--vip-content-muted, #595959);
font-size: .75rem;
}
.process-details-footer .pagination {
margin: 0;
}
@media (max-width: 900px) {
.process-details-toolbar {
align-items: stretch;
}
.process-details-field,
.process-details-field.is-wide {
min-width: 100%;
}
.process-details-actions {
width: 100%;
}
}
</style>
<div class="process-details-page">
<div class="process-details-meta">
<span>数据范围:<strong>{{ $scopeLabel }}</strong></span>
<span>镜像状态:<strong>{{ $mirrorStatus ?? 'unknown' }}</strong></span>
@if (! empty($mirrorSyncedAt))
<span>最近同步:<strong>{{ $mirrorSyncedAt }}</strong></span>
@endif
</div>
@if ($error)
<div class="process-details-alert" role="alert">{{ $error }}</div>
@endif
<form method="GET" action="{{ $pageUrl }}" class="process-details-toolbar" aria-label="流程明细筛选">
<div class="process-details-field">
<label for="process-details-month">月份</label>
<input id="process-details-month" type="month" name="month" value="{{ $filters['month'] ?? '' }}">
</div>
<div class="process-details-field">
<label for="process-details-type">单据类型</label>
<select id="process-details-type" name="document_type">
<option value="">全部类型</option>
@foreach ($documentTypes as $option)
<option value="{{ $option }}" @selected(($filters['document_type'] ?? '') === $option)>{{ $option }}</option>
@endforeach
</select>
</div>
<div class="process-details-field">
<label for="process-details-status">状态</label>
<select id="process-details-status" name="status">
<option value="">全部状态</option>
@foreach ($statuses as $option)
<option value="{{ $option }}" @selected(($filters['status'] ?? '') === $option)>{{ $option }}</option>
@endforeach
</select>
</div>
<div class="process-details-field is-wide">
<label for="process-details-business-id">审批编号</label>
<input id="process-details-business-id" type="search" name="business_id" value="{{ $filters['business_id'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-field">
<label for="process-details-originator">发起人</label>
<input id="process-details-originator" type="search" name="originator_name" value="{{ $filters['originator_name'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-field is-wide">
<label for="process-details-keyword">用途/摘要</label>
<input id="process-details-keyword" type="search" name="keyword" value="{{ $filters['keyword'] ?? '' }}" placeholder="支持包含查询">
</div>
<div class="process-details-actions">
<button class="process-details-button is-primary" type="submit">
<span class="material-icons-outlined" aria-hidden="true">search</span>查询
</button>
<a class="process-details-button" href="{{ $pageUrl }}">
<span class="material-icons-outlined" aria-hidden="true">refresh</span>重置
</a>
<a class="process-details-button" href="{{ $exportUrl }}" title="导出当前筛选结果(CSV,包含全部匹配行)">
<span class="material-icons-outlined" aria-hidden="true">download</span>导出
</a>
</div>
</form>
<div class="process-details-summary">
<div class="item"><span>明细行数</span><b>{{ number_format((int) ($summary['rows'] ?? 0)) }}</b></div>
<div class="item"><span>审批单数</span><b>{{ number_format((int) ($summary['approvals'] ?? 0)) }}</b></div>
<div class="item"><span>金额合计</span><b>{{ $money($summary['amount_total'] ?? null) }}</b></div>
<div class="item"><span>银行付款合计</span><b>{{ $money($summary['bank_amount_total'] ?? null) }}</b></div>
</div>
<p class="process-details-note">
当前展示的是当前账号权限范围内可读取的钉钉审批流程明细;审批中的金额和行项目仍可能随流程变化。
企业级全量数据待领导开通 OA 权限后切换。
</p>
<div class="process-details-table-wrap">
<table class="process-details-table">
<thead>
<tr>
<th>序号</th>
<th>审批编号</th>
<th>发起人</th>
<th>状态</th>
<th>单据类型</th>
<th>用途/摘要</th>
<th class="center">单据内行号</th>
<th>科目编码</th>
<th>科目名称</th>
<th class="num">金额(元)</th>
<th>银行科目编码</th>
<th>银行科目名称</th>
<th class="num">银行付款金额</th>
<th>付款方式</th>
<th>打款时间</th>
</tr>
</thead>
<tbody>
@forelse ($rows as $row)
<tr>
<td class="num">{{ ($rows->currentPage() - 1) * $rows->perPage() + $loop->iteration }}</td>
<td>{{ $row->business_id }}</td>
<td>{{ $text($row->originator_name) }}</td>
<td class="center">
<span class="process-details-status {{ $statusClass((string) $row->status) }}">{{ $text($row->status) }}</span>
</td>
<td>{{ $text($row->document_type) }}</td>
<td class="wide" title="{{ $row->purpose }}">{{ $text($row->purpose) }}</td>
<td class="center">{{ $row->line_no }}</td>
<td>{{ $text($row->account_code) }}</td>
<td class="wide" title="{{ $row->account_name }}">{{ $text($row->account_name) }}</td>
<td class="num">{{ $money($row->amount) }}</td>
<td>{{ $text($row->bank_account_code) }}</td>
<td class="wide" title="{{ $row->bank_account_name }}">{{ $text($row->bank_account_name) }}</td>
<td class="num">{{ $money($row->bank_amount) }}</td>
<td>{{ $text($row->payment_method) }}</td>
<td>{{ $text($row->paid_at) }}</td>
</tr>
@empty
<tr>
<td colspan="15" class="process-details-empty">
当前筛选条件没有流程明细。可以调整月份、单据类型、状态或关键词后重试。
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="process-details-footer">
<span>
第 {{ $rows->currentPage() }} / {{ max($rows->lastPage(), 1) }} 页,共 {{ number_format($rows->total()) }} 行
</span>
<div>{{ $rows->links() }}</div>
</div>
</div>
</x-slot>
</x-layouts.admin>
<x-slot name="content">
@include('business.pages.financial-operations.process-details-content')
</x-slot>
</x-layouts.admin>
@endif

View File

@ -4,6 +4,9 @@
}
.installation-fee-card {
--installation-fee-accent: #856632;
--installation-fee-accent-soft: #f7f0de;
--installation-fee-accent-ring: rgba(133, 102, 50, 0.2);
position: relative;
display: flex;
width: 100%;
@ -13,7 +16,8 @@
box-sizing: border-box;
padding: 0.7rem 1rem 0 1.15rem;
border: 1px solid #d8d2c7;
border-left: 3px solid #006395;
border-right: 3px solid var(--installation-fee-accent);
border-left: 3px solid var(--installation-fee-accent);
border-radius: 0.75rem;
background: #ffffff;
color: #171717;
@ -150,7 +154,7 @@
border: 0;
border-radius: 0.3rem;
background: transparent;
color: #006395;
color: var(--installation-fee-accent);
cursor: pointer;
font: inherit;
font-size: 0.75rem;
@ -159,12 +163,12 @@
}
.installation-fee-card__detail-button:hover {
background: #eef6fa;
background: var(--installation-fee-accent-soft);
}
.installation-fee-card__detail-button:focus-visible {
background: #eef6fa;
box-shadow: 0 0 0 3px rgba(0, 99, 149, 0.16);
background: var(--installation-fee-accent-soft);
box-shadow: 0 0 0 3px var(--installation-fee-accent-ring);
outline: none;
}
@ -201,9 +205,12 @@
}
.installation-fee-dialog {
--installation-fee-table-cell-padding: 0.7rem 0.65rem;
--installation-fee-table-head-padding: 0.75rem 0.65rem;
width: min(68rem, calc(100vw - 2rem));
max-width: none;
max-height: calc(100vh - 2rem);
box-sizing: border-box;
padding: 0;
border: 1px solid #d8d2c7;
border-radius: 0.75rem;
@ -285,6 +292,47 @@
border-bottom: 1px solid #eee8dd;
}
.installation-fee-tabs {
display: flex;
align-items: stretch;
gap: 1.25rem;
overflow-x: auto;
padding: 0 1.1rem;
border-bottom: 1px solid #e8e0d2;
background: #ffffff;
overscroll-behavior-inline: contain;
scrollbar-width: thin;
white-space: nowrap;
}
.installation-fee-tab {
flex: 0 0 auto;
min-height: 2.75rem;
padding: 0 0.2rem;
border: 0;
border-bottom: 2px solid transparent;
background: transparent;
color: #595959;
cursor: pointer;
font: inherit;
font-size: 0.8125rem;
font-weight: 600;
}
.installation-fee-tab:hover {
color: #856632;
}
.installation-fee-tab[aria-selected="true"] {
border-bottom-color: #b9954f;
color: #856632;
}
.installation-fee-tab:focus-visible {
outline: 3px solid rgba(133, 102, 50, 0.2);
outline-offset: -3px;
}
.installation-fee-filter span {
display: block;
margin-bottom: 0.25rem;
@ -304,13 +352,49 @@
}
.installation-fee-dialog__scroll {
min-height: 12rem;
flex: 1 1 auto;
min-height: 0;
box-sizing: border-box;
overflow: auto;
padding: 0 1.1rem;
padding: 0 1.1rem 0.65rem;
overscroll-behavior: contain;
scrollbar-color: #b9954f #f1ece3;
scrollbar-gutter: stable;
scrollbar-width: thin;
cursor: grab;
touch-action: pan-x pan-y;
}
.installation-fee-dialog__scroll.is-dragging {
cursor: grabbing;
user-select: none;
}
.installation-fee-dialog__scroll::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.installation-fee-dialog__scroll::-webkit-scrollbar-track {
background: #f1ece3;
}
.installation-fee-dialog__scroll::-webkit-scrollbar-thumb {
border-radius: 999px;
background: #b9954f;
}
.installation-fee-dialog__scroll::-webkit-scrollbar-thumb:hover {
background: #856632;
}
.installation-fee-panel {
min-width: 100%;
}
.installation-fee-table {
width: 100%;
min-width: 72rem;
border-collapse: collapse;
font-size: 0.75rem;
font-variant-numeric: tabular-nums;
@ -318,15 +402,19 @@
.installation-fee-table th,
.installation-fee-table td {
padding: 0.6rem 0.5rem;
padding: var(--installation-fee-table-cell-padding);
border-bottom: 1px solid #eee8dd;
line-height: 1.5;
text-align: left;
vertical-align: middle;
white-space: nowrap;
}
.installation-fee-table thead th {
position: sticky;
top: 0;
z-index: 1;
padding: var(--installation-fee-table-head-padding);
background: #f7f0de;
color: #595959;
font-weight: 600;
@ -344,19 +432,13 @@
}
.installation-fee-platform-summary {
margin: 0.75rem 0 1rem;
padding-top: 0.75rem;
border-top: 1px solid #d8d2c7;
}
.installation-fee-platform-summary h3 {
margin: 0 0 0.5rem;
color: #171717;
font-size: 0.75rem;
margin: 0;
padding: 0;
}
.installation-fee-platform-summary table {
width: 100%;
min-width: 32rem;
border-collapse: collapse;
font-size: 0.75rem;
font-variant-numeric: tabular-nums;
@ -364,12 +446,16 @@
.installation-fee-platform-summary th,
.installation-fee-platform-summary td {
padding: 0.5rem;
padding: var(--installation-fee-table-cell-padding);
border-bottom: 1px solid #eee8dd;
line-height: 1.5;
text-align: left;
vertical-align: middle;
white-space: nowrap;
}
.installation-fee-platform-summary th {
padding: var(--installation-fee-table-head-padding);
background: #f7f0de;
color: #595959;
font-weight: 600;
@ -437,7 +523,7 @@
</div>
<div class="installation-fee-dialog__side">
<div class="installation-fee-dialog__total">
<span>当前筛选合计(元)</span>
<span>当前筛选合计(万元)</span>
<strong data-installation-fee-current-total>¥0.00</strong>
</div>
<button type="button" class="installation-fee-dialog__close" data-installation-fee-close aria-label="关闭安装费明细">×</button>
@ -469,34 +555,44 @@
</select>
</label>
</div>
<div class="installation-fee-dialog__scroll">
<table class="installation-fee-table">
<thead>
<tr>
<th scope="col">店铺名称</th>
<th scope="col">安装公司</th>
<th scope="col">收款渠道</th>
<th scope="col" class="is-number">结算明细金额</th>
</tr>
</thead>
<tbody data-installation-fee-rows></tbody>
</table>
<div class="installation-fee-empty" data-installation-fee-empty>请选择客服审核日期后查看明细</div>
<section class="installation-fee-platform-summary" aria-label="安装费平台汇总">
<h3>平台汇总</h3>
<div class="installation-fee-tabs" role="tablist" aria-label="安装费汇总子页面">
<button type="button" class="installation-fee-tab" id="installationFeePlatformTab" role="tab" aria-selected="true" aria-controls="installationFeePlatformPanel" data-installation-fee-tab="platform" tabindex="0">平台汇总</button>
<button type="button" class="installation-fee-tab" id="installationFeeDetailTab" role="tab" aria-selected="false" aria-controls="installationFeeDetailPanel" data-installation-fee-tab="detail" tabindex="-1">店铺明细</button>
</div>
<div
class="installation-fee-dialog__scroll"
data-installation-fee-scroll
aria-label="安装费明细表格,内容超出时可左右拖动或使用底部滚动条"
>
<section class="installation-fee-platform-summary installation-fee-panel is-active" id="installationFeePlatformPanel" role="tabpanel" aria-labelledby="installationFeePlatformTab" data-installation-fee-panel="platform">
<table>
<thead>
<tr>
<th scope="col">平台</th>
<th scope="col" class="is-number">结算明细金额</th>
<th scope="col" class="is-number">结算明细金额(万元)</th>
</tr>
</thead>
<tbody data-installation-fee-platform-rows></tbody>
</table>
<div class="installation-fee-empty" data-installation-fee-platform-empty hidden>当前客服审核时间内没有平台汇总。</div>
</section>
<section class="installation-fee-panel" id="installationFeeDetailPanel" role="tabpanel" aria-labelledby="installationFeeDetailTab" data-installation-fee-panel="detail" hidden>
<table class="installation-fee-table">
<thead>
<tr>
<th scope="col">店铺名称</th>
<th scope="col">安装公司</th>
<th scope="col">收款渠道</th>
<th scope="col" class="is-number">结算明细金额(万元)</th>
</tr>
</thead>
<tbody data-installation-fee-rows></tbody>
</table>
<div class="installation-fee-empty" data-installation-fee-empty>请选择客服审核日期后查看明细</div>
</section>
</div>
<div class="installation-fee-dialog__foot">
<span data-installation-fee-count>共 0 条明细汇总</span>
<span data-installation-fee-count>共 0 条平台汇总</span>
</div>
</dialog>
@ -526,17 +622,48 @@
var rowsEl = dialog.querySelector('[data-installation-fee-rows]');
var platformRowsEl = dialog.querySelector('[data-installation-fee-platform-rows]');
var emptyEl = dialog.querySelector('[data-installation-fee-empty]');
var platformEmptyEl = dialog.querySelector('[data-installation-fee-platform-empty]');
var countEl = dialog.querySelector('[data-installation-fee-count]');
var scrollEl = dialog.querySelector('[data-installation-fee-scroll]');
var tabsEl = dialog.querySelector('.installation-fee-tabs');
var tabButtons = Array.from(dialog.querySelectorAll('[data-installation-fee-tab]'));
var tabPanels = Array.from(dialog.querySelectorAll('[data-installation-fee-panel]'));
var allRows = [];
var loadedSignature = '';
var timer = null;
var controller = null;
var detailRowCount = 0;
var platformRowCount = 0;
var activeTab = 'platform';
function yuan(value) {
return '¥' + Number(value || 0).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
function updateCount() {
var count = activeTab === 'platform' ? platformRowCount : detailRowCount;
var suffix = activeTab === 'platform' ? '平台汇总' : '明细汇总';
countEl.textContent = '共 ' + count.toLocaleString('zh-CN') + ' 条' + suffix;
}
function activateTab(name, focusTab) {
activeTab = name;
tabButtons.forEach(function (tab) {
var selected = tab.dataset.installationFeeTab === name;
tab.setAttribute('aria-selected', selected ? 'true' : 'false');
tab.tabIndex = selected ? 0 : -1;
if (selected && focusTab) {
tab.focus();
}
});
tabPanels.forEach(function (panel) {
var selected = panel.dataset.installationFeePanel === name;
panel.hidden = !selected;
panel.classList.toggle('is-active', selected);
panel.style.display = selected ? 'block' : 'none';
panel.setAttribute('aria-hidden', selected ? 'false' : 'true');
});
if (scrollEl) {
scrollEl.scrollTop = 0;
scrollEl.scrollLeft = 0;
}
updateCount();
}
function amount(value) {
@ -550,6 +677,14 @@
return amount(Number(value || 0) / 10000);
}
function rawYuan(value) {
return '¥' + amount(value);
}
function wanYuan(value) {
return '¥' + wanAmount(value);
}
function captionRange(value) {
var matchFrom = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.from);
var matchTo = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.to);
@ -686,7 +821,8 @@
});
var amount = document.createElement('td');
amount.className = 'is-number';
amount.textContent = yuan(row.amount);
amount.textContent = wanYuan(row.amount);
amount.title = rawYuan(row.amount);
tr.appendChild(amount);
rowsEl.appendChild(tr);
});
@ -697,6 +833,8 @@
byPlatform[key] ??= 0;
byPlatform[key] += Number(row.amount || 0);
});
detailRowCount = rows.length;
platformRowCount = Object.keys(byPlatform).length;
platformRowsEl.replaceChildren();
Object.keys(byPlatform).sort(function (left, right) {
return Math.abs(byPlatform[right]) - Math.abs(byPlatform[left])
@ -708,28 +846,38 @@
tr.appendChild(platformCell);
var amount = document.createElement('td');
amount.className = 'is-number';
amount.textContent = yuan(byPlatform[name]);
amount.textContent = wanYuan(byPlatform[name]);
amount.title = rawYuan(byPlatform[name]);
tr.appendChild(amount);
platformRowsEl.appendChild(tr);
});
currentTotal.textContent = yuan(total);
countEl.textContent = '共 ' + rows.length.toLocaleString('zh-CN') + ' 条明细汇总';
currentTotal.textContent = wanYuan(total);
currentTotal.title = rawYuan(total);
updateCount();
emptyEl.hidden = rows.length > 0;
emptyEl.textContent = allRows.length
? '当前筛选条件下没有安装费明细。'
: '当前客服审核时间内没有安装费明细。';
platformEmptyEl.hidden = platformRowCount > 0;
platformEmptyEl.textContent = allRows.length
? '当前筛选条件下没有平台汇总。'
: '当前客服审核时间内没有平台汇总。';
}
function resetDialog(message) {
allRows = [];
loadedSignature = '';
detailRowCount = 0;
platformRowCount = 0;
rowsEl.replaceChildren();
platformRowsEl.replaceChildren();
currentTotal.textContent = '¥0.00';
countEl.textContent = '共 0 条明细汇总';
updateCount();
emptyEl.hidden = false;
emptyEl.textContent = message;
platformEmptyEl.hidden = false;
platformEmptyEl.textContent = message;
fillFilter(storeFilter, '全部店铺', []);
fillFilter(platformFilter, '全部平台', []);
fillFilter(companyFilter, '全部安装公司', []);
@ -737,6 +885,7 @@
}
function openDialog() {
activateTab('platform', false);
if (typeof dialog.showModal === 'function') {
dialog.showModal();
} else {
@ -816,10 +965,96 @@
timer = window.setTimeout(function () { refresh(true); }, 250);
}
var dragState = null;
function finishHorizontalDrag(event) {
if (!dragState) {
return;
}
var state = dragState;
dragState = null;
scrollEl.classList.remove('is-dragging');
if (event && state.pointerId !== null && scrollEl.hasPointerCapture(state.pointerId)) {
scrollEl.releasePointerCapture(state.pointerId);
}
}
if (scrollEl) {
scrollEl.addEventListener('pointerdown', function (event) {
if (event.button !== 0 || event.target.closest('button, a, input, select, textarea')) {
return;
}
dragState = {
active: false,
pointerId: event.pointerId,
startX: event.clientX,
startY: event.clientY,
scrollLeft: scrollEl.scrollLeft
};
});
scrollEl.addEventListener('pointermove', function (event) {
if (!dragState || dragState.pointerId !== event.pointerId) {
return;
}
var dx = event.clientX - dragState.startX;
var dy = event.clientY - dragState.startY;
if (!dragState.active) {
if (Math.abs(dx) < 6 || Math.abs(dx) <= Math.abs(dy)) {
return;
}
dragState.active = true;
scrollEl.classList.add('is-dragging');
scrollEl.setPointerCapture(event.pointerId);
var selection = window.getSelection();
if (selection) {
selection.removeAllRanges();
}
}
event.preventDefault();
scrollEl.scrollLeft = dragState.scrollLeft - dx;
});
['pointerup', 'pointercancel', 'lostpointercapture'].forEach(function (eventName) {
scrollEl.addEventListener(eventName, finishHorizontalDrag);
});
scrollEl.addEventListener('wheel', function (event) {
if (!event.shiftKey || Math.abs(event.deltaY) <= Math.abs(event.deltaX)) {
return;
}
scrollEl.scrollLeft += event.deltaY;
event.preventDefault();
}, { passive: false });
}
openButton.addEventListener('click', function () {
openDialog();
refresh(false);
});
tabsEl.addEventListener('click', function (event) {
var tab = event.target.closest('[data-installation-fee-tab]');
if (!tab || !tabsEl.contains(tab)) {
return;
}
activateTab(tab.dataset.installationFeeTab, false);
});
tabButtons.forEach(function (tab, index) {
tab.addEventListener('keydown', function (event) {
var nextIndex = null;
if (event.key === 'ArrowRight') {
nextIndex = (index + 1) % tabButtons.length;
} else if (event.key === 'ArrowLeft') {
nextIndex = (index - 1 + tabButtons.length) % tabButtons.length;
} else if (event.key === 'Home') {
nextIndex = 0;
} else if (event.key === 'End') {
nextIndex = tabButtons.length - 1;
}
if (nextIndex === null) {
return;
}
event.preventDefault();
activateTab(tabButtons[nextIndex].dataset.installationFeeTab, true);
});
});
[fromInput, toInput].forEach(function (input) {
if (input) { input.addEventListener('change', scheduleRefresh); }
});

View File

@ -29,7 +29,7 @@
.sys-todo-filter__multi details[open] > summary { border-color:var(--sys-gold); box-shadow:0 0 0 3px rgba(133,102,50,.14); }
.sys-todo-filter__multi details[open] > summary .material-icons-outlined { transform:translateY(-50%) rotate(180deg); }
.sys-todo-filter__multi-label { color:#595959; font-size:.72rem; line-height:1; }
.sys-todo-filter__multi-value { overflow:hidden; font-size:.8125rem; line-height:1.2; text-overflow:ellipsis; white-space:nowrap; }
.sys-todo-filter__multi-value { font-size:.8125rem; line-height:1.35; overflow-wrap:anywhere; white-space:normal; }
.sys-todo-filter__multi-menu { position:absolute; top:calc(100% + .3rem); left:0; z-index:20; display:grid; width:max(100%,13rem); max-height:17rem; padding:.35rem; border:1px solid var(--sys-border); border-radius:.55rem; background:#fff; box-shadow:0 8px 22px rgba(23,23,23,.16); overflow:auto; }
.sys-todo-filter__multi-menu label { display:flex; flex:none; align-items:center; gap:.45rem; min-height:2rem; padding:.3rem .45rem; border-radius:.35rem; color:#333; font-size:.78rem; cursor:pointer; }
.sys-todo-filter__multi-menu label:hover { background:var(--sys-gold-soft); }
@ -42,15 +42,21 @@
.sys-todo-table th { position:sticky; top:0; z-index:4; padding:.55rem .48rem; border-bottom:1px solid var(--sys-border); background:#f3ece0; color:#3d3a35; text-align:left; white-space:nowrap; }
.sys-todo-table th:first-child { left:0; z-index:8; width:5.4rem; min-width:5.4rem; text-align:center; box-shadow:1px 0 0 #e5ddcf; }
.sys-todo-table td { padding:.72rem .6rem; border-bottom:1px solid #eee7da; background:#fff; color:#2f2a23; line-height:1.6; vertical-align:top; }
.sys-todo-table tbody tr { cursor:pointer; }
.sys-todo-table tbody tr:hover td { background:#fdfbf6; }
.sys-todo-table tbody tr.is-highlighted td { background:#fff4cf !important; }
.sys-todo-table tbody tr:focus-visible { outline:2px solid var(--sys-gold); outline-offset:-2px; }
.sys-todo-table__index-cell { width:3.6rem; min-width:3.6rem; text-align:center; }
.sys-todo-table [data-sys-todo-row-edit], .sys-todo-table [data-sys-todo-group-edit] { cursor:pointer; }
.sys-todo-table [data-sys-todo-row-edit]:hover, .sys-todo-table [data-sys-todo-group-edit]:hover { background:#fff4cf; }
.sys-todo-table [data-sys-todo-row-edit]:focus-visible, .sys-todo-table [data-sys-todo-group-edit]:focus-visible { outline:2px solid var(--sys-gold); outline-offset:-2px; }
.sys-todo-table__index-cell { width:4.8rem; min-width:4.8rem; text-align:center; }
.sys-todo-table__index-actions { display:inline-flex; align-items:center; justify-content:center; gap:.32rem; }
.sys-todo-table__index { color:#6d5630; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
.sys-todo-table__insert-after { display:inline-flex; align-items:center; justify-content:center; width:1.45rem; height:1.45rem; padding:0; border:1px solid #d8c9aa; border-radius:999px; background:#fffaf0; color:var(--sys-gold); cursor:pointer; }
.sys-todo-table__insert-after:hover { border-color:var(--sys-gold); background:var(--sys-gold-soft); color:#6a5129; }
.sys-todo-table__insert-after:focus-visible { outline:2px solid var(--sys-gold); outline-offset:2px; }
.sys-todo-table__insert-after .material-icons-outlined { font-size:.95rem; line-height:1; }
.sys-todo-table__group { padding-top:.9rem; padding-bottom:.9rem; background:#fcfaf5; font-weight:600; line-height:1.7; vertical-align:middle; }
.sys-todo-table__group-content { display:inline-flex; align-items:flex-start; gap:.38rem; min-width:0; }
.sys-todo-table__group-text { min-width:0; }
.sys-todo-table__group-text { min-width:0; white-space:pre-line; overflow-wrap:anywhere; }
.sys-todo-table__level { display:inline-flex; flex:0 0 auto; align-items:center; justify-content:center; min-width:1.35rem; height:1.35rem; margin-top:.05rem; border:1px solid #d8c9aa; border-radius:999px; background:#fffaf0; color:var(--sys-gold); font-size:.68rem; font-weight:700; font-variant-numeric:tabular-nums; }
.sys-todo-table__type { position:sticky; left:0; z-index:3; width:5.4rem; min-width:5.4rem; text-align:center; white-space:nowrap; box-shadow:1px 0 0 #e5ddcf; }
.sys-todo-table__type .sys-todo-table__group-text { white-space:normal; }
@ -59,8 +65,6 @@
.sys-todo-table__title { min-width:17rem; max-width:24rem; font-weight:600; }
.sys-todo-table__progress { min-width:12rem; max-width:20rem; }
.sys-todo-table__notes { min-width:9rem; max-width:16rem; }
.sys-todo-table__clamp { display:-webkit-box; overflow:hidden; -webkit-box-orient:vertical; -webkit-line-clamp:3; }
.sys-todo-table__section .sys-todo-table__clamp { -webkit-line-clamp:2; }
.sys-todo-badge { display:inline-flex; align-items:center; padding:.1rem .45rem; border:1px solid #dfd6c5; border-radius:999px; background:#faf6ee; color:#51483c; white-space:nowrap; }
.sys-todo-badge--progress { border-color:#dbbf7a; background:#fff7df; color:#935f07; }
.sys-todo-badge--completed { border-color:#bad0ac; background:#f2f8ed; color:#53793e; }
@ -69,16 +73,13 @@
.sys-todo-shots { display:flex; flex-wrap:wrap; gap:.3rem; max-width:13rem; }
.sys-todo-shots button { display:block; width:4.25rem; height:3.2rem; padding:0; border:1px solid #ddd4c4; border-radius:.35rem; overflow:hidden; background:#faf8f3; cursor:zoom-in; }
.sys-todo-shots img { width:100%; height:100%; object-fit:cover; }
.sys-todo-table__add { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.65rem; margin-top:1rem; padding:.55rem .7rem; border:1px dashed #d8cdb8; border-radius:.55rem; background:#fcfaf5; color:#666; font-size:.72rem; }
.sys-todo-table__add { margin-top:1rem; padding:.55rem .7rem; border:1px dashed #d8cdb8; border-radius:.55rem; background:#fcfaf5; color:#666; font-size:.72rem; }
.sys-todo-scrollrail { position:fixed; bottom:.85rem; z-index:35; height:1.15rem; padding:2px; border:1px solid #d8cdb8; border-radius:999px; background:rgba(243,236,224,.96); box-shadow:0 5px 18px rgba(23,23,23,.16); opacity:0; pointer-events:none; overflow-x:scroll; overflow-y:hidden; transition:opacity 150ms ease; }
.sys-todo-scrollrail.is-visible { opacity:1; pointer-events:auto; }
.sys-todo-scrollrail__spacer { height:1px; }
.sys-todo-scrollrail::-webkit-scrollbar { height:.7rem; }
.sys-todo-scrollrail::-webkit-scrollbar-track { border-radius:999px; background:#eee7d9; }
.sys-todo-scrollrail::-webkit-scrollbar-thumb { border-radius:999px; background:var(--sys-gold); }
.sys-todo-table__add button { display:inline-flex; align-items:center; gap:.25rem; min-height:2rem; padding:0 .7rem; border:1px solid var(--sys-border); border-radius:.4rem; background:#fff; color:#51483c; font:inherit; font-size:.76rem; cursor:pointer; }
.sys-todo-table__add button:hover { border-color:#c7b687; background:var(--sys-gold-soft); }
.sys-todo-table__add .material-icons-outlined { font-size:1rem; }
.sys-todo-empty { padding:2rem 1rem; color:#777; text-align:center; }
.sys-todo-flash { margin:0 0 .85rem; padding:.65rem .85rem; border:1px solid #bad0ac; border-radius:.45rem; background:#f2f8ed; color:#53793e; font-size:.8125rem; }
.sys-todo-flash--error { border-color:#e7c3c3; background:#fff3f3; color:#b80000; }
@ -95,13 +96,14 @@
.sys-todo-dialog__body { max-height:calc(90vh - 9rem); overflow:auto; padding:1rem 1.25rem; }
.sys-todo-form-grid { display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:.75rem 1rem; }
.sys-todo-field { display:grid; gap:.3rem; min-width:0; color:#595959; font-size:.75rem; }
.sys-todo-field--2 { grid-column:span 2; }
.sys-todo-field--3 { grid-column:span 3; }
.sys-todo-field--4 { grid-column:span 4; }
.sys-todo-field--6 { grid-column:span 6; }
.sys-todo-field--12 { grid-column:span 12; }
.sys-todo-field input, .sys-todo-field select, .sys-todo-field textarea { width:100%; padding:.5rem .6rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; color:#171717; font:inherit; font-size:.8125rem; }
.sys-todo-field input, .sys-todo-field select { min-height:2.15rem; }
.sys-todo-field textarea { min-height:5.5rem; resize:vertical; line-height:1.55; }
.sys-todo-field textarea { min-height:5.5rem; resize:vertical; line-height:1.55; overflow:hidden; }
.sys-todo-new-category { margin-top:.35rem; }
.sys-todo-new-category[hidden] { display:none; }
.sys-todo-owner-checks { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.2rem .45rem; max-height:7rem; padding:.4rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; overflow:auto; }
@ -135,6 +137,18 @@
.sys-todo-confirm__actions button { min-height:2.1rem; padding:0 .9rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; font:inherit; font-size:.8125rem; cursor:pointer; }
.sys-todo-confirm__actions .sys-todo-confirm__submit { border-color:#b80000; background:#b80000; color:#fff; }
.sys-todo-confirm__actions .sys-todo-confirm__submit:hover { background:#920000; }
.sys-todo-group-dialog { width:min(34rem,calc(100vw - 2rem)); padding:0; border:1px solid var(--sys-border); border-radius:.8rem; background:#fff; color:#171717; overflow:hidden; }
.sys-todo-group-dialog::backdrop { background:rgba(23,23,23,.58); }
.sys-todo-group-dialog__head { display:flex; align-items:center; gap:.75rem; padding:.9rem 1rem; border-bottom:1px solid #e8e0d2; background:#faf6ee; }
.sys-todo-group-dialog__head h2 { margin:0; font-size:.95rem; }
.sys-todo-group-dialog__head button { margin-left:auto; width:2rem; height:2rem; padding:0; border:1px solid var(--sys-border); border-radius:999px; background:#fff; color:#595959; cursor:pointer; }
.sys-todo-group-dialog__body { display:grid; gap:.55rem; padding:1rem; }
.sys-todo-group-dialog__body label { display:grid; gap:.35rem; color:#595959; font-size:.76rem; }
.sys-todo-group-dialog__body textarea { width:100%; min-height:5.5rem; padding:.55rem .65rem; border:1px solid var(--sys-border); border-radius:.45rem; font:inherit; font-size:.84rem; line-height:1.6; overflow:hidden; resize:vertical; }
.sys-todo-group-dialog__note { margin:0; color:#666; font-size:.73rem; line-height:1.55; }
.sys-todo-group-dialog__actions { display:flex; justify-content:flex-end; gap:.5rem; padding:.75rem 1rem; border-top:1px solid #e8e0d2; background:#fcfaf5; }
.sys-todo-group-dialog__actions button { min-height:2.1rem; padding:0 .9rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; font:inherit; font-size:.8125rem; cursor:pointer; }
.sys-todo-group-dialog__actions button[type="submit"] { border-color:var(--sys-gold); background:var(--sys-gold); color:#fff; }
.sys-todo-image-dialog { width:min(72rem,calc(100vw - 2rem)); max-height:92vh; padding:0; border:1px solid var(--sys-border); border-radius:.8rem; background:#111; color:#fff; overflow:hidden; }
.sys-todo-image-dialog::backdrop { background:rgba(5,5,6,.78); }
.sys-todo-image-dialog__head { display:flex; align-items:center; gap:1rem; padding:.65rem .85rem; background:#1d1d1f; }
@ -146,7 +160,7 @@
.sys-todo-image-dialog__foot a { color:#f0e4bf; font-size:.75rem; }
@media (max-width:1300px) { .sys-todo-summary { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (max-width:900px) { .sys-todo-filter label, .sys-todo-filter label.sys-todo-filter__keyword { flex-basis:9rem; } .sys-todo-filter__actions { width:100%; } .sys-todo-filter__actions .sys-todo-page__button { flex:1; } }
@media (max-width:720px) { .sys-todo-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } .sys-todo-filter label, .sys-todo-filter label.sys-todo-filter__keyword { flex-basis:10rem; } .sys-todo-field--3,.sys-todo-field--4,.sys-todo-field--6 { grid-column:span 12; } }
@media (max-width:720px) { .sys-todo-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } .sys-todo-filter label, .sys-todo-filter label.sys-todo-filter__keyword { flex-basis:10rem; } .sys-todo-field--2,.sys-todo-field--3,.sys-todo-field--4,.sys-todo-field--6 { grid-column:span 12; } }
</style>
<div class="biz-card-head">
@ -203,9 +217,6 @@
<option value="{{ $category }}" @selected($todoFilters['category'] === $category)>{{ $category }}</option>
@endforeach
</select></label>
<label>类型序号<input type="number" name="type_sequence" min="1" step="1" value="{{ $todoFilters['type_sequence'] ?: '' }}" placeholder="如:1"></label>
<label>内容序号<input type="number" name="content_sequence" min="1" step="1" value="{{ $todoFilters['content_sequence'] ?: '' }}" placeholder="如:2"></label>
<label>待办序号<input type="number" name="item_sequence" min="1" step="1" value="{{ $todoFilters['item_sequence'] ?: '' }}" placeholder="如:3"></label>
@php
$selectedOwners = $todoOwners->filter(
static fn (string $owner): bool => in_array($owner, $todoFilters['owners'], true)
@ -266,7 +277,7 @@
@php
$cleanDisplayLabel = static function (?string $value): string {
return trim((string) preg_replace(
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、..::)]\s*/u',
'/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、,,..::;;)]\s*/u',
'',
(string) $value,
));
@ -315,25 +326,18 @@
}
}
}
$lastItem = $items->last();
$lastSectionLabel = $items->isNotEmpty() ? ($sectionLabels[$items->count() - 1] ?? '') : '';
$highlightId = max(0, (int) request('highlight', 0));
@endphp
<div class="sys-todo-table__add">
<span>共 {{ number_format($items->count()) }} 条,已全部显示。点击任意事项行可直接编辑。</span>
<button type="button" data-sys-todo-create
data-sys-todo-default-category="{{ $lastItem?->category ?? '' }}"
data-sys-todo-default-section="{{ $lastSectionLabel }}">
<span class="material-icons-outlined" aria-hidden="true">playlist_add</span>新增一条
</button>
共 {{ number_format($items->count()) }} 条,已全部显示。点击序号旁的+可在该条之后插入,原后续序号自动顺延;点击待办事项编辑详情,点击类型或内容可单独修改该组名称。
</div>
<div class="sys-todo-table-wrap" tabindex="0" aria-label="待办列表,可横向滚动查看全部内容" data-sys-todo-table-wrap>
<table class="sys-todo-table" aria-label="财务系统化待办清单">
<thead>
<tr>
<th scope="col">类型</th><th scope="col">内容</th><th scope="col">待办序号</th><th scope="col">待办事项</th><th scope="col">总负责人</th><th scope="col">责任人</th>
<th scope="col">类型</th><th scope="col">内容</th><th scope="col">待办事项序号</th><th scope="col">待办事项</th><th scope="col">总负责人</th><th scope="col">责任人</th>
<th scope="col">开始时间</th><th scope="col">完成时间</th><th scope="col">状态</th><th scope="col">完成情况</th><th scope="col">完成截图</th><th scope="col">备注</th>
</tr>
</thead>
@ -351,6 +355,7 @@
};
$todoPayload = [
'id' => $item->id,
'position' => (int) $item->item_sequence,
'category' => $item->category ?? '',
'section' => $sectionLabels[$loop->index] ?? '',
'title' => $titleLabels[$loop->index] ?? '',
@ -375,9 +380,16 @@
$categorySpan = $groupRowspans['category'][$loop->index] ?? 1;
$sectionSpan = $groupRowspans['section'][$loop->index] ?? 1;
@endphp
<tr id="sys-todo-row-{{ $item->id }}" class="{{ $highlightId === (int) $item->id ? 'is-highlighted' : '' }}" tabindex="0" data-sys-todo-row-edit="{{ $todoPayloadEncoded }}" title="点击整行直接编辑">
<tr id="sys-todo-row-{{ $item->id }}" class="{{ $highlightId === (int) $item->id ? 'is-highlighted' : '' }}">
@if ($categorySpan !== 0)
<td class="sys-todo-table__group sys-todo-table__type" @if ($categorySpan > 1) rowspan="{{ $categorySpan }}" @endif>
<td class="sys-todo-table__group sys-todo-table__type"
@if ($categorySpan > 1) rowspan="{{ $categorySpan }}" @endif
tabindex="0"
role="button"
title="点击修改类型名称"
data-sys-todo-group-edit="category"
data-sys-todo-group-value="{{ $item->category ?? '' }}"
data-sys-todo-group-count="{{ (int) $item->type_count }}">
<span class="sys-todo-table__group-content">
<span class="sys-todo-table__level" title="类型序号">{{ (int) $item->type_sequence }}</span>
<span class="sys-todo-table__group-text">{{ $item->category_display ?: '未分类' }}</span>
@ -385,15 +397,39 @@
</td>
@endif
@if ($sectionSpan !== 0)
<td class="sys-todo-table__group sys-todo-table__section" @if ($sectionSpan > 1) rowspan="{{ $sectionSpan }}" @endif>
<td class="sys-todo-table__group sys-todo-table__section"
@if ($sectionSpan > 1) rowspan="{{ $sectionSpan }}" @endif
tabindex="0"
role="button"
title="点击修改内容名称"
data-sys-todo-group-edit="section"
data-sys-todo-group-value="{{ $sectionLabels[$loop->index] ?? '' }}"
data-sys-todo-group-count="{{ (int) $item->content_count }}">
<span class="sys-todo-table__group-content">
<span class="sys-todo-table__level" title="内容序号">{{ (int) $item->content_sequence }}</span>
<span class="sys-todo-table__group-text sys-todo-table__clamp" title="{{ $sectionLabels[$loop->index] ?: '未填写内容' }}">{{ $sectionLabels[$loop->index] ?: '未填写内容' }}</span>
<span class="sys-todo-table__group-text">{{ $sectionLabels[$loop->index] ?: '未填写内容' }}</span>
</span>
</td>
@endif
<td class="sys-todo-table__index-cell"><span class="sys-todo-table__index" title="当前内容内待办序号">{{ (int) $item->item_sequence }}</span></td>
<td class="sys-todo-table__title"><div class="sys-todo-table__clamp" title="{{ $titleLabels[$loop->index] }}">{{ $titleLabels[$loop->index] }}</div></td>
<td class="sys-todo-table__index-cell">
<span class="sys-todo-table__index-actions">
<span class="sys-todo-table__index" title="当前内容内待办序号">{{ (int) $item->item_sequence }}</span>
<button type="button" class="sys-todo-table__insert-after"
data-sys-todo-insert-after
data-sys-todo-insert-category="{{ $item->category ?? '' }}"
data-sys-todo-insert-section="{{ $sectionLabels[$loop->index] ?? '' }}"
data-sys-todo-insert-position="{{ (int) $item->item_sequence + 1 }}"
data-sys-todo-insert-after-sequence="{{ (int) $item->item_sequence }}"
title="在第 {{ (int) $item->item_sequence }} 条后新增一条"
aria-label="在第 {{ (int) $item->item_sequence }} 条后新增一条">
<span class="material-icons-outlined" aria-hidden="true">add</span>
</button>
</span>
</td>
<td class="sys-todo-table__title"
tabindex="0"
title="点击编辑待办"
data-sys-todo-row-edit="{{ $todoPayloadEncoded }}">{{ $titleLabels[$loop->index] }}</td>
<td>{{ $item->owner ?: '—' }}</td>
<td>{{ $item->assignee ?: '—' }}</td>
<td>{{ $item->start_date?->format('Y-m-d') ?: ($item->start_note ?: '—') }}</td>
@ -402,7 +438,7 @@
@if ($isOverdue)<br><span class="sys-todo-badge sys-todo-badge--overdue">已逾期</span>@endif
</td>
<td><span class="sys-todo-badge {{ $statusClass }}">{{ $item->status }}</span></td>
<td class="sys-todo-table__progress"><div class="sys-todo-table__clamp" title="{{ $item->progress ?: '—' }}">{{ $item->progress ?: '—' }}</div></td>
<td class="sys-todo-table__progress">{{ $item->progress ?: '—' }}</td>
<td>
@if ($item->attachments->isNotEmpty())
<div class="sys-todo-shots">
@ -423,7 +459,7 @@
—
@endif
</td>
<td class="sys-todo-table__notes"><div class="sys-todo-table__clamp" title="{{ $item->notes ?: '—' }}">{{ $item->notes ?: '—' }}</div></td>
<td class="sys-todo-table__notes">{{ $item->notes ?: '—' }}</td>
</tr>
@empty
<tr><td colspan="12"><div class="sys-todo-empty">当前筛选条件下没有待办事项。</div></td></tr>
@ -459,7 +495,23 @@
<input type="text" maxlength="100" placeholder="输入新类型" data-sys-todo-new-category-input>
</div>
</div>
<label class="sys-todo-field sys-todo-field--4">内容<input name="section" maxlength="255"></label>
<div class="sys-todo-field sys-todo-field--4">
<label for="sysTodoSectionSelect">内容</label>
<select id="sysTodoSectionSelect" data-sys-todo-section-select>
<option value="">请选择内容</option>
@foreach (collect($todoContentOptions)->flatten()->unique()->sort()->values() as $section)
<option value="{{ $section }}">{{ $section }}</option>
@endforeach
<option value="__new__">+ 新增内容</option>
</select>
<input type="hidden" name="section" data-sys-todo-section-value>
<div class="sys-todo-new-category" data-sys-todo-new-section hidden>
<input type="text" maxlength="255" placeholder="输入新内容" data-sys-todo-new-section-input>
</div>
</div>
<label class="sys-todo-field sys-todo-field--2 sys-todo-position-field" data-sys-todo-position-field>待办事项序号
<select name="position" data-sys-todo-position></select>
</label>
<label class="sys-todo-field sys-todo-field--3">状态<select name="status" required>@foreach ($todoStatuses as $status)<option value="{{ $status }}">{{ $status }}</option>@endforeach</select></label>
<div class="sys-todo-field sys-todo-field--3">
<span>总负责人</span>
@ -475,9 +527,9 @@
<label class="sys-todo-field sys-todo-field--3">责任人<input name="assignee" maxlength="255" list="sysTodoAssignees"></label>
<label class="sys-todo-field sys-todo-field--3">开始时间<input type="date" name="start_date"></label>
<label class="sys-todo-field sys-todo-field--3">完成时间<input type="date" name="due_date"></label>
<label class="sys-todo-field sys-todo-field--6">待办事项<textarea name="title" maxlength="5000" required></textarea></label>
<label class="sys-todo-field sys-todo-field--6">完成情况<textarea name="progress" maxlength="10000"></textarea></label>
<label class="sys-todo-field sys-todo-field--6">备注<textarea name="notes" maxlength="10000"></textarea></label>
<label class="sys-todo-field sys-todo-field--6">待办事项<textarea name="title" maxlength="5000" required data-sys-todo-auto-grow></textarea></label>
<label class="sys-todo-field sys-todo-field--6">完成情况<textarea name="progress" maxlength="10000" data-sys-todo-auto-grow></textarea></label>
<label class="sys-todo-field sys-todo-field--6">备注<textarea name="notes" maxlength="10000" data-sys-todo-auto-grow></textarea></label>
<div class="sys-todo-field sys-todo-field--6" data-sys-todo-upload>
<span>完成截图</span>
<div class="sys-todo-upload-zone">
@ -497,6 +549,28 @@
</form>
</dialog>
<dialog class="sys-todo-group-dialog" id="sysTodoGroupDialog" aria-labelledby="sysTodoGroupDialogTitle">
<form method="POST" data-sys-todo-group-form>
@csrf
@method('PATCH')
<div class="sys-todo-group-dialog__head">
<h2 id="sysTodoGroupDialogTitle" data-sys-todo-group-title>修改类型</h2>
<button type="button" data-sys-todo-group-close aria-label="关闭">×</button>
</div>
<div class="sys-todo-group-dialog__body">
<label>
<span data-sys-todo-group-label>类型名称</span>
<textarea name="category" required data-sys-todo-group-input data-sys-todo-auto-grow></textarea>
</label>
<p class="sys-todo-group-dialog__note" data-sys-todo-group-note>保存后会同步修改当前分组的名称。</p>
</div>
<div class="sys-todo-group-dialog__actions">
<button type="button" data-sys-todo-group-close>取消</button>
<button type="submit">保存</button>
</div>
</form>
</dialog>
<dialog class="sys-todo-confirm" id="sysTodoDeleteConfirm" aria-labelledby="sysTodoDeleteConfirmTitle">
<form method="POST" data-sys-todo-delete-form>
@csrf
@ -549,6 +623,12 @@
var categoryValue = dialog.querySelector('[data-sys-todo-category-value]');
var newCategoryWrap = dialog.querySelector('[data-sys-todo-new-category]');
var newCategoryInput = dialog.querySelector('[data-sys-todo-new-category-input]');
var sectionSelect = dialog.querySelector('[data-sys-todo-section-select]');
var sectionValue = dialog.querySelector('[data-sys-todo-section-value]');
var newSectionWrap = dialog.querySelector('[data-sys-todo-new-section]');
var newSectionInput = dialog.querySelector('[data-sys-todo-new-section-input]');
var positionField = dialog.querySelector('[data-sys-todo-position-field]');
var positionSelect = dialog.querySelector('[data-sys-todo-position]');
var ownerValue = dialog.querySelector('[data-sys-todo-owner-value]');
var ownerOptionInputs = Array.prototype.slice.call(
dialog.querySelectorAll('[data-sys-todo-owner-options] input[type="checkbox"]')
@ -557,8 +637,17 @@
var deleteConfirm = document.getElementById('sysTodoDeleteConfirm');
var deleteForm = deleteConfirm.querySelector('[data-sys-todo-delete-form]');
var deleteTitle = deleteConfirm.querySelector('[data-sys-todo-delete-title]');
var groupDialog = document.getElementById('sysTodoGroupDialog');
var groupForm = groupDialog.querySelector('[data-sys-todo-group-form]');
var groupTitle = groupDialog.querySelector('[data-sys-todo-group-title]');
var groupLabel = groupDialog.querySelector('[data-sys-todo-group-label]');
var groupInput = groupDialog.querySelector('[data-sys-todo-group-input]');
var groupNote = groupDialog.querySelector('[data-sys-todo-group-note]');
var routes = @json($todoRoutes, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
var positionGroups = @json($todoPositionGroups, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
var contentOptions = @json($todoContentOptions, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
var currentTodoId = null;
var currentGroupTodoId = null;
var currentTodoTitle = '';
var uploadPrompt = '点击选择、拖入此区域或直接粘贴,支持多张,每张不超过 10 MB。';
var ownerFilter = document.querySelector('[data-sys-todo-owner-filter]');
@ -582,6 +671,58 @@
if (field) field.value = value || '';
}
function resizeTextarea(field) {
if (!field || field.offsetParent === null) return;
field.style.height = 'auto';
field.style.height = Math.max(field.scrollHeight, 72) + 'px';
}
function resizeTextareas(root) {
(root || document).querySelectorAll('[data-sys-todo-auto-grow]').forEach(resizeTextarea);
}
function normalizedGroupText(value) {
return String(value || '')
.replace(/^\s*(?:\d+|[一二三四五六七八九十百]+)\s*[、,,..::;;)]\s*/u, '')
.replace(/[\s\p{Z}\u200B\uFEFF]+/gu, '')
.toLowerCase();
}
function currentPositionGroup() {
var category = normalizedGroupText(categoryValue.value);
var section = normalizedGroupText(sectionValue.value);
return positionGroups.find(function (group) {
return normalizedGroupText(group.category) === category
&& normalizedGroupText(group.section) === section;
}) || null;
}
function populatePositionOptions() {
positionSelect.replaceChildren();
positionField.hidden = false;
positionSelect.disabled = false;
var group = currentPositionGroup();
var count = group ? Number(group.count || 0) : 0;
var positionCount = currentTodoId ? Math.max(count, 1) : count;
for (var index = 1; index <= positionCount; index++) {
var before = document.createElement('option');
before.value = String(index);
before.textContent = currentTodoId
? '第 ' + index + ' 条'
: '第 ' + index + ' 条前插入(原第 ' + index + ' 条及之后顺延)';
positionSelect.appendChild(before);
}
if (!currentTodoId) {
var end = document.createElement('option');
end.value = String(count + 1);
end.textContent = count > 0
? '+ 新增第 ' + (count + 1) + ' 条(添加到末尾)'
: '+ 新增为第 1 条';
positionSelect.appendChild(end);
positionSelect.value = String(count + 1);
}
}
function syncScrollRail() {
var rect = tableWrap.getBoundingClientRect();
var left = Math.max(8, rect.left);
@ -679,6 +820,82 @@
: categorySelect.value;
}
function availableSectionLabels() {
var category = normalizedGroupText(categoryValue.value);
if (category === '') return [];
var matchingKey = Object.keys(contentOptions || {}).find(function (key) {
return normalizedGroupText(key) === category;
});
return matchingKey && Array.isArray(contentOptions[matchingKey])
? contentOptions[matchingKey].slice()
: [];
}
function setSectionSelection(value) {
var normalized = String(value || '').trim();
var hasOption = Array.prototype.some.call(
sectionSelect.options,
function (option) { return option.value === normalized && normalized !== '__new__'; }
);
if (normalized !== '' && !hasOption) {
var custom = document.createElement('option');
custom.value = normalized;
custom.textContent = normalized;
sectionSelect.insertBefore(custom, sectionSelect.lastElementChild);
hasOption = true;
}
sectionSelect.value = normalized;
newSectionWrap.hidden = true;
newSectionInput.required = false;
newSectionInput.value = '';
sectionValue.value = normalized;
}
function refreshSectionOptions(selectedValue) {
var normalized = String(selectedValue || '').trim();
var labels = availableSectionLabels();
sectionSelect.replaceChildren();
var placeholder = document.createElement('option');
placeholder.value = '';
placeholder.textContent = '请选择内容';
sectionSelect.appendChild(placeholder);
labels.forEach(function (label) {
var option = document.createElement('option');
option.value = label;
option.textContent = label;
sectionSelect.appendChild(option);
});
if (normalized !== '' && labels.indexOf(normalized) === -1) {
var current = document.createElement('option');
current.value = normalized;
current.textContent = normalized;
sectionSelect.appendChild(current);
}
var create = document.createElement('option');
create.value = '__new__';
create.textContent = '+ 新增内容';
sectionSelect.appendChild(create);
setSectionSelection(normalized);
}
function syncSectionValue() {
var creating = sectionSelect.value === '__new__';
newSectionWrap.hidden = !creating;
newSectionInput.required = creating;
sectionValue.value = creating
? newSectionInput.value.trim()
: sectionSelect.value;
}
function refreshSectionForCategory() {
var labels = availableSectionLabels();
refreshSectionOptions(labels.length ? labels[0] : '');
populatePositionOptions();
}
function appendScreenshotFiles(files) {
var images = Array.prototype.slice.call(files || []).filter(function (file) {
return /^image\/(jpeg|png|webp)$/.test(file.type)
@ -719,17 +936,41 @@
imagePreview.removeAttribute('src');
}
function openGroupDialog(type, value, count) {
var isCategory = type === 'category';
groupForm.action = routes[isCategory ? 'category' : 'section'].replace('__TODO__', currentGroupTodoId);
groupInput.name = isCategory ? 'category' : 'section';
groupInput.value = value || '';
groupTitle.textContent = isCategory ? '修改类型' : '修改内容';
groupLabel.textContent = isCategory ? '类型名称' : '内容名称';
groupNote.textContent = '保存后会同步修改当前分组内的 ' + count + ' 条待办。';
if (typeof groupDialog.showModal === 'function') groupDialog.showModal();
else groupDialog.setAttribute('open', '');
window.setTimeout(function () {
resizeTextarea(groupInput);
groupInput.focus();
groupInput.select();
}, 0);
}
function closeGroupDialog() {
if (typeof groupDialog.close === 'function') groupDialog.close();
else groupDialog.removeAttribute('open');
}
function openDialog(payload) {
currentTodoId = payload && payload.id ? payload.id : null;
currentTodoTitle = payload && payload.title ? payload.title : '';
form.reset();
methodInput.value = currentTodoId ? 'PATCH' : 'POST';
form.action = currentTodoId ? routes.update.replace('__TODO__', currentTodoId) : routes.store;
title.textContent = currentTodoId ? '编辑待办' : '新增待办';
title.textContent = currentTodoId
? '编辑待办'
: (payload && payload.afterSequence ? '在第 ' + payload.afterSequence + ' 条后新增待办' : '新增待办');
deleteButton.hidden = !currentTodoId;
if (payload) {
setCategoryValue(payload.category);
setValue('section', payload.section);
refreshSectionOptions(payload.section);
setValue('title', payload.title);
setOwnerValue(payload.owner);
setValue('assignee', payload.assignee);
@ -741,11 +982,26 @@
setValue('notes', payload.notes);
} else {
setCategoryValue('');
refreshSectionOptions('');
setOwnerValue('');
}
if (!currentTodoId && !(payload && payload.status)) {
setValue('status', '待办');
}
populatePositionOptions();
if (currentTodoId) {
var requestedPosition = Number((payload && payload.position) || 1);
positionSelect.value = String(Math.min(
Math.max(requestedPosition, 1),
Math.max(positionSelect.options.length, 1)
));
} else if (payload && Number(payload.insertPosition) > 0) {
var insertPosition = Number(payload.insertPosition);
positionSelect.value = String(Math.min(
Math.max(insertPosition, 1),
Math.max(positionSelect.options.length, 1)
));
}
existing.replaceChildren();
((payload && payload.attachments) || []).forEach(function (attachment) {
@ -776,6 +1032,7 @@
else dialog.setAttribute('open', '');
uploadNote.textContent = uploadPrompt;
window.setTimeout(function () {
resizeTextareas(dialog);
var titleField = form.querySelector('[name="title"]');
if (titleField) titleField.focus();
}, 0);
@ -817,6 +1074,30 @@
});
return;
}
var insertAfter = event.target.closest('[data-sys-todo-insert-after]');
if (insertAfter) {
openDialog({
category: insertAfter.getAttribute('data-sys-todo-insert-category') || '',
section: insertAfter.getAttribute('data-sys-todo-insert-section') || '',
insertPosition: Number(insertAfter.getAttribute('data-sys-todo-insert-position') || 1),
afterSequence: Number(insertAfter.getAttribute('data-sys-todo-insert-after-sequence') || 0),
});
return;
}
var groupCell = event.target.closest('[data-sys-todo-group-edit]');
if (groupCell) {
var groupRow = groupCell.closest('tr');
var groupRowId = groupRow ? Number(String(groupRow.id).replace('sys-todo-row-', '')) : 0;
if (groupRowId) {
currentGroupTodoId = groupRowId;
openGroupDialog(
groupCell.getAttribute('data-sys-todo-group-edit'),
groupCell.getAttribute('data-sys-todo-group-value'),
Number(groupCell.getAttribute('data-sys-todo-group-count') || 1)
);
}
return;
}
if (event.target.closest('[data-sys-todo-open-delete]')) {
openDeleteConfirm();
return;
@ -827,6 +1108,7 @@
return;
}
if (event.target.closest('[data-sys-todo-close]')) closeDialog();
if (event.target.closest('[data-sys-todo-group-close]')) closeGroupDialog();
if (event.target.closest('[data-sys-todo-delete-close]')) closeDeleteConfirm();
if (event.target.closest('[data-sys-todo-image-close]')) closeImageViewer();
if (event.target.closest('[data-sys-todo-choose-files]')) screenshotInput.click();
@ -834,6 +1116,9 @@
dialog.addEventListener('click', function (event) {
if (event.target === dialog) closeDialog();
});
groupDialog.addEventListener('click', function (event) {
if (event.target === groupDialog) closeGroupDialog();
});
dialog.addEventListener('paste', function (event) {
var files = Array.prototype.slice.call(event.clipboardData?.items || [])
.filter(function (item) { return item.kind === 'file'; })
@ -850,9 +1135,31 @@
deleteConfirm.addEventListener('click', function (event) {
if (event.target === deleteConfirm) closeDeleteConfirm();
});
categorySelect.addEventListener('change', syncCategoryValue);
categorySelect.addEventListener('change', function () {
syncCategoryValue();
refreshSectionForCategory();
});
newCategoryInput.addEventListener('input', function () {
if (categorySelect.value === '__new__') syncCategoryValue();
if (categorySelect.value === '__new__') {
syncCategoryValue();
refreshSectionForCategory();
}
});
sectionSelect.addEventListener('change', function () {
syncSectionValue();
populatePositionOptions();
});
newSectionInput.addEventListener('input', function () {
if (sectionSelect.value === '__new__') {
syncSectionValue();
populatePositionOptions();
}
});
dialog.addEventListener('input', function (event) {
if (event.target.matches('[data-sys-todo-auto-grow]')) resizeTextarea(event.target);
});
groupDialog.addEventListener('input', function (event) {
if (event.target.matches('[data-sys-todo-auto-grow]')) resizeTextarea(event.target);
});
ownerOptionInputs.forEach(function (input) {
input.addEventListener('change', updateOwnerValue);
@ -881,6 +1188,21 @@
closeImageViewer();
return;
}
var groupCell = event.target.closest('[data-sys-todo-group-edit]');
if (groupCell && event.target === groupCell && (event.key === 'Enter' || event.key === ' ')) {
event.preventDefault();
var groupRow = groupCell.closest('tr');
var groupRowId = groupRow ? Number(String(groupRow.id).replace('sys-todo-row-', '')) : 0;
if (groupRowId) {
currentGroupTodoId = groupRowId;
openGroupDialog(
groupCell.getAttribute('data-sys-todo-group-edit'),
groupCell.getAttribute('data-sys-todo-group-value'),
Number(groupCell.getAttribute('data-sys-todo-group-count') || 1)
);
}
return;
}
var row = event.target.closest('[data-sys-todo-row-edit]');
if (row && event.target === row && (event.key === 'Enter' || event.key === ' ')) {
event.preventDefault();

View File

@ -785,6 +785,12 @@ Route::prefix('workspace/other/systemization-todos')
->middleware('import')
->name('import');
Route::post('/', [SystemizationTodos::class, 'store'])->name('store');
Route::patch('{todo}/category', [SystemizationTodos::class, 'updateCategory'])
->whereNumber('todo')
->name('category');
Route::patch('{todo}/section', [SystemizationTodos::class, 'updateSection'])
->whereNumber('todo')
->name('section');
Route::patch('{todo}', [SystemizationTodos::class, 'update'])
->whereNumber('todo')
->name('update');

View File

@ -147,6 +147,31 @@ class FinanceLedgerHeaderControlsTest extends FeatureTestCase
}
}
public function test_shop_ledger_header_labels_and_column_order(): void
{
$html = $this->loginAs()->get($this->pageUrl())->assertOk()->getContent();
$panelStart = strpos($html, 'id="ledger-panel-shops"');
$theadStart = strpos($html, '<thead>', $panelStart);
$theadEnd = strpos($html, '</thead>', $theadStart);
$this->assertNotFalse($panelStart);
$this->assertNotFalse($theadStart);
$this->assertNotFalse($theadEnd);
$headerHtml = substr($html, $theadStart, $theadEnd - $theadStart);
$platformPosition = strpos($headerHtml, 'data-ledger-header-field="platform"');
$shopNamePosition = strpos($headerHtml, 'data-ledger-header-field="shop_name"');
$this->assertNotFalse($platformPosition);
$this->assertNotFalse($shopNamePosition);
$this->assertLessThan($shopNamePosition, $platformPosition);
$this->assertStringContainsString('data-ledger-header-label>平台</span>', $headerHtml);
$this->assertStringContainsString('data-ledger-header-label>ERP系统店铺名称</span>', $headerHtml);
$this->assertStringContainsString('data-ledger-header-label>店铺主体</span>', $headerHtml);
$this->assertStringNotContainsString('data-ledger-header-label>店铺名称</span>', $headerHtml);
$this->assertStringNotContainsString('data-ledger-header-label>所属公司</span>', $headerHtml);
}
public function test_transaction_account_filter_provides_typeahead_suggestions(): void
{
$html = $this->loginAs()->get($this->pageUrl())

View File

@ -115,6 +115,79 @@ class FinanceLedgerShopDataSynchronizerTest extends FeatureTestCase
$this->assertStringContainsString('待确认回款账户', (string) $shop->remark);
}
public function test_rebuild_clears_stale_shop_ledger_and_reloads_latest_snapshot(): void
{
Carbon::setTestNow('2026-10-26 09:00:00');
$connection = DB::connection('business_mirror');
$connection->table('fin_shops')->insert([
'shop_name' => '历史脏数据店',
'platform' => '天猫',
'shop_balance' => 99,
'created_at' => now(),
'updated_at' => now(),
]);
StoreReceivingAccount::withoutGlobalScopes()->create([
'company_id' => $this->company->id,
'store_platform' => '拼多多',
'store_name' => '拼多多-台账重建店',
'store_entity_name' => '台账重建主体有限公司',
'withdrawal_account_name' => '台账重建回款户',
'bank_card_last_four' => '7788',
'store_status' => '正常',
]);
$connection->table('fin_account_map')->insert([
'source' => 'shop',
'source_value' => '拼多多-台账重建店',
'account_short' => '重建账户',
'created_at' => now(),
'updated_at' => now(),
]);
$this->insertBalance(
$connection,
'2026-10-25',
'拼多多-台账重建店',
1588.66,
'拼多多',
);
$result = app(FinanceLedgerShopDataSynchronizer::class)
->syncShopBalances('2026-10-25', true);
$this->assertSame(1, $result['rebuilt']);
$this->assertSame(1, $result['matched']);
$this->assertDatabaseMissing('fin_shops', ['shop_name' => '历史脏数据店'], 'business_mirror');
$shop = $connection->table('fin_shops')->first();
$this->assertSame('拼多多-台账重建店', $shop->shop_name);
$this->assertSame('拼多多', $shop->platform);
$this->assertSame('台账重建主体有限公司', $shop->company_name);
$this->assertSame('重建账户', $shop->account_short);
$this->assertSame('在营', $shop->status);
$this->assertSame('台账重建回款户 7788', $shop->payout_account);
$this->assertSame(1588.66, (float) $shop->shop_balance);
$this->assertSame('2026-10-25', substr((string) $shop->shop_balance_date, 0, 10));
}
public function test_rebuild_without_balance_snapshot_keeps_existing_shop_ledger(): void
{
$connection = DB::connection('business_mirror');
$connection->table('fin_shops')->insert([
'shop_name' => '保留店铺',
'platform' => '天猫',
'shop_balance' => 88,
'created_at' => now(),
'updated_at' => now(),
]);
$result = app(FinanceLedgerShopDataSynchronizer::class)
->syncShopBalances('2026-10-25', true);
$this->assertSame(0, $result['rebuilt']);
$this->assertDatabaseHas('fin_shops', [
'shop_name' => '保留店铺',
'shop_balance' => 88,
], 'business_mirror');
}
public function test_withdrawal_rows_are_mapped_to_shop_account_income_and_are_idempotent(): void
{
Carbon::setTestNow('2026-10-24 09:00:00');

View File

@ -0,0 +1,93 @@
<?php
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
use Modules\EcommerceFinance\Repositories\BusinessInformationMirrorRepository;
use Modules\EcommerceFinance\Services\StoreReportPeriodBuilder;
use Tests\Feature\FeatureTestCase;
class FinanceLedgerShopDirectoryTest extends FeatureTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->user->attachPermission(
Permission::where('name', 'read-admin-panel')->firstOrFail(),
);
}
public function test_shop_ledger_uses_store_report_current_subject_and_platform(): void
{
$openStore = [
'id' => 901,
'platform' => '天猫',
'erp_store_name' => '天猫-报表测试店',
'company_name' => '历史主体',
'store_status' => '0',
'withdrawal_account' => '回款账户甲',
];
$closedStore = [
'id' => 902,
'platform' => '京东',
'erp_store_name' => '京东-已关店',
'company_name' => '历史主体',
'store_status' => '6',
'withdrawal_account' => null,
];
$openStoreWithoutSubject = [
'id' => 903,
'platform' => '淘宝',
'erp_store_name' => '淘宝-无主体店',
'company_name' => null,
'store_status' => '0',
'withdrawal_account' => null,
];
$this->mock(BusinessInformationMirrorRepository::class)
->shouldReceive('allStores')
->once()
->andReturn([$openStore, $closedStore, $openStoreWithoutSubject]);
$this->mock(StoreReportPeriodBuilder::class)
->shouldReceive('build')
->once()
->with([$openStore, $openStoreWithoutSubject])
->andReturn([
'天猫-报表测试店' => [
[
'company_name' => '历史主体',
'effective_at' => '2026-07-01',
'expires_at' => '2026-10-01',
'source' => 'initial',
],
[
'company_name' => '当前存续主体',
'effective_at' => '2026-10-02',
'expires_at' => null,
'source' => 'crawl',
],
],
]);
$this->loginAs()->get($this->pageUrl())
->assertOk()
->assertSeeText('天猫')
->assertSeeText('天猫-报表测试店')
->assertSeeText('当前存续主体')
->assertSeeText('淘宝-无主体店')
->assertSeeText('在营')
->assertSeeText('回款账户甲')
->assertDontSeeText('京东-已关店')
->assertDontSeeText('历史主体');
}
private function pageUrl(): string
{
return route('business.pages.show', [
'company_id' => $this->company->id,
'section' => 'financial-operations',
'page' => 'ledger',
]);
}
}

View File

@ -69,7 +69,7 @@ class LaborExpensePageAccessTest extends FeatureTestCase
);
$this->assertCount(61, $fields);
$this->assertCount(40, $formulaFields);
$this->assertCount(48, $formulaFields);
$response = $this->loginAs($chenxi)->get(route('business.pages.show', [
'section' => 'financial-operations',
@ -87,11 +87,44 @@ class LaborExpensePageAccessTest extends FeatureTestCase
->assertSee('=IF(AN#&lt;=0,0,IF(AN#&lt;=4000,800,AN#*0.2))', false)
->assertSee('=IF(J#&lt;=0,&quot;&quot;,IF(J#&lt;=3000,0.03', false)
->assertSee('=IF(J#&lt;=0,&quot;&quot;,IF(J#&lt;=3000,0,IF(J#&lt;=12000,210', false)
->assertSee('=J#*K#-L#', false)
->assertSee('=IF(F#&lt;=0,&quot;&quot;,IF(F#&lt;=8500,4952', false)
->assertSee('=O#*0.12', false)
->assertSee('=Q#-H#', false)
->assertSee('=S#*T#-U#', false)
->assertSee('=IF(T#&lt;=0.03,0,IF(T#&lt;=0.1,3000,12000))', false)
->assertDontSee('data-labor-row="0"', false);
$html = $response->getContent();
$this->assertSame(61, substr_count($html, 'data-labor-header="'));
$this->assertSame(40, substr_count($html, 'class="labor-expense-formula"'));
$this->assertSame(48, substr_count($html, 'class="labor-expense-formula"'));
}
public function test_basic_deduction_tax_amount_and_housing_fund_base_are_formula_driven(): void
{
$fields = collect(config('labor_expense_table.fields'))->keyBy('key');
$this->assertSame('formula_number', $fields['I']['kind']);
$this->assertSame('=5000', $fields['I']['formula']);
$this->assertSame('formula_number', $fields['AZ']['kind']);
$this->assertSame('=60000', $fields['AZ']['formula']);
$this->assertSame('formula_number', $fields['M']['kind']);
$this->assertSame('=J#*K#-L#', $fields['M']['formula']);
$this->assertSame('=M#*12', $fields['N']['formula']);
$this->assertSame('formula_number', $fields['O']['kind']);
$this->assertSame(
[4952, 8000, 10000, 12000],
$this->housingFundBases($fields['O']['formula'])
);
foreach (['P' => '=O#*0.12', 'Q' => '=O#*0.12', 'R' => '=Q#-H#', 'V' => '=S#*T#-U#'] as $key => $formula) {
$this->assertSame('formula_number', $fields[$key]['kind']);
$this->assertSame($formula, $fields[$key]['formula']);
}
$this->assertSame('formula_number', $fields['AA']['kind']);
$this->assertSame('=IF(T#<=0.03,0,IF(T#<=0.1,3000,12000))', $fields['AA']['formula']);
}
public function test_monthly_and_annual_tax_quick_deductions_are_formula_driven(): void
@ -158,4 +191,16 @@ class LaborExpensePageAccessTest extends FeatureTestCase
return $deductions;
}
private function housingFundBases(string $formula): array
{
preg_match_all('/IF\(F#<=\d+,(\d+)/', $formula, $matches);
$bases = array_map('intval', $matches[1]);
if (preg_match('/,(\d+)\)+\s*$/', $formula, $fallback)) {
$bases[] = (int) $fallback[1];
}
return $bases;
}
}

View File

@ -234,7 +234,7 @@ class ManagementCrudTest extends FeatureTestCase
]);
$this->app->instance(InstallationDetailMirrorRepository::class, $mirror);
$this->loginAs()
$response = $this->loginAs()
->get(route('business.pages.show', [
'section' => 'financial-operations',
'page' => 'installation-details',
@ -288,7 +288,31 @@ class ManagementCrudTest extends FeatureTestCase
->assertSee('data-installation-fee-trend', false)
->assertSee('data-installation-fee-package', false)
->assertSee('data-installation-fee-non-package', false)
->assertSee('border-left: 3px solid #006395', false)
->assertSeeText('当前筛选合计(万元)')
->assertSeeText('结算明细金额(万元)')
->assertSee('data-installation-fee-tab="platform"', false)
->assertSee('data-installation-fee-tab="detail"', false)
->assertSee('data-installation-fee-panel="platform"', false)
->assertSee('data-installation-fee-panel="detail"', false)
->assertSee('installation-fee-panel is-active', false)
->assertSeeText('店铺明细')
->assertSee('overflow-x: auto', false)
->assertSee('data-installation-fee-scroll', false)
->assertSee('scrollbar-color: #b9954f #f1ece3', false)
->assertSee('scrollbar-gutter: stable', false)
->assertSee('cursor: grab', false)
->assertSee('min-width: 72rem', false)
->assertSee("scrollEl.addEventListener('pointerdown'", false)
->assertSee('scrollEl.scrollLeft = dragState.scrollLeft - dx', false)
->assertSeeText('共 0 条平台汇总')
->assertSee('--installation-fee-accent: #856632', false)
->assertSee('border-left: 3px solid var(--installation-fee-accent)', false)
->assertSee('border-right: 3px solid var(--installation-fee-accent)', false)
->assertSee('color: var(--installation-fee-accent)', false)
->assertSee('--installation-fee-table-cell-padding: 0.7rem 0.65rem', false)
->assertSee('--installation-fee-table-head-padding: 0.75rem 0.65rem', false)
->assertSee('padding: var(--installation-fee-table-head-padding)', false)
->assertSee('vertical-align: middle', false)
->assertSee('height: 8rem', false)
->assertSee('font-size: 2.5rem', false)
->assertSee('font-family: "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace', false)
@ -296,6 +320,13 @@ class ManagementCrudTest extends FeatureTestCase
->assertSee('function captionRange(value)', false)
->assertSee('function setCardValue(total, rows, value, data)', false)
->assertSee('function wanAmount(value)', false)
->assertSee('function wanYuan(value)', false)
->assertSee('amount.textContent = wanYuan(row.amount)', false)
->assertSee('currentTotal.textContent = wanYuan(total)', false)
->assertSee('function activateTab(name, focusTab)', false)
->assertSee("panel.style.display = selected ? 'block' : 'none'", false)
->assertSee("tabsEl.addEventListener('click'", false)
->assertSee("event.key === 'ArrowRight'", false)
->assertSeeText('平台')
->assertSeeText('店铺名称')
->assertSeeText('安装公司')
@ -313,6 +344,13 @@ class ManagementCrudTest extends FeatureTestCase
->assertSeeText('测试安装公司')
->assertSeeText('120.50')
->assertSeeText('共 1 条');
$html = $response->getContent();
$platformSummaryPosition = strpos($html, 'class="installation-fee-platform-summary"');
$detailTablePosition = strpos($html, '<th scope="col">店铺名称</th>');
$this->assertNotFalse($platformSummaryPosition);
$this->assertNotFalse($detailTablePosition);
$this->assertLessThan($detailTablePosition, $platformSummaryPosition);
}
public function testInstallationDetailsExportUsesFiltersAndMirrorRows(): void

View File

@ -46,7 +46,6 @@ class ProcessDetailsPageTest extends FeatureTestCase
'scope' => 'personal_permission',
]);
$repository->shouldReceive('filterOptions')->once()->andReturn([
'months' => ['2026-01'],
'document_types' => ['公摊日常报销'],
'statuses' => ['已完成'],
]);
@ -67,6 +66,8 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertSee('审批编号')
->assertSee('发起人')
->assertSee('单据类型')
->assertSee('打款日期')
->assertSee('name="paid_date"', false)
->assertSee('银行付款金额')
->assertSee('202601011200000000001')
->assertSee('张三')

View File

@ -17,7 +17,7 @@ class SystemizationTodosTest extends FeatureTestCase
{
Storage::fake('uploads');
$this->loginAs()
$pageResponse = $this->loginAs()
->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
@ -28,13 +28,10 @@ class SystemizationTodosTest extends FeatureTestCase
->assertSeeText('从 Excel 同步待办')
->assertSeeText('总负责人')
->assertSeeText('责任人')
->assertSeeText('类型序号')
->assertSeeText('内容序号')
->assertSeeText('待办序号')
->assertSeeText('待办事项序号')
->assertSeeText('已逾期')
->assertSeeText('开始时间')
->assertSeeText('完成时间')
->assertSeeText('新增一条')
->assertSee('data-sys-todo-create', false)
->assertSee('data-sys-todo-owner-filter', false)
->assertSee('data-sys-todo-assignee-filter', false)
@ -42,15 +39,33 @@ class SystemizationTodosTest extends FeatureTestCase
->assertSee('name="assignee[]"', false)
->assertSee('data-sys-todo-category-select', false)
->assertSee('data-sys-todo-new-category-input', false)
->assertSee('data-sys-todo-section-select', false)
->assertSee('data-sys-todo-new-section-input', false)
->assertSee('data-sys-todo-position', false)
->assertSee('data-sys-todo-insert-after', false)
->assertSeeText('待办事项序号')
->assertDontSee('name="type_sequence"', false)
->assertDontSee('name="content_sequence"', false)
->assertDontSee('name="item_sequence"', false)
->assertSee('data-sys-todo-group-edit', false)
->assertSee('id="sysTodoGroupDialog"', false)
->assertDontSee('sys-todo-table__clamp', false)
->assertSeeText('+ 新增类型')
->assertSeeText('+ 新增内容')
->assertSeeText('点击序号旁的+可在该条之后插入')
->assertSee('data-sys-todo-choose-files', false)
->assertSee('data-sys-todo-open-delete', false)
->assertSee('id="sysTodoDeleteConfirm"', false)
->assertSee('data-sys-todo-table-wrap', false)
->assertSee('data-sys-todo-scrollrail', false)
->assertDontSee('playlist_add', false)
->assertDontSee('<th scope="col">操作</th>', false)
->assertDontSeeText('下一页')
->assertSee('id="sysTodoImageViewer"', false);
$this->assertSame(
1,
substr_count((string) $pageResponse->getContent(), 'data-sys-todo-create>'),
);
$storeResponse = $this->post(route('business.systemization-todos.store'), [
'category' => '收入',
@ -127,6 +142,174 @@ class SystemizationTodosTest extends FeatureTestCase
$this->assertSoftDeleted('business_systemization_todos', ['id' => $todo->id]);
}
public function test_can_insert_a_todo_at_a_selected_sequence_and_shift_existing_items(): void
{
$this->loginAs();
$items = [];
foreach (range(1, 7) as $index) {
$items[$index] = $this->createTodo(
'收入',
'平台收入核对',
'原待办 ' . $index,
'2026-11-30',
$index,
);
}
$initialPage = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
]))->assertOk()
->assertSee('title="在第 3 条后新增一条"', false)
->assertSee('data-sys-todo-insert-position="4"', false);
$this->assertMatchesRegularExpression(
'/id="sys-todo-row-' . $items[3]->id . '".*?data-sys-todo-insert-position="4"/s',
(string) $initialPage->getContent(),
);
$this->post(route('business.systemization-todos.store'), [
'category' => '收入',
'section' => '平台收入核对',
'position' => 7,
'title' => '新增待办 7',
'owner' => '晨曦',
'assignee' => '栎阳',
'status' => SystemizationTodo::STATUS_PENDING,
])->assertRedirect()
->assertSessionHas('success', '待办事项已新增为当前内容第 7 条并定位。');
$page = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
]))->assertOk()->viewData('content');
$group = $page['items']
->where('category', '收入')
->where('section', '平台收入核对')
->values();
$this->assertSame([
'原待办 1',
'原待办 2',
'原待办 3',
'原待办 4',
'原待办 5',
'原待办 6',
'新增待办 7',
'原待办 7',
], $group->pluck('title')->all());
$this->assertSame(
range(1, 8),
$group->pluck('item_sequence')->map(static fn (mixed $value): int => (int) $value)->all(),
);
$this->assertGreaterThan(
$items[6]->fresh()->sort_order,
$items[7]->fresh()->sort_order,
);
$this->patch(route('business.systemization-todos.update', ['todo' => $items[7]->id]), [
'category' => '收入',
'section' => '平台收入核对',
'position' => 2,
'title' => '原待办 7',
'owner' => '晨曦',
'assignee' => '栎阳',
'status' => SystemizationTodo::STATUS_PENDING,
])->assertRedirect();
$reordered = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
]))->assertOk()->viewData('content')['items']
->where('category', '收入')
->where('section', '平台收入核对')
->values();
$this->assertSame([
'原待办 1',
'原待办 7',
'原待办 2',
'原待办 3',
'原待办 4',
'原待办 5',
'原待办 6',
'新增待办 7',
], $reordered->pluck('title')->all());
}
public function test_can_add_a_new_sequence_after_the_last_todo(): void
{
$this->loginAs();
foreach (range(1, 7) as $index) {
$this->createTodo(
'收入',
'平台收入核对',
'原待办 ' . $index,
'2026-11-30',
$index,
);
}
$this->post(route('business.systemization-todos.store'), [
'category' => '收入',
'section' => '平台收入核对',
'position' => 8,
'title' => '新增待办 8',
'owner' => '晨曦',
'assignee' => '栎阳',
'status' => SystemizationTodo::STATUS_PENDING,
])->assertRedirect()
->assertSessionHas('success', '待办事项已新增为当前内容第 8 条并定位。');
$group = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
]))->assertOk()->viewData('content')['items']
->where('category', '收入')
->where('section', '平台收入核对')
->values();
$this->assertSame([
'原待办 1',
'原待办 2',
'原待办 3',
'原待办 4',
'原待办 5',
'原待办 6',
'原待办 7',
'新增待办 8',
], $group->pluck('title')->all());
$this->assertSame(8, (int) $group->last()->item_sequence);
}
public function test_type_and_content_cells_can_be_edited_for_the_whole_group(): void
{
$this->loginAs();
$incomeA = $this->createTodo('收入', '平台收入核对', '收入事项 A', '2026-11-30', 1);
$incomeB = $this->createTodo('收入', '平台收入核对', '收入事项 B', '2026-11-30', 2);
$incomeOther = $this->createTodo('收入', '退款核对', '退款事项', '2026-11-30', 3);
$cost = $this->createTodo('成本', '成本核对', '成本事项', '2026-11-30', 4);
$this->patch(route('business.systemization-todos.category', ['todo' => $incomeA->id]), [
'category' => '业务收入',
])->assertRedirect();
foreach ([$incomeA, $incomeB, $incomeOther] as $todo) {
$this->assertSame('业务收入', $todo->fresh()->category);
}
$this->assertSame('成本', $cost->fresh()->category);
$this->patch(route('business.systemization-todos.section', ['todo' => $incomeA->id]), [
'section' => '收入核对新版',
])->assertRedirect();
$this->assertSame('收入核对新版', $incomeA->fresh()->section);
$this->assertSame('收入核对新版', $incomeB->fresh()->section);
$this->assertSame('退款核对', $incomeOther->fresh()->section);
$this->assertSame('成本核对', $cost->fresh()->section);
}
public function test_excel_import_preserves_hierarchy_and_does_not_overwrite_existing_rows(): void
{
$path = sys_get_temp_dir() . '/systemization-todos-' . uniqid() . '.xlsx';
@ -179,7 +362,7 @@ class SystemizationTodosTest extends FeatureTestCase
{
$this->loginAs();
$this->createTodo('收入', '1、平台收入核对', '1、收入事项 A', '2026-10-26', 1, '晨曦', '栎阳、秋香');
$this->createTodo('1、收入', '1、平台收入核对', '1、收入事项 A', '2026-10-26', 1, '晨曦', '栎阳、秋香');
$this->createTodo('收入', '平台收入核对', '2、收入事项 B', '2026-10-27', 2);
$this->createTodo('成本', '3、退款核销', '3、成本事项', '2026-10-26', 3, '常仪', '山时');
$this->createTodo('费用', '4、逾期核对', '4、逾期事项', '2026-10-20', 4, '人参', '玉兔');
@ -191,7 +374,7 @@ class SystemizationTodosTest extends FeatureTestCase
$pageResponse
->assertOk()
->assertSee('rowspan="2"', false)
->assertSee('<th scope="col">内容</th><th scope="col">待办序号</th><th scope="col">待办事项</th>', false)
->assertSee('<th scope="col">内容</th><th scope="col">待办事项序号</th><th scope="col">待办事项</th>', false)
->assertSee('sys-todo-table__type', false)
->assertSee('title="类型序号">1</span>', false)
->assertSee('title="内容序号">1</span>', false)
@ -203,6 +386,8 @@ class SystemizationTodosTest extends FeatureTestCase
->assertSee('收入事项 A')
->assertSee('收入事项 B');
$pageContent = $pageResponse->viewData('content');
$this->assertContains('平台收入核对', $pageContent['todoContentOptions']['收入']);
$this->assertArrayNotHasKey('1、收入', $pageContent['todoContentOptions']);
$this->assertSame(
['__overdue__', '待办'],
array_column($pageContent['todoStatusOptions']->all(), 'value'),
@ -210,7 +395,7 @@ class SystemizationTodosTest extends FeatureTestCase
$pageItems = $pageContent['items'];
$this->assertSame(
[1, 1],
$pageItems->where('category', '收入')
$pageItems->where('category_display', '收入')
->pluck('type_sequence')
->map(static fn (mixed $value): int => (int) $value)
->values()
@ -218,7 +403,7 @@ class SystemizationTodosTest extends FeatureTestCase
);
$this->assertSame(
[1, 2],
$pageItems->where('category', '收入')
$pageItems->where('category_display', '收入')
->pluck('item_sequence')
->map(static fn (mixed $value): int => (int) $value)
->values()
@ -233,22 +418,6 @@ class SystemizationTodosTest extends FeatureTestCase
->all(),
);
$sequenceResponse = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
'category' => '收入',
'item_sequence' => 2,
]))->assertOk();
$sequenceContent = $sequenceResponse->viewData('content');
$this->assertSame(['2、收入事项 B'], $sequenceContent['items']->pluck('title')->all());
$typeSequenceContent = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
'type_sequence' => 2,
]))->assertOk()->viewData('content');
$this->assertSame(['3、成本事项'], $typeSequenceContent['items']->pluck('title')->all());
$highlightedTodo = $pageItems->firstWhere('title', '2、收入事项 B');
$this->get(route('business.pages.show', [
'section' => 'other',
@ -343,16 +512,6 @@ class SystemizationTodosTest extends FeatureTestCase
->values()
->all(),
);
$contentResponse = $this->get(route('business.pages.show', [
'section' => 'other',
'page' => 'systemization-todos',
'type_sequence' => 1,
'content_sequence' => 2,
]))->assertOk();
$this->assertSame(
[$secondContent->id],
$contentResponse->viewData('content')['items']->pluck('id')->all(),
);
$this->assertSame(
[$completed->id, $inProgress->id],
$items
@ -364,7 +523,10 @@ class SystemizationTodosTest extends FeatureTestCase
);
$this->assertSame(
1,
substr_count((string) $response->getContent(), '>' . $mergedSection . '<'),
substr_count(
(string) $response->getContent(),
'sys-todo-table__group-text">' . $mergedSection . '</span>',
),
);
}
@ -461,6 +623,77 @@ class SystemizationTodosTest extends FeatureTestCase
}
}
public function test_excel_sync_splits_numbered_titles_and_keeps_attachment_on_first_item(): void
{
Storage::fake('uploads');
$this->loginAs();
$combinedTitle = "1、核对平台收入\n\n2、核对订单收入\n3,核对特殊订单";
$historical = SystemizationTodo::query()->create([
'company_id' => (int) company_id(),
'category' => '收入',
'section' => '平台收入核对',
'title' => $combinedTitle,
'owner' => '晨曦',
'assignee' => '栎阳',
'start_date' => '2026-10-20',
'due_date' => '2026-10-21',
'status' => SystemizationTodo::STATUS_COMPLETED,
'completed_at' => '2026-10-21',
'progress' => '已完成',
'sort_order' => 2,
'source_key' => 'legacy-combined-row',
'imported_at' => now(),
'created_by' => user_id(),
'updated_by' => user_id(),
]);
Storage::disk('uploads')->put('systemization-todos/combined.png', 'image');
SystemizationTodoAttachment::query()->create([
'company_id' => (int) company_id(),
'systemization_todo_id' => $historical->id,
'path' => 'systemization-todos/combined.png',
'original_name' => 'combined.png',
'mime_type' => 'image/png',
'size' => 5,
'uploaded_by' => user_id(),
]);
$path = sys_get_temp_dir() . '/systemization-split-' . uniqid() . '.xlsx';
try {
$this->writeWorkbook($path, [
['收入', '平台收入核对', $combinedTitle, '晨曦', '栎阳', '2026-10-20', '2026-10-21', '已完成', null],
]);
$preview = app(SystemizationTodoWorkbookImporter::class)
->sync($path, (int) company_id(), user_id(), true);
$this->assertSame(2, $preview['created']);
$this->assertSame(1, $preview['updated']);
$this->assertSame(0, $preview['retained']);
$result = app(SystemizationTodoWorkbookImporter::class)
->sync($path, (int) company_id(), user_id());
$this->assertSame(2, $result['created']);
$this->assertSame(1, $result['updated']);
$this->assertSame(0, $result['retained']);
$todos = SystemizationTodo::query()->orderBy('sort_order')->get();
$this->assertSame([
'核对平台收入',
'核对订单收入',
'核对特殊订单',
], $todos->pluck('title')->all());
$this->assertSame($historical->id, $todos->first()->id);
$this->assertSame(1, $todos->first()->attachments()->count());
$secondResult = app(SystemizationTodoWorkbookImporter::class)
->sync($path, (int) company_id(), user_id());
$this->assertSame(0, $secondResult['created']);
$this->assertSame(0, $secondResult['updated']);
$this->assertSame(3, SystemizationTodo::query()->count());
} finally {
@unlink($path);
}
}
private function createTodo(
string $category,
string $section,

View File

@ -125,6 +125,17 @@ class BusinessMirrorScheduleTest extends TestCase
$this->assertStringContainsString('esign:poll-signatures --quiet', $contents, $script);
$this->assertStringContainsString('/run/caiwu-esign-polling.lock', $contents, $script);
$this->assertSame(1, substr_count($contents, 'esign:poll-signatures --quiet'), $script);
$this->assertStringNotContainsString('finance-ledger:sync-shop-data', $contents, $script);
$this->assertStringContainsString(
'# 财务台账:每天 02:30 同步 AI 库动账并重算流水;店铺台账默认不自动回填。',
$contents,
$script,
);
$this->assertStringContainsString(
'30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --quiet >/dev/null 2>&1',
$contents,
$script,
);
}
}

View File

@ -93,4 +93,31 @@ class FinanceBatchIsolationTest extends TestCase
rmdir($directory);
}
}
public function test_business_mirror_history_backfill_runs_in_the_isolated_batch_profile(): void
{
$directory = sys_get_temp_dir() . '/caiwu-mirror-batch-' . bin2hex(random_bytes(6));
mkdir($directory);
$arguments = [
'business-mirror:sync-tables',
'jiansun.dbo.fys_Ticketing_install_item',
'--full',
'--batch=500',
'--max-batches=20',
];
try {
$process = $this->runBatch($directory, $arguments);
$this->assertTrue($process->isSuccessful(), $process->getErrorOutput());
$called = file($directory . '/called', FILE_IGNORE_NEW_LINES);
$this->assertContains('batch', $called);
$this->assertContains('--no-deps', $called);
$this->assertSame('image=123456789abc', $called[0]);
$this->assertSame($arguments, array_slice($called, -count($arguments)));
} finally {
foreach (glob($directory . '/*') as $path) {
unlink($path);
}
rmdir($directory);
}
}
}

View File

@ -46,18 +46,22 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
$this->assertSame('personal_permission', $result['scope']);
$options = $this->repository->filterOptions();
$this->assertSame(['2026-02', '2026-01'], $options['months']);
$this->assertArrayNotHasKey('months', $options);
$this->assertContains('公摊日常报销', $options['document_types']);
$this->assertContains('应付申请流程', $options['document_types']);
$this->assertContains('已完成', $options['statuses']);
$this->assertContains('审批中', $options['statuses']);
}
public function test_paginate_applies_month_status_and_keyword_filters(): void
public function test_paginate_applies_paid_date_status_and_keyword_filters(): void
{
$this->assertSame(
2,
$this->repository->paginate(['month' => '2026-01'], 1, 50)['total'],
1,
$this->repository->paginate(['paid_date' => '2026-01-02'], 1, 50)['total'],
);
$this->assertSame(
1,
$this->repository->paginate(['paid_date' => '2026-02-03'], 1, 50)['total'],
);
$this->assertSame(
2,
@ -110,10 +114,10 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
{
$now = now();
$rows = [
$this->row('202601011200000000001', 1, '202601', '张三', '已完成', '公摊日常报销', '办公用品采购', 100.00),
$this->row('202601011200000000001', 2, '202601', '张三', '已完成', '公摊日常报销', '交通费', 50.50),
$this->row('202602031200000000002', 1, '202602', '李四', '审批中', '应付申请流程', '供应商货款', 200.00),
$this->row('202602031200000000002', 2, '202602', '李四', '审批中', '应付申请流程', '供应商货款', 300.00),
$this->row('202601011200000000001', 1, '202601', '张三', '已完成', '公摊日常报销', '办公用品采购', 100.00, '2026-01-02 00:00'),
$this->row('202601011200000000001', 2, '202601', '张三', '已完成', '公摊日常报销', '交通费', 50.50, '2026-01-15 00:00'),
$this->row('202602031200000000002', 1, '202602', '李四', '审批中', '应付申请流程', '供应商货款', 200.00, '2026-02-03 00:00'),
$this->row('202602031200000000002', 2, '202602', '李四', '审批中', '应付申请流程', '供应商货款', 300.00, '2026-02-20 00:00'),
];
DB::connection('business_mirror')
@ -151,6 +155,7 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
string $documentType,
string $purpose,
float $amount,
string $paidAt,
): array {
$now = now();
@ -169,7 +174,7 @@ class DingProcessDetailMirrorRepositoryTest extends TestCase
'bank_account_name' => '华夏银行-测试',
'bank_amount' => $amount,
'payment_method' => '银行卡',
'paid_at' => '2026-01-02 00:00',
'paid_at' => $paidAt,
'source_scope' => 'personal_permission',
'synced_at' => $now,
'created_at' => $now,

View File

@ -0,0 +1,85 @@
<?php
namespace Tests\Unit\EcommerceFinance;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Modules\EcommerceFinance\Repositories\DingProcessDetailMirrorRepository;
use Modules\EcommerceFinance\View\ProcessDetailsPageData;
use PHPUnit\Framework\TestCase;
class ProcessDetailsPageDataTest extends TestCase
{
public function test_embedded_process_page_uses_content_only_without_nested_admin_layout(): void
{
$root = dirname(__DIR__, 3);
$page = (string) file_get_contents(
$root . '/resources/views/business/pages/financial-operations/process-details.blade.php',
);
$content = (string) file_get_contents(
$root . '/resources/views/business/pages/financial-operations/process-details-content.blade.php',
);
$this->assertStringContainsString('$processDetailsEmbedded', $page);
$this->assertStringContainsString(
"@include('business.pages.financial-operations.process-details-content')",
$page,
);
$this->assertStringNotContainsString('<x-layouts.admin>', $content);
$this->assertStringContainsString('class="process-details-page"', $content);
$this->assertStringContainsString('class="process-details-table-card"', $content);
$this->assertStringContainsString('class="process-details-pagination"', $content);
$this->assertStringContainsString('class="process-details-page-jump"', $content);
$this->assertStringNotContainsString('$processRows->links()', $content);
}
public function test_page_data_contains_real_paginator_filters_and_summary(): void
{
$row = (object) [
'business_id' => '202610241052000241951',
'line_no' => 1,
'status' => '审批中',
];
$repository = $this->createMock(DingProcessDetailMirrorRepository::class);
$repository->expects($this->once())
->method('paginate')
->with($this->callback(static fn (array $filters): bool => $filters['paid_date'] === '2026-10-24'), 2, 50)
->willReturn([
'data' => [$row],
'total' => 11331,
'summary' => [
'rows' => 11331,
'approvals' => 4775,
'amount_total' => 225953332.98,
'bank_amount_total' => 225862410.66,
],
'status' => 'succeeded',
'last_synced_at' => '2026-10-26 16:55:11',
'scope' => 'personal_permission',
]);
$repository->expects($this->once())
->method('filterOptions')
->willReturn([
'document_types' => ['种菜核销/种菜报销'],
'statuses' => ['审批中'],
]);
$data = (new ProcessDetailsPageData($repository))->page(Request::create(
'/1/workspace/financial-operations/process-details',
'GET',
['paid_date' => '2026-10-24', 'page' => 2],
));
$this->assertInstanceOf(LengthAwarePaginator::class, $data['processRows']);
$this->assertSame(11331, $data['processRows']->total());
$this->assertSame(50, $data['processRows']->perPage());
$this->assertSame(2, $data['processRows']->currentPage());
$this->assertSame($row, $data['processRows']->items()[0]);
$this->assertSame('succeeded', $data['mirrorStatus']);
$this->assertSame(11331, $data['summary']['rows']);
$this->assertSame('2026-10-24', $data['filters']['paid_date']);
$this->assertArrayNotHasKey('months', $data);
$this->assertNull($data['error']);
}
}

View File

@ -469,7 +469,7 @@ class StoreReportRepositoryTest extends TestCase
$this->assertSame('小规模纳税人', $rows['存续主体']->tax_type);
$this->assertSame('/', $rows['存续主体']->business_registration_type);
$this->assertSame('/', $rows['注销主体']->tax_type);
$this->assertSame('一般纳税人', $rows['注销主体']->tax_type);
$this->assertSame('/', $rows['注销主体']->business_registration_type);
$this->assertSame(1, $summaryCards['正常存续主体']['value']);
$this->assertSame(30.0, (float) $summaryCards['上月(8月)收入']['value']);
@ -523,7 +523,7 @@ class StoreReportRepositoryTest extends TestCase
$summaryCards = collect($this->app['request']->attributes->get('business-page-summary-cards'))->keyBy('label');
$this->assertSame('/', $rows['保留主体']->business_registration_type);
$this->assertSame('/', $rows['待注销主体']->tax_type);
$this->assertSame('一般纳税人', $rows['待注销主体']->tax_type);
$this->assertSame('/', $rows['待注销主体']->business_registration_type);
$this->assertSame(1, $summaryCards['正常存续主体']['value']);
$this->assertSame(30.0, (float) $summaryCards['上月(8月)收入']['value']);