|
@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Statistics;
|
|
|
using OASystem.Domain.Entities.Customer;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
|
+using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
|
using OASystem.Domain.ViewModels.Statistics;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
using System.Data;
|
|
@@ -2316,8 +2317,8 @@ ORDER BY
|
|
|
{
|
|
|
//全部人员Id
|
|
|
//查询所有公司的市场部
|
|
|
- List<int> pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
|
|
|
- List<int> userIds = new List<int>();
|
|
|
+ var pickGroupIds = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).Select(it => it.JietuanOperator).Distinct().ToList();
|
|
|
+ var 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))
|
|
@@ -2462,7 +2463,6 @@ FROM
|
|
|
public string yoy { get; set; } = "1.00";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 市场部销售额
|
|
|
/// 团组列表
|
|
@@ -2615,6 +2615,132 @@ FROM
|
|
|
return Ok(JsonView(true, "操作成功!", groupData, total));
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 市场部销售额
|
|
|
+ /// 团组列表Excel下载
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">市场部销售额请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("PostMarketingSalesGroupExcel")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostMarketingSalesGroupExcel(MarketingSalesGroupListDto _dto)
|
|
|
+ {
|
|
|
+ #region 参数验证
|
|
|
+
|
|
|
+ MarketingSalesStatisticsDtoFoalidator validationRules = new MarketingSalesStatisticsDtoFoalidator();
|
|
|
+ var validResult = await validationRules.ValidateAsync(_dto);
|
|
|
+ if (!validResult.IsValid)
|
|
|
+ {
|
|
|
+ var errors = new StringBuilder();
|
|
|
+ foreach (var error in validResult.Errors) errors.AppendLine(error.ErrorMessage);
|
|
|
+ return Ok(JsonView(false, errors.ToString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+
|
|
|
+ #region 页面操作权限验证
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, MsgTips.CheckAuth));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ string userSql = "";
|
|
|
+ var userIds = new List<int>();
|
|
|
+ userIds = await GetUserIds(_dto.CompanyId, _dto.GroupPickupUserId);
|
|
|
+
|
|
|
+ if (userIds.Count <= 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false));
|
|
|
+ }
|
|
|
+ else userSql = @$" And di.JietuanOperator In ({string.Join(",", userIds)})";
|
|
|
+
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(_dto.SearchCriteria))
|
|
|
+ {
|
|
|
+ userSql += string.Format(@$" AND di.TeamName Like '%{_dto.SearchCriteria}%'");
|
|
|
+ }
|
|
|
+
|
|
|
+ string beginDt = $"{_dto.BeginDt} 00:00:00",
|
|
|
+ endDt = $"{_dto.EndDt} 23:59:59";
|
|
|
+
|
|
|
+ string sql = string.Format(@$"SELECT
|
|
|
+ ROW_NUMBER() OVER (
|
|
|
+ ORDER BY
|
|
|
+ CollectionDays
|
|
|
+ ) AS RowNumber,
|
|
|
+ *
|
|
|
+FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ di.Id,
|
|
|
+ di.TeamName,
|
|
|
+ di.ClientUnit,
|
|
|
+ di.ClientName,
|
|
|
+ di.VisitDate,
|
|
|
+ di.VisitPNumber,
|
|
|
+ di.JietuanOperator,
|
|
|
+ di.VisitEndDate,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ COALESCE(SUM(ItemSumPrice * Rate), 0) AS DECIMAL(12, 2)
|
|
|
+ ) AS GroupSales
|
|
|
+ FROM
|
|
|
+ Fin_ForeignReceivables
|
|
|
+ WHERE
|
|
|
+ IsDel = 0
|
|
|
+ AND di.Id = Diid
|
|
|
+ AND AddingWay IN (0, 1, 2)
|
|
|
+ ) AS GroupSales,
|
|
|
+ u.CnName AS GroupPickupUser,
|
|
|
+ DATEADD(DAY, 7, di.VisitEndDate) AS CollectionDays
|
|
|
+ FROM
|
|
|
+ Grp_DelegationInfo di
|
|
|
+ WITH
|
|
|
+ (NoLock)
|
|
|
+ LEFT JOIN Sys_Users u ON di.JietuanOperator = u.Id
|
|
|
+ WHERE
|
|
|
+ di.Isdel = 0
|
|
|
+ AND (
|
|
|
+ SELECT
|
|
|
+ CAST(
|
|
|
+ COALESCE(SUM(ItemSumPrice * Rate), 0) AS DECIMAL(12, 2)
|
|
|
+ ) AS GroupSales
|
|
|
+ FROM
|
|
|
+ Fin_ForeignReceivables
|
|
|
+ WHERE
|
|
|
+ IsDel = 0
|
|
|
+ AND di.Id = Diid
|
|
|
+ AND AddingWay IN (0, 1, 2)
|
|
|
+ ) > 0
|
|
|
+ {userSql}
|
|
|
+ AND VisitDate Between '{beginDt}' And '{endDt}'
|
|
|
+ ) Temp ");
|
|
|
+
|
|
|
+ var view = await _sqlSugar.SqlQueryable<MarketingSalesGroupList>(sql).ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ if (view.Count < 1 ) return Ok(JsonView(false, "暂无数据!"));
|
|
|
+
|
|
|
+ //DataTable dt = GeneralMethod.
|
|
|
+ DataTable dt = CommonFun.GetDataTableFromIList(view);
|
|
|
+ dt.TableName = $"_view";
|
|
|
+ WorkbookDesigner designer = new WorkbookDesigner();
|
|
|
+ designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/营业额团组报表模板.xls");
|
|
|
+ designer.SetDataSource(dt);
|
|
|
+ designer.SetDataSource("Total", view.Sum(x => x.GroupSales));
|
|
|
+ designer.Workbook.Worksheets[0].Name = "营业额团组报表";
|
|
|
+
|
|
|
+ designer.Process();
|
|
|
+
|
|
|
+ string fileName = $"MarketingSales/{_dto.BeginDt}~{_dto.EndDt}营业额团组报表{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 }));
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 市场部销售额
|
|
|
/// 客户类型、客户等级 统计
|
|
@@ -3685,7 +3811,7 @@ ORDER BY
|
|
|
|
|
|
/// <summary>
|
|
|
/// 国交数据统计-机票相关
|
|
|
- /// 1、机票票数、2、机票到达地
|
|
|
+ /// 机票票数、机票到达地、预订平台
|
|
|
/// </summary>
|
|
|
/// <param name="_dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -3709,7 +3835,12 @@ SELECT
|
|
|
sd.Name As CTypeName,
|
|
|
atr.FlightsCity,
|
|
|
atr.ClientNum,
|
|
|
- atr.ClientName
|
|
|
+ atr.ClientName,
|
|
|
+ di.TeamName As 'GroupName',
|
|
|
+ CASE
|
|
|
+ WHEN ccp.Payee = '' OR ccp.Payee IS NULL THEN '未知'
|
|
|
+ ELSE ccp.Payee
|
|
|
+ END AS 'Platform'
|
|
|
FROM
|
|
|
Grp_AirTicketReservations atr
|
|
|
INNER JOIN Grp_CreditCardPayment ccp ON atr.Id = ccp.CId
|
|
@@ -3720,7 +3851,7 @@ FROM
|
|
|
WHERE
|
|
|
atr.IsDel = 0
|
|
|
AND di.TeamDid IN (38,39,40,1048)
|
|
|
- And atr.CType IN(457,458,459,460,574,575)
|
|
|
+ AND atr.CType IN(457,458,459,460,574,575)
|
|
|
AND CHARINDEX('行程单',atr.ClientName) = 0
|
|
|
AND CHARINDEX('返点',atr.ClientName) = 0
|
|
|
AND CHARINDEX('-1',atr.ClientName) = 0
|
|
@@ -3808,7 +3939,7 @@ WHERE
|
|
|
|
|
|
//机票城市处理
|
|
|
//城市处理
|
|
|
- List<string> airTicketCityInfos = new List<string>();
|
|
|
+ var airTicketCityInfos = new List<string>();
|
|
|
foreach (var item in monthData)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.FlightsCityName))
|
|
@@ -3850,12 +3981,41 @@ WHERE
|
|
|
monthIndex++;
|
|
|
}
|
|
|
|
|
|
- return Ok(JsonView(true, "操作成功!", new { airTicketNumData = airTicketNumData, airTicketAreaData = airTicketAreaData }));
|
|
|
+ var airTicketPlatformData = data.GroupBy(g => g.Platform)
|
|
|
+ .Select(g => new
|
|
|
+ {
|
|
|
+ platform = g.Key,
|
|
|
+ total = g.Sum(x => x.ClientNum),
|
|
|
+ children = g.GroupBy(g1 => g1.DIId)
|
|
|
+ .Select(g1 => new {
|
|
|
+ diId = g1.Key,
|
|
|
+ groupName = g1.FirstOrDefault()?.GroupName ?? "-",
|
|
|
+ total = g1.Sum(x1 => x1.ClientNum),
|
|
|
+ children = g1.Select(x1 => new {
|
|
|
+ //diId = x1.DIId,
|
|
|
+ //groupName = x1.GroupName,
|
|
|
+ flightsCityName=x1.FlightsCityName,
|
|
|
+ total = x1.ClientNum
|
|
|
+ })
|
|
|
+ .ToList()
|
|
|
+ })
|
|
|
+ .OrderByDescending(x1 => x1.total)
|
|
|
+ .ToList()
|
|
|
+ })
|
|
|
+ .OrderByDescending(x => x.total)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功!", new
|
|
|
+ {
|
|
|
+ airTicketNumData = airTicketNumData,
|
|
|
+ airTicketAreaData = airTicketAreaData,
|
|
|
+ airTicketPlatformData = airTicketPlatformData
|
|
|
+ }));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 国交数据统计
|
|
|
- /// 酒店预订地区TOP10
|
|
|
+ /// 国交数据统计-酒店
|
|
|
+ /// 地区TOP10、预订平台
|
|
|
/// </summary>
|
|
|
/// <param name="_dto"></param>
|
|
|
/// <returns></returns>
|
|
@@ -3948,7 +4108,31 @@ ORDER BY
|
|
|
.Take(10)
|
|
|
.ToList();
|
|
|
|
|
|
- return Ok(JsonView(true, "操作成功!", hotelCityGroupByData));
|
|
|
+ var hotelPlatformGroupByData = data.GroupBy(x => x.BookinSite)
|
|
|
+ .Select(g => new
|
|
|
+ {
|
|
|
+ Platform = g.Key,
|
|
|
+ BookingRoomNum = g.Sum(x => x.RoomTotal),
|
|
|
+ hotelData = g.GroupBy(x => x.HotelName)
|
|
|
+ .Select(g1 => new
|
|
|
+ {
|
|
|
+ hotelName = g1.Key,
|
|
|
+ roomNights = g1.Sum(x => x.RoomNights),
|
|
|
+ roomTotal = g1.Sum(x => x.RoomTotal),
|
|
|
+ singleRoomCount = g1.Sum(x => x.SingleRoomCount),
|
|
|
+ doubleRoomCount = g1.Sum(x => x.DoubleRoomCount),
|
|
|
+ suiteRoomCount = g1.Sum(x => x.SuiteRoomCount),
|
|
|
+ otherRoomCount = g1.Sum(x => x.OtherRoomCount),
|
|
|
+ })
|
|
|
+ .ToList(),
|
|
|
+ linkGroupIds = g.Select(x => x.DIId).Distinct().ToList()
|
|
|
+
|
|
|
+ })
|
|
|
+ .OrderByDescending(x => x.BookingRoomNum)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+
|
|
|
+ return Ok(JsonView(true, "操作成功!", new { hotelCityData = hotelCityGroupByData , hotelPlatformData = hotelPlatformGroupByData }));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|