From 083d5c03f1bf9b654277d4289313d0664ec36d2f Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Thu, 19 Nov 2026 11:44:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=A7=8D=E8=8F=9C?= =?UTF-8?q?=E6=8A=A5=E9=94=80=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E4=B8=8E=E6=98=8E=E7=BB=86=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...PlantingReimbursementWorkbenchPageData.php | 4 +- .../planting-workbench-assets.blade.php | 330 ++++++++++++++++++ .../planting-workbench-settings.blade.php | 16 + ...planting-reimbursement-workbench.blade.php | 255 +++++--------- .../PlantingReimbursementWorkbenchTest.php | 32 ++ 5 files changed, 474 insertions(+), 163 deletions(-) create mode 100644 resources/views/business/pages/billing-transactions/partials/planting-workbench-assets.blade.php create mode 100644 resources/views/business/pages/billing-transactions/partials/planting-workbench-settings.blade.php diff --git a/modules/EcommerceFinance/View/PlantingReimbursementWorkbenchPageData.php b/modules/EcommerceFinance/View/PlantingReimbursementWorkbenchPageData.php index d546cd1a..2daecaa5 100644 --- a/modules/EcommerceFinance/View/PlantingReimbursementWorkbenchPageData.php +++ b/modules/EcommerceFinance/View/PlantingReimbursementWorkbenchPageData.php @@ -81,10 +81,8 @@ class PlantingReimbursementWorkbenchPageData } } + // 保留完整批次供页面局部筛选;切换结果不重新取单,也不改变汇总或导出范围。 $rows = $result['rows'] ?? []; - if ($filters['decision'] !== 'all') { - $rows = array_values(array_filter($rows, static fn (array $row): bool => $row['decision'] === $filters['decision'])); - } // 先看要处理的:取消、待复查在前。 $order = [Auditor::DECISION_CANCEL => 0, Auditor::DECISION_RECHECK => 1, Auditor::DECISION_PASS => 2]; usort($rows, static fn (array $a, array $b): int => [$order[$a['decision']], $a['initiator'], $a['paid_at']] <=> [$order[$b['decision']], $b['initiator'], $b['paid_at']]); diff --git a/resources/views/business/pages/billing-transactions/partials/planting-workbench-assets.blade.php b/resources/views/business/pages/billing-transactions/partials/planting-workbench-assets.blade.php new file mode 100644 index 00000000..1164367e --- /dev/null +++ b/resources/views/business/pages/billing-transactions/partials/planting-workbench-assets.blade.php @@ -0,0 +1,330 @@ + +@push('body_end') + +@endpush diff --git a/resources/views/business/pages/billing-transactions/partials/planting-workbench-settings.blade.php b/resources/views/business/pages/billing-transactions/partials/planting-workbench-settings.blade.php new file mode 100644 index 00000000..14f7d05f --- /dev/null +++ b/resources/views/business/pages/billing-transactions/partials/planting-workbench-settings.blade.php @@ -0,0 +1,16 @@ +
钉钉机器人设置{{ $workbenchRobot['configured'] ? '(已配置)' : '(未配置)' }} +
+ @csrf + @foreach($exportQuery as $key => $value)@endforeach + + + + + + + @if($workbenchRobot['digest_webhook'])@endif + +

Webhook 和密钥加密保存,页面不回显,留空表示不改。每天 10:25 自动把当天批次汇总推到群里并 @ 报销人;取消通知要在上面核对后手动点发送。

+
+
+
校验规则

取单与聚工单锁单一致:种菜报销、工单状态待处理(可切换处理中)、订单付款时间默认报销日前 7 天至前一天、ERP订单状态不为取消 / 删除 / 空、售后单号为空。重复报销(本月、上月已报销过或本批重复)、最终报销金额 ≠ 任务付款+快递费+佣金+京喜差价−扣款−空包费、发起人不在报销佣金人员名单却报了佣金、收款人不在花名册在职名单(柴嘉伟(建行)除外)、ERP订单标签含「以旧换新」的天猫 / 淘宝店报销金额大于买家实付(取工单买家实付、看板订单实付金额中最低的)→ 取消工单;查不到标签且大于买家实付的待复查。看板标「超额」的按 ID负责人 分组:每日超额且付款都在同一天的,按付款时间先后报到日限额为止,其余取消;不在同一天的全部取消。看板提示职级为空的取消工单,群里告知原因「职级为空」。看板没匹配到的待复查。店铺查不到利润中心只提示,可上传店铺信息补齐。

diff --git a/resources/views/business/pages/billing-transactions/planting-reimbursement-workbench.blade.php b/resources/views/business/pages/billing-transactions/planting-reimbursement-workbench.blade.php index 4df6fc8e..5af85b08 100644 --- a/resources/views/business/pages/billing-transactions/planting-reimbursement-workbench.blade.php +++ b/resources/views/business/pages/billing-transactions/planting-reimbursement-workbench.blade.php @@ -2,179 +2,114 @@ use Modules\EcommerceFinance\Services\PlantingReimbursementAuditor as Auditor; use Modules\EcommerceFinance\Services\PlantingReimbursementReferences as References; use Modules\EcommerceFinance\Services\PlantingReimbursementWorkbookExporter as Exporter; + use Modules\EcommerceFinance\Services\PlantingReimbursementWorkbench as Workbench; use Modules\EcommerceFinance\View\PlantingReimbursementWorkbenchPageData as PageData; - $columns = PageData::COLUMNS; + $defaultColumns = ['decision_label', 'work_order_no', 'initiator', 'shop_name', 'reimbursement_amount', 'issue_text', 'online_order_no', 'paid_at', 'payee_name']; + $columns = array_replace(array_fill_keys($defaultColumns, ''), PageData::COLUMNS); $summary = $workbenchSummary; - $syncLabels = ['ready' => '工单镜像已同步', 'failed' => '最近一次同步失败,展示上次成功数据', 'initializing' => '首次同步中', 'initial_failed' => '首次同步失败', 'unavailable' => '镜像未建立']; - $resultClass = [Auditor::DECISION_PASS => 'is-exempt', Auditor::DECISION_CANCEL => 'is-deduct', Auditor::DECISION_RECHECK => '']; $monitorUpload = $workbenchUploads[References::KIND_MONITOR] ?? null; $exportQuery = ['date' => $workbenchFilters['date'], 'paid_from' => $workbenchFilters['paid_from'], 'scope' => $workbenchFilters['scope']]; + $syncLabels = ['ready' => '工单已同步', 'failed' => '同步失败', 'initializing' => '首次同步中', 'initial_failed' => '首次同步失败', 'unavailable' => '数据未就绪']; + $checkCount = $summary ? count(array_filter($summary['checks'], fn ($check) => $check['ok'])) : 0; @endphp -
-
-

报销日 {{ $workbenchFilters['date'] }}:按锁单口径取付款时间 {{ $workbenchWindow['from'] }} 至 {{ $workbenchWindow['to'] }}、工单状态「{{ \Modules\EcommerceFinance\Services\PlantingReimbursementWorkbench::SCOPES[$workbenchFilters['scope']] }}」、ERP订单状态不为取消 / 删除 / 空、售后单号为空的种菜工单,按《种菜报销规则与操作步骤》逐单校验,生成打款明细、钉钉「种菜报销流程」明细和要取消的工单。工作台只读,不会改动聚工单和钉钉。

-
{{ $syncLabels[$workbenchSync['code']] ?? $workbenchSync['code'] }}@if($workbenchSync['last_succeeded_at']) · {{ \Illuminate\Support\Str::of($workbenchSync['last_succeeded_at'])->substr(0, 16) }}@endif
+
+
+
当前报销批次{{ $summary['purpose'] ?? $workbenchFilters['date'] }}先校验工单,再核对导出
+ {{ $syncLabels[$workbenchSync['code']] ?? $workbenchSync['code'] }}@if($workbenchSync['last_succeeded_at'])· {{ substr($workbenchSync['last_succeeded_at'], 5, 11) }}@endif
- -
- - - - - -
- @if($workbenchSyncStale) - - @endif - - @if($errors->any())@endif - @if(session('success'))
{{ session('success') }}
@endif - @if(session('error'))@endif - @if($workbenchError)@endif - -
- @foreach(References::KINDS as $kind => $label) - @php $upload = $workbenchUploads[$kind] ?? null; @endphp -
- @csrf - - - - {{ $label }} - {{ $upload ? $upload['uploaded_at'] . ' 上传 · ' . number_format($upload['row_count']) . ' 条 · ' . $upload['file_name'] : '尚未上传' }} - -
+
+ @foreach(['date' => '报销日期', 'paid_from' => '付款起始日'] as $name => $label) +
+ + + +
@endforeach -
- @if($monitorUpload === null) -
还没上传种菜监控看板,超额和看板匹配暂不校验。请在看板按付款时间 {{ substr($workbenchWindow['from'], 0, 10) }} 至 {{ substr($workbenchWindow['to'], 0, 10) }} 导出明细后上传。
- @endif - @if($workbenchRosterSource === 'dingtalk') -
没上传花名册,收款人在职按钉钉花名册里的在职真名判断;要用人事给的花名册,上传即可。
- @elseif($workbenchRosterSource === 'none') -
取不到在职名单(没上传花名册,钉钉花名册也暂时读不到),本次没校验收款人是否在职。
- @endif - @if($summary && $summary['counts'][Auditor::DECISION_RECHECK] > 0) -
有 {{ $summary['counts'][Auditor::DECISION_RECHECK] }} 单待复查:看板没匹配到的@if($monitorUpload)(看板 {{ $monitorUpload['uploaded_at'] }} 上传)@endif,20 分钟后重新导出看板上传再看,仍匹配不到的取消工单;查不到 ERP订单标签的,到聚水潭确认是否以旧换新。
- @endif +
工单范围
{{ Workbench::SCOPES[$workbenchFilters['scope']] }}
@foreach(Workbench::SCOPES as $key => $label)@endforeach
+ +

付款区间 {{ substr($workbenchWindow['from'], 0, 10) }}至{{ substr($workbenchWindow['to'], 0, 10) }}

+ + + @if($workbenchSyncStale)@endif + @if($errors->any())@endif + @if(session('success'))
{{ session('success') }}
@endif + @if(session('error'))@endif + @if($workbenchError)@endif @if($summary) -
-

① 先与聚工单核对原数据

-

在聚工单「打款工单 → 种菜报销」按同样条件查询:工单状态 {{ \Modules\EcommerceFinance\Services\PlantingReimbursementWorkbench::SCOPES[$workbenchFilters['scope']] }}、订单付款时间 {{ $workbenchWindow['from'] }} ~ {{ $workbenchWindow['to'] }}、ERP订单状态除取消 / 删除 / 为空 / 不为空外全选、售后单号查询为空。应为 {{ number_format($summary['source']['count']) }} 条,最终报销金额合计 {{ number_format((float) $summary['source']['amount'], 2) }} 元;对不上先别报销。

-
- @foreach($exportQuery as $key => $value)@endforeach - - @foreach(Exporter::TYPES as $type => $label) - - @endforeach -
-
- @csrf - @foreach($exportQuery as $key => $value)@endforeach - - - - @if(! $workbenchRobot['configured'])先在下方「钉钉机器人设置」里填 Webhook@endif - @if($workbenchNoticeLog)今天已发:{{ collect($workbenchNoticeLog)->map(fn ($v, $k) => $k . ' ' . substr($v['sent_at'], 11, 5))->implode('、') }}@endif -
-

② 自检

-
    - @foreach($summary['checks'] as $check)
  • {{ $check['ok'] ? '✓' : '✗' }} {{ $check['label'] }}
  • @endforeach -
-

标记已打款、提交钉钉后,用聚工单「已完成」状态 + 完成时间再查一遍:条数 = 可报销 {{ $summary['counts'][Auditor::DECISION_PASS] }} 条、金额 = {{ number_format((float) $summary['total'], 2) }} 元、钉钉收款合计相同。

+
+
可报销金额 元{{ number_format((float) $summary['total'], 2) }}

三大天猫 {{ number_format((float) $summary['group_amounts'][Auditor::GROUP_BIG_TMALL], 2) }} · 其他 {{ number_format((float) $summary['group_amounts'][Auditor::GROUP_OTHER], 2) }}

+ @foreach([Auditor::DECISION_PASS => '可报销工单', Auditor::DECISION_CANCEL => '取消工单', Auditor::DECISION_RECHECK => '待复查'] as $decision => $label) + + @endforeach
- -
-
本次报销合计(元){{ number_format((float) $summary['total'], 2) }}{{ $summary['counts'][Auditor::DECISION_PASS] }} 单 · {{ $summary['purpose'] }}
-
三大天猫(元){{ number_format((float) $summary['group_amounts'][Auditor::GROUP_BIG_TMALL], 2) }}
-
其他(元){{ number_format((float) $summary['group_amounts'][Auditor::GROUP_OTHER], 2) }}
-
取消工单{{ $summary['counts'][Auditor::DECISION_CANCEL] }}{{ number_format((float) $summary['amounts'][Auditor::DECISION_CANCEL], 2) }} 元
-
待复查{{ $summary['counts'][Auditor::DECISION_RECHECK] }}{{ number_format((float) $summary['amounts'][Auditor::DECISION_RECHECK], 2) }} 元
-
- -
-
-

钉钉「种菜报销流程」明细

-

报销类型:种菜核销;收款人、开户行、账号填「账号详见附件」,附件放「种菜报销明细{{ (int) substr($summary['bill_date'], 5, 2) }}.{{ (int) substr($summary['bill_date'], 8, 2) }}」。提交前先在聚工单标记已打款,并核对合计与钉钉金额一致。

-
- @forelse($summary['ding_lines'] as $line) - - @empty - - @endforelse - @if($summary['ding_lines'])@endif -
费用承担部门店铺用途支付方式金额(元)
{{ $line['department'] ?: '(利润中心待补)' }}{{ $line['shop'] }}{{ $line['purpose'] }}{{ $line['payment_method'] }}{{ number_format($line['cents'] / 100, 2) }}
本次没有可报销的单。
合计{{ number_format((float) $summary['total'], 2) }}
-
- -
-

发群通知 · 取消工单(按发起人)

- @forelse($summary['notices'] as $notice) -
-
{{ $notice['initiator'] }} · {{ count($notice['items']) }} 单
-
{{ $notice['message'] }}
- 工单号:{{ implode('、', array_column($notice['items'], 'work_order_no')) }} -
- @empty -

本次没有要取消或复查的单。

- @endforelse -
-
@endif -
钉钉机器人设置{{ $workbenchRobot['configured'] ? '(已配置)' : '(未配置)' }} -
- @csrf - @foreach($exportQuery as $key => $value)@endforeach - - - - - - - @if($workbenchRobot['digest_webhook'])@endif - -

Webhook 和密钥加密保存,页面不回显,留空表示不改。每天 10:25 自动把当天批次汇总推到群里并 @ 报销人;取消通知要在上面核对后手动点发送。

-
+
+ 参考资料{{ count(array_filter($workbenchUploads)) }} / {{ count(References::KINDS) }} 已上传{{ $monitorUpload ? '按需更新名单和看板' : '未上传看板,超额与看板匹配暂不校验' }} +
+ @foreach(References::KINDS as $kind => $label) + @php $upload = $workbenchUploads[$kind] ?? null; @endphp +
+ @csrf + @foreach($exportQuery as $key => $value)@endforeach +
{{ $label }}{{ $upload ? '已上传' : '未上传' }}
+

{{ $upload ? $upload['file_name'] : '支持 Excel / CSV' }}

+ {{ $upload ? substr($upload['uploaded_at'], 5, 11) . ' · ' . number_format($upload['row_count']) . ' 条' : ($kind === References::KIND_ROSTER && $workbenchRosterSource === 'dingtalk' ? '当前使用钉钉花名册' : '上传后用于本批次校验') }} +
+
+ @endforeach +
+

看板请按付款时间 {{ substr($workbenchWindow['from'], 0, 10) }} 至 {{ substr($workbenchWindow['to'], 0, 10) }} 导出。@if($workbenchRosterSource === 'dingtalk')未上传花名册时,按钉钉花名册里的在职真名校验。@endif

-
校验规则

取单与聚工单锁单一致:种菜报销、工单状态待处理(可切换处理中)、订单付款时间默认报销日前 7 天至前一天、ERP订单状态不为取消 / 删除 / 空、售后单号为空。重复报销(本月、上月已报销过或本批重复)、最终报销金额 ≠ 任务付款+快递费+佣金+京喜差价−扣款−空包费、发起人不在报销佣金人员名单却报了佣金、收款人不在花名册在职名单(柴嘉伟(建行)除外)、ERP订单标签含「以旧换新」的天猫 / 淘宝店报销金额大于买家实付(取工单买家实付、看板订单实付金额中最低的)→ 取消工单;查不到标签且大于买家实付的待复查。看板标「超额」的按 ID负责人 分组:每日超额且付款都在同一天的,按付款时间先后报到日限额为止,其余取消;不在同一天的全部取消。看板提示职级为空的取消工单,群里告知原因「职级为空」。看板没匹配到的待复查。店铺查不到利润中心只提示,可上传店铺信息补齐。

+ @if($workbenchRosterSource === 'none')

未取得在职名单,本次未校验收款人是否在职。请在参考资料中上传花名册。

@endif -
-
- @foreach($columns as $key => $label)@endforeach - - @forelse($workbenchRows as $row) - @foreach($columns as $key => $label) - @if($key === 'decision_label') - - @elseif(in_array($key, PageData::MONEY_COLUMNS, true)) - - @else - - @endif - @endforeach - @empty - - @endforelse -
{{ $label }}
{{ $row['decision_label'] }}{{ $row[$key] === null || $row[$key] === '' ? '—' : number_format((float) $row[$key], 2) }}{{ ($row[$key] ?? '') !== '' ? $row[$key] : '—' }}
{{ $workbenchError ?: '这一天没有待报销的种菜工单。' }}
- + @if($summary) +
+
核对聚工单原数据

相同条件下,应为 {{ number_format($summary['source']['count']) }} 条 / 最终报销金额 {{ number_format((float) $summary['source']['amount'], 2) }} 元。一致后再导出。

查看核对条件

聚工单「打款工单 → 种菜报销」:工单状态 {{ Workbench::SCOPES[$workbenchFilters['scope']] }};付款时间 {{ $workbenchWindow['from'] }} 至 {{ $workbenchWindow['to'] }};ERP订单状态除取消 / 删除 / 为空 / 不为空外全选,售后单号查询为空。条数或金额不一致,先别报销。

+
+ @foreach($exportQuery as $key => $value)@endforeach + +
@foreach(Exporter::TYPES as $type => $label)@endforeach
+
+
金额与条数自检 {{ $checkCount }} / {{ count($summary['checks']) }} 通过
    @foreach($summary['checks'] as $check)
  • {{ $check['ok'] ? '✓' : '✗' }} {{ $check['label'] }}
  • @endforeach

标记已打款、提交钉钉后,用聚工单「已完成」状态 + 完成时间复核:{{ $summary['counts'][Auditor::DECISION_PASS] }} 条 / {{ number_format((float) $summary['total'], 2) }} 元,并确认钉钉收款合计相同。

+
+ @endif + +
+
+ + + +
+
+
@foreach(PageData::DECISION_FILTERS as $key => $label)@endforeach
列设置

勾选显示,拖动调整顺序

@foreach($columns as $key => $label)@endforeach
+
@foreach($columns as $key => $label)@endforeach + @foreach($workbenchRows as $row) + @foreach($columns as $key => $label)@endforeach + @endforeach + +
+
共 {{ number_format(count($workbenchRows)) }} 单上方汇总与导出均为整个批次
1 / 1
+
+ +
+ @include('business.pages.billing-transactions.partials.planting-workbench-settings')
- -@include('business.pages.billing-transactions.partials.planting-work-order-assets') -@push('body_end') - -@endpush +@include('business.pages.partials.date-range-picker') +@include('business.pages.billing-transactions.partials.planting-workbench-assets') diff --git a/tests/Feature/Business/PlantingReimbursementWorkbenchTest.php b/tests/Feature/Business/PlantingReimbursementWorkbenchTest.php index 3386c971..88e945da 100644 --- a/tests/Feature/Business/PlantingReimbursementWorkbenchTest.php +++ b/tests/Feature/Business/PlantingReimbursementWorkbenchTest.php @@ -113,6 +113,38 @@ class PlantingReimbursementWorkbenchTest extends FeatureTestCase $this->withExceptionHandling()->loginAs()->get($this->url(['date' => '2026-11-12', 'scope' => 'x']))->assertStatus(422); } + public function test_initial_decision_filter_keeps_complete_batch_and_totals_for_local_switching(): void + { + $this->mockRepository([$this->row('101', '60.00'), $this->row('900', '10.00')]); + + $page = $this->loginAs()->get($this->url(['date' => '2026-11-12', 'decision' => 'cancel'])) + ->assertOk() + ->assertViewHas('content', static fn (array $content): bool => $content['workbenchFilters']['decision'] === 'cancel' + && count($content['workbenchRows']) === 2 + && array_column($content['workbenchRows'], 'decision') === ['cancel', 'pass'] + && $content['workbenchSummary']['source']['count'] === 2 + && $content['workbenchSummary']['total'] === '60.00'); + $dom = new \DOMDocument; + @$dom->loadHTML($page->getContent()); + $this->assertSame(1, (new \DOMXPath($dom))->query('//tr[@data-pwb-row and @data-decision="pass" and @hidden]')->length); + + $this->withExceptionHandling()->loginAs()->get($this->url(['date' => '2026-11-12', 'decision' => 'invalid']))->assertStatus(422); + } + + public function test_unready_mirror_shows_retry_without_export_actions(): void + { + $this->mockRepository([]); + $repository = \Mockery::mock(PlantingReimbursementRepository::class); + $repository->shouldReceive('syncStatus')->once()->andReturn(['code' => 'unavailable', 'last_succeeded_at' => null]); + $repository->shouldNotReceive('pendingRows'); + $this->app->instance(PlantingReimbursementRepository::class, $repository); + + $this->loginAs()->get($this->url(['date' => '2026-11-12']))->assertOk() + ->assertSee('聚工单镜像未就绪') + ->assertSee('data-pwb-retry', false) + ->assertDontSee('data-pwb-export', false); + } + public function test_bad_upload_reports_error(): void { $this->mockRepository([]); -- 2.47.2