diff --git a/Directory.Build.props b/Directory.Build.props index 8cc5bf9e..346fc896 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 3.803.0 + 3.804.0 $(VersionSuffix)-$(BuildNumber) diff --git a/src/VirtoCommerce.OrdersModule.Core/ModuleConstants.cs b/src/VirtoCommerce.OrdersModule.Core/ModuleConstants.cs index 8418dab7..389e97f6 100644 --- a/src/VirtoCommerce.OrdersModule.Core/ModuleConstants.cs +++ b/src/VirtoCommerce.OrdersModule.Core/ModuleConstants.cs @@ -9,7 +9,9 @@ namespace VirtoCommerce.OrdersModule.Core [ExcludeFromCodeCoverage] public class ModuleConstants { - public static string OrderIndexDocumentType { get; } = nameof(CustomerOrder); + public const string OrderIndexDocumentTypeConstant = nameof(CustomerOrder); + + public static string OrderIndexDocumentType { get; } = OrderIndexDocumentTypeConstant; public static class Security { diff --git a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj index ff4bc2c6..21832245 100644 --- a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj +++ b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderService.cs b/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderService.cs index 225c04a4..f6a6aba3 100644 --- a/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderService.cs +++ b/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderService.cs @@ -31,7 +31,7 @@ public class CustomerOrderService : CrudService _repositoryFactory; private readonly IPlatformMemoryCache _platformMemoryCache; private readonly IEventPublisher _eventPublisher; - private readonly IUniqueNumberGenerator _uniqueNumberGenerator; + private readonly ITenantUniqueNumberGenerator _uniqueNumberGenerator; private readonly IStoreService _storeService; private readonly ICustomerOrderTotalsCalculator _totalsCalculator; private readonly IShippingMethodsSearchService _shippingMethodsSearchService; @@ -41,7 +41,7 @@ public CustomerOrderService( Func repositoryFactory, IPlatformMemoryCache platformMemoryCache, IEventPublisher eventPublisher, - IUniqueNumberGenerator uniqueNumberGenerator, + ITenantUniqueNumberGenerator uniqueNumberGenerator, IStoreService storeService, ICustomerOrderTotalsCalculator totalsCalculator, IShippingMethodsSearchService shippingMethodsSearchService, @@ -245,7 +245,7 @@ protected virtual async Task EnsureThatAllOperationsHaveNumber(CustomerOrder ord numberTemplate = store.Settings.GetValue(descriptor); } - operation.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate); + operation.Number = _uniqueNumberGenerator.GenerateNumber(order.StoreId, numberTemplate); } } } diff --git a/src/VirtoCommerce.OrdersModule.Data/Services/PaymentFlowService.cs b/src/VirtoCommerce.OrdersModule.Data/Services/PaymentFlowService.cs index 80592ea1..aa42fe76 100644 --- a/src/VirtoCommerce.OrdersModule.Data/Services/PaymentFlowService.cs +++ b/src/VirtoCommerce.OrdersModule.Data/Services/PaymentFlowService.cs @@ -25,7 +25,7 @@ public class PaymentFlowService : IPaymentFlowService private readonly IPaymentService _paymentService; private readonly IStoreService _storeService; private readonly IValidator _validator; - private readonly IUniqueNumberGenerator _uniqueNumberGenerator; + private readonly ITenantUniqueNumberGenerator _uniqueNumberGenerator; protected virtual string[] CaptureRuleSets => new[] { PaymentRequestValidator.DefaultRuleSet, PaymentRequestValidator.CaptureRuleSet }; protected virtual string[] RefundRuleSets => new[] { PaymentRequestValidator.DefaultRuleSet, PaymentRequestValidator.RefundRuleSet }; @@ -38,7 +38,7 @@ public PaymentFlowService( IPaymentService paymentService, IStoreService storeService, IValidator validator, - IUniqueNumberGenerator uniqueNumberGenerator) + ITenantUniqueNumberGenerator uniqueNumberGenerator) { _customerOrderService = customerOrderService; _paymentService = paymentService; @@ -322,7 +322,7 @@ protected virtual Refund CreateRefund(PaymentIn payment, Store store, RefundOrde var refund = AbstractTypeFactory.TryCreateInstance(); var numberTemplate = store.Settings.GetValue(Core.ModuleConstants.Settings.General.RefundNewNumberTemplate); - refund.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + refund.Number = _uniqueNumberGenerator.GenerateNumber(store.Id, numberTemplate); refund.Amount = request.Amount ?? payment.Sum; refund.ReasonCode = EnumUtility.SafeParse(request.ReasonCode, RefundReasonCode.Other); @@ -359,7 +359,7 @@ protected virtual Capture CreateCapture(PaymentIn payment, Store store, CaptureO var capture = AbstractTypeFactory.TryCreateInstance(); var numberTemplate = store.Settings.GetValue(Core.ModuleConstants.Settings.General.CaptureNewNumberTemplate); - capture.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + capture.Number = _uniqueNumberGenerator.GenerateNumber(store.Id, numberTemplate); capture.Amount = request.Amount ?? payment.Sum; capture.Comment = request.CaptureDetails; diff --git a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs index d68fdc49..14b08cbb 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs +++ b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs @@ -50,7 +50,7 @@ public class OrderModuleController : Controller { private readonly ICustomerOrderService _customerOrderService; private readonly ICustomerOrderSearchService _searchService; - private readonly IUniqueNumberGenerator _uniqueNumberGenerator; + private readonly ITenantUniqueNumberGenerator _uniqueNumberGenerator; private readonly IStoreService _storeService; private readonly IPlatformMemoryCache _platformMemoryCache; private readonly ICustomerOrderStatisticService _customerOrderStatisticService; @@ -73,7 +73,7 @@ public OrderModuleController( ICustomerOrderService customerOrderService , ICustomerOrderSearchService searchService , IStoreService storeService - , IUniqueNumberGenerator numberGenerator + , ITenantUniqueNumberGenerator numberGenerator , IPlatformMemoryCache platformMemoryCache , ICustomerOrderStatisticService customerOrderStatisticService , ICustomerOrderBuilder customerOrderBuilder @@ -423,7 +423,7 @@ public async Task> GetNewShipment(string id) retVal.Status = "New"; var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderShipmentNewNumberTemplate); - retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + retVal.Number = _uniqueNumberGenerator.GenerateNumber(store.Id, numberTemplate); return Ok(retVal); } @@ -456,7 +456,7 @@ public async Task> GetNewPayment(string id) retVal.Status = retVal.PaymentStatus.ToString(); var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderPaymentInNewNumberTemplate); - retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + retVal.Number = _uniqueNumberGenerator.GenerateNumber(store.Id, numberTemplate); return Ok(retVal); } diff --git a/src/VirtoCommerce.OrdersModule.Web/Localizations/en.VirtoCommerce.Orders.json b/src/VirtoCommerce.OrdersModule.Web/Localizations/en.VirtoCommerce.Orders.json index ec50a99a..f12eff32 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Localizations/en.VirtoCommerce.Orders.json +++ b/src/VirtoCommerce.OrdersModule.Web/Localizations/en.VirtoCommerce.Orders.json @@ -447,20 +447,20 @@ "description": "Refund statuses" }, "Order.CustomerOrderNewNumberTemplate": { - "description": "This template will be used to generate the ID for a new Customer Order. Parameters: 0: Date and time (UTC) the ID was generated at, 1: Order ID", - "title": "Order ID template" + "description": "Used to generate new Customer Order Number, with parameters:\n\n0: Date and Time in UTC\n1: Counter\n\nFormat supports counter options directly within the template using the format:\n@[:[:]]\n\nDefault values:\n* Daily for reset_counter_type. Choose from None, Daily, Weekly, Monthly, and Yearly reset counter types.\n* 1 for start_counter_from.\n* 1 for counter_increment.\n\nExample: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nResult: CO240101-00001.", + "title": "Order number template" }, "Order.ShipmentNewNumberTemplate": { - "description": "This template will be used to generate the ID for a new Shipment. Parameters: 0: Date and time (UTC) the ID was generated at, 1: Order ID", - "title": "Order shipment ID template" + "description": "Used to generate new Shipment Number, with parameters:\n\n0: Date and Time in UTC\n1: Counter\n\nFormat supports counter options directly within the template using the format:\n@[:[:]]\n\nDefault values:\n* Daily for reset_counter_type. Choose from None, Daily, Weekly, Monthly, and Yearly reset counter types.\n* 1 for start_counter_from.\n* 1 for counter_increment.\n\nExample: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nResult: CO240101-00001.", + "title": "Order shipment number template" }, "Order.PaymentInNewNumberTemplate": { - "description": "This template will be used to generate the ID for a new incoming Payment. Parameters: 0: Date and time (UTC) the ID was generated at, 1: Order ID", - "title": "Order payment ID template" + "description": "Used to generate new Payment Number, with parameters:\n\n0: Date and Time in UTC\n1: Counter\n\nFormat supports counter options directly within the template using the format:\n@[:[:]]\n\nDefault values:\n* Daily for reset_counter_type. Choose from None, Daily, Weekly, Monthly, and Yearly reset counter types.\n* 1 for start_counter_from.\n* 1 for counter_increment.\n\nExample: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nResult: CO240101-00001.", + "title": "Order payment number template" }, "Order.RefundNewNumberTemplate": { - "description": "This template will be used to generate the ID for a new order Refund. Parameters: 0: Date and time (UTC) the ID was generated at, 1: Order ID", - "title": "Order refund ID template" + "description": "Used to generate new Refund Number, with parameters:\n\n0: Date and Time in UTC\n1: Counter\n\nFormat supports counter options directly within the template using the format:\n@[:[:]]\n\nDefault values:\n* Daily for reset_counter_type. Choose from None, Daily, Weekly, Monthly, and Yearly reset counter types.\n* 1 for start_counter_from.\n* 1 for counter_increment.\n\nExample: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nResult: CO240101-00001.", + "title": "Order refund number template" }, "Order.SendOrderNotifications": { "description": "Sends a notification when the order status changes", diff --git a/src/VirtoCommerce.OrdersModule.Web/Localizations/ru.VirtoCommerce.Orders.json b/src/VirtoCommerce.OrdersModule.Web/Localizations/ru.VirtoCommerce.Orders.json index 1cc8d7fa..897a8894 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Localizations/ru.VirtoCommerce.Orders.json +++ b/src/VirtoCommerce.OrdersModule.Web/Localizations/ru.VirtoCommerce.Orders.json @@ -317,16 +317,16 @@ "title": "Статусы платежей" }, "Order.CustomerOrderNewNumberTemplate": { - "description": "Этот шаблон будет использоваться для создания ID нового Заказа. Параметры: 0: Дата и время (UTC), когда был сгенерирован ID, 1: ID заказа.", - "title": "Шаблон ID заказа" + "description": "Используется для создания нового номера заказов с параметрами:\n\n0: дата и время в формате UTC.\n1: Счетчик\n\nПоддерживает параметры счетчика непосредственно в шаблоне, используя формат:\n@[:[:]]\n\nЗначения по умолчанию:\n* Ежедневно для reset_counter_type. Выберите типы счетчиков сброса «Нет», «Ежедневно», «Еженедельно», «Ежемесячно» и «Ежегодно».\n* 1 для start_counter_from.\n* 1 для counter_increment.\n\nПример: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nРезультат: CO240101-00001.", + "title": "Шаблон номера заказа" }, "Order.ShipmentNewNumberTemplate": { - "description": "Этот шаблон будет использоваться для создания ID новой доставки. Параметры: 0: Дата и время (UTC), когда был сгенерирован ID, 1: ID заказа.", - "title": "Шаблон ID доставки заказа" + "description": "Используется для создания нового номера документа доставки с параметрами:\n\n0: дата и время в формате UTC.\n1: Счетчик\n\nПоддерживает параметры счетчика непосредственно в шаблоне, используя формат:\n@[:[:]]\n\nЗначения по умолчанию:\n* Ежедневно для reset_counter_type. Выберите типы счетчиков сброса «Нет», «Ежедневно», «Еженедельно», «Ежемесячно» и «Ежегодно».\n* 1 для start_counter_from.\n* 1 для counter_increment.\n\nПример: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nРезультат: CO240101-00001.", + "title": "Шаблон номера документа доставки" }, "Order.PaymentInNewNumberTemplate": { - "description": "Этот шаблон будет использоваться для генерации ID нового входящего платежа. Параметры: 0: Дата и время (UTC), когда был сгенерирован ID, 1: ID заказа.", - "title": "Шаблон ID оплаты заказа" + "description": "Используется для создания нового номера платежного документа с параметрами:\n\n0: дата и время в формате UTC.\n1: Счетчик\n\nПоддерживает параметры счетчика непосредственно в шаблоне, используя формат:\n@[:[:]]\n\nЗначения по умолчанию:\n* Ежедневно для reset_counter_type. Выберите типы счетчиков сброса «Нет», «Ежедневно», «Еженедельно», «Ежемесячно» и «Ежегодно».\n* 1 для start_counter_from.\n* 1 для counter_increment.\n\nПример: CO{0:yyMMdd}-{1:D5}@Weekly:1:10.\nРезультат: CO240101-00001.", + "title": "Шаблон номера платежного документа" }, "Order.SendOrderNotifications": { "description": "Отправление уведомлений при изменении статуса заказа", diff --git a/src/VirtoCommerce.OrdersModule.Web/module.manifest b/src/VirtoCommerce.OrdersModule.Web/module.manifest index ff7f6a4d..1f15f719 100644 --- a/src/VirtoCommerce.OrdersModule.Web/module.manifest +++ b/src/VirtoCommerce.OrdersModule.Web/module.manifest @@ -1,13 +1,13 @@ VirtoCommerce.Orders - 3.803.0 + 3.804.0 3.800.0 - + diff --git a/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceImplIntegrationTests.cs b/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceImplIntegrationTests.cs index 5d86a706..101b5b78 100644 --- a/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceImplIntegrationTests.cs +++ b/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceImplIntegrationTests.cs @@ -45,7 +45,7 @@ public class CustomerOrderServiceImplIntegrationTests private readonly Mock _paymentMethodRegistrarMock; private readonly Mock _paymentMethodsSearchService; private readonly Mock _customerOrderTotalsCalculatorMock; - private readonly Mock _uniqueNumberGeneratorMock; + private readonly Mock _uniqueNumberGeneratorMock; private readonly Mock _dynamicPropertyServiceMock; private readonly IPlatformMemoryCache _platformMemoryCache; private readonly Mock _changeLogServiceMock; @@ -64,7 +64,7 @@ public CustomerOrderServiceImplIntegrationTests() _paymentMethodRegistrarMock = new Mock(); _paymentMethodsSearchService = new Mock(); _paymentMethodsSearchService.Setup(s => s.SearchAsync(It.IsAny(), It.IsAny())).ReturnsAsync(new PaymentMethodsSearchResult()); - _uniqueNumberGeneratorMock = new Mock(); + _uniqueNumberGeneratorMock = new Mock(); _customerOrderTotalsCalculatorMock = new Mock(); _dynamicPropertyServiceMock = new Mock(); _cacheEntryMock = new Mock(); diff --git a/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceUnitTests.cs b/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceUnitTests.cs index 80347eac..5053e042 100644 --- a/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceUnitTests.cs +++ b/tests/VirtoCommerce.OrdersModule.Tests/CustomerOrderServiceUnitTests.cs @@ -32,7 +32,7 @@ public class CustomerOrderServiceUnitTests { private readonly Mock _unitOfWorkMock; private readonly Mock _orderRepositoryMock; - private readonly Mock _uniqueNumberGeneratorMock; + private readonly Mock _uniqueNumberGeneratorMock; private readonly Mock _storeServiceMock; private readonly Mock _eventPublisherMock; private readonly Mock _customerOrderTotalsCalculatorMock; @@ -43,7 +43,7 @@ public CustomerOrderServiceUnitTests() { _unitOfWorkMock = new Mock(); _orderRepositoryMock = new Mock(); - _uniqueNumberGeneratorMock = new Mock(); + _uniqueNumberGeneratorMock = new Mock(); _storeServiceMock = new Mock(); _eventPublisherMock = new Mock(); _customerOrderTotalsCalculatorMock = new Mock();