2025-04-24 18:31:27 +08:00

272 lines
9.8 KiB
C#

using MyCode.Project.Domain.Message.Request.Million;
using MyCode.Project.Domain.Message.Request.Report;
using MyCode.Project.Domain.Message.Request.Report40;
using MyCode.Project.Domain.Message.Response.Report;
using MyCode.Project.Domain.Message.Response.Report40;
using MyCode.Project.Domain.Message.Response.Shop;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Enumeration;
using MyCode.Project.Infrastructure.Extensions;
using MyCode.Project.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
{
/// <summary>
/// 4.0的数据看板的报表
/// </summary>
public class Report40Controller : BaseWechatController
{
private IReport40Service _report40Service;
private readonly IStorageService _storageService;
private IShopActionLogService _shopActionLogService;
/// <summary>
/// 初始化一个<see cref="GoodsController"/>类型的实例
/// </summary>
public Report40Controller(IReport40Service report40Service
, IStorageService storageService
, IShopActionLogService shopActionLogService)
{
_shopActionLogService = shopActionLogService;
_report40Service = report40Service;
_storageService = storageService;
}
#region GetHomePageReport(--4.0)
/// <summary>
/// 首页--获取4.0报表数据看板首页的数据
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public ReportHomeResp GetHomePageReport(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
//记录小程序操作
if (this.CurrentLogin.RoleType == LoginRoleType.CustomerID)
_shopActionLogService.SetShopActionLog(req.ShopId, this.CurrentLogin.CustomerId.SafeValue(), 1, 11);
else
_shopActionLogService.SetShopActionLog(req.ShopId, this.CurrentLogin.ClerkId.SafeValue(), 2, 11);
return _report40Service.GetHomePageReport(req, clerkId);
}
#endregion
#region GetEmployeePerformanceRankings(--4.0)
/// <summary>
/// 排行榜--获取4.0报表的员工排行榜
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<EmployeePerformanceRankingResp> GetEmployeePerformanceRankings(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetEmployeePerformanceRankings(req);
}
#endregion
#region GetGoodsPerformanceRanking(--4.0 TOP 10)
/// <summary>
/// 排行榜--4.0获取商品销售排行榜 TOP 10
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<GoodsPerformanceRankingResp> GetGoodsPerformanceRanking(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetGoodsPerformanceRanking(req);
}
#endregion
#region GetMemberConsumptionRankings(-- TOP 10)
/// <summary>
/// 排行榜--会员消费排行榜 TOP 10
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<MemberConsumptionRankingsResp> GetMemberConsumptionRankings(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetMemberConsumptionRankings(req);
}
#endregion
#region GetCategoryPerformancePieChart(--)
/// <summary>
/// 月度--商品各品类销售占比
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<Rp40CategoryPieChartResp> GetCategoryPerformancePieChart(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetCategoryPerformancePieChart(req, clerkId);
}
#endregion
#region GetSixMonthPerformanceHistogram(--6)
/// <summary>
/// 月度--最近6个月业绩柱状图
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<HistogramItem> GetSixMonthPerformanceHistogram(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetSixMonthPerformanceHistogram(req, clerkId).Items;
}
#endregion
#region GetShopMonthPerformance(--)
/// <summary>
/// 月度--本月业绩和本月护理
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public ShopMonthPerformanceResp GetShopMonthPerformance(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetShopMonthPerformance(req, clerkId);
}
#endregion
#region GetActivityDataResp(--)
/// <summary>
/// 活动--门店营销活动数据
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public ActivityDataResp GetActivityDataResp(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetActivityDataResp(req, clerkId);
}
#endregion
#region GetActivityDataDetails(--)
/// <summary>
/// 活动--营销活动明细
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<ActivityDataDetailResp> GetActivityDataDetails(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetActivityDataDetails(req, clerkId);
}
#endregion
#region GetInvitationMemberMonthReport(--)
/// <summary>
/// 邀约--门店邀约数据
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public InvitationMemberMonthReportResp GetInvitationMemberMonthReport(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetInvitationMemberMonthReport(req, clerkId);
}
#endregion
#region GetInvitationMemberRankings(--)
/// <summary>
/// 邀约--门店邀约排行榜
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<InvitationMemberRankingsResp> GetInvitationMemberRankings(ShopSalesPerformancReq req)
{
return _report40Service.GetInvitationMemberRankings(req);
}
#endregion
#region GetInvitationMemberWeekReport(--)
/// <summary>
/// 邀约--本周邀约数据
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public List<YaoYueHistogramItem> GetInvitationMemberWeekReport(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetInvitationMemberWeekReport(req, clerkId).Items;
}
#endregion
#region SendMemberOrderChat( --)
/// <summary>
/// 不用对接 会员会话--会员预约到店提醒
/// </summary>
[HttpGet]
[AllowAnonymous]
public void SendMemberOrderChat()
{
_storageService.SendChatBeforeOneHour();//会话页面--邀约提醒
}
#endregion
//[HttpGet]
//[AllowAnonymous]
//public List<int> TestGroup()
//{
// DateTime lastMonthEnd = DateTime.Parse("2021-07-30").AddMonths(-1);
// lastMonthEnd = DateTime.Parse("2021-07-31").AddMonths(-1);
// List<int> list = new List<int> { 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5 };
// var huoYueMember = list.GroupBy(t => t).Where(t => t.Count() >= 3).Select(t => t.Key).ToList();
// return huoYueMember;
//}
}
}