This commit is contained in:
Илья Федотов 2024-07-27 12:48:31 +04:00
parent 4137695876
commit 44a14b6d77
5 changed files with 27 additions and 27 deletions

View File

@ -39,6 +39,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
var paymeants = _paymeantstorage.GetFillteredList(new PaymeantSearchModel {
DateFrom = model.DateFrom,
DateTo = model.DateTo,
ClientID = model.ClientID,
});
List<ReportProductsViewModel>? products = new();
@ -91,17 +92,15 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
TotalCount = 0
};
foreach (var payment in paymeants) {
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID })
?? throw new Exception("Ошибка полуения данных");
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID })
?? throw new Exception("Ошибка полуения данных");
foreach (var product in order.ProductList) {
record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2));
record.TotalCount += product.Value.Item2;
}
}
list.Add(record);
foreach (var product in order.ProductList) {
record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2));
record.TotalCount += product.Value.Item2;
}
list.Add(record);
}
return list;

View File

@ -13,5 +13,6 @@ namespace ElectronicsShopContracts.BindingModels
public string ClientEmail { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public int ClientID { get; set; }
}
}

View File

@ -113,6 +113,19 @@ namespace ElectronicsShopRestAPI.Controllers {
}
_payLogic.CreatePay(model);
var order = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID });
if (order == null) {
throw new Exception("Ошибка получения данных");
}
_orderLogic.Update(new OrderBindingModel {
ID = order.ID,
ClientID = order.ClientID,
DateCreate = order.DateCreate,
Sum = order.Sum - model.SumPayment,
ProductList = order.ProductList,
});
}
if (model.PayOption == 0) {
@ -126,26 +139,11 @@ namespace ElectronicsShopRestAPI.Controllers {
ID = model.OrderID,
ClientID = order.ClientID,
DateCreate = order.DateCreate,
Sum = order.Sum - model.SumPayment,
Sum = order.Sum,
ProductList = order.ProductList,
Status = OrderStatus.Оплачено
});
}
else {
var order = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID });
if (order == null) {
throw new Exception("Ошибка получения данных");
}
_orderLogic.Update(new OrderBindingModel {
ID = order.ID,
ClientID = order.ClientID,
DateCreate = order.DateCreate,
Sum = order.Sum - model.SumPayment,
ProductList = order.ProductList,
});
}
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка создания оплаты");

View File

@ -274,6 +274,7 @@ namespace ElectronicsShopUserApp.Controllers {
return PaymeantOption.Íåîïëà÷åíî;
}
}
[HttpPost]
public double Calc(int count, int product) {
var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}");
@ -333,7 +334,8 @@ namespace ElectronicsShopUserApp.Controllers {
APIClient.PostRequest("api/client/SendReportMail", new ReportBindingModel {
ClientEmail = APIClient.Client?.Email ?? throw new Exception("Îøèáêà ïîëó÷åíèÿ àäðåñà"),
DateFrom = DateTime.Parse(DateFrom),
DateTo = DateTime.Parse(DateTo)
DateTo = DateTime.Parse(DateTo),
ClientID = APIClient.Client.ID
});
return View("Report");
}