This commit is contained in:
@@ -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