| | | 1 | | using Microsoft.AspNetCore.Authorization; |
| | | 2 | | using Microsoft.AspNetCore.Mvc; |
| | | 3 | | using OzonDomains; |
| | | 4 | | using OzonDomains.Models; |
| | | 5 | | using OzonOrdersWeb.Areas.Studio2.Controllers.Base; |
| | | 6 | | using OzonRepositories.Context; |
| | | 7 | | using PartsInfo.HttpUtils; |
| | | 8 | | using Services.ApiServices; |
| | | 9 | | using Services.ApiServices.OzonApi; |
| | | 10 | | using Services.CacheServices.Cache.OzonOrdersCache; |
| | | 11 | | using Services.CacheServices.Cache.UserCacheService; |
| | | 12 | | using Services.DataServices; |
| | | 13 | | using OzonOrdersWeb.WebServices.Currency; |
| | | 14 | | using Services.TransactionUtilsServices; |
| | | 15 | | using Services.CacheServices.Cache; |
| | | 16 | | |
| | | 17 | | namespace OzonOrdersWeb.Areas.Studio2.Controllers.Transactions; |
| | | 18 | | |
| | | 19 | | [Authorize(Roles = "User,Admin")] |
| | | 20 | | [Area("Studio2")] |
| | | 21 | | public class AcceptedToWarehouseTransactionController : BaseTransactionController |
| | | 22 | | { |
| | | 23 | | public AcceptedToWarehouseTransactionController( |
| | | 24 | | ApplicationDbContext context, |
| | | 25 | | AppStatusDataServices appStatusServices, |
| | | 26 | | OrdersDataServices orderServices, |
| | | 27 | | TransactionManager transactionManager, |
| | | 28 | | TransactionCache transactionCache, |
| | | 29 | | SupplierDataServices supplierDataServices, |
| | | 30 | | IUserCacheService userCacheService, |
| | | 31 | | ICurrencyRatesViewBagService currencyRatesViewBagService, |
| | | 32 | | CacheUpdater<Order> cacheUpdater, |
| | | 33 | | OrderCache orderCache, |
| | | 34 | | OneCDataManager? oneCDataManager = null, |
| | | 35 | | WarehouseDataServices? warehouseDataServices = null, |
| | | 36 | | ProxyHttpClientService? proxyHttpClientService = null, |
| | | 37 | | StatusTransitionDataServices? statusTransitionDataServices = null, |
| | | 38 | | OzonOrderCancellationService? ozonCancellationService = null) |
| | 0 | 39 | | : base(context, appStatusServices, orderServices, transactionManager, transactionCache, |
| | 0 | 40 | | supplierDataServices, userCacheService, currencyRatesViewBagService, cacheUpdater, orderCache, |
| | 0 | 41 | | oneCDataManager: oneCDataManager, |
| | 0 | 42 | | warehouseDataServices: warehouseDataServices, |
| | 0 | 43 | | proxyHttpClientService: proxyHttpClientService, |
| | 0 | 44 | | statusTransitionDataServices: statusTransitionDataServices, |
| | 0 | 45 | | ozonCancellationService: ozonCancellationService) |
| | | 46 | | { |
| | 0 | 47 | | } |
| | | 48 | | |
| | 0 | 49 | | protected override TransactionConfig GetTransactionConfig() => new() |
| | 0 | 50 | | { |
| | 0 | 51 | | TransactionType = TransactionType.AcceptedToWarehouse, |
| | 0 | 52 | | PrimaryStatusName = "ПринятНаСкладе", |
| | 0 | 53 | | UseStatusTransitions = false, |
| | 0 | 54 | | RequiredSourceStatuses = new List<string> { "Заказан поставщику", "Не указан", "Отгружен поставщиком" }, |
| | 0 | 55 | | ViewName = "AcceptedToWarehouseTransaction", |
| | 0 | 56 | | IncludeCancelledOrders = true, |
| | 0 | 57 | | SupportsOzonCancelPanel = true, |
| | 0 | 58 | | OrderFilter = TransactionConfig.StandardOrderFilter, |
| | 0 | 59 | | CreateTransactionMethod = (tm, orders, userName, createAt, comment) => |
| | 0 | 60 | | tm.AcceptedToWarehouseTransaction(orders, userName, createAt, comment), |
| | 0 | 61 | | SuccessMessageBuilder = (changeCount, cancelCount, dateTime, userName, comment, orders) => |
| | 0 | 62 | | TransactionConfig.BuildStandardSuccessMessage( |
| | 0 | 63 | | changeCount, cancelCount, dateTime, userName, comment, orders, "ПринятНаСкладе") |
| | 0 | 64 | | }; |
| | | 65 | | |
| | | 66 | | [HttpGet] |
| | | 67 | | public Task<IActionResult> AcceptedToWarehouseTransaction(string ids, int page) |
| | 0 | 68 | | => CreateTransactionBase(ids, page); |
| | | 69 | | |
| | | 70 | | [HttpPost] |
| | | 71 | | [ValidateAntiForgeryToken] |
| | | 72 | | public async Task<IActionResult> AcceptedToWarehouseTransaction( |
| | | 73 | | List<Order> orders, string userName, string? comment, |
| | | 74 | | int page, string? deletedOrders, Dictionary<int, string?>? orderSupplierMap) |
| | | 75 | | { |
| | 0 | 76 | | var result = await CreateTransactionPostBase( |
| | 0 | 77 | | orders, userName, comment, page, deletedOrders, orderSupplierMap); |
| | | 78 | | |
| | | 79 | | // Обычно форму перехватывает AJAX и получает JSON с redirectTo. Если JavaScript не загрузился |
| | | 80 | | // или был отключён, обычный POST не должен оставлять пользователя на странице с JSON. |
| | 0 | 81 | | if (Request.Headers["X-Requested-With"] == "XMLHttpRequest") |
| | 0 | 82 | | return result; |
| | | 83 | | |
| | 0 | 84 | | return RedirectToAction("Index", "Orders", new { sortOrder = GetSortStateCookie(), page }); |
| | 0 | 85 | | } |
| | | 86 | | } |