fix: Worker 订单服务注入员工代收款建账能力
批量订购线下支付在 Worker 内建单时,订单服务缺少员工代收款建账能力, 每行都会以“员工代收款建账能力未配置”失败;与 API 进程保持一致。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
28
internal/bootstrap/worker_services_test.go
Normal file
28
internal/bootstrap/worker_services_test.go
Normal file
@@ -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 订单服务未注入员工代收款建账能力")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user