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

115 lines
4.7 KiB
C#

using MyCode.Project.Domain.Message.Request.Activity;
using MyCode.Project.Domain.Message.Request.Clerk;
using MyCode.Project.Domain.Message.Request.PerformanceRecord;
using MyCode.Project.Domain.Message.Response.Activity;
using MyCode.Project.Domain.Message.Response.CardCover;
using MyCode.Project.Domain.Message.Response.Member;
using MyCode.Project.Domain.Message.Response.PerformanceRecord;
using MyCode.Project.Domain.Message.Response.Shop;
using MyCode.Project.Domain.Message.Response.User;
using MyCode.Project.Infrastructure.Common;
using MyCode.Project.Infrastructure.Constant;
using MyCode.Project.Infrastructure.Exceptions;
using MyCode.Project.Services;
using System;
using System.Collections.Generic;
using System.Web.Http;
namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
{
/// <summary>
///商品分类业绩统计 相关
/// </summary>
public class PerformanceRecordController : BaseWechatController
{
private IPerformanceRecordService _performanceRecordService;
/// <summary>
///
/// </summary>
/// <param name="performanceRecordService"></param>
public PerformanceRecordController(IPerformanceRecordService performanceRecordService )
{
_performanceRecordService = performanceRecordService;
}
#region GetCustomerPerformanceResp(//)
/// <summary>
/// 获取加盟商/区总/大区完成率的报表
/// </summary>
/// <param name="query"></param>
[HttpPost]
public PerformanceReportResp GetCustomerPerformanceResp(CustomerPerformanceResp query)
{
PerformanceReportResp result = new PerformanceReportResp();
if (this.CurrentLogin.RoleId == Const.DirectorOfSalesRole || this.CurrentLogin.RoleId == Const.GeneralManagerRole || this.CurrentLogin.RoleId == Const.RegionalManagerRole)
{
if (query.DataType == 0)
{
query.Id = this.CurrentLogin.UserId;
if (this.CurrentLogin.RoleId == Const.RegionalManagerRole)
{
result = _performanceRecordService.GetCustomerPerformanceResp(query, this.CurrentLogin.UserId);
}
else if (this.CurrentLogin.RoleId == Const.DirectorOfSalesRole || this.CurrentLogin.RoleId == Const.GeneralManagerRole)
{
result = _performanceRecordService.GetRegionalPerformanceResp(query);
}
}
else if (query.DataType == 3)
{
result = _performanceRecordService.GetCustomerPerformanceResp(query, query.Id.Value);
}
else if (query.DataType == 4)
{
result = _performanceRecordService.GetRegionalManagerPerformanceResp(query, query.Id.Value);
}
else if (query.DataType == 2)
{
result = _performanceRecordService.GetShopsPerformanceResp(query);
}
result.DataList.ForEach(t =>
{
t.CompletionRate = Math.Round(t.CompletionRate, 2, MidpointRounding.AwayFromZero);
t.CompletionRateString = t.CompletionRate.ToString() + "%";
});
}
else
{
throw new BaseException("当前账号没有权限查看此报表");
}
return result;
}
#endregion
#region GetPerformanceDetail()
/// <summary>
/// 获取明细列表
/// </summary>
/// <param name="query"></param>
[HttpPost]
public PerformanceDetailReportResp GetPerformanceDetail(CustomerPerformanceResp query)
{
PerformanceDetailReportResp result = new PerformanceDetailReportResp();
if (query.DataType==2)
result= _performanceRecordService.GetCustomerPerformanceDetail(query);
else if (query.DataType == 1)
result= _performanceRecordService.GetShopPerformanceDetail(query);
result.DataList.ForEach(t =>
{
t.DifferenceAmount = Math.Round(t.DifferenceAmount, 2, MidpointRounding.AwayFromZero);
t.PlanReplenishmentAmount = Math.Round(t.PlanReplenishmentAmount, 2, MidpointRounding.AwayFromZero);
t.ReplenishmentAmount = Math.Round(t.ReplenishmentAmount, 2, MidpointRounding.AwayFromZero);
t.SalesTotalAmount = Math.Round(t.SalesTotalAmount, 2, MidpointRounding.AwayFromZero);
});
return result;
}
#endregion
}
}