This commit is contained in:
@@ -193,7 +193,7 @@ func initServices(s *stores, deps *Dependencies) *services {
|
||||
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)
|
||||
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{
|
||||
Account: account,
|
||||
|
||||
@@ -35,6 +35,8 @@ type Service struct {
|
||||
packageStore *postgres.PackageStore
|
||||
packageSeriesStore *postgres.PackageSeriesStore
|
||||
agentWalletStore *postgres.AgentWalletStore
|
||||
deviceSimBindingStore *postgres.DeviceSimBindingStore
|
||||
deviceStore *postgres.DeviceStore
|
||||
}
|
||||
|
||||
// New 创建代理开放接口业务编排服务
|
||||
@@ -50,6 +52,8 @@ func New(
|
||||
packageStore *postgres.PackageStore,
|
||||
packageSeriesStore *postgres.PackageSeriesStore,
|
||||
agentWalletStore *postgres.AgentWalletStore,
|
||||
deviceSimBindingStore *postgres.DeviceSimBindingStore,
|
||||
deviceStore *postgres.DeviceStore,
|
||||
) *Service {
|
||||
return &Service{
|
||||
assetService: assetService,
|
||||
@@ -63,6 +67,8 @@ func New(
|
||||
packageStore: packageStore,
|
||||
packageSeriesStore: packageSeriesStore,
|
||||
agentWalletStore: agentWalletStore,
|
||||
deviceSimBindingStore: deviceSimBindingStore,
|
||||
deviceStore: deviceStore,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,8 +291,24 @@ func (s *Service) CreateWalletPackageOrders(ctx context.Context, req *dto.AgentO
|
||||
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{
|
||||
Identifier: card.ICCID,
|
||||
Identifier: identifier,
|
||||
PackageIDs: []uint{pkg.ID},
|
||||
PaymentMethod: model.PaymentMethodWallet,
|
||||
}, model.BuyerTypeAgent, shopID)
|
||||
|
||||
Reference in New Issue
Block a user