From 4f16eb1834ea2e6fd2493b7895f98ed1db494b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=BF=9B?= Date: Tue, 20 Oct 2026 15:59:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Worker=20=E8=AE=A2=E5=8D=95=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=B3=A8=E5=85=A5=E5=91=98=E5=B7=A5=E4=BB=A3=E6=94=B6?= =?UTF-8?q?=E6=AC=BE=E5=BB=BA=E8=B4=A6=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 批量订购线下支付在 Worker 内建单时,订单服务缺少员工代收款建账能力, 每行都会以“员工代收款建账能力未配置”失败;与 API 进程保持一致。 Co-Authored-By: Claude Opus 5.5 --- internal/bootstrap/worker_services.go | 3 +++ internal/bootstrap/worker_services_test.go | 28 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 internal/bootstrap/worker_services_test.go diff --git a/internal/bootstrap/worker_services.go b/internal/bootstrap/worker_services.go index dbdf7fe2..8e202630 100644 --- a/internal/bootstrap/worker_services.go +++ b/internal/bootstrap/worker_services.go @@ -4,6 +4,7 @@ import ( assetAutoRenewalApp "github.com/break/junhong_cmp_fiber/internal/application/assetautorenewal" cardObservationApp "github.com/break/junhong_cmp_fiber/internal/application/cardobservation" carrierThresholdApp "github.com/break/junhong_cmp_fiber/internal/application/carrierthreshold" + employeecollectionApp "github.com/break/junhong_cmp_fiber/internal/application/employeecollection" walletapp "github.com/break/junhong_cmp_fiber/internal/application/wallet" assetAutoRenewalInfra "github.com/break/junhong_cmp_fiber/internal/infrastructure/assetautorenewal" auditInfra "github.com/break/junhong_cmp_fiber/internal/infrastructure/audit" @@ -154,6 +155,8 @@ func initWorkerServices(stores *queue.WorkerStores, deps *WorkerDependencies) *q stores.PersonalCustomer, stores.PersonalCustomerPhone, ) + // 批量订购线下支付建单需在订单事务内生成员工代收款账单,与 API 进程保持一致。 + orderService.SetEmployeeCollectionBillCreation(employeecollectionApp.NewBillCreationService(auditWriter)) orderService.SetLifecycleAudit(auditWriter) orderService.SetPaymentIntegrationLog(integrationlog.NewRepository(deps.DB)) walletOutbox := outbox.NewRepository() diff --git a/internal/bootstrap/worker_services_test.go b/internal/bootstrap/worker_services_test.go new file mode 100644 index 00000000..98a42bfd --- /dev/null +++ b/internal/bootstrap/worker_services_test.go @@ -0,0 +1,28 @@ +package bootstrap + +import ( + "reflect" + "testing" + + orderSvc "github.com/break/junhong_cmp_fiber/internal/service/order" + "github.com/break/junhong_cmp_fiber/pkg/queue" + "go.uber.org/zap" +) + +// 批量订购线下支付在 Worker 内建单,订单服务必须注入员工代收款建账能力, +// 否则每行都会以“员工代收款建账能力未配置”失败。 +func TestInitWorkerServices_OrderServiceHasEmployeeCollectionBillCreation(t *testing.T) { + services := initWorkerServices(&queue.WorkerStores{}, &WorkerDependencies{Logger: zap.NewNop()}) + + svc, ok := services.AssetPackageOrderCreator.(*orderSvc.Service) + if !ok { + t.Fatalf("AssetPackageOrderCreator 类型为 %T,期望 *order.Service", services.AssetPackageOrderCreator) + } + billCreation := reflect.ValueOf(svc).Elem().FieldByName("billCreation") + if !billCreation.IsValid() { + t.Fatal("order.Service 缺少 billCreation 字段,请同步更新本测试") + } + if billCreation.IsNil() { + t.Fatal("Worker 订单服务未注入员工代收款建账能力") + } +}