| | | 1 | | using System; |
| | | 2 | | using WinSolutions.Sveta.Common.Extensions; |
| | | 3 | | using System.Collections.Concurrent; |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Collections.Immutable; |
| | | 6 | | using System.Diagnostics; |
| | | 7 | | using System.Linq; |
| | | 8 | | using System.Threading.Tasks; |
| | | 9 | | using Microsoft.AspNetCore.Http; |
| | | 10 | | using Microsoft.AspNetCore.Mvc; |
| | | 11 | | using Microsoft.AspNetCore.Authorization; |
| | | 12 | | using Microsoft.EntityFrameworkCore; |
| | | 13 | | using WinSolutions.Sveta.Server.Services.Interfaces; |
| | | 14 | | using Microsoft.Extensions.Logging; |
| | | 15 | | using Swashbuckle.AspNetCore.Annotations; |
| | | 16 | | using Microsoft.Extensions.Options; |
| | | 17 | | using SVETA.Api.Data.Domain; |
| | | 18 | | using WinSolutions.Sveta.Server.Data.DataModel.Entities; |
| | | 19 | | using SVETA.Api.Data.DTO.Showcase; |
| | | 20 | | using SVETA.Api.Data.DTO; |
| | | 21 | | using SVETA.Api.Data.DTO.Goods; |
| | | 22 | | using SVETA.Api.Services.Interfaces; |
| | | 23 | | using WinSolutions.Sveta.Common; |
| | | 24 | | using WinSolutions.Sveta.Server.Data.DataModel.Extensions; |
| | | 25 | | using WinSolutions.Sveta.Server.Data.DataModel.Kinds; |
| | | 26 | | using System.IO; |
| | | 27 | | |
| | | 28 | | namespace SVETA.Api.Controllers |
| | | 29 | | { |
| | | 30 | | /// <summary> |
| | | 31 | | /// Витрина |
| | | 32 | | /// </summary> |
| | | 33 | | [Route("api/v1/Showcase")] |
| | | 34 | | [ApiController] |
| | | 35 | | //[Authorize] |
| | | 36 | | public class ShowcaseController : SvetaController |
| | | 37 | | { |
| | | 38 | | const string _routeUrl = "api/v1/Showcase"; |
| | | 39 | | readonly IShowcaseWorker _worker; |
| | | 40 | | readonly ILogger<ShowcaseController> _logger; |
| | | 41 | | private readonly ICategoryService _categoryService; |
| | | 42 | | private readonly IGoodService _goodService; |
| | | 43 | | private readonly IDepartmentService _departmentService; |
| | | 44 | | private readonly IAuthenticationService _authService; |
| | | 45 | | private readonly CommonSettings _commonSettings; |
| | | 46 | | private readonly AuthorizationSettings _authorizationSettings; |
| | | 47 | | IDiskStorageService _diskStorage; |
| | | 48 | | |
| | | 49 | | public ShowcaseController(IShowcaseWorker worker, ILogger<ShowcaseController> logger, ICategoryService categoryS |
| | | 50 | | IGoodService goodService, IDepartmentService departmentService, IAuthenticationService authService, IDiskSto |
| | | 51 | | IOptions<CommonSettings> options, |
| | 0 | 52 | | IOptions<AuthorizationSettings> authOptions) : base(logger) |
| | 0 | 53 | | { |
| | 0 | 54 | | _worker = worker; |
| | 0 | 55 | | _logger = logger; |
| | 0 | 56 | | _categoryService = categoryService; |
| | 0 | 57 | | _goodService = goodService; |
| | 0 | 58 | | _departmentService = departmentService; |
| | 0 | 59 | | _authService = authService; |
| | 0 | 60 | | _commonSettings = options.Value; |
| | 0 | 61 | | _authorizationSettings = authOptions.Value; |
| | 0 | 62 | | _diskStorage = diskStorage; |
| | 0 | 63 | | } |
| | | 64 | | |
| | | 65 | | async Task<Department> CheckDepartment(long departmentId) |
| | 0 | 66 | | { |
| | 0 | 67 | | var dep = _authService.IsUserPlatform() |
| | 0 | 68 | | ? await _departmentService.GetDepartment(departmentId) |
| | 0 | 69 | | : await _departmentService.GetDepartment(departmentId, _authService.ContragentId); |
| | 0 | 70 | | if (dep == null) |
| | 0 | 71 | | { |
| | 0 | 72 | | throw new KeyNotFoundException("Не найден магазин"); |
| | | 73 | | } |
| | 0 | 74 | | if (dep.Cluster == null) |
| | 0 | 75 | | { |
| | 0 | 76 | | throw new ArgumentException("Не найден кластер"); |
| | | 77 | | } |
| | 0 | 78 | | if (dep.Cluster.Warehouse == null) |
| | 0 | 79 | | { |
| | 0 | 80 | | throw new ArgumentException("Не найден склад-владелец"); |
| | | 81 | | } |
| | 0 | 82 | | return dep; |
| | 0 | 83 | | } |
| | | 84 | | |
| | | 85 | | /// <summary> |
| | | 86 | | /// Возвращает товары для витрины |
| | | 87 | | /// </summary> |
| | | 88 | | /// <param name="categoryId">Id категории (0 для всех категорий)</param> |
| | | 89 | | /// <param name="departmentId">Id магазина, для которого будут возвращены товары с конкретными ценами под этот м |
| | | 90 | | /// <param name="showNA">возвращать ли товары, которых нет на остатке</param> |
| | | 91 | | /// <param name="page">пейджинг: номер страницы (любое значение ниже нуля изменится на 1)</param> |
| | | 92 | | /// <param name="limit">пейджинг: размер страницы (любое значение ниже нуля изменится на 10)</param> |
| | | 93 | | /// <param name="filter">фильтр по значимым полям (имя товара и штрихкод)</param> |
| | | 94 | | /// <param name="sort">сортировка по полям name,name|desc, brandName,brandName|desc, price,price|desc discount,d |
| | | 95 | | /// <param name="sidebarFilterJson">sidebar фильтр { "brands": [ "6" ], "country": [ "174" ], "price": { "price_ |
| | | 96 | | /// <remarks>author: oboligatov</remarks> |
| | | 97 | | [HttpGet("FromCategory/{categoryId}/ForDepartment/{departmentId}")] |
| | | 98 | | [SwaggerResponse(200, "Успешно", typeof(BaseResponseDTO<ShowcaseListGoodDTO>))] |
| | | 99 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 100 | | public async Task<IActionResult> GetGoods(long categoryId, long departmentId, bool showNA = false, int page = 1, |
| | | 101 | | string sidebarFilterJson = null) |
| | 0 | 102 | | { |
| | 0 | 103 | | await CheckDepartment(departmentId); |
| | 0 | 104 | | filter = filter.NormalizeName(); |
| | 0 | 105 | | page = page < 1 ? 1 : page; |
| | 0 | 106 | | limit = limit < 1 ? 10 : limit; |
| | 0 | 107 | | var goods = _worker.GetShowcaseGoods(categoryId > 0 ? categoryId : (long?)null, departmentId, showNA, page - |
| | 0 | 108 | | var totalCount = count; |
| | 0 | 109 | | var totalFiltredCount = filteredCount; |
| | | 110 | | |
| | 0 | 111 | | var response = new BaseResponseDTO<ShowcaseListGoodDTO>(_routeUrl, page, limit, totalFiltredCount, totalCoun |
| | 0 | 112 | | { |
| | 0 | 113 | | Data = goods.Select(x => new ShowcaseListGoodDTO(x)).ToList() |
| | 0 | 114 | | }; |
| | 0 | 115 | | return Ok(response); |
| | 0 | 116 | | } |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// Возвращает товар для витрины |
| | | 120 | | /// </summary> |
| | | 121 | | /// <param name="goodId">Id товара</param> |
| | | 122 | | /// <param name="departmentId">Id магазина, для которого будут возвращены товары с конкретными ценами под этот м |
| | | 123 | | /// <returns></returns> |
| | | 124 | | [HttpGet("Good/{goodId}/ForDepartment/{departmentId}")] |
| | | 125 | | [SwaggerResponse(200, "Успешно", typeof(ShowcaseGoodDTO))] |
| | | 126 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 127 | | //[Authorize] |
| | | 128 | | public async Task<IActionResult> GetGood(long goodId, long departmentId) |
| | 0 | 129 | | { |
| | 0 | 130 | | await CheckDepartment(departmentId); |
| | | 131 | | |
| | 0 | 132 | | var good = await _worker.GetShowcaseGood(goodId, departmentId); |
| | 0 | 133 | | return Ok(good); |
| | 0 | 134 | | } |
| | | 135 | | |
| | | 136 | | /// <summary> |
| | | 137 | | /// Получить категории по фильтру |
| | | 138 | | /// </summary> |
| | | 139 | | /// <param name="parentId">Идентифиатор родительской категории (0 - все категории)</param> |
| | | 140 | | /// <param name="departmentId">Id магазина, для которого будут возвращены товары с конкретными ценами под этот м |
| | | 141 | | [HttpGet("Categories/{parentId}/ForDepartment/{departmentId}")] |
| | | 142 | | [SwaggerResponse(200, "Успешно", typeof(List<CategoryResponseDTO>))] |
| | | 143 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 144 | | [Obsolete] |
| | | 145 | | //[AllowAnonymous] |
| | | 146 | | public async Task<IActionResult> GetCategories(long parentId, long departmentId) |
| | 0 | 147 | | { |
| | 0 | 148 | | var dep = await CheckDepartment(departmentId); |
| | 0 | 149 | | var result = new List<CategoryResponseDTO>(); |
| | | 150 | | |
| | 0 | 151 | | if((await _worker.GetContractRatio(dep)) == 0 || dep.Cluster.RatioForCalculations == 0) |
| | 0 | 152 | | { |
| | 0 | 153 | | return Ok(result); |
| | | 154 | | } |
| | | 155 | | |
| | 0 | 156 | | var categories = await _categoryService.GetCategories(1, int.MaxValue, null, parentId == 0 ? -1 : parentId); |
| | | 157 | | |
| | 0 | 158 | | var goodCategories = (await _worker.GetShowcaseGoodsBaseQuery(parentId == 0 ? (long?)null : parentId, depart |
| | 0 | 159 | | .Select(x => x.Category.Id) |
| | 0 | 160 | | .Distinct() |
| | 0 | 161 | | .ToList(); |
| | | 162 | | |
| | 0 | 163 | | var cats = new List<Category>(); |
| | 0 | 164 | | foreach (var cat in categories) |
| | 0 | 165 | | { |
| | 0 | 166 | | var tree = _goodService.ExpandCategoryTree(new List<long>() { cat.Id }); |
| | 0 | 167 | | tree.Add(cat.Id); |
| | | 168 | | |
| | 0 | 169 | | if(tree.Intersect(goodCategories).Any()) |
| | 0 | 170 | | { |
| | 0 | 171 | | cats.Add(cat); |
| | 0 | 172 | | } |
| | 0 | 173 | | } |
| | | 174 | | |
| | 0 | 175 | | result.AddRange(cats.Select(x => new CategoryResponseDTO(x) |
| | 0 | 176 | | { |
| | 0 | 177 | | Expandable = cats.Any(c => c.Parent != null && c.Parent.Id == x.Id) |
| | 0 | 178 | | })); |
| | | 179 | | |
| | 0 | 180 | | return Ok(result); |
| | 0 | 181 | | } |
| | | 182 | | |
| | | 183 | | /// <summary> |
| | | 184 | | /// Получить дерево категорий по фильтру |
| | | 185 | | /// </summary> |
| | | 186 | | /// <param name="parentId">Идентифиатор родительской категории (0 - все категории)</param> |
| | | 187 | | /// <param name="departmentId">Id магазина, для которого будут возвращены товары с конкретными ценами под этот м |
| | | 188 | | [HttpGet("CategoriesTree/{parentId}/ForDepartment/{departmentId}")] |
| | | 189 | | [SwaggerResponse(200, "Успешно", typeof(List<CategoryResponseDTO>))] |
| | | 190 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 191 | | //[AllowAnonymous] |
| | | 192 | | public async Task<IActionResult> GetCategoriesTree(long parentId, long departmentId) |
| | | 193 | | { |
| | | 194 | | var dep = await CheckDepartment(departmentId); |
| | | 195 | | var result = new List<CategoryResponseDTO>(); |
| | | 196 | | |
| | | 197 | | if ((await _worker.GetContractRatio(dep)) == 0 || dep.Cluster.RatioForCalculations == 0) |
| | | 198 | | { |
| | | 199 | | return Ok(result); |
| | | 200 | | } |
| | | 201 | | |
| | | 202 | | var categories = await _categoryService.GetCategories(1, int.MaxValue, null, parentId == 0 ? -1 : parentId); |
| | | 203 | | |
| | | 204 | | var goodCategories = (await _worker.GetShowcaseGoodsBaseQuery(parentId == 0 ? (long?)null : parentId, depart |
| | | 205 | | .Select(x => x.Category.Id) |
| | | 206 | | .Distinct() |
| | | 207 | | .ToList(); |
| | | 208 | | |
| | | 209 | | var cats = new List<Category>(); |
| | | 210 | | foreach (var cat in categories) |
| | | 211 | | { |
| | | 212 | | var tree = _goodService.ExpandCategoryTree(new List<long>() { cat.Id }); |
| | | 213 | | tree.Add(cat.Id); |
| | | 214 | | |
| | | 215 | | if (tree.Intersect(goodCategories).Any()) |
| | | 216 | | { |
| | | 217 | | cats.Add(cat); |
| | | 218 | | } |
| | | 219 | | } |
| | | 220 | | |
| | 0 | 221 | | result.AddRange(cats.Select(x => new CategoryResponseDTO(x) |
| | 0 | 222 | | { |
| | 0 | 223 | | Expandable = cats.Any(c => c.Parent != null && c.Parent.Id == x.Id) |
| | 0 | 224 | | })); |
| | | 225 | | |
| | | 226 | | var result2 = new List<CategoryResponseDTO>(); |
| | 0 | 227 | | result2.AddRange(result.Where(x => x.ParentId == 0)); |
| | | 228 | | foreach (var cat in result2) |
| | | 229 | | { |
| | | 230 | | BuildCategoryTree(cat, result); |
| | | 231 | | } |
| | | 232 | | return Ok(result2); |
| | | 233 | | } |
| | | 234 | | |
| | | 235 | | void BuildCategoryTree(CategoryResponseDTO parent, List<CategoryResponseDTO> flatList) |
| | 0 | 236 | | { |
| | 0 | 237 | | var children = flatList.Where(x => x.ParentCode == parent.Code); |
| | 0 | 238 | | parent.Children.AddRange(children); |
| | | 239 | | |
| | 0 | 240 | | foreach(var child in children) |
| | 0 | 241 | | { |
| | 0 | 242 | | BuildCategoryTree(child, flatList); |
| | 0 | 243 | | } |
| | 0 | 244 | | } |
| | | 245 | | |
| | | 246 | | /// <summary> |
| | | 247 | | /// Возвращаем топ 6 самых высоких скидок |
| | | 248 | | /// </summary> |
| | | 249 | | /// <returns></returns> |
| | | 250 | | [SwaggerResponse(200, "Успешно", typeof(TopGoodDiscountDto))] |
| | | 251 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 252 | | [HttpGet("TopDiscount")] |
| | | 253 | | public async Task<IActionResult> GetTopDiscountGoods() |
| | 0 | 254 | | { |
| | 0 | 255 | | _logger.LogInformation("Start return top discount goods"); |
| | 0 | 256 | | Department dep = |
| | 0 | 257 | | (await _departmentService.GetDepartmentsByUserAndKind(_authService.UserId, DepartmentKind.Shop, default) |
| | 0 | 258 | | )?.First() |
| | 0 | 259 | | ?? throw new ArgumentException("Не найден магазин для расчета"); |
| | 0 | 260 | | if (dep.Cluster == null || dep.Cluster.WarehouseId == 0) |
| | 0 | 261 | | throw new ArgumentException("Не найден склад для расчета"); |
| | 0 | 262 | | var category = await _categoryService.GetCategories(0, 1, default); |
| | 0 | 263 | | int count = 0; |
| | 0 | 264 | | int filteredCount = 0; |
| | | 265 | | List<ShowcaseGoodDTO> goods; |
| | | 266 | | List<TopGoodDiscount> topGoods; |
| | 0 | 267 | | int goodsCount = await _goodService.GetGoodsCount(default, null, true); |
| | 0 | 268 | | goods = _worker.GetShowcaseGoods( (long?)null, dep.Id, false, 0, goodsCount, default, "discount|desc", null, |
| | 0 | 269 | | if (goods != null && goods.Count > 0) |
| | 0 | 270 | | { |
| | 0 | 271 | | topGoods = goods.Select(good => new TopGoodDiscount |
| | 0 | 272 | | { |
| | 0 | 273 | | CurrentPrice = good.Price, |
| | 0 | 274 | | OldPrice = good.OldPrice ?? 0, |
| | 0 | 275 | | Name = good.Name, |
| | 0 | 276 | | Img = good.Photos.FirstOrDefault() ?? new PhotoDTO(), |
| | 0 | 277 | | Category = good.Category.Name, |
| | 0 | 278 | | Discount = good.Discount ?? 0, |
| | 0 | 279 | | Url = _commonSettings.BaseFrontUrl + $"/showcase/catalog?product={good.Id}&department=-1", |
| | 0 | 280 | | LabelColor = good.LabelColor |
| | 0 | 281 | | }).ToList(); |
| | 0 | 282 | | } |
| | | 283 | | else |
| | 0 | 284 | | { |
| | 0 | 285 | | goods = _worker.GetShowcaseGoods( (long?)null, dep.Id, false, 0, goodsCount, default, "discount|desc", n |
| | 0 | 286 | | var top = goods |
| | 0 | 287 | | .OrderByDescending(good => good.Discount) |
| | 0 | 288 | | .GroupBy(d => d.Category.Id); |
| | | 289 | | |
| | 0 | 290 | | if (top.Count() >= 6) |
| | 0 | 291 | | { |
| | 0 | 292 | | topGoods = top |
| | 0 | 293 | | .Select(d => d.First()) |
| | 0 | 294 | | .Select(good => new TopGoodDiscount |
| | 0 | 295 | | { |
| | 0 | 296 | | CurrentPrice = good.Price, |
| | 0 | 297 | | OldPrice = good.OldPrice ?? 0, |
| | 0 | 298 | | Name = good.Name, |
| | 0 | 299 | | Img = good.Photos.FirstOrDefault() ?? new PhotoDTO(), |
| | 0 | 300 | | Category = good.Category.Name, |
| | 0 | 301 | | Discount = good.Discount ?? 0, |
| | 0 | 302 | | Url = _commonSettings.BaseFrontUrl + $"/showcase/catalog?product={good.Id}&department=-1", |
| | 0 | 303 | | LabelColor = good.LabelColor |
| | 0 | 304 | | }) |
| | 0 | 305 | | .Take(6) |
| | 0 | 306 | | .ToList(); |
| | 0 | 307 | | } |
| | | 308 | | else |
| | 0 | 309 | | { |
| | 0 | 310 | | int countGroup = top.Count(); |
| | 0 | 311 | | topGoods = new List<TopGoodDiscount>(); |
| | 0 | 312 | | for (int i = 0; i < 6; i++) |
| | 0 | 313 | | { |
| | 0 | 314 | | for (int j = 0; j < countGroup; j++) |
| | 0 | 315 | | { |
| | 0 | 316 | | topGoods.Append(new TopGoodDiscount |
| | 0 | 317 | | { |
| | 0 | 318 | | Name = top.ElementAt(j).ElementAt(i).Name, |
| | 0 | 319 | | Category = top.ElementAt(j).ElementAt(i).Category.Name, |
| | 0 | 320 | | Img = top.ElementAt(j).ElementAt(i).Photos.FirstOrDefault() ?? new PhotoDTO(), |
| | 0 | 321 | | CurrentPrice = top.ElementAt(j).ElementAt(i).Price, |
| | 0 | 322 | | OldPrice = top.ElementAt(j).ElementAt(i).OldPrice ?? 0, |
| | 0 | 323 | | Discount = top.ElementAt(j).ElementAt(i).Discount ?? 0, |
| | 0 | 324 | | Url = _commonSettings.BaseFrontUrl+ $"/showcase/catalog?product={top.ElementAt(j).Elemen |
| | 0 | 325 | | LabelColor = top.ElementAt(j).ElementAt(i).LabelColor |
| | 0 | 326 | | }); |
| | 0 | 327 | | } |
| | 0 | 328 | | } |
| | 0 | 329 | | } |
| | 0 | 330 | | } |
| | | 331 | | |
| | 0 | 332 | | TopGoodDiscountDto result = new TopGoodDiscountDto |
| | 0 | 333 | | { |
| | 0 | 334 | | DiscountGoods = topGoods, |
| | 0 | 335 | | StsServer = _authorizationSettings.IdentityUrl, |
| | 0 | 336 | | BaseFronUrl = _commonSettings.BaseFrontUrl |
| | 0 | 337 | | }; |
| | 0 | 338 | | _logger.LogInformation("Stop return top discount goods"); |
| | 0 | 339 | | return Ok(result); |
| | 0 | 340 | | } |
| | | 341 | | |
| | | 342 | | /// <summary> |
| | | 343 | | /// Выгрузка номенклатуры в excel |
| | | 344 | | /// </summary> |
| | | 345 | | /// <param name="activeOnly">выгружать только активные товары (иначе все)</param> |
| | | 346 | | /// <returns></returns> |
| | | 347 | | [HttpGet("DownloadPrices")] |
| | | 348 | | [SwaggerResponse(200, "Успешно")] |
| | | 349 | | [SwaggerResponse(500, "Ошибка на стороне сервера", typeof(ErrorDTO))] |
| | | 350 | | [Authorize(Roles = Role.SystemAdmin + "," + Role.SystemOperator)] |
| | | 351 | | public async Task<IActionResult> DownloadPrices(string departmentFilter = null) |
| | 0 | 352 | | { |
| | 0 | 353 | | if(string.IsNullOrWhiteSpace(departmentFilter)) |
| | 0 | 354 | | { |
| | 0 | 355 | | throw new ArgumentException("Не задан фильтр по магазинам"); |
| | | 356 | | } |
| | 0 | 357 | | departmentFilter = departmentFilter.NormalizeName().ToLower(); |
| | | 358 | | |
| | 0 | 359 | | var rows = new List<string[]>(); |
| | 0 | 360 | | rows.Add(new string[] |
| | 0 | 361 | | { |
| | 0 | 362 | | "Дата выгрузки", |
| | 0 | 363 | | "Магазин-Получатель", |
| | 0 | 364 | | "ИД Товара", |
| | 0 | 365 | | "ШК товара", |
| | 0 | 366 | | "Артикул Товара", |
| | 0 | 367 | | "Название товара", |
| | 0 | 368 | | "Регулярная Цена товара", |
| | 0 | 369 | | "Акционная цена товара", |
| | 0 | 370 | | "Скидка", |
| | 0 | 371 | | "Количество на складе", |
| | 0 | 372 | | "Ярлыки товара", |
| | 0 | 373 | | "Наличие картинки", |
| | 0 | 374 | | "Название картинки" |
| | 0 | 375 | | }); |
| | | 376 | | |
| | 0 | 377 | | var downloadDate = DateTime.Today.ToString(); |
| | 0 | 378 | | var departments = (await _departmentService.GetAllDepartments()) |
| | 0 | 379 | | .Where(x => x.Name.ToLower().Contains(departmentFilter) && x.Cluster != null && !x.Cluster.IsDeleted) |
| | 0 | 380 | | .ToList(); |
| | 0 | 381 | | foreach(var dep in departments) |
| | 0 | 382 | | { |
| | 0 | 383 | | var goods = _worker.GetShowcaseGoods((long?)null, dep.Id, true, 0, int.MaxValue, null, null, null, out i |
| | 0 | 384 | | goods.ForEach(x => |
| | 0 | 385 | | { |
| | 0 | 386 | | string pictureFileName = ""; |
| | 0 | 387 | | if (x.Photos.Any()) |
| | 0 | 388 | | { |
| | 0 | 389 | | pictureFileName = x.Photos.First().FullSizeUrl; |
| | 0 | 390 | | Uri uri = new Uri(pictureFileName); |
| | 0 | 391 | | pictureFileName = Path.GetFileName(uri.LocalPath); |
| | 0 | 392 | | } |
| | 0 | 393 | | |
| | 0 | 394 | | rows.Add(new string[] |
| | 0 | 395 | | { |
| | 0 | 396 | | downloadDate, |
| | 0 | 397 | | dep.Name, |
| | 0 | 398 | | x.UniqueCode, |
| | 0 | 399 | | x.MainBarcode?.Code, |
| | 0 | 400 | | x.VendorCode, |
| | 0 | 401 | | x.Name, |
| | 0 | 402 | | x.OldPrice?.ToString(), |
| | 0 | 403 | | x.Price.ToString(), |
| | 0 | 404 | | x.Discount?.ToString(), |
| | 0 | 405 | | x.RestQuantity.ToString(), |
| | 0 | 406 | | string.Join(',', x.Labels.Select(x => x.Name).ToArray()), |
| | 0 | 407 | | _diskStorage.PictureExists(pictureFileName) ? "1" : "0", |
| | 0 | 408 | | pictureFileName |
| | 0 | 409 | | }); |
| | 0 | 410 | | }); |
| | 0 | 411 | | } |
| | | 412 | | |
| | 0 | 413 | | var stream = CsvUtil.ToExcelStream(rows); |
| | 0 | 414 | | _diskStorage.SaveDownload("prices.xlsx", stream, out string fileName); |
| | 0 | 415 | | return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Path.GetFileName(fi |
| | 0 | 416 | | } |
| | | 417 | | } |
| | | 418 | | } |