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
{
///
/// 4.0的数据看板的报表
///
public class Report40Controller : BaseWechatController
{
private IReport40Service _report40Service;
private readonly IStorageService _storageService;
private IShopActionLogService _shopActionLogService;
///
/// 初始化一个类型的实例
///
public Report40Controller(IReport40Service report40Service
, IStorageService storageService
, IShopActionLogService shopActionLogService)
{
_shopActionLogService = shopActionLogService;
_report40Service = report40Service;
_storageService = storageService;
}
#region GetHomePageReport(首页--获取4.0报表数据看板首页的数据)
///
/// 首页--获取4.0报表数据看板首页的数据
///
///
///
[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报表的员工排行榜)
///
/// 排行榜--获取4.0报表的员工排行榜
///
///
///
[HttpPost]
public List GetEmployeePerformanceRankings(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetEmployeePerformanceRankings(req);
}
#endregion
#region GetGoodsPerformanceRanking(排行榜--4.0获取商品销售排行榜 TOP 10)
///
/// 排行榜--4.0获取商品销售排行榜 TOP 10
///
///
///
[HttpPost]
public List GetGoodsPerformanceRanking(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetGoodsPerformanceRanking(req);
}
#endregion
#region GetMemberConsumptionRankings(排行榜--会员消费排行榜 TOP 10)
///
/// 排行榜--会员消费排行榜 TOP 10
///
///
///
[HttpPost]
public List GetMemberConsumptionRankings(EmployeePerformanceRankingQuery req)
{
return _report40Service.GetMemberConsumptionRankings(req);
}
#endregion
#region GetCategoryPerformancePieChart(月度--商品各品类销售占比)
///
/// 月度--商品各品类销售占比
///
///
///
[HttpPost]
public List 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个月业绩柱状图)
///
/// 月度--最近6个月业绩柱状图
///
///
///
[HttpPost]
public List 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(月度--本月业绩和本月护理)
///
/// 月度--本月业绩和本月护理
///
///
///
[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(活动--门店营销活动数据)
///
/// 活动--门店营销活动数据
///
///
///
[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(活动--营销活动明细)
///
/// 活动--营销活动明细
///
///
///
[HttpPost]
public List GetActivityDataDetails(ShopSalesPerformancReq req)
{
Guid? clerkId = null;
if (this.CurrentLogin.RoleType == LoginRoleType.Clerk)
{
clerkId = this.CurrentLogin.ClerkId;
}
return _report40Service.GetActivityDataDetails(req, clerkId);
}
#endregion
#region GetInvitationMemberMonthReport(邀约--门店邀约数据)
///
/// 邀约--门店邀约数据
///
///
///
[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(邀约--门店邀约排行榜)
///
/// 邀约--门店邀约排行榜
///
///
///
[HttpPost]
public List GetInvitationMemberRankings(ShopSalesPerformancReq req)
{
return _report40Service.GetInvitationMemberRankings(req);
}
#endregion
#region GetInvitationMemberWeekReport(邀约--本周邀约数据)
///
/// 邀约--本周邀约数据
///
///
///
[HttpPost]
public List 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(调度发送 会员会话--会员预约到店提醒)
///
/// 不用对接 会员会话--会员预约到店提醒
///
[HttpGet]
[AllowAnonymous]
public void SendMemberOrderChat()
{
_storageService.SendChatBeforeOneHour();//会话页面--邀约提醒
}
#endregion
//[HttpGet]
//[AllowAnonymous]
//public List TestGroup()
//{
// DateTime lastMonthEnd = DateTime.Parse("2021-07-30").AddMonths(-1);
// lastMonthEnd = DateTime.Parse("2021-07-31").AddMonths(-1);
// List list = new List { 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;
//}
}
}