|
@@ -0,0 +1,122 @@
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using NPOI.SS.Formula.PTG;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using ZhonTai.Admin.Core.Attributes;
|
|
|
+using ZhonTai.Admin.Core.Configs;
|
|
|
+using ZhonTai.Admin.Core.Consts;
|
|
|
+using ZhonTai.Admin.Core.Dto;
|
|
|
+using ZhonTai.Admin.Domain.Org;
|
|
|
+using ZhonTai.Admin.Domain.Platform;
|
|
|
+using ZhonTai.Admin.Domain.Tenant;
|
|
|
+using ZhonTai.Admin.Repositories.Platform;
|
|
|
+using ZhonTai.Admin.Services.Auth.Dto;
|
|
|
+using ZhonTai.Admin.Services.DiTuiAPI.Dto;
|
|
|
+using ZhonTai.Admin.Services.DiTuiAPI.Team.Dto;
|
|
|
+using ZhonTai.Common.Helpers;
|
|
|
+using ZhonTai.DynamicApi;
|
|
|
+using ZhonTai.DynamicApi.Attributes;
|
|
|
+
|
|
|
+namespace ZhonTai.Admin.Services.DiTuiAPI.Team
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 团队接口
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [DynamicApi(Area = AdminConsts.DiTuiName)]
|
|
|
+ public class TeamService : BaseService, ITeamService, IDynamicApi
|
|
|
+ {
|
|
|
+ private readonly IOrgRepository _orgRepository;
|
|
|
+ private readonly AppConfig _appConfig;
|
|
|
+ private readonly IPlatformUserRepository _platformUserRepository;
|
|
|
+
|
|
|
+ public TeamService(IOrgRepository orgRepository,AppConfig appConfig, IPlatformUserRepository platformUserRepository)
|
|
|
+ {
|
|
|
+ _orgRepository = orgRepository;
|
|
|
+ _appConfig = appConfig;
|
|
|
+ _platformUserRepository = platformUserRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团队主页
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="input"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ [HttpGet]
|
|
|
+ [NoOprationLog]
|
|
|
+ public async Task<dynamic> IndexAsync()
|
|
|
+ {
|
|
|
+ TeamIndexOutput teamIndex = new TeamIndexOutput();
|
|
|
+ var user = User;
|
|
|
+
|
|
|
+ /// TODO 使用 _platformUserRepository 联表查询统计
|
|
|
+ var result = await _orgRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
|
|
|
+ .Where(a => a.TenantId == User.TenantId)
|
|
|
+ .FirstAsync();
|
|
|
+ //PlatformUserEntity
|
|
|
+ var platformUser = await _platformUserRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
|
|
|
+ .Where(a => a.Id == User.Id)
|
|
|
+ .FirstAsync();
|
|
|
+ teamIndex.Id = Convert.ToInt64(User.TenantId);
|
|
|
+ teamIndex.CommissionRatio = platformUser.CommissionRatio;
|
|
|
+
|
|
|
+ //var userCount = await _platformUserRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
|
|
|
+ /// 总人数
|
|
|
+ var userCount = await _platformUserRepository.Select
|
|
|
+ .Count(out var userTotal)
|
|
|
+ .ToListAsync();
|
|
|
+ teamIndex.HumanCount = userTotal;
|
|
|
+
|
|
|
+ // 团队概况
|
|
|
+ TeamOverview teamOverview = new TeamOverview();
|
|
|
+ // 总人数
|
|
|
+ teamOverview.LowerCount = userTotal;
|
|
|
+
|
|
|
+ /// 当日新增
|
|
|
+ var theSameDayAdd = await _platformUserRepository.Select
|
|
|
+ .Where(a => a.CreatedTime >= DateTime.Now.Date)
|
|
|
+ .Count(out var theSameDayAddTotal)
|
|
|
+ .ToListAsync();
|
|
|
+ teamOverview.TodayAdd = theSameDayAddTotal;
|
|
|
+
|
|
|
+ /// 七日新增
|
|
|
+ var weekDayAdd = await _platformUserRepository.Select
|
|
|
+ .Where(a => a.CreatedTime >= DateTime.Now.Date.AddDays(-7))
|
|
|
+ .Count(out var weekAddTotal)
|
|
|
+ .ToListAsync();
|
|
|
+ teamOverview.WeekAdd = weekAddTotal;
|
|
|
+ teamIndex.TeamOverview = teamOverview;
|
|
|
+
|
|
|
+ /// 邀请链接
|
|
|
+ string InviteUrl = _appConfig.InviteUrlSet.Prefix + result.Code + _appConfig.InviteUrlSet.Suffix + platformUser.InviteCode;
|
|
|
+ teamIndex.InviteUrl = InviteUrl;
|
|
|
+
|
|
|
+ /// 邀请图文教程
|
|
|
+ teamIndex.InviteDesc = "https://test-dt.zhongjie51.com/assetsImg/invite_jiaocheng.png";
|
|
|
+
|
|
|
+ // 温馨提示
|
|
|
+ List<string> tipsList = new List<string>();
|
|
|
+ tipsList.Add("邀请好友,好友通过你的专属链接、海报、邀请码注册,与你绑定关系,成为你的下级代理。");
|
|
|
+ tipsList.Add("什么是抽成比例?即下级接单价格=“你的接单价格*(100-抽成比例)/100”,你获得的提成就是:你的价格*(抽成比例/100)。");
|
|
|
+ tipsList.Add("邀请默认抽成:邀请的下级代理,所有项目默认的抽成比例。");
|
|
|
+ tipsList.Add("单独项目默认抽成:你可以点击更多设置进入我的价格页面,单独设置每个项目的默认抽成。");
|
|
|
+ tipsList.Add("单独代理抽成设置:进入我的价格页面,点击每个项目上的三个点点图标去单独设置每个代理的抽成。");
|
|
|
+ tipsList.Add("当项目价格有变动时,如果你设置的是抽成比例,则所有下级代理的价格都会根据抽成比例进行自动调整。如果设置的是代理价,则下级的价格不会变动。");
|
|
|
+ tipsList.Add("下级代理推广的数据明细,可以通过点击此页面的【推广统计】按钮查看。");
|
|
|
+ teamIndex.InviteTips = tipsList;
|
|
|
+
|
|
|
+ /// 邀请按钮
|
|
|
+ teamIndex.InviteButton = "https://test-dt.zhongjie51.com/assetsImg/invite_button.png";
|
|
|
+ /// 邀请头图
|
|
|
+ teamIndex.InviteTitle = "https://test-dt.zhongjie51.com/assetsImg/invite_title.png";
|
|
|
+
|
|
|
+ return teamIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|