1
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m18s

This commit is contained in:
Break
2026-06-02 16:56:09 +08:00
parent c6e65fde9b
commit a6cd550b94
2 changed files with 24 additions and 2 deletions

View File

@@ -193,7 +193,7 @@ func initServices(s *stores, deps *Dependencies) *services {
packageService := packageSvc.New(s.Package, s.PackageSeries, s.ShopPackageAllocation, s.ShopSeriesAllocation) packageService := packageSvc.New(s.Package, s.PackageSeries, s.ShopPackageAllocation, s.ShopSeriesAllocation)
orderService := orderSvc.New(deps.DB, deps.Redis, s.Order, s.OrderItem, s.AgentWallet, s.AssetWallet, s.Payment, purchaseValidation, s.ShopPackageAllocation, s.ShopSeriesAllocation, s.IotCard, s.Device, s.PackageSeries, s.PackageUsage, s.Package, wechatConfig, deps.WechatPayment, paymentLoader, deps.QueueClient, deps.Logger, s.AssetIdentifier, s.PersonalCustomer, s.PersonalCustomerPhone) orderService := orderSvc.New(deps.DB, deps.Redis, s.Order, s.OrderItem, s.AgentWallet, s.AssetWallet, s.Payment, purchaseValidation, s.ShopPackageAllocation, s.ShopSeriesAllocation, s.IotCard, s.Device, s.PackageSeries, s.PackageUsage, s.Package, wechatConfig, deps.WechatPayment, paymentLoader, deps.QueueClient, deps.Logger, s.AssetIdentifier, s.PersonalCustomer, s.PersonalCustomerPhone)
assetService := assetSvc.New(deps.DB, s.Device, s.IotCard, s.PackageUsage, s.Package, s.PackageSeries, s.DeviceSimBinding, s.Shop, deps.Redis, iotCard, deps.GatewayClient, s.AssetIdentifier, s.Order, s.OrderItem, s.ExchangeOrder) assetService := assetSvc.New(deps.DB, s.Device, s.IotCard, s.PackageUsage, s.Package, s.PackageSeries, s.DeviceSimBinding, s.Shop, deps.Redis, iotCard, deps.GatewayClient, s.AssetIdentifier, s.Order, s.OrderItem, s.ExchangeOrder)
agentOpenAPI := agentOpenAPISvc.New(assetService, packageService, orderService, shopCommission, stopResumeService, device, s.IotCard, s.PackageUsage, s.Package, s.PackageSeries, s.AgentWallet) agentOpenAPI := agentOpenAPISvc.New(assetService, packageService, orderService, shopCommission, stopResumeService, device, s.IotCard, s.PackageUsage, s.Package, s.PackageSeries, s.AgentWallet, s.DeviceSimBinding, s.Device)
return &services{ return &services{
Account: account, Account: account,

View File

@@ -35,6 +35,8 @@ type Service struct {
packageStore *postgres.PackageStore packageStore *postgres.PackageStore
packageSeriesStore *postgres.PackageSeriesStore packageSeriesStore *postgres.PackageSeriesStore
agentWalletStore *postgres.AgentWalletStore agentWalletStore *postgres.AgentWalletStore
deviceSimBindingStore *postgres.DeviceSimBindingStore
deviceStore *postgres.DeviceStore
} }
// New 创建代理开放接口业务编排服务 // New 创建代理开放接口业务编排服务
@@ -50,6 +52,8 @@ func New(
packageStore *postgres.PackageStore, packageStore *postgres.PackageStore,
packageSeriesStore *postgres.PackageSeriesStore, packageSeriesStore *postgres.PackageSeriesStore,
agentWalletStore *postgres.AgentWalletStore, agentWalletStore *postgres.AgentWalletStore,
deviceSimBindingStore *postgres.DeviceSimBindingStore,
deviceStore *postgres.DeviceStore,
) *Service { ) *Service {
return &Service{ return &Service{
assetService: assetService, assetService: assetService,
@@ -63,6 +67,8 @@ func New(
packageStore: packageStore, packageStore: packageStore,
packageSeriesStore: packageSeriesStore, packageSeriesStore: packageSeriesStore,
agentWalletStore: agentWalletStore, agentWalletStore: agentWalletStore,
deviceSimBindingStore: deviceSimBindingStore,
deviceStore: deviceStore,
} }
} }
@@ -285,8 +291,24 @@ func (s *Service) CreateWalletPackageOrders(ctx context.Context, req *dto.AgentO
continue continue
} }
// 卡已绑定设备时,自动转为设备维度购买
identifier := card.ICCID
if !card.IsStandalone {
binding, bindErr := s.deviceSimBindingStore.GetActiveBindingByCardID(ctx, card.ID)
if bindErr != nil {
resp.FailedCards = append(resp.FailedCards, buildFailedCard(cardNo, errors.Wrap(errors.CodeInternalError, bindErr, "查询卡绑定设备失败")))
continue
}
device, devErr := s.deviceStore.GetByID(ctx, binding.DeviceID)
if devErr != nil {
resp.FailedCards = append(resp.FailedCards, buildFailedCard(cardNo, errors.Wrap(errors.CodeInternalError, devErr, "查询绑定设备信息失败")))
continue
}
identifier = device.VirtualNo
}
orderResp, err := s.orderService.CreateAdminOrder(ctx, &dto.CreateAdminOrderRequest{ orderResp, err := s.orderService.CreateAdminOrder(ctx, &dto.CreateAdminOrderRequest{
Identifier: card.ICCID, Identifier: identifier,
PackageIDs: []uint{pkg.ID}, PackageIDs: []uint{pkg.ID},
PaymentMethod: model.PaymentMethodWallet, PaymentMethod: model.PaymentMethodWallet,
}, model.BuyerTypeAgent, shopID) }, model.BuyerTypeAgent, shopID)