Browse Source

Merge branch 'master' of http://192.144.191.50/zhongjie51/99ditui

lifa 1 year ago
parent
commit
5879f119d1

+ 14 - 0
src/platform/ZhonTai.Admin/Domain/Project/IProjectRecordRepository.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Core.Repositories;
+
+namespace ZhonTai.Admin.Domain.Project
+{
+    public interface IProjectRecordRepository : IRepositoryBase<ProjectRecordEntity>
+    {
+
+    }
+}

+ 1 - 1
src/platform/ZhonTai.Admin/Domain/Project/ProjectEntity.cs

@@ -38,7 +38,7 @@ namespace ZhonTai.Admin.Domain.Project
         /// </summary>
         public string VideoUrl { get; set; }
         /// <summary>
-        /// 状态 0待上架 1上架 2下架 3暂停
+        /// 状态 1待上架 2上架 3下架 4暂停 5名额已满
         /// </summary>
         public int Status { get; set; }
         /// <summary>

+ 31 - 0
src/platform/ZhonTai.Admin/Domain/Project/ProjectRecordEntity.cs

@@ -0,0 +1,31 @@
+using FreeSql.DataAnnotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using ZhonTai.Admin.Core.Entities;
+
+namespace ZhonTai.Admin.Domain.Project
+{
+    /// <summary>
+    /// 项目记录
+    /// </summary>
+    [Table(Name = "ditui_project_record")]
+    public class ProjectRecordEntity : EntityTenant
+    {
+        /// <summary>
+        /// 项目Id
+        /// </summary>
+        public long ProjectId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+        /// <summary>
+        /// 同项目状态
+        /// </summary>
+        public int Type { get; set; }
+    }
+}

+ 15 - 0
src/platform/ZhonTai.Admin/Domain/ProjectLink/IProjectLinkRepository.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Core.Repositories;
+using ZhonTai.Admin.Domain.Project;
+
+namespace ZhonTai.Admin.Domain.ProjectLink
+{   
+    public interface IProjectLinkRepository : IRepositoryBase<ProjectLinkEntity>
+    {
+
+    }
+}

+ 77 - 0
src/platform/ZhonTai.Admin/Domain/ProjectLink/ProjectLinkEntity.cs

@@ -0,0 +1,77 @@
+using FreeSql.DataAnnotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using ZhonTai.Admin.Core.Entities;
+
+namespace ZhonTai.Admin.Domain.ProjectLink
+{
+    /// <summary>
+    /// 推广码
+    /// </summary>
+    [Table(Name = "duitui_project_link")]
+    [Index("idx_{tablename}_01", nameof(Num), true)]
+    public partial class ProjectLinkEntity : EntityTenant
+    {
+        /// <summary>
+        /// 项目Id
+        /// </summary>
+        public long ProjectId { get; set; }
+        /// <summary>
+        /// 公司
+        /// </summary>
+        public string Company { get; set; }
+        /// <summary>
+        /// 二维码类型
+        /// </summary>
+        public string QrcodeType { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public string Num { get; set; }
+        /// <summary>
+        /// 短链
+        /// </summary>
+        public string ShortUrl { get; set; }
+        /// <summary>
+        /// 二维码链接
+        /// </summary>
+        public string QrcodeUrl { get; set; }
+        /// <summary>
+        /// 推广口令
+        /// </summary>
+        public string ShareCommand { get; set; }
+        /// <summary>
+        /// 是否使用 1使用
+        /// </summary>
+        public int IsUse { get; set; }
+        /// <summary>
+        /// 使用时间
+        /// </summary>
+        public DateTime UseTime { get; set; }
+        /// <summary>
+        /// 业务员姓名
+        /// </summary>
+        public string Salesman { get; set; }
+        /// <summary>
+        /// 业务员手机号
+        /// </summary>
+        public string SalesmanPhone { get; set; }
+        /// <summary>
+        /// 业务员省
+        /// </summary>
+        public string SalesmanProvince { get; set; }
+        /// <summary>
+        /// 业务员市
+        /// </summary>
+        public string SalesmanCity { get; set; }
+        /// <summary>
+        /// 业务员备注
+        /// </summary>
+        public string SalesmanRemark { get; set; }
+
+    }
+}

+ 18 - 0
src/platform/ZhonTai.Admin/Repositories/Project/ProjectRecordRepository.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Core.Db.Transaction;
+using ZhonTai.Admin.Domain.Project;
+
+namespace ZhonTai.Admin.Repositories.Project
+{
+    public class ProjectRecordRepository : AdminRepositoryBase<ProjectRecordEntity>, IProjectRecordRepository
+    {
+        public ProjectRecordRepository(UnitOfWorkManagerCloud muowm) : base(muowm)
+        {
+
+        }
+    }
+}

+ 20 - 0
src/platform/ZhonTai.Admin/Repositories/ProjectLink/ProjectLinkRepository.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Core.Db.Transaction;
+using ZhonTai.Admin.Domain.Project;
+using ZhonTai.Admin.Domain.ProjectLink;
+
+namespace ZhonTai.Admin.Repositories.ProjectLink
+{
+    public class ProjectLinkRepository : AdminRepositoryBase<ProjectLinkEntity>, IProjectLinkRepository
+    {
+        public ProjectLinkRepository(UnitOfWorkManagerCloud muowm) : base(muowm)
+        {
+
+        }
+    }
+}
+

+ 78 - 4
src/platform/ZhonTai.Admin/Services/Project/ProjectService.cs

@@ -24,6 +24,7 @@ using ZhonTai.Admin.Services.Tenant.Dto;
 using System.Linq.Expressions;
 using ZhonTai.Admin.Domain.Org;
 using ZhonTai.Admin.Services.Pkg;
+using ZhonTai.Admin.Domain.ProjectLink;
 
 namespace ZhonTai.Admin.Services.Project
 {
@@ -36,11 +37,15 @@ namespace ZhonTai.Admin.Services.Project
     {
         private readonly IProjectRepository _projectRepository;
         private readonly IProjectPriceRepository _projectPriceRepository;
+        private readonly IProjectRecordRepository _projectRecordRepository;
+        private readonly IProjectLinkRepository _projectLinkRepository;
 
-        public ProjectService(IProjectRepository projectRepository, IProjectPriceRepository projectPriceRepository)
+        public ProjectService(IProjectRepository projectRepository, IProjectPriceRepository projectPriceRepository, IProjectRecordRepository projectRecordRepository,IProjectLinkRepository projectLinkRepository)
         {
             _projectRepository = projectRepository;
             _projectPriceRepository = projectPriceRepository;
+            _projectRecordRepository = projectRecordRepository;
+            _projectLinkRepository = projectLinkRepository;
         }
         /// <summary>
         /// 查询
@@ -61,7 +66,7 @@ namespace ZhonTai.Admin.Services.Project
                 Works = a.Works,
                 VideoUrl = a.VideoUrl,
                 Detail = a.Detail,
-                Id = a.Id,                
+                Id = a.Id,
                 prices = _projectPriceRepository.Select.Where(m => m.ProjectId == a.Id).ToList<ProjectPriceAddInput>()
             });
             return project;
@@ -105,6 +110,7 @@ namespace ZhonTai.Admin.Services.Project
 
             //添加项目
             ProjectEntity entity = Mapper.Map<ProjectEntity>(input);
+            entity.Status = 1;
             ProjectEntity project = await _projectRepository.InsertAsync(entity);
             long projectId = project.Id;
 
@@ -112,8 +118,8 @@ namespace ZhonTai.Admin.Services.Project
             var prices = input.prices.Select(m => new ProjectPriceEntity
             {
                 ProjectId = projectId,
-                Name=m.Name,
-                Price=m.Price
+                Name = m.Name,
+                Price = m.Price
             }).ToList();
 
             await _projectPriceRepository.InsertAsync(prices);
@@ -127,6 +133,7 @@ namespace ZhonTai.Admin.Services.Project
         /// <returns></returns>
         public async Task UpdateAsync(ProjectUpdateInput input)
         {
+            throw ResultOutput.Exception("暂未开发");
 
             var project = await _projectRepository.GetAsync(input.Id);
             if (!(project?.Id > 0))
@@ -187,5 +194,72 @@ namespace ZhonTai.Admin.Services.Project
 
 
         }
+
+        /// <summary>
+        /// 更新状态
+        /// </summary>
+        ///<param name="Id"></param>
+        ///<param name="status">状态 2上架 3下架 4暂停</param>
+        /// <returns></returns>
+        public async Task UpdateStatusAsync(long Id, int status)
+        {
+            var project = await _projectRepository.GetAsync(Id);
+            if (!(project?.Id > 0))
+            {
+                throw ResultOutput.Exception("项目不存在");
+            }
+            if (!new int[] { 2, 3, 4, 5 }.Contains(status))
+            {
+                throw ResultOutput.Exception("请做出有效操作");
+            }
+            //上架项目需要验证推广码是否大于0
+            if (status == 2) { 
+                var count= await _projectLinkRepository.Where(m=>m.ProjectId==Id&&m.IsUse==0).CountAsync();
+                if (count <= 0) {
+                    throw ResultOutput.Exception("请去上传推广码");
+                }
+            }
+
+
+
+            string statusText = GetStatusText(project.Status);
+            string statusText2 = GetStatusText(status);
+
+            string remark = $"{project.Name}从{statusText}变更为{statusText2}";
+
+            //更新项目
+            await _projectRepository.UpdateDiy.SetSource(
+            new ProjectEntity()
+            {
+                Id = project.Id,
+                Status = status,
+            })
+            .UpdateColumns(a => new { a.Status }).ExecuteAffrowsAsync();
+
+            //项目记录
+            await _projectRecordRepository.InsertAsync(new ProjectRecordEntity()
+            {
+                ProjectId = Id,
+                Remark = remark,
+                Type = status,
+            });
+        }
+        #region 私有方法
+        /// <summary>
+        /// 获取项目状态
+        /// </summary>
+        /// <param name="status"></param>
+        /// <returns></returns>
+        private static string GetStatusText(int status) => status switch
+        {
+            1 => "待上架",
+            2 => "上架",
+            3 => "下架",
+            4 => "暂停",
+            5 => "名额已满",
+            _ => "未知状态"
+        };
+        #endregion
+
     }
 }

+ 12 - 0
src/platform/ZhonTai.Admin/Services/ProjectLink/IProjectLinkService.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.ProjectLink
+{
+    public interface IProjectLinkService
+    {
+    }
+}

+ 14 - 0
src/platform/ZhonTai.Admin/Services/ProjectLink/ProjectLinkService.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZhonTai.Admin.Services.Project;
+using ZhonTai.DynamicApi;
+
+namespace ZhonTai.Admin.Services.ProjectLink
+{
+    public class ProjectLinkService : BaseService, IProjectLinkService, IDynamicApi
+    {
+    }
+}