2 Commits 16032118b1 ... f780bc493b

Author SHA1 Message Date
  lifa f780bc493b 团队主页接口功能实现 1 year ago
  lifa 0a1686224c 短信发送接口 新增 version 参数 1 year ago

+ 8 - 0
src/hosts/DiTui.Host/Configs/appconfig.json

@@ -119,5 +119,13 @@
   "qCloudSet": {
     "appId": 1400153514,
     "appKey": "fe967a103fcfac54b41bddf50a2863b8"
+  },
+  // 邀请链接
+  "inviteUrlSet": {
+    "prefix": "http://dev.gl.zjdg.cn/",
+    "suffix": "/#/pages/my/register?iv=",
+    "inviteTutorial": "https://test-dt.zhongjie51.com/assetsImg/invite_jiaocheng.png",
+    "inviteButton": "https://test-dt.zhongjie51.com/assetsImg/invite_button.png",
+    "inviteTitle": "https://test-dt.zhongjie51.com/assetsImg/invite_title.png"
   }
 }

+ 34 - 0
src/platform/ZhonTai.Admin/Core/Configs/AppConfig.cs

@@ -110,10 +110,44 @@ public class AppConfig
     /// </summary>
     public KuaKeConfig KuaKeSet { get; set; } = new KuaKeConfig();
 
+    /// <summary>
+    /// 腾讯云短信相关配置
+    /// </summary>
     public QCloud QCloudSet { get; set; } = new QCloud();
+
+    public InviteUrl InviteUrlSet { get; set; } = new InviteUrl();
     
 }
 
+public class InviteUrl
+{
+    /// <summary>
+    /// 前缀
+    /// </summary>
+    public string Prefix { get; set; }
+    /// <summary>
+    /// 后缀
+    /// </summary>
+    public string Suffix { get; set; }
+
+    /// <summary>
+    /// 教程
+    /// </summary>
+    public string InviteTutorial { get; set; }
+
+    /// <summary>
+    /// 邀请按钮
+    /// </summary>
+    public string InviteButton { get; set; }
+
+    /// <summary>
+    /// 邀请头图
+    /// </summary>
+    public string InviteTitle { get; set; }
+
+}
+
+
 /// <summary>
 /// Swagger配置
 /// </summary>

+ 5 - 0
src/platform/ZhonTai.Admin/Domain/Platform/PlatformUserEntity.cs

@@ -58,6 +58,11 @@ namespace ZhonTai.Admin.Domain.Platform
         /// </summary>
         public string InviteCode { get; set; }
 
+        /// <summary>
+        /// 抽成比例
+        /// </summary>
+        public int CommissionRatio { get; set; }
+
 
         /// 通过手机号和上级ID 来判断唯一(一个手机号可注册多个不同上级的账号)
     }

+ 9 - 2
src/platform/ZhonTai.Admin/Services/DiTuiAPI/DiTuiAPIService.cs

@@ -358,9 +358,16 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
         [HttpPost]
         [AllowAnonymous]
         [NoOprationLog]
-        public string SendCode(string phone)
+        public string SendCode(SendCodeInput input)
         {
-             //= new ISmsRepository();
+            string phone = input.Phone;
+            
+            if (string.IsNullOrEmpty(phone))
+            {
+                throw ResultOutput.Exception(string.Format("手机号不可为空"));
+            }
+
+            //= new ISmsRepository();
             var result = _smsRepository.Select.DisableGlobalFilter(FilterNames.Tenant)
                 .Where(a => a.Mobile == phone && a.Status == 0 && a.CreatedTime >= DateTime.Now.AddMinutes(-2))
                 .First(a => new

+ 20 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Dto/SendCodeInput.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.DiTuiAPI.Dto
+{
+    public class SendCodeInput
+    {
+        /// <summary>
+        ///  手机号
+        /// </summary>
+        public string Phone { get; set; }
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        public string Version { get; set; }
+    }
+}

+ 80 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Team/Dto/TeamIndexOutput.cs

@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.DiTuiAPI.Team.Dto
+{
+    public class TeamIndexOutput
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public long Id { get; set; }
+
+        /// <summary>
+        /// 总人数
+        /// </summary>
+        public long HumanCount { get; set; }
+
+        /// <summary>
+        /// 总收益
+        /// </summary>
+        public decimal IncomeCount { get; set; }
+
+        /// <summary>
+        /// 邀请链接
+        /// </summary>
+        public string InviteUrl { get; set; }
+
+        /// <summary>
+        /// 默认抽成比例
+        /// </summary>
+        public int CommissionRatio { get; set; }
+
+        /// <summary>
+        /// 团队概况
+        /// </summary>
+        public TeamOverview TeamOverview { get; set; }
+
+        /// <summary>
+        /// 邀请教程流程图
+        /// </summary>
+        public string InviteDesc { get; set; }
+
+        /// <summary>
+        /// 邀请提示文字内容
+        /// </summary>
+        public List<string> InviteTips { get; set; }
+
+        /// <summary>
+        /// 邀请按钮图片
+        /// </summary>
+        public string InviteButton { get; set; }
+
+        /// <summary>
+        /// 邀请顶部图片
+        /// </summary>
+        public string InviteTitle { get; set; }
+
+    }
+
+    public class TeamOverview
+    {
+        /// <summary>
+        /// 下级总数
+        /// </summary>
+        public long LowerCount { get; set; }
+
+        /// <summary>
+        /// 当日新增
+        /// </summary>
+        public long TodayAdd { get; set; }
+
+        /// <summary>
+        /// 七日新增
+        /// </summary>
+        public long WeekAdd { get; set; }
+    }
+}

+ 12 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Team/ITeamService.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.DiTuiAPI.Team
+{
+    public interface ITeamService
+    {
+    }
+}

+ 122 - 0
src/platform/ZhonTai.Admin/Services/DiTuiAPI/Team/TeamService.cs

@@ -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;
+        }
+    }
+}

+ 125 - 1
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -425,6 +425,36 @@
             夸克相关配置
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.AppConfig.QCloudSet">
+            <summary>
+            腾讯云短信相关配置
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.InviteUrl.Prefix">
+            <summary>
+            前缀
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.InviteUrl.Suffix">
+            <summary>
+            后缀
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.InviteUrl.InviteTutorial">
+            <summary>
+            教程
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.InviteUrl.InviteButton">
+            <summary>
+            邀请按钮
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Core.Configs.InviteUrl.InviteTitle">
+            <summary>
+            邀请头图
+            </summary>
+        </member>
         <member name="T:ZhonTai.Admin.Core.Configs.SwaggerConfig">
             <summary>
             Swagger配置
@@ -3160,6 +3190,11 @@
             邀请码
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Domain.Platform.PlatformUserEntity.CommissionRatio">
+            <summary>
+            抽成比例
+            </summary>
+        </member>
         <member name="T:ZhonTai.Admin.Domain.ProjectLink.ProjectLinkEntity">
             <summary>
             推广码
@@ -5819,7 +5854,7 @@
             </summary>
             <returns></returns>
         </member>
-        <member name="M:ZhonTai.Admin.Services.DiTuiAPI.DiTuiAPIService.SendCode(System.String)">
+        <member name="M:ZhonTai.Admin.Services.DiTuiAPI.DiTuiAPIService.SendCode(ZhonTai.Admin.Services.DiTuiAPI.Dto.SendCodeInput)">
             <summary>
             获取手机验证码
             </summary>
@@ -6353,6 +6388,16 @@
             邀请码
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.SendCodeInput.Phone">
+            <summary>
+             手机号
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.SendCodeInput.Version">
+            <summary>
+            版本号
+            </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Dto.UserInfoOutput.Avatar">
             <summary>
             头像
@@ -6615,6 +6660,85 @@
             <param name="input"></param>
             <returns></returns>
         </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.Id">
+            <summary>
+            ID
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.HumanCount">
+            <summary>
+            总人数
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.IncomeCount">
+            <summary>
+            总收益
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.InviteUrl">
+            <summary>
+            邀请链接
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.CommissionRatio">
+            <summary>
+            默认抽成比例
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.TeamOverview">
+            <summary>
+            团队概况
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.InviteDesc">
+            <summary>
+            邀请教程流程图
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.InviteTips">
+            <summary>
+            邀请提示文字内容
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.InviteButton">
+            <summary>
+            邀请按钮图片
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamIndexOutput.InviteTitle">
+            <summary>
+            邀请顶部图片
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamOverview.LowerCount">
+            <summary>
+            下级总数
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamOverview.TodayAdd">
+            <summary>
+            当日新增
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.DiTuiAPI.Team.Dto.TeamOverview.WeekAdd">
+            <summary>
+            七日新增
+            </summary>
+        </member>
+        <member name="T:ZhonTai.Admin.Services.DiTuiAPI.Team.TeamService">
+            <summary>
+            团队接口
+            </summary>
+            <returns></returns>
+        </member>
+        <member name="M:ZhonTai.Admin.Services.DiTuiAPI.Team.TeamService.IndexAsync">
+            <summary>
+            团队主页
+            </summary>
+            <param name="input"></param>
+            <returns></returns>
+            <exception cref="T:System.NotImplementedException"></exception>
+        </member>
         <member name="T:ZhonTai.Admin.Services.Document.DocumentService">
             <summary>
             文档服务