|
@@ -1,4 +1,5 @@
|
|
|
using Aspose.Cells;
|
|
|
+using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.Domain.Dtos.Statistics;
|
|
|
using OASystem.Domain.Entities.Customer;
|
|
@@ -6,7 +7,10 @@ using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
|
using OASystem.Domain.ViewModels.Statistics;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+using OfficeOpenXml.Drawing;
|
|
|
using System.Data;
|
|
|
+using System.Linq;
|
|
|
+using System.Security.Cryptography.Xml;
|
|
|
using static OASystem.API.OAMethodLib.GeneralMethod;
|
|
|
using TypeInfo = OASystem.Domain.ViewModels.Statistics.TypeInfo;
|
|
|
|
|
@@ -237,7 +241,7 @@ namespace OASystem.API.Controllers
|
|
|
Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
|
|
|
Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
|
|
|
Left Join Sys_Users u On ccp.CreateUserId = u.Id
|
|
|
- Where ccp.IsDel = 0 And ccp.CTable = 1015 {1} And ccp.DiId = {0} Order By CreateTime", _dto.DiId ,_dto.isAudit ? "And ccp.IsAuditGM = 1 And ccp.IsPay = 1 " : " ");
|
|
|
+ Where ccp.IsDel = 0 And ccp.CTable = 1015 {1} And ccp.DiId = {0} Order By CreateTime", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1 And ccp.IsPay = 1 " : " ");
|
|
|
|
|
|
List<Gsd_ExtraCostsView> _ExtraCostsViews = await _sqlSugar.SqlQueryable<Gsd_ExtraCostsView>(_ecSql).ToListAsync();
|
|
|
|
|
@@ -426,7 +430,7 @@ namespace OASystem.API.Controllers
|
|
|
Left Join Sys_SetData sd5 On hr.GovernmentRentCurrency = sd5.Id
|
|
|
Left Join Sys_SetData sd6 On hr.CityTaxCurrency = sd6.Id
|
|
|
Where hr.IsDel = 0 And ccp.IsDel = 0 And ccp.CTable = 76 {1} And ccp.PayMoney<> 0 And hr.DiId = {0}
|
|
|
- Order By CheckInDate Asc", _dto.DiId , _dto.isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
+ Order By CheckInDate Asc", _dto.DiId, _dto.isAudit ? "And ccp.IsAuditGM = 1" : " ");
|
|
|
|
|
|
groupHotelFeeViews = await _sqlSugar.SqlQueryable<GroupHotelFeeView>(hotelFeeSql).ToListAsync();
|
|
|
|
|
@@ -463,7 +467,7 @@ namespace OASystem.API.Controllers
|
|
|
是否由地接支付:{isFeeMark1} <br/>";
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var breakfastData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 2);
|
|
|
|
|
|
item.BreakfastPrice = breakfastData?.Price ?? 0.00M;
|
|
@@ -501,7 +505,7 @@ namespace OASystem.API.Controllers
|
|
|
卡类型:{_setDatas.Find(it => it.Id == landTaxData?.CTDId)?.Name} <br/>
|
|
|
是否由地接支付:{isFeeMark3} <br/>";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var cityTaxData = groupHotelContentFeeViews.Find(it => it.HrId == item.HrId && it.PriceType == 4);
|
|
|
|
|
|
item.CityTax = cityTaxData?.Price ?? 0.00M;
|
|
@@ -537,7 +541,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
item.RoomPriceCurrency = item.PaymentCurrency;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
HotelCNYTotalPrice += item.CNYPrice;
|
|
|
item.PayMoney = item.PayMoney.ConvertToDecimal1();
|
|
|
item.CNYPrice = item.CNYPrice.ConvertToDecimal1();
|
|
@@ -2157,7 +2161,7 @@ namespace OASystem.API.Controllers
|
|
|
List<int> companyIds = companyData.Select(it => it.id).ToList();
|
|
|
|
|
|
List<int> pickGroupUserIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0)
|
|
|
- .Select(it => it.JietuanOperator )
|
|
|
+ .Select(it => it.JietuanOperator)
|
|
|
.ToList();
|
|
|
|
|
|
|
|
@@ -2177,7 +2181,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
var dtData = new List<dynamic>();
|
|
|
int dt = DateTime.Now.Year;
|
|
|
- for (int y = dt; y >= dt-4; y--)
|
|
|
+ for (int y = dt; y >= dt - 4; y--)
|
|
|
{
|
|
|
|
|
|
var quarterDatas = new List<dynamic>();
|
|
@@ -2208,7 +2212,7 @@ namespace OASystem.API.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
- quarterData = new { name = "第二季度", monthData = monthDatas };
|
|
|
+ quarterData = new { name = "第二季度", monthData = monthDatas };
|
|
|
}
|
|
|
else if (q == 2)
|
|
|
{
|
|
@@ -2234,7 +2238,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
quarterData = new { name = "第四季度", monthData = monthDatas };
|
|
|
}
|
|
|
- quarterDatas.Add(quarterData);
|
|
|
+ quarterDatas.Add(quarterData);
|
|
|
}
|
|
|
|
|
|
dtData.Add(new
|
|
@@ -2294,8 +2298,8 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- string beginDt = $"{_dto.BeginDt} 00:00:00",endDt = $"{_dto.EndDt} 23:59:59";
|
|
|
-
|
|
|
+ string beginDt = $"{_dto.BeginDt} 00:00:00", endDt = $"{_dto.EndDt} 23:59:59";
|
|
|
+
|
|
|
return Ok(JsonView(true, "操作成功!", await GroupSales(_dto.CompanyId, _dto.GroupPickupUserId, beginDt, endDt)));
|
|
|
}
|
|
|
|
|
@@ -2308,7 +2312,7 @@ namespace OASystem.API.Controllers
|
|
|
List<int> userIds = new List<int>();
|
|
|
var userDatas = await _sqlSugar.Queryable<Sys_Users>()
|
|
|
.InnerJoin<Sys_Company>((u, c) => u.CompanyId == c.Id)
|
|
|
- .Where((u, c) => u.IsDel == 0 && pickGroupIds.Contains( u.Id))
|
|
|
+ .Where((u, c) => u.IsDel == 0 && pickGroupIds.Contains(u.Id))
|
|
|
.Select((u, c) => new { u.Id, u.CompanyId, u.CnName })
|
|
|
.ToListAsync();
|
|
|
|
|
@@ -2333,7 +2337,7 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
- private async Task<SalesYOYView> GroupSales(int companyId, int groupPickupUserId,string beginDt, string endDt)
|
|
|
+ private async Task<SalesYOYView> GroupSales(int companyId, int groupPickupUserId, string beginDt, string endDt)
|
|
|
{
|
|
|
decimal thisSales = 0.00M, lastSales = 0.00M, yoy = 1.00M;
|
|
|
|
|
@@ -2392,10 +2396,10 @@ FROM
|
|
|
|
|
|
var salesData = await _sqlSugar.SqlQueryable<SalesView>(salesSql).ToListAsync();
|
|
|
|
|
|
- thisSales = salesData.Where(x => x.Name.Equals("ThisSales")).First()?.Sales ?? 0;
|
|
|
- lastSales = salesData.Where(x => x.Name.Equals("LastSales")).First()?.Sales ?? 0;
|
|
|
+ thisSales = salesData.Where(x => x.Name.Equals("ThisSales")).First()?.Sales ?? 0;
|
|
|
+ lastSales = salesData.Where(x => x.Name.Equals("LastSales")).First()?.Sales ?? 0;
|
|
|
|
|
|
- if (lastSales != 0 && thisSales != 0) yoy = (thisSales - lastSales) / lastSales;
|
|
|
+ if (lastSales != 0 && thisSales != 0) yoy = (thisSales - lastSales) / lastSales;
|
|
|
|
|
|
return new SalesYOYView() {
|
|
|
thisYearSales = thisSales.ToString("#0.00"),
|
|
@@ -2554,7 +2558,7 @@ FROM
|
|
|
string userSql = "";
|
|
|
if (userIds.Count > 0)
|
|
|
{
|
|
|
- userSql = string.Format(@$" AND JietuanOperator IN ({string.Join(",",userIds)})");
|
|
|
+ userSql = string.Format(@$" AND JietuanOperator IN ({string.Join(",", userIds)})");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -2574,7 +2578,7 @@ FROM
|
|
|
|
|
|
string sql = "";
|
|
|
|
|
|
- if (_dto.StatisticsType == 1 )
|
|
|
+ if (_dto.StatisticsType == 1)
|
|
|
{
|
|
|
sql = string.Format(@$"Select
|
|
|
sd.[Name],
|
|
@@ -2629,7 +2633,7 @@ Group By [Name]
|
|
|
Order By Count Desc");
|
|
|
var clientGradeData = await _sqlSugar.SqlQueryable<MarketingSalesGroupStatisticsView>(sql2).ToListAsync();
|
|
|
return Ok(JsonView(true, "操作成功!", new {
|
|
|
- customerTypeData= customerTypeData,
|
|
|
+ customerTypeData = customerTypeData,
|
|
|
clientGradeData = clientGradeData
|
|
|
}));
|
|
|
|
|
@@ -2681,7 +2685,7 @@ Order By Count Desc");
|
|
|
if (userIds.Count > 0)
|
|
|
{
|
|
|
userSql = string.Format(@$" AND JietuanOperator IN ({string.Join(",", userIds)})");
|
|
|
- }else return Ok(JsonView(true, "操作成功!", new List<object> { }, 0));
|
|
|
+ } else return Ok(JsonView(true, "操作成功!", new List<object> { }, 0));
|
|
|
|
|
|
string sql = string.Format(@$"Select
|
|
|
ROW_NUMBER() Over(Order By Count(*) Desc) As RowNumber,
|
|
@@ -2886,7 +2890,7 @@ Order By Count Desc");
|
|
|
if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, MsgTips.CheckAuth));
|
|
|
#endregion
|
|
|
#endregion
|
|
|
- return Ok(await _visitingClientsRep._List(_dto.PortType,_dto.PageIndex,_dto.PageSize,_dto.DiId,_dto.Search));
|
|
|
+ return Ok(await _visitingClientsRep._List(_dto.PortType, _dto.PageIndex, _dto.PageSize, _dto.DiId, _dto.Search));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2930,8 +2934,8 @@ Order By Count Desc");
|
|
|
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
public async Task<IActionResult> PostMarketingSalesVCDel(MarketingSalesVCDelDto _dto)
|
|
|
{
|
|
|
-
|
|
|
- return Ok(await _visitingClientsRep._Del(_dto.Id,_dto.UserId));
|
|
|
+
|
|
|
+ return Ok(await _visitingClientsRep._Del(_dto.Id, _dto.UserId));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2979,7 +2983,7 @@ Order By Count Desc");
|
|
|
public async Task<IActionResult> DailypaymentTypeInit(DailypaymentTypeInitDto _dto)
|
|
|
{
|
|
|
#region 参数验证
|
|
|
- if (_dto.PortType < 1 || _dto.PortType > 3) return Ok(JsonView(false, msg:MsgTips.Port));
|
|
|
+ if (_dto.PortType < 1 || _dto.PortType > 3) return Ok(JsonView(false, msg: MsgTips.Port));
|
|
|
|
|
|
PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
#region 页面操作权限验证
|
|
@@ -3057,9 +3061,9 @@ Order By Count Desc");
|
|
|
var res = await RedisRepository.RedisFactory
|
|
|
.CreateRedisRepository()
|
|
|
.StringSetAsync(
|
|
|
- key:"DailypaymentTypeData",
|
|
|
+ key: "DailypaymentTypeData",
|
|
|
_dto.TypeIds,
|
|
|
- timeout:null );
|
|
|
+ timeout: null);
|
|
|
|
|
|
if (!res) return Ok(JsonView(false, "操作失败"));
|
|
|
|
|
@@ -3092,7 +3096,7 @@ Order By Count Desc");
|
|
|
}
|
|
|
return Ok(JsonView(false, sb.ToString()));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
#region 页面操作权限验证
|
|
@@ -3107,12 +3111,12 @@ Order By Count Desc");
|
|
|
DateTime _beginDt = Convert.ToDateTime($"{_dto.BeginDt} 00:00:00"),
|
|
|
_endDt = Convert.ToDateTime($"{_dto.EndDt} 23:59:59");
|
|
|
|
|
|
- string sqlWhere = string.Format(@" And dfp.CreateTime Between '{0}' And '{1}'",_beginDt,_endDt);
|
|
|
+ string sqlWhere = string.Format(@" And dfp.CreateTime Between '{0}' And '{1}'", _beginDt, _endDt);
|
|
|
|
|
|
var dailypaymentTypeData = await RedisRepository.RedisFactory
|
|
|
.CreateRedisRepository()
|
|
|
.StringGetAsync<List<int>>("DailypaymentTypeData") ?? new List<int>();
|
|
|
-
|
|
|
+
|
|
|
string sql = string.Format(@"
|
|
|
Select
|
|
|
dfp.Id,
|
|
@@ -3138,7 +3142,7 @@ Left Join Sys_SetData sd2 On dfp.PriceTypeId = sd2.Id
|
|
|
Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
", sqlWhere);//--Order By dfp.CreateTime Desc
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if (_dto.Type == 1)
|
|
|
{
|
|
|
RefAsync<int> total = 0;
|
|
@@ -3178,7 +3182,7 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
.ToPageListAsync(
|
|
|
pageNumber: 1,
|
|
|
pageSize: 99999
|
|
|
- ) ;
|
|
|
+ );
|
|
|
|
|
|
_sqlSugar.ThenMapper(_view, x =>
|
|
|
{
|
|
@@ -3199,10 +3203,10 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
x.ContentStr = str;
|
|
|
});
|
|
|
|
|
|
- if (_view.Count > 0 )
|
|
|
+ if (_view.Count > 0)
|
|
|
{
|
|
|
|
|
|
- DataTable dt = CommonFun.GetDataTableFromIList(_view );
|
|
|
+ DataTable dt = CommonFun.GetDataTableFromIList(_view);
|
|
|
dt.TableName = $"_view";
|
|
|
decimal total = _view.Sum(x => x.SumPrice);
|
|
|
WorkbookDesigner designer = new WorkbookDesigner();
|
|
@@ -3213,10 +3217,10 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
|
|
|
designer.Process();
|
|
|
|
|
|
- string fileName = $"DailyPayment/日付报表{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
|
|
|
+ string fileName = $"DailyPayment/日付报表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
|
|
|
designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
|
|
|
string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
|
|
|
- return Ok(JsonView(true, "操作成功", new { url = rst })) ;
|
|
|
+ return Ok(JsonView(true, "操作成功", new { url = rst }));
|
|
|
}
|
|
|
|
|
|
return Ok(JsonView(true, ",暂无数据"));
|
|
@@ -3232,7 +3236,7 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
#endregion
|
|
|
|
|
|
#region 统计模块
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -3244,10 +3248,10 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
|
|
|
public async Task<IActionResult> StatisticsYOY(YOYDto _dto)
|
|
|
{
|
|
|
|
|
|
- if (_dto.Year < 1) return Ok(JsonView(false,"操作失败"));
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
|
|
|
|
|
|
- string beginDt = $"{_dto.Year-1}-01-01 00:00:00",
|
|
|
+ string beginDt = $"{_dto.Year - 1}-01-01 00:00:00",
|
|
|
endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
|
|
|
string sql = string.Format(@"
|
|
@@ -3439,7 +3443,7 @@ WHERE
|
|
|
AND di.VisitDate BETWEEN '{0}' AND '{1}'
|
|
|
ORDER BY
|
|
|
di.VisitDate
|
|
|
-", beginDt,endDt);
|
|
|
+", beginDt, endDt);
|
|
|
|
|
|
var data = await _sqlSugar.SqlQueryable<StatisticsYOYView>(sql).ToListAsync();
|
|
|
|
|
@@ -3475,7 +3479,7 @@ ORDER BY
|
|
|
grossProfitYOYData = grossProfitYOYData.OrderBy(x => x.Month).ToList();
|
|
|
|
|
|
|
|
|
- return Ok(JsonView(true,"操作成功!", new { salesYOYData = salesYOYData, costYOYData = costYOYData, grossProfitYOYData = grossProfitYOYData }));
|
|
|
+ return Ok(JsonView(true, "操作成功!", new { salesYOYData = salesYOYData, costYOYData = costYOYData, grossProfitYOYData = grossProfitYOYData }));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3550,7 +3554,7 @@ WHERE
|
|
|
|
|
|
if (!string.IsNullOrEmpty(code))
|
|
|
{
|
|
|
- if (i == cityNum-1)
|
|
|
+ if (i == cityNum - 1)
|
|
|
{
|
|
|
cityName += threeCodeData.Find(x => x.Three.Equals(code))?.City ?? "";
|
|
|
}
|
|
@@ -3582,7 +3586,7 @@ WHERE
|
|
|
foreach (var item in monthData)
|
|
|
{
|
|
|
string groupName = groupNames.Find(x => item.DIId == x.Id)?.GroupName ?? "";
|
|
|
- aitTicketInfos.Add(new AitTicketInfo(item.DIId,groupName,item.ClientNum));
|
|
|
+ aitTicketInfos.Add(new AitTicketInfo(item.DIId, groupName, item.ClientNum));
|
|
|
}
|
|
|
var aitTicketInfosGroupBy = aitTicketInfos.GroupBy(x => x.Id);
|
|
|
|
|
@@ -3598,7 +3602,7 @@ WHERE
|
|
|
|
|
|
linkGroupIds = linkGroupIds.Distinct().ToList();
|
|
|
|
|
|
- airTicketNumData.Add(new AirTicketReturnView(_dto.Year, monthIndex, airticket_quantity, aitTicketInfos1,linkGroupIds));
|
|
|
+ airTicketNumData.Add(new AirTicketReturnView(_dto.Year, monthIndex, airticket_quantity, aitTicketInfos1, linkGroupIds));
|
|
|
|
|
|
|
|
|
|
|
@@ -3612,7 +3616,7 @@ WHERE
|
|
|
var cityArray = item.FlightsCityName.Split("、").ToList();
|
|
|
foreach (var item1 in cityArray)
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(item.FlightsCityName))
|
|
|
+ if (!string.IsNullOrEmpty(item1))
|
|
|
{
|
|
|
airTicketCityInfos.Add(item1);
|
|
|
}
|
|
@@ -3712,7 +3716,7 @@ WHERE
|
|
|
AND hr.CheckInDate BETWEEN CONVERT(datetime,'{0}') AND CONVERT(datetime,'{1}')
|
|
|
ORDER BY
|
|
|
hr.CheckInDate
|
|
|
-", beginDt,endDt);
|
|
|
+", beginDt, endDt);
|
|
|
|
|
|
var data = await _sqlSugar.SqlQueryable<StatisticsHotelView>(sql).ToListAsync();
|
|
|
|
|
@@ -3734,9 +3738,9 @@ ORDER BY
|
|
|
otherRoomCount = g1.Sum(x => x.OtherRoomCount),
|
|
|
})
|
|
|
.ToList(),
|
|
|
- linkGroupIds = g.Select(x => x.DIId).Distinct().ToList()
|
|
|
+ linkGroupIds = g.Select(x => x.DIId).Distinct().ToList()
|
|
|
|
|
|
- })
|
|
|
+ })
|
|
|
.OrderByDescending(x => x.BookingRoomNum)
|
|
|
.Take(10)
|
|
|
.ToList();
|
|
@@ -3783,9 +3787,9 @@ WHERE
|
|
|
var groupByData = data.GroupBy(x => x.Country)
|
|
|
.Select(g => new
|
|
|
{
|
|
|
- Country = g.Key,
|
|
|
- TimeNum = g.Count(),
|
|
|
- LinkGroupIds = g.Select(x => x.DIId).ToList()
|
|
|
+ Country = g.Key,
|
|
|
+ TimeNum = g.Count(),
|
|
|
+ LinkGroupIds = g.Select(x => x.DIId).ToList()
|
|
|
|
|
|
})
|
|
|
.OrderByDescending(x => x.TimeNum)
|
|
@@ -3846,6 +3850,448 @@ WHERE
|
|
|
return Ok(JsonView(true, "操作成功!", groupByData));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("StatisticsCooperativeCustomer")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsCooperativeCustomer(YOYDto _dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
+
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
+ DateTime _beginDt = Convert.ToDateTime(beginDt),
|
|
|
+ _endDt = Convert.ToDateTime(endDt);
|
|
|
+
|
|
|
+ var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .Where(x => x.IsSure == 1)
|
|
|
+ .Where(x => x.VisitDate >= _beginDt && x.VisitDate <= _endDt)
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var groupInfos1 = groupInfos.GroupBy(x => x.ClientName);
|
|
|
+
|
|
|
+ var view = groupInfos1.Select(x =>
|
|
|
+ new {
|
|
|
+ clienName = x.Key,
|
|
|
+ clientUnit = x.FirstOrDefault()?.ClientUnit ?? "",
|
|
|
+ visitsNum = x.Count()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .OrderByDescending(x => x.visitsNum)
|
|
|
+ .Take(10)
|
|
|
+ .ToList();
|
|
|
+ return Ok(JsonView(true, "操作成功!", view));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("StatisticsCooperativeCustomerType")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsCooperativeCustomerType(YOYDto _dto)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
+
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
+ DateTime _beginDt = Convert.ToDateTime(beginDt),
|
|
|
+ _endDt = Convert.ToDateTime(endDt);
|
|
|
+
|
|
|
+ var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .LeftJoin<Sys_SetData>((di, sd) => di.TeamDid == sd.Id)
|
|
|
+ .Where((di, sd) => di.IsDel == 0)
|
|
|
+ .Where((di, sd) => di.VisitDate >= _beginDt && di.VisitDate <= _endDt)
|
|
|
+ .Select((di, sd) => new {
|
|
|
+ Id = di.Id,
|
|
|
+ GroupTypeId = di.TeamDid,
|
|
|
+ GroupTypeName = sd.Name,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ var groupInfos1 = groupInfos.GroupBy(x => x.GroupTypeName);
|
|
|
+
|
|
|
+ var view = groupInfos1.Select(x =>
|
|
|
+ new {
|
|
|
+ groupTypeName = x.Key,
|
|
|
+ groupNum = x.Count(),
|
|
|
+ linkGroupId = x.Select(x1 => x1.Id).ToList()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .OrderByDescending(x => x.groupNum)
|
|
|
+ .ToList();
|
|
|
+ return Ok(JsonView(true, "操作成功!", view));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("StatisticsGroupNum")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsGroupNum(YOYDto _dto)
|
|
|
+ {
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
+ DateTime _beginDt = Convert.ToDateTime(beginDt),
|
|
|
+ _endDt = Convert.ToDateTime(endDt);
|
|
|
+
|
|
|
+ var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .Where(x => x.VisitDate >= _beginDt && x.VisitDate <= _endDt)
|
|
|
+ .Select(x => new StatisticsGroupInfoEntity
|
|
|
+ {
|
|
|
+ Id = x.Id,
|
|
|
+ VisitDate = x.VisitDate,
|
|
|
+ Month = x.VisitDate.Month,
|
|
|
+
|
|
|
+ VisitPNumber = x.VisitPNumber
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .OrderBy(x => new { x.Month })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ string groupNumStr = $"年度出访量:{groupInfos.Count}\r\n";
|
|
|
+
|
|
|
+ var groupNumYearData = new
|
|
|
+ {
|
|
|
+ year = _dto.Year,
|
|
|
+ yearName = _dto.Year + "年",
|
|
|
+ num = groupInfos.Count,
|
|
|
+ linkGroupIds = groupInfos.Select(x => x.Id).ToList()
|
|
|
+ };
|
|
|
+ var groupNumData = groupInfos.GroupBy(x => x.Quarter)
|
|
|
+ .Select(x => new {
|
|
|
+ Quarter = x.Key,
|
|
|
+ QuarterName = x.FirstOrDefault()?.QuarterName ?? "-",
|
|
|
+ Num = x.Count(),
|
|
|
+ LinkGroupIds = x.Select(x1 => x1.Id).ToList()
|
|
|
+ })
|
|
|
+ .OrderBy(x => x.Quarter)
|
|
|
+ .ToList();
|
|
|
+ groupNumData.ForEach(x =>
|
|
|
+ {
|
|
|
+ groupNumStr += $"{x.QuarterName}出访量:{x.Num};";
|
|
|
+ });
|
|
|
+
|
|
|
+ var groupNumMonthData = groupInfos.GroupBy(x => x.Month)
|
|
|
+ .Select(x => new {
|
|
|
+ Month = x.Key,
|
|
|
+ MonthName = x.FirstOrDefault()?.MonthName ?? "-",
|
|
|
+ Num = x.Count(),
|
|
|
+ LinkGroupIds = x.Select(x1 => x1.Id).ToList()
|
|
|
+ })
|
|
|
+ .OrderBy(x => x.Month)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功!", new
|
|
|
+ {
|
|
|
+ yearData = groupNumYearData,
|
|
|
+ quarterData = groupNumData,
|
|
|
+ monthData = groupNumMonthData,
|
|
|
+ remark = groupNumStr
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("StatisticsGroupPeopleNum")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsGroupPeopleNum(YOYDto _dto)
|
|
|
+ {
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.Year}-01-01 00:00:00",
|
|
|
+ endDt = $"{_dto.Year}-12-31 23:59:59";
|
|
|
+ DateTime _beginDt = Convert.ToDateTime(beginDt),
|
|
|
+ _endDt = Convert.ToDateTime(endDt);
|
|
|
+
|
|
|
+ var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .Where(x => x.VisitDate >= _beginDt && x.VisitDate <= _endDt)
|
|
|
+ .Select(x => new StatisticsGroupInfoEntity
|
|
|
+ {
|
|
|
+ Id = x.Id,
|
|
|
+ VisitDate = x.VisitDate,
|
|
|
+ Month = x.VisitDate.Month,
|
|
|
+ VisitPNumber = x.VisitPNumber
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .OrderBy(x => new { x.Month })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ string groupPeopleNumStr = $"年度出访人数:{groupInfos.Sum(x => x.VisitPNumber)}\r\n";
|
|
|
+
|
|
|
+ var groupPeopleNumYearData = new
|
|
|
+ {
|
|
|
+ year = _dto.Year,
|
|
|
+ yearName = _dto.Year + "年",
|
|
|
+ num = groupInfos.Sum(x => x.VisitPNumber),
|
|
|
+ linkGroupIds = groupInfos.Select(x => x.Id).ToList()
|
|
|
+ };
|
|
|
+ var groupPeopleNumData = groupInfos.GroupBy(x => x.Quarter)
|
|
|
+ .Select(x => new {
|
|
|
+ Quarter = x.Key,
|
|
|
+ QuarterName = x.FirstOrDefault()?.QuarterName ?? "-",
|
|
|
+ Num = x.Sum(x1 => x1.VisitPNumber),
|
|
|
+ LinkGroupIds = x.Select(x1 => x1.Id).ToList()
|
|
|
+ })
|
|
|
+ .OrderBy(x => x.Quarter)
|
|
|
+ .ToList();
|
|
|
+ groupPeopleNumData.ForEach(x =>
|
|
|
+ {
|
|
|
+ groupPeopleNumStr += $"{x.QuarterName}出访人数:{x.Num};";
|
|
|
+ });
|
|
|
+
|
|
|
+ var groupPeopleNumMonthData = groupInfos.GroupBy(x => x.Month)
|
|
|
+ .Select(x => new {
|
|
|
+ Month = x.Key,
|
|
|
+ MonthName = x.FirstOrDefault()?.MonthName ?? "-",
|
|
|
+ Num = x.Sum(x1 => x1.VisitPNumber),
|
|
|
+ LinkGroupIds = x.Select(x1 => x1.Id).ToList()
|
|
|
+ })
|
|
|
+ .OrderBy(x => x.Month)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功!", new
|
|
|
+ {
|
|
|
+ yearData = groupPeopleNumYearData,
|
|
|
+ quarterData = groupPeopleNumData,
|
|
|
+ monthData = groupPeopleNumMonthData,
|
|
|
+ remark = groupPeopleNumStr
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost("StatisticsOP")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> StatisticsOP(StatisticsOPDto _dto)
|
|
|
+ {
|
|
|
+ if (_dto.Year < 1) return Ok(JsonView(false, "Year参数错误!"));
|
|
|
+ if (_dto.Type < 1 || _dto.Type > 2) return Ok(JsonView(false, "Type参数错误!"));
|
|
|
+
|
|
|
+
|
|
|
+ int thisYear = _dto.Year, lastYear = _dto.Year - 1;
|
|
|
+ string beginDt = $"{lastYear}-01-01 00:00:00",
|
|
|
+ endDt = $"{thisYear}-12-31 23:59:59";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string sql = string.Format(@"
|
|
|
+SELECT
|
|
|
+ temp.Id,
|
|
|
+ DiId,
|
|
|
+ PaymentTime,
|
|
|
+ [Year],
|
|
|
+ [Quarter],
|
|
|
+ [Month],
|
|
|
+ Area,
|
|
|
+ FeeType,
|
|
|
+ sd1.Name AS FeeTypeName,
|
|
|
+ FeeSubType,
|
|
|
+ sd2.Name AS FeeSubTypeName,
|
|
|
+ CONVERT(DECIMAL(12, 2), Price * Qauntity * ExchangeRate) AS Price
|
|
|
+FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ctggr.Id,
|
|
|
+ ctggr.DiId,
|
|
|
+ ctggr.Area,
|
|
|
+ CASE
|
|
|
+ WHEN ctggr.PriceType IS NULL THEN 1069
|
|
|
+ ELSE ctggr.PriceType
|
|
|
+ END AS FeeType,
|
|
|
+ ctggrc.SId AS FeeSubType,
|
|
|
+ ctggrc.Price,
|
|
|
+ CASE
|
|
|
+ WHEN ctggrc.Count IS NULL THEN 1
|
|
|
+ ELSE ctggrc.Count
|
|
|
+ END AS Qauntity,
|
|
|
+ ccp.DayRate AS ExchangeRate,
|
|
|
+ ctggrc.CreateTime AS PaymentTime,
|
|
|
+ YEAR(ctggrc.CreateTime) AS [Year],
|
|
|
+ CONVERT(INT,DATENAME(QUARTER, ctggrc.CreateTime)) AS [Quarter],
|
|
|
+ MONTH(ctggrc.CreateTime) AS [Month]
|
|
|
+ FROM
|
|
|
+ Grp_CarTouristGuideGroundReservations ctggr
|
|
|
+ INNER JOIN Grp_CarTouristGuideGroundReservationsContent ctggrc ON ctggr.Id = ctggrc.CTGGRId
|
|
|
+ AND ctggrc.IsDel = 0
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ctggr.Id = ccp.CId
|
|
|
+ AND ccp.CTable = 79
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ WHERE
|
|
|
+ ctggr.IsDel = 0
|
|
|
+ AND ctggrc.SId != 1070 --费用子项筛掉尾款
|
|
|
+ AND ctggrc.Price > 0 --筛选真实存在的数据
|
|
|
+ AND ccp.IsPay = 1
|
|
|
+ ) temp
|
|
|
+ LEFT JOIN Sys_SetData sd1 ON FeeType = sd1.Id
|
|
|
+ LEFT JOIN Sys_SetData sd2 ON FeeSubType = sd2.Id
|
|
|
+WHERE
|
|
|
+ temp.Area NOT LIKE '%尾款%' -- 筛选掉尾款相关信息
|
|
|
+ AND temp.FeeType != 1062 --费用类型筛选掉全款和首付款数据
|
|
|
+ AND temp.PaymentTime BETWEEN CONVERT(datetime,'{0}') AND CONVERT(datetime,'{1}')
|
|
|
+ORDER BY
|
|
|
+ temp.[Year],
|
|
|
+ temp.[Quarter],
|
|
|
+ temp.[Month]
|
|
|
+", beginDt,endDt);
|
|
|
+
|
|
|
+ var opInfos = await _sqlSugar.SqlQueryable<StatisticsOP>(sql).ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
+
|
|
|
+ for (int i = 0; i < opInfos.Count; i++)
|
|
|
+ {
|
|
|
+ string country = string.Empty,city =string.Empty;
|
|
|
+
|
|
|
+ int dataId = 0;
|
|
|
+ bool isCountryId = int.TryParse(opInfos[i].Area, out dataId);
|
|
|
+ string[] citySelecter = new string[] {"其他城市","所有城市" };
|
|
|
+ if (isCountryId)
|
|
|
+ {
|
|
|
+ var countryInfo = countrys.Find(x => x.Id == dataId);
|
|
|
+ country = countryInfo?.Country ?? "";
|
|
|
+ if (citySelecter.Contains(countryInfo?.City)) city = country;
|
|
|
+ else city = countryInfo?.City ?? "";
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var countryInfo1 = countrys.Find(x => opInfos[i].Area.Contains(x.Country));
|
|
|
+ if (countryInfo1 != null)
|
|
|
+ {
|
|
|
+ country = countryInfo1?.Country ?? "";
|
|
|
+ city = countryInfo1?.City ?? country;
|
|
|
+ var countryInfo2 = countrys.Find(x => opInfos[i].Area.Contains(x.City));
|
|
|
+
|
|
|
+ if (citySelecter.Contains(countryInfo2?.City)) city = country;
|
|
|
+ else city = countryInfo2?.City ?? country;
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var countryInfo2 = countrys.Find(x => opInfos[i].Area.Contains(x.City));
|
|
|
+
|
|
|
+ if (countryInfo2 != null)
|
|
|
+ {
|
|
|
+ country = countryInfo2?.Country ?? "";
|
|
|
+ city = countryInfo2?.City ?? "";
|
|
|
+
|
|
|
+ if (citySelecter.Contains(countryInfo2?.City)) city = country;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ opInfos[i].Country = country;
|
|
|
+ opInfos[i].City = city;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_dto.Type == 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ var yearData = opInfos.GroupBy(x => x.ParentFeeName)
|
|
|
+ .Select(x => new StatisticsOPYOY(
|
|
|
+ feeId: x.FirstOrDefault()?.ParentFeeId ?? 0,
|
|
|
+ feeName: x.Key,
|
|
|
+ currPeriodFee: x.Where(x => x.Year == thisYear).Sum(x => x.Price),
|
|
|
+ samePeriodFee: x.Where(x => x.Year == lastYear).Sum(x => x.Price),
|
|
|
+ currPeriodGroupTotal: x.Where(x => x.Year == thisYear).Select(x => x.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x.Where(x => x.Year == lastYear).Select(x => x.DiId).Distinct().Count(),
|
|
|
+ subFeeData: x.GroupBy(x1 => x1.FeeSubType)
|
|
|
+ .Select(x1 => new StatisticsOPSubFeeYOY(
|
|
|
+ feeId: x1.Key,
|
|
|
+ feeName: x1.FirstOrDefault()?.FeeSubTypeName ?? "",
|
|
|
+ currPeriodFee: x1.Where(x1 => x1.Year == thisYear).Sum(x1 => x1.Price),
|
|
|
+ samePeriodFee: x1.Where(x1 => x1.Year == lastYear).Sum(x1 => x1.Price),
|
|
|
+ currPeriodGroupTotal: x1.Where(x1 => x1.Year == thisYear).Select(x1 => x1.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x1.Where(x1 => x1.Year == lastYear).Select(x1 => x1.DiId).Distinct().Count(),
|
|
|
+ cityData: x1.GroupBy(x2 => x2.City)
|
|
|
+ .Select(x2 => new StatisticsOPCityYOY(
|
|
|
+ cityName: x2.Key,
|
|
|
+ currPeriodGroupTotal: x2.Where(x2 => x2.Year == thisYear).Select(x2 => x2.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x2.Where(x2 => x2.Year == lastYear).Select(x2 => x2.DiId).Distinct().Count(),
|
|
|
+ currPeriodFee: x2.Where(x2 => x2.Year == thisYear).Sum(x2 => x2.Price),
|
|
|
+ samePeriodFee: x2.Where(x2 => x2.Year == lastYear).Sum(x2 => x2.Price)
|
|
|
+ ))
|
|
|
+ .ToArray()
|
|
|
+ ))
|
|
|
+ .ToArray()
|
|
|
+ ))
|
|
|
+ .OrderBy(x => x.FeeId)
|
|
|
+ .ToList();
|
|
|
+ return Ok(JsonView(true, "操作成功!", yearData));
|
|
|
+ }
|
|
|
+ else if (_dto.Type == 2)
|
|
|
+ {
|
|
|
+ var monthData = opInfos.GroupBy(x => x.Month)
|
|
|
+ .Select(x => new StatisticsOPMonthYOY(
|
|
|
+ monthId: x.Key,
|
|
|
+ monthName: Enum.IsDefined(typeof(MonthEnum), (int)x.Key) ? ((MonthEnum)(int)x.Key).GetEnumDescription() : "",
|
|
|
+ feeDatas:x.GroupBy(x1 => x1.ParentFeeId)
|
|
|
+ .Select(x1 => new StatisticsOPYOY(
|
|
|
+ feeId:x1.Key,
|
|
|
+ feeName: x1.FirstOrDefault()?.ParentFeeName ?? "",
|
|
|
+ currPeriodFee: x1.Where(x1 => x1.Year == thisYear).Sum(x1 => x1.Price),
|
|
|
+ samePeriodFee: x1.Where(x1 => x1.Year == lastYear).Sum(x1 => x1.Price),
|
|
|
+ currPeriodGroupTotal: x1.Where(x1 => x1.Year == thisYear).Select(x1 => x1.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x1.Where(x1 => x1.Year == lastYear).Select(x1 => x1.DiId).Distinct().Count(),
|
|
|
+ subFeeData:x1.GroupBy(x2 => x2.FeeSubType)
|
|
|
+ .Select(x2 => new StatisticsOPSubFeeYOY(
|
|
|
+ feeId: x2.Key,
|
|
|
+ feeName: x2.FirstOrDefault()?.FeeSubTypeName ?? "",
|
|
|
+ currPeriodFee: x2.Where(x2 => x2.Year == thisYear).Sum(x2 => x2.Price),
|
|
|
+ samePeriodFee: x2.Where(x2 => x2.Year == lastYear).Sum(x2 => x2.Price),
|
|
|
+ currPeriodGroupTotal: x2.Where(x2 => x2.Year == thisYear).Select(x2 => x2.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x2.Where(x2 => x2.Year == lastYear).Select(x2 => x2.DiId).Distinct().Count(),
|
|
|
+ cityData: x2.GroupBy(x3 => x3.City)
|
|
|
+ .Select(x3 => new StatisticsOPCityYOY(
|
|
|
+ cityName: x3.Key,
|
|
|
+ currPeriodFee: x3.Where(x3 => x3.Year == thisYear).Sum(x3 => x3.Price),
|
|
|
+ samePeriodFee: x3.Where(x3 => x3.Year == lastYear).Sum(x3 => x3.Price),
|
|
|
+ currPeriodGroupTotal: x3.Where(x3 => x3.Year == thisYear).Select(x3 => x3.DiId).Distinct().Count(),
|
|
|
+ samePeriodGroupTotal: x3.Where(x3 => x3.Year == lastYear).Select(x3 => x3.DiId).Distinct().Count()
|
|
|
+ ))
|
|
|
+ .ToArray()
|
|
|
+ ))
|
|
|
+ .ToArray()
|
|
|
+
|
|
|
+ ))
|
|
|
+ .ToArray()
|
|
|
+ ))
|
|
|
+ .OrderBy(x => x.MonthId)
|
|
|
+ .ToList();
|
|
|
+ return Ok(JsonView(true, "操作成功!", monthData));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(false, "操作失败!"));
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|