Browse Source

夸克申请信息相关接口

zmq 1 year ago
parent
commit
34fbfb418c

+ 1 - 1
src/hosts/DiTui.Host/Configs/appconfig.json

@@ -111,7 +111,7 @@
   },
   //夸克相关设置
   "kuakeSet": {
-    "firstImg": "https://lmg.jj20.com/up/allimg/1114/062621110J7/210626110J7-10-1200.jpg",
+    "firstImg": "https://test-dt.zhongjie51.com/images/kuake.png",
     "signUrl": "https://broccoli.uc.cn/apps/dtEOu8NBM/routes/hZOc6scpp?uc_param_str=dsdnfrpfbivesscpgimibtbmnijblauputogpintnwktprchmt&uc_biz_str=S%3Acustom%7CC%3Atitlebar_hover_2",
     "industry": "[{\"label\":\"资料软件\",\"value\":\"资料软件\"},{\"label\":\"视频\",\"value\":\"视频\"},{\"label\":\"搜索\",\"value\":\"搜索\"},{\"label\":\"壁纸\",\"value\":\"壁纸\"},{\"label\":\"小说\",\"value\":\"小说\"},{\"label\":\"抖快\",\"value\":\"抖快\"},{\"label\":\"软件\",\"value\":\"软件\"},{\"label\":\"教育\",\"value\":\"教育\"},{\"label\":\"视频(QQ群)\",\"value\":\"视频(QQ群)\"},{\"label\":\"代运营\",\"value\":\"代运营\"},{\"label\":\"垂直资料\",\"value\":\"垂直资料\"},{\"label\":\"其他\",\"value\":\"其他\"}]"
   }

+ 16 - 8
src/platform/ZhonTai.Admin/Core/Helpers/NOPIHelper.cs

@@ -62,7 +62,13 @@ namespace ZhonTai.Admin.Core.Helpers
             }
             return dtTable;
         }
-        public static void WriteExcel(string json, string path)
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="json"></param>
+        /// <param name="path"></param>
+        /// <param name="skipCloumn">1跳过表头设置 0不跳过</param>
+        public static void WriteExcel(string json, string path,int skipCloumn=0)
         {
             var table = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable)));
             var memoryStream = new MemoryStream();
@@ -76,14 +82,16 @@ namespace ZhonTai.Admin.Core.Helpers
                 IRow row = excelSheet.CreateRow(0);
                 int columnIndex = 0;
 
-                foreach (System.Data.DataColumn column in table.Columns)
+                if (skipCloumn != 0)
                 {
-                    columns.Add(column.ColumnName);
-                    row.CreateCell(columnIndex).SetCellValue(column.ColumnName);
-                    columnIndex++;
-                }
-
-                int rowIndex = 1;
+                    foreach (System.Data.DataColumn column in table.Columns)
+                    {
+                        columns.Add(column.ColumnName);
+                        row.CreateCell(columnIndex).SetCellValue(column.ColumnName);
+                        columnIndex++;
+                    }
+                }                                
+                int rowIndex =skipCloumn==0? 1:0;
                 foreach (DataRow dsrow in table.Rows)
                 {
                     row = excelSheet.CreateRow(rowIndex);

+ 4 - 0
src/platform/ZhonTai.Admin/Domain/KuaKe/KuaKeEntity.cs

@@ -42,5 +42,9 @@ namespace ZhonTai.Admin.Domain.KuaKe
         /// 用户Id
         /// </summary>
         public long UserId { get; set; }
+        /// <summary>
+        ///状态 1未报备 2报备成功 3报备失败
+        /// </summary>
+        public int Status { get; set; } = 1;
     }    
 }

+ 195 - 0
src/platform/ZhonTai.Admin/Services/AdKuake/AdKuaKeService.cs

@@ -0,0 +1,195 @@
+using NPOI.SS.Formula.PTG;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Core.Consts;
+using ZhonTai.Admin.Services.Project;
+using ZhonTai.DynamicApi.Attributes;
+using ZhonTai.DynamicApi;
+using Microsoft.AspNetCore.Mvc;
+using ZhonTai.Admin.Core.Dto;
+using ZhonTai.Admin.Services.ProjectLink.Dto;
+using ZhonTai.Admin.Domain.Org;
+using ZhonTai.Admin.Domain.KuaKe;
+using ZhonTai.Admin.Domain.Tenant;
+using ZhonTai.Admin.Domain.Platform;
+using ZhonTai.Admin.Services.AdKuake.Dto;
+using NPOI.SS.Formula.Functions;
+using ZhonTai.Admin.Core.Auth;
+using ZhonTai.Admin.Core.Entities;
+using ZhonTai.Admin.Domain.Project;
+using ZhonTai.Admin.Services.Project.Dto;
+using ZhonTai.Admin.Core.Helpers;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Hosting;
+using System.IO;
+using Yitter.IdGenerator;
+using ZhonTai.Admin.Domain.File;
+
+namespace ZhonTai.Admin.Services.AdKuake
+{
+    public class IAdKuaKeService
+    {
+    }
+    /// <summary>
+    /// 夸克后端服务
+    /// </summary>
+    [Order(10)]
+    [DynamicApi(Area = AdminConsts.AreaName)]
+    public partial class AdKuaKeService : BaseService, IProjectService, IDynamicApi
+    {
+        private IKuaKeRepository _kuaKeRepository => LazyGetRequiredService<IKuaKeRepository>();
+        private IHttpContextAccessor _httpContextAccessor => LazyGetRequiredService<IHttpContextAccessor>();
+
+        public AdKuaKeService()
+        {
+        }
+        /// <summary>
+        /// 查询分页
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<PageOutput<AdKuaKePageOutput>> GetPageAsync(PageInput<AdKuaKePageInput> input)
+        {
+            var BeginDate = input.Filter?.BeginDate;
+            var EndDate = input.Filter?.EndDate;
+            var TenantId = input.Filter?.TenantId;
+            var Status = input.Filter?.Status;
+            var key = input.Filter?.Keyword;
+
+            var list =await _kuaKeRepository.Select.From<TenantEntity, OrgEntity, PlatformUserEntity>(
+                (kuake, tenant, org, user) => kuake.LeftJoin(m => m.TenantId == tenant.Id)
+                .LeftJoin(m => m.UserId == user.Id)
+                .LeftJoin(m => tenant.OrgId == org.Id)
+                .WhereIf(BeginDate.HasValue, m => m.CreatedTime >= BeginDate)
+                .WhereIf(EndDate.HasValue, m => m.CreatedTime <= EndDate)
+                .WhereIf(TenantId.HasValue && TenantId.Value > 0, m => m.TenantId == TenantId)
+                .WhereIf(Status.HasValue && Status > 0, m => m.Status >= Status)
+                .WhereIf(!string.IsNullOrEmpty(key), m => m.KuaKeID == key || m.Name == key || m.Phone == key)
+                )
+            .DisableGlobalFilter(FilterNames.Tenant)
+            .OrderByDescending((kuake, tenant, org, user) => kuake.CreatedTime)
+            .OrderByDescending((kuake, tenant, org, user) => kuake.Id)
+            .Count(out var total)
+            .Page(input.CurrentPage, input.PageSize)
+            .ToListAsync((kuake, tenant, org, user) => new AdKuaKePageOutput()
+            {
+                Id = kuake.Id,
+                OrgName = org.Name,
+                UserName = user.Name,
+                UserRole=user.Role,
+                CreatedTime = kuake.CreatedTime.Value,
+                KuaKeID = kuake.KuaKeID,
+                Name = kuake.Name,
+                Phone = kuake.Phone,
+                Industry = kuake.Industry,
+                Platfrom = kuake.Platfrom,
+                Status = kuake.Status
+            });
+
+            var data = new PageOutput<AdKuaKePageOutput>()
+            {
+                List = list,
+                Total = total
+            };
+
+            return data;
+        }
+        /// <summary>
+        /// 更新状态
+        /// </summary>
+        ///<param name="Id"></param>
+        ///<param name="status">状态 2成功 3失败</param>
+        /// <returns></returns>        
+        public async Task UpdateStatusAsync(UpdateKuaKeStatusInput input)
+        {
+            if (!(input?.Ids.Count() > 0))
+            {
+                throw ResultOutput.Exception("请选择操作信息");
+            }
+            if (!new int[] { 2, 3 }.Contains(input.Status))
+            {
+                throw ResultOutput.Exception("请做出有效操作");
+            }
+
+            var count = await _kuaKeRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m => input.Ids.Contains(m.Id) && m.Status == 1).CountAsync();
+            if (input.Ids.Count != count)
+            {
+                throw ResultOutput.Exception("部分数据状态已更新,请刷新后重试");
+            }
+
+            //更新项目
+            var result = await _kuaKeRepository.UpdateDiy.SetDto(
+             new
+             {
+                 Status = input.Status,
+             })
+             .Where(m => input.Ids.Contains(m.Id) && m.Status == 1).DisableGlobalFilter(FilterNames.Tenant).ExecuteAffrowsAsync();
+            if (result <= 0)
+            {
+                throw ResultOutput.Exception("操作失败");
+            }
+
+        }
+        /// <summary>
+        /// 导出Excel
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<string> GetExcelAsync(PageInput<AdKuaKePageInput> input)
+        {
+            var BeginDate = input.Filter?.BeginDate;
+            var EndDate = input.Filter?.EndDate;
+            var TenantId = input.Filter?.TenantId;
+            var Status = input.Filter?.Status;
+            var key = input.Filter?.Keyword;
+
+            var list = await _kuaKeRepository.Select
+                .WhereIf(BeginDate.HasValue, m => m.CreatedTime >= BeginDate)
+                .WhereIf(EndDate.HasValue, m => m.CreatedTime <= EndDate)
+                .WhereIf(TenantId.HasValue && TenantId.Value > 0, m => m.TenantId == TenantId)
+                .WhereIf(Status.HasValue && Status > 0, m => m.Status >= Status)
+                .WhereIf(!string.IsNullOrEmpty(key), m => m.KuaKeID == key || m.Name == key || m.Phone == key)               
+            .DisableGlobalFilter(FilterNames.Tenant)
+            .OrderByDescending(m => m.CreatedTime)
+            .OrderByDescending(m => m.Id)            
+            .ToListAsync(m => new AdKuaKeExcelOutput()
+            {                                
+                CreatedTime = m.CreatedTime.Value.ToString("yyyy-MM-dd HH:mm"),
+                KuaKeID = m.KuaKeID,
+                Name = m.Name,                
+                Industry = m.Industry,
+                Platfrom = m.Platfrom                
+            });
+            //导入数据
+            list.Insert(0,new AdKuaKeExcelOutput() { 
+                KuaKeID="夸克ID",
+                Name= "姓名",
+                Industry= "行业",
+                Platfrom= "推广平台",
+                CreatedTime= "申请时间"
+            });
+            var json=Newtonsoft.Json.JsonConvert.SerializeObject(list);
+            var env = LazyGetRequiredService<IWebHostEnvironment>();
+
+            string filename = FreeUtil.NewMongodbId() + ".xlsx";
+            string filepath = "kuake" + Path.DirectorySeparatorChar + DateTime.Today.ToString("yyyyMMdd");            
+            var path = Path.Combine(env.WebRootPath, filepath).ToPath();
+            if (!Directory.Exists(path))
+            {
+                Directory.CreateDirectory(path);
+            }
+            path = path + Path.DirectorySeparatorChar + filename;
+
+            NOPIHelper.WriteExcel(json,path,1);
+
+            string url= $"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Value}/{filepath}/{filename}";
+
+            return url;
+        }
+    }
+}

+ 17 - 0
src/platform/ZhonTai.Admin/Services/AdKuake/Dto/AdKuaKeExcelOutput.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.AdKuake.Dto
+{
+    public class AdKuaKeExcelOutput
+    {        
+        public string CreatedTime { get; set; }
+        public string KuaKeID { get; set; }
+        public string Name { get; set; }        
+        public string Industry { get; set; }
+        public string Platfrom { get; set; }        
+    }
+}

+ 32 - 0
src/platform/ZhonTai.Admin/Services/AdKuake/Dto/AdKuaKePageInput.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.AdKuake.Dto
+{
+    public class AdKuaKePageInput
+    {
+        /// <summary>
+        /// 开始日期
+        /// </summary>
+        public DateTime? BeginDate { get; set; }
+        /// <summary>
+        /// 结束日期
+        /// </summary>
+        public DateTime? EndDate { get; set; }
+        /// <summary>
+        /// 平台
+        /// </summary>
+        public long? TenantId { get; set; }
+        /// <summary>
+        /// 状态
+        /// </summary>
+        public int? Status { get; set; }
+        /// <summary>
+        /// 关键字 夸克Id,姓名,手机号
+        /// </summary>
+        public string? Keyword { get; set; }
+    }
+}

+ 23 - 0
src/platform/ZhonTai.Admin/Services/AdKuake/Dto/AdKuaKePageOutput.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.AdKuake.Dto
+{
+    public class AdKuaKePageOutput
+    {
+        public long Id { get; set; }
+        public string OrgName { get; set; }
+        public string UserName { get; set; }
+        public DateTime CreatedTime { get; set; }
+        public string KuaKeID { get; set; }
+        public string Name { get; set; }
+        public string Phone { get; set; }
+        public string Industry { get; set; }
+        public string Platfrom { get; set; }
+        public int Status { get; set; }
+        public string UserRole { get; set; }
+    }
+}

+ 14 - 0
src/platform/ZhonTai.Admin/Services/AdKuake/Dto/UpdateKuaKeStatusInput.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZhonTai.Admin.Services.AdKuake.Dto
+{
+    public class UpdateKuaKeStatusInput
+    {
+        public List<long> Ids { get; set; }
+        public int Status { get; set; }
+    }
+}

+ 65 - 0
src/platform/ZhonTai.Admin/ZhonTai.Admin.xml

@@ -1928,6 +1928,14 @@
             Excel帮助类
             </summary>
         </member>
+        <member name="M:ZhonTai.Admin.Core.Helpers.NOPIHelper.WriteExcel(System.String,System.String,System.Int32)">
+            <summary>
+            
+            </summary>
+            <param name="json"></param>
+            <param name="path"></param>
+            <param name="skipCloumn">1跳过表头设置 0不跳过</param>
+        </member>
         <member name="T:ZhonTai.Admin.Core.Helpers.UploadHelper">
             <summary>
             文件上传帮助类
@@ -2607,6 +2615,11 @@
             用户Id
             </summary>
         </member>
+        <member name="P:ZhonTai.Admin.Domain.KuaKe.KuaKeEntity.Status">
+             <summary>
+            状态 1未报备 2报备成功 3报备失败
+             </summary>
+        </member>
         <member name="P:ZhonTai.Admin.Domain.LogGetPageDto.CreatedUserName">
             <summary>
             创建者
@@ -4515,6 +4528,58 @@
             <param name="idList"></param>
             <returns></returns>
         </member>
+        <member name="T:ZhonTai.Admin.Services.AdKuake.AdKuaKeService">
+            <summary>
+            夸克后端服务
+            </summary>
+        </member>
+        <member name="M:ZhonTai.Admin.Services.AdKuake.AdKuaKeService.GetPageAsync(ZhonTai.Admin.Core.Dto.PageInput{ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput})">
+            <summary>
+            查询分页
+            </summary>
+            <param name="input"></param>
+            <returns></returns>
+        </member>
+        <member name="M:ZhonTai.Admin.Services.AdKuake.AdKuaKeService.UpdateStatusAsync(ZhonTai.Admin.Services.AdKuake.Dto.UpdateKuaKeStatusInput)">
+             <summary>
+             更新状态
+             </summary>
+            <param name="Id"></param>
+            <param name="status">状态 2成功 3失败</param>
+             <returns></returns>        
+        </member>
+        <member name="M:ZhonTai.Admin.Services.AdKuake.AdKuaKeService.GetExcelAsync(ZhonTai.Admin.Core.Dto.PageInput{ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput})">
+            <summary>
+            导出Excel
+            </summary>
+            <param name="input"></param>
+            <returns></returns>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput.BeginDate">
+            <summary>
+            开始日期
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput.EndDate">
+            <summary>
+            结束日期
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput.TenantId">
+            <summary>
+            平台
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput.Status">
+            <summary>
+            状态
+            </summary>
+        </member>
+        <member name="P:ZhonTai.Admin.Services.AdKuake.Dto.AdKuaKePageInput.Keyword">
+            <summary>
+            关键字 夸克Id,姓名,手机号
+            </summary>
+        </member>
         <member name="T:ZhonTai.Admin.Services.Api.ApiService">
             <summary>
             接口服务