diff --git a/app/Http/Controllers/Business/SystemizationTodos.php b/app/Http/Controllers/Business/SystemizationTodos.php index 1420c6aa..e1538461 100644 --- a/app/Http/Controllers/Business/SystemizationTodos.php +++ b/app/Http/Controllers/Business/SystemizationTodos.php @@ -106,27 +106,6 @@ class SystemizationTodos extends Controller }); $items = $items->sortBy('hierarchy_order')->values(); $positionGroups = $this->positionGroups($sequenceMap); - 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(); - } $base = SystemizationTodo::query(); $categories = SystemizationTodo::query() @@ -428,7 +407,11 @@ class SystemizationTodos extends Controller ); } - private function contentSiblings(?string $category, ?string $section): Collection + private function contentSiblings( + ?string $category, + ?string $section, + ?int $excludeId = null, + ): Collection { $categoryKey = $this->hierarchyGroupKey($this->hierarchyLabel($category)); $sectionKey = $this->hierarchyGroupKey($this->hierarchyLabel($section)); @@ -439,12 +422,54 @@ class SystemizationTodos extends Controller ->lockForUpdate() ->get() ->filter(fn (SystemizationTodo $todo): bool => - $this->hierarchyGroupKey($this->hierarchyLabel($todo->category)) === $categoryKey + (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)); @@ -480,6 +505,7 @@ class SystemizationTodos extends Controller 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); @@ -500,7 +526,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); @@ -572,9 +607,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', '')), ]; } diff --git a/deploy/activate-incremental-release.sh b/deploy/activate-incremental-release.sh index 131cc511..4321641b 100644 --- a/deploy/activate-incremental-release.sh +++ b/deploy/activate-incremental-release.sh @@ -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 diff --git a/deploy/activate-release.sh b/deploy/activate-release.sh index 93efb479..5a6684e0 100644 --- a/deploy/activate-release.sh +++ b/deploy/activate-release.sh @@ -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 diff --git a/docs/财务台账开发说明.md b/docs/财务台账开发说明.md index c5ac60c2..b654644a 100644 --- a/docs/财务台账开发说明.md +++ b/docs/财务台账开发说明.md @@ -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`。 diff --git a/resources/views/business/pages/partials/installation-fee-summary.blade.php b/resources/views/business/pages/partials/installation-fee-summary.blade.php index 83e4aab6..fabf2bc6 100644 --- a/resources/views/business/pages/partials/installation-fee-summary.blade.php +++ b/resources/views/business/pages/partials/installation-fee-summary.blade.php @@ -470,18 +470,6 @@
- - - - - - - - - - -
店铺名称安装公司收款渠道结算明细金额
-
请选择客服审核日期后查看明细

平台汇总

@@ -494,6 +482,18 @@
+ + + + + + + + + + +
店铺名称安装公司收款渠道结算明细金额
+
请选择客服审核日期后查看明细
共 0 条明细汇总 diff --git a/resources/views/business/pages/systemization-todos.blade.php b/resources/views/business/pages/systemization-todos.blade.php index 2c555b77..380637b1 100644 --- a/resources/views/business/pages/systemization-todos.blade.php +++ b/resources/views/business/pages/systemization-todos.blade.php @@ -215,9 +215,6 @@ @endforeach - - - @php $selectedOwners = $todoOwners->filter( static fn (string $owner): bool => in_array($owner, $todoFilters['owners'], true) @@ -345,7 +342,7 @@ - + @@ -363,6 +360,7 @@ }; $todoPayload = [ 'id' => $item->id, + 'position' => (int) $item->item_sequence, 'category' => $item->category ?? '', 'section' => $sectionLabels[$loop->index] ?? '', 'title' => $titleLabels[$loop->index] ?? '', @@ -489,7 +487,7 @@ - '); + $this->assertNotFalse($platformSummaryPosition); + $this->assertNotFalse($detailTablePosition); + $this->assertLessThan($detailTablePosition, $platformSummaryPosition); } public function testInstallationDetailsExportUsesFiltersAndMirrorRows(): void diff --git a/tests/Feature/Business/SystemizationTodosTest.php b/tests/Feature/Business/SystemizationTodosTest.php index 4ed5ecea..739cabf5 100644 --- a/tests/Feature/Business/SystemizationTodosTest.php +++ b/tests/Feature/Business/SystemizationTodosTest.php @@ -28,9 +28,7 @@ class SystemizationTodosTest extends FeatureTestCase ->assertSeeText('从 Excel 同步待办') ->assertSeeText('总负责人') ->assertSeeText('责任人') - ->assertSeeText('类型序号') - ->assertSeeText('内容序号') - ->assertSeeText('待办序号') + ->assertSeeText('待办事项序号') ->assertSeeText('已逾期') ->assertSeeText('开始时间') ->assertSeeText('完成时间') @@ -43,6 +41,10 @@ class SystemizationTodosTest extends FeatureTestCase ->assertSee('data-sys-todo-category-select', false) ->assertSee('data-sys-todo-new-category-input', false) ->assertSee('data-sys-todo-position', 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) @@ -184,6 +186,34 @@ class SystemizationTodosTest extends FeatureTestCase $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_type_and_content_cells_can_be_edited_for_the_whole_group(): void @@ -278,7 +308,7 @@ class SystemizationTodosTest extends FeatureTestCase $pageResponse ->assertOk() ->assertSee('rowspan="2"', false) - ->assertSee('', false) + ->assertSee('', false) ->assertSee('sys-todo-table__type', false) ->assertSee('title="类型序号">1', false) ->assertSee('title="内容序号">1', false) @@ -320,22 +350,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', @@ -430,16 +444,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 diff --git a/tests/Unit/Deployment/BusinessMirrorScheduleTest.php b/tests/Unit/Deployment/BusinessMirrorScheduleTest.php index 47fb49d1..c76bcbe4 100644 --- a/tests/Unit/Deployment/BusinessMirrorScheduleTest.php +++ b/tests/Unit/Deployment/BusinessMirrorScheduleTest.php @@ -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, + ); } }
类型内容待办序号待办事项总负责人责任人类型内容待办事项序号待办事项总负责人责任人 开始时间完成时间状态完成情况完成截图备注
店铺名称内容待办序号待办事项内容待办事项序号待办事项