| | | 1 | | using Microsoft.AspNetCore.Mvc; |
| | | 2 | | using OzonDomains; |
| | | 3 | | using OzonDomains.Models; |
| | | 4 | | using OzonOrdersWeb.Areas.Studio2.Controllers.Base; |
| | | 5 | | using OzonRepositories.Context; |
| | | 6 | | using Services.ApiServices.OzonApi; |
| | | 7 | | using Services.CacheServices.Cache.OzonOrdersCache; |
| | | 8 | | using Services.CacheServices.Cache.UserCacheService; |
| | | 9 | | using Services.DataServices; |
| | | 10 | | using OzonOrdersWeb.WebServices.Currency; |
| | | 11 | | using Services.TransactionUtilsServices; |
| | | 12 | | using Services.CacheServices.Cache; |
| | | 13 | | |
| | | 14 | | namespace OzonOrdersWeb.Areas.Studio2.Controllers.Transactions; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Контроллер транзакции "Смена склада" |
| | | 18 | | /// </summary> |
| | | 19 | | public class WarehouseChangeTransactionController : BaseTransactionController |
| | | 20 | | { |
| | | 21 | | public WarehouseChangeTransactionController( |
| | | 22 | | ApplicationDbContext context, |
| | | 23 | | AppStatusDataServices appStatusServices, |
| | | 24 | | OrdersDataServices orderServices, |
| | | 25 | | TransactionManager transactionManager, |
| | | 26 | | TransactionCache transactionCache, |
| | | 27 | | SupplierDataServices supplierDataServices, |
| | | 28 | | IUserCacheService userCacheService, |
| | | 29 | | ICurrencyRatesViewBagService currencyRatesViewBagService, |
| | | 30 | | CacheUpdater<Order> cacheUpdater, |
| | | 31 | | OrderCache orderCache, |
| | | 32 | | WarehouseDataServices warehouseDataServices, |
| | | 33 | | ExpenseTypeDataServices expenseTypeDataServices, |
| | | 34 | | OrderExtraExpenseDataServices orderExtraExpenseDataServices, |
| | | 35 | | StatusTransitionDataServices statusTransitionDataServices, |
| | | 36 | | OzonOrderCancellationService? ozonCancellationService = null) |
| | 0 | 37 | | : base(context, appStatusServices, orderServices, transactionManager, transactionCache, |
| | 0 | 38 | | supplierDataServices, userCacheService, currencyRatesViewBagService, cacheUpdater, orderCache, |
| | 0 | 39 | | warehouseDataServices: warehouseDataServices, expenseTypeDataServices: expenseTypeDataServices, |
| | 0 | 40 | | orderExtraExpenseDataServices: orderExtraExpenseDataServices, |
| | 0 | 41 | | statusTransitionDataServices: statusTransitionDataServices, |
| | 0 | 42 | | ozonCancellationService: ozonCancellationService) |
| | | 43 | | { |
| | 0 | 44 | | } |
| | | 45 | | |
| | 0 | 46 | | protected override TransactionConfig GetTransactionConfig() => new() |
| | 0 | 47 | | { |
| | 0 | 48 | | TransactionType = TransactionType.WarehouseChange, |
| | 0 | 49 | | PrimaryStatusName = string.Empty, // Не меняем статус, оставляем оригинальный |
| | 0 | 50 | | ViewName = "CreateWarehouseChangeTransaction", |
| | 0 | 51 | | IncludeCancelledOrders = true, |
| | 0 | 52 | | SupportsOzonCancelPanel = true, |
| | 0 | 53 | | // Принимаем любые заказы |
| | 0 | 54 | | OrderFilter = _ => true, |
| | 0 | 55 | | ConfigureViewModel = vm => ViewBag.ShowWarehouseSelect = true, |
| | 0 | 56 | | CreateTransactionMethod = (tm, orders, userName, createAt, comment) => |
| | 0 | 57 | | tm.CreateWarehouseChangeTransaction(orders, userName, createAt, comment), |
| | 0 | 58 | | SuccessMessageBuilder = (changeCount, cancelCount, dateTime, userName, comment, orders) => |
| | 0 | 59 | | TransactionConfig.BuildStandardSuccessMessage( |
| | 0 | 60 | | changeCount, |
| | 0 | 61 | | cancelCount, |
| | 0 | 62 | | dateTime, |
| | 0 | 63 | | userName, |
| | 0 | 64 | | comment, |
| | 0 | 65 | | orders, |
| | 0 | 66 | | "Изменены статус/склад/поставщик") |
| | 0 | 67 | | }; |
| | | 68 | | |
| | | 69 | | public Task<IActionResult> CreateWarehouseChangeTransaction(string ids, int page) |
| | 0 | 70 | | => CreateTransactionBase(ids, page); |
| | | 71 | | |
| | | 72 | | [HttpPost] |
| | | 73 | | [ValidateAntiForgeryToken] |
| | | 74 | | public Task<IActionResult> CreateWarehouseChangeTransaction( |
| | | 75 | | List<Order> orders, string userName, string? comment, |
| | | 76 | | int page, string? deletedOrders, Dictionary<int, string?>? orderSupplierMap) |
| | 0 | 77 | | => CreateTransactionPostBase(orders, userName, comment, page, deletedOrders, orderSupplierMap); |
| | | 78 | | } |