done
This commit is contained in:
parent
e96c1a10e7
commit
15f9e41b4c
@ -4,7 +4,9 @@ using FurnitureAssemblyContracts.BusinessLogicContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using FurnitureAssemblyDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Org.BouncyCastle.Asn1.X9;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FurnitureAssemblyRestApi.Controllers
|
||||
@ -110,6 +112,78 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>>? GetGraphicOrdersByPreviousDay()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Tuple<string, double>> list = new List<Tuple<string, double>>();
|
||||
var orderInfos = _orderInfo.ReadList(new OrderInfoSearchModel
|
||||
{
|
||||
DateFrom = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 1, 0, 0, 0),
|
||||
DateTo = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day - 1, 23, 59, 59)
|
||||
});
|
||||
foreach (var orderInfo in orderInfos)
|
||||
{
|
||||
list.Add(new Tuple<string, double>(orderInfo.Id.ToString(), orderInfo.Sum));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов по времени}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>>? GetGraphicOrdersByPaymentType()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<(PaymentType, double)> list = new List<(PaymentType, double)>();
|
||||
list.Add((PaymentType.Наличными, 0));
|
||||
list.Add((PaymentType.Картой, 0));
|
||||
list.Add((PaymentType.Смешанный, 0));
|
||||
List<OrderInfoViewModel> orderInfos = _orderInfo.ReadList(null);
|
||||
foreach (var orderInfo in orderInfos)
|
||||
{
|
||||
switch (orderInfo.PaymentType)
|
||||
{
|
||||
case PaymentType.Наличными:
|
||||
list[0] = (PaymentType.Наличными, list[0].Item2 + orderInfo.Sum);
|
||||
break;
|
||||
case PaymentType.Картой:
|
||||
list[1] = (PaymentType.Картой, list[1].Item2 + orderInfo.Sum);
|
||||
break;
|
||||
case PaymentType.Смешанный:
|
||||
list[2] = (PaymentType.Смешанный, list[2].Item2 + orderInfo.Sum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Tuple<string, double>> listRes = new List<Tuple<string, double>>();
|
||||
foreach (var el in list)
|
||||
{
|
||||
switch (el.Item1)
|
||||
{
|
||||
case PaymentType.Наличными:
|
||||
listRes.Add(new Tuple<string, double>("Наличными", el.Item2));
|
||||
break;
|
||||
case PaymentType.Картой:
|
||||
listRes.Add(new Tuple<string, double>("Картой", el.Item2));
|
||||
break;
|
||||
case PaymentType.Смешанный:
|
||||
listRes.Add(new Tuple<string, double>("Смешанный", el.Item2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return listRes;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов по времени}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public OrderInfoViewModel? AddOrderInfo(OrderInfoBindingModel model)
|
||||
{
|
||||
|
@ -759,5 +759,41 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
}
|
||||
return APIClient.GetRequest<List<Tuple<string, double>>>($"api/orderinfo/getgraphicusersbypreviousmonth");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult GraphicOrdersByPaymentType()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>> GetGraphicOrdersByPaymentType()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return APIClient.GetRequest<List<Tuple<string, double>>>($"api/orderinfo/getgraphicordersbypaymenttype") ;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult GraphicOrdersByPreviousDay()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>> GetGraphicOrdersByPreviousDay()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return APIClient.GetRequest<List<Tuple<string, double>>>($"api/orderinfo/GetGraphicOrdersByPreviousDay");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "График по типам оплаты";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<h3 class="display-4">График по типам оплаты</h3>
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetGraphicOrdersByPaymentType",
|
||||
success: function (result) {
|
||||
|
||||
var data = [];
|
||||
console.log(result)
|
||||
result.forEach((el) => {
|
||||
data.push({ year: el.item1, europe: el.item2 });
|
||||
});
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "График продаж за предыдущий день";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<h3 class="display-4">График продаж за предыдущий день</h3>
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetGraphicOrdersByPreviousDay",
|
||||
success: function (result) {
|
||||
|
||||
var data = [];
|
||||
|
||||
result.forEach((el) => {
|
||||
data.push({year: el.item1, europe: el.item2});
|
||||
});
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
@ -14,6 +14,8 @@
|
||||
<div>
|
||||
<a asp-action="GraphicOrdersByPreviousYear">График продаж за предыдущий год</a>
|
||||
<a asp-action="GraphicUsersByPreviousMonth">График продаж продавцов за предыдущий месяц</a>
|
||||
<a asp-action="GraphicOrdersByPaymentType">График продаж по типам оплаты</a>
|
||||
<a asp-action="GraphicOrdersByPreviousDay">График продаж за предыдущий день</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user