From d4f1bc9a208b50d2ec2ac92785b3113b99129200 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Fri, 30 Oct 2026 15:42:41 +0800 Subject: [PATCH] =?UTF-8?q?hotfix:=20=E4=BF=AE=E5=A4=8DOA=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=B6=E9=97=B4=E4=B8=8E=E9=A1=B5=E9=9D=A2=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Business/Pages.php | 11 ++++++ .../DingProcessDetailMirrorSynchronizer.php | 2 +- .../Support/OaProcessTime.php | 17 ++++++++ .../Business/ProcessDetailsPageTest.php | 39 +++++++++++++++++++ ...ingProcessDetailMirrorSynchronizerTest.php | 8 ++-- .../EcommerceFinance/OaProcessTimeTest.php | 8 ++++ 6 files changed, 80 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 604ec2a1..088c7f4c 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -964,6 +964,17 @@ class Pages extends Controller public function show(string $section, ?string $page = null, ?string $tab = null) { + if ($section === 'process-data' && $page === 'oa-process') { + if (request()->boolean('refresh_current')) { + return app(\Modules\EcommerceFinance\Http\Controllers\ProcessDetails::class) + ->requestRefresh(request()); + } + if (request()->filled('refresh_status')) { + return app(\Modules\EcommerceFinance\Http\Controllers\ProcessDetails::class) + ->refreshStatus((string) request()->query('refresh_status')); + } + } + if ($section === 'refunds' && $page === 'small-payment-work-orders') { $url = route('business.pages.show', [ 'section' => self::SMALL_PAYMENT_SECTION, diff --git a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php index 076b690c..6a1b039c 100644 --- a/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php +++ b/modules/EcommerceFinance/Services/DingProcessDetailMirrorSynchronizer.php @@ -1533,7 +1533,7 @@ class DingProcessDetailMirrorSynchronizer private function taskDateTime(mixed $value): ?Carbon { - $parsed = OaProcessTime::parse($value); + $parsed = OaProcessTime::parseDingTalkTask($value); return $parsed === null ? null : Carbon::instance($parsed); } diff --git a/modules/EcommerceFinance/Support/OaProcessTime.php b/modules/EcommerceFinance/Support/OaProcessTime.php index c5ca2cdb..11b618cf 100644 --- a/modules/EcommerceFinance/Support/OaProcessTime.php +++ b/modules/EcommerceFinance/Support/OaProcessTime.php @@ -35,6 +35,23 @@ final class OaProcessTime } } + public static function parseDingTalkTask(mixed $value): ?CarbonImmutable + { + $text = trim((string) $value); + if ($text === '') { + return null; + } + + try { + return CarbonImmutable::parse( + str_replace('T', ' ', preg_replace('/Z$/', '', $text)), + self::timezone(), + ); + } catch (Throwable) { + return null; + } + } + public static function formatDateTime(mixed $value): string { return self::parse($value)?->format('Y-m-d H:i') ?? '-'; diff --git a/tests/Feature/Business/ProcessDetailsPageTest.php b/tests/Feature/Business/ProcessDetailsPageTest.php index 92267c4a..7a5e8c13 100644 --- a/tests/Feature/Business/ProcessDetailsPageTest.php +++ b/tests/Feature/Business/ProcessDetailsPageTest.php @@ -2,7 +2,9 @@ namespace Tests\Feature\Business; +use App\Http\Controllers\Business\Pages; use App\Models\Auth\Permission; +use Illuminate\Http\Request; use Mockery; use Modules\EcommerceFinance\Repositories\DingProcessDetailMirrorRepository; use Modules\EcommerceFinance\Services\DingProcessRefreshQueue; @@ -199,6 +201,43 @@ class ProcessDetailsPageTest extends FeatureTestCase ->assertJsonPath('refresh.count', 1); } + public function test_generic_business_page_controller_handles_refresh_requests(): void + { + $moduleController = Mockery::mock(\Modules\EcommerceFinance\Http\Controllers\ProcessDetails::class); + $moduleController->shouldReceive('requestRefresh') + ->once() + ->andReturn(response()->json(['success' => true, 'queued' => true])); + $moduleController->shouldReceive('refreshStatus') + ->once() + ->with('00000000-0000-4000-8000-000000000001') + ->andReturn(response()->json(['success' => true, 'refresh' => ['status' => 'completed']])); + $this->app->instance( + \Modules\EcommerceFinance\Http\Controllers\ProcessDetails::class, + $moduleController, + ); + $genericPage = (new \ReflectionClass(Pages::class))->newInstanceWithoutConstructor(); + + $this->app->instance('request', Request::create( + '/1/workspace/process-data/oa-process', + 'GET', + ['refresh_current' => '1'], + )); + $this->assertSame( + 200, + $genericPage->show('process-data', 'oa-process')->getStatusCode(), + ); + + $this->app->instance('request', Request::create( + '/1/workspace/process-data/oa-process', + 'GET', + ['refresh_status' => '00000000-0000-4000-8000-000000000001'], + )); + $this->assertSame( + 200, + $genericPage->show('process-data', 'oa-process')->getStatusCode(), + ); + } + public function test_page_stays_readable_when_mirror_is_not_ready(): void { $this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail()); diff --git a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php index f3e5028b..becc497c 100644 --- a/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php +++ b/tests/Unit/EcommerceFinance/DingProcessDetailMirrorSynchronizerTest.php @@ -282,9 +282,9 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase ->first(); $this->assertSame('财务审批 / 出纳打款', $row->current_task_name); $this->assertSame('王五', $row->current_approver_name); - $this->assertSame('2026-06-03 23:00:00', (string) $row->current_task_started_at); + $this->assertSame('2026-06-03 15:00:00', (string) $row->current_task_started_at); $this->assertSame('出纳打款', $row->cashier_task_name); - $this->assertSame('2026-06-03 23:34:00', (string) $row->cashier_task_started_at); + $this->assertSame('2026-06-03 15:34:00', (string) $row->cashier_task_started_at); $this->assertSame('pending', $row->cashier_status); $this->assertSame( '待付款', @@ -332,7 +332,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase ->first(); $this->assertSame('出纳打款', $row->current_task_name); $this->assertSame('王五', $row->current_approver_name); - $this->assertSame('2026-10-30 02:50:00', (string) $row->current_task_started_at); + $this->assertSame('2026-10-29 18:50:00', (string) $row->current_task_started_at); } public function test_running_workflow_without_payment_fields_resolves_current_task_and_approver(): void @@ -380,7 +380,7 @@ class DingProcessDetailMirrorSynchronizerTest extends TestCase ->first(); $this->assertSame('行政核价', $row->current_task_name); $this->assertSame('赵六', $row->current_approver_name); - $this->assertSame('2026-10-30 03:20:00', (string) $row->current_task_started_at); + $this->assertSame('2026-10-29 19:20:00', (string) $row->current_task_started_at); $this->assertSame('not_applicable', $row->payment_source_state); } diff --git a/tests/Unit/EcommerceFinance/OaProcessTimeTest.php b/tests/Unit/EcommerceFinance/OaProcessTimeTest.php index 617fba78..1faf808a 100644 --- a/tests/Unit/EcommerceFinance/OaProcessTimeTest.php +++ b/tests/Unit/EcommerceFinance/OaProcessTimeTest.php @@ -58,6 +58,14 @@ class OaProcessTimeTest extends TestCase ); } + public function test_dingtalk_task_suffix_is_treated_as_local_wall_time(): void + { + $this->assertSame( + '10:56', + OaProcessTime::parseDingTalkTask('2026-10-30T10:56Z')?->format('H:i'), + ); + } + public function test_future_timestamp_is_not_shown_as_less_than_one_minute(): void { $now = CarbonImmutable::parse('2026-10-30 12:00:00', 'Asia/Shanghai'); -- 2.47.2