diff --git a/antis-ncc-admin/src/views/tbAreaLine/Form.vue b/antis-ncc-admin/src/views/tbAreaLine/Form.vue index a8ea308..224cab8 100644 --- a/antis-ncc-admin/src/views/tbAreaLine/Form.vue +++ b/antis-ncc-admin/src/views/tbAreaLine/Form.vue @@ -1,45 +1,58 @@  \ No newline at end of file + } + diff --git a/antis-ncc-admin/src/views/tbPoster/ExportBox.vue b/antis-ncc-admin/src/views/tbPoster/ExportBox.vue new file mode 100644 index 0000000..4fc5c07 --- /dev/null +++ b/antis-ncc-admin/src/views/tbPoster/ExportBox.vue @@ -0,0 +1,66 @@ + + + + \ No newline at end of file diff --git a/antis-ncc-admin/src/views/tbPoster/Form.vue b/antis-ncc-admin/src/views/tbPoster/Form.vue new file mode 100644 index 0000000..cc3b99d --- /dev/null +++ b/antis-ncc-admin/src/views/tbPoster/Form.vue @@ -0,0 +1,149 @@ + + diff --git a/antis-ncc-admin/src/views/tbPoster/index.vue b/antis-ncc-admin/src/views/tbPoster/index.vue new file mode 100644 index 0000000..dd6cd97 --- /dev/null +++ b/antis-ncc-admin/src/views/tbPoster/index.vue @@ -0,0 +1,216 @@ + + \ No newline at end of file diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/MBT人格线路节点/Dto/TbMbtLineNodeListOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/MBT人格线路节点/Dto/TbMbtLineNodeListOutput.cs index 3e14fd5..3e10762 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/MBT人格线路节点/Dto/TbMbtLineNodeListOutput.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/MBT人格线路节点/Dto/TbMbtLineNodeListOutput.cs @@ -73,4 +73,77 @@ namespace NCC.Blind.Entitys.Dto.TbMbtLineNode } } } + + + /// + /// MBT人格线路节点输入参数自定义 + /// + public class TbMbtLineNodeListOutputCustom + { + /// + /// 主键 + /// + public string id { get; set; } + + /// + /// MBT人格线路ID + /// + public string mbtLineId { get; set; } + /// + /// MBT人格线路信息 + /// + public TbMbtLineEntity mbtLine { get; set; } + + /// + /// 节点标题 + /// + public string title { get; set; } + + /// + /// 节点简介 + /// + public string description { get; set; } + + /// + /// 节点注意事项 + /// + public string remark { get; set; } + + /// + /// 创建时间 + /// + public DateTime? creatorTime { get; set; } + + /// + /// 修改时间 + /// + public DateTime? lastModifyTime { get; set; } + /// + /// 排序 + /// + public int? sorts { get; set; } + + /// + /// 图片信息 + /// + public string banner { get; set; } + /// + /// 图片信息 + /// + public List Banner + { + get + { + try + { + return JsonConvert.DeserializeObject>(banner); + } + catch (Exception ex) + { + return new List(); + } + } + } + + } } diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineCrInput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineCrInput.cs index 89eb3a7..848b066 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineCrInput.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineCrInput.cs @@ -38,6 +38,11 @@ namespace NCC.Blind.Entitys.Dto.TbAreaLine /// 线路图片 /// public List banner { get; set; } - + + /// + /// 百分比% + /// + public decimal ratio { get; set; } + } } diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineInfoOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineInfoOutput.cs index 3f7704e..e0a12d2 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineInfoOutput.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineInfoOutput.cs @@ -43,6 +43,10 @@ namespace NCC.Blind.Entitys.Dto.TbAreaLine /// 线路图片 /// public List banner { get; set; } - + + /// + /// 百分比% + /// + public decimal ratio { get; set; } } } diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineListOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineListOutput.cs index 701e87a..b1b552f 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineListOutput.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Dto/TbAreaLineListOutput.cs @@ -65,6 +65,12 @@ namespace NCC.Blind.Entitys.Dto.TbAreaLine return new List(); } } } - + + + /// + /// 百分比% + /// + public decimal ratio { get; set; } + } } diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Entity/TbAreaLineEntity.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Entity/TbAreaLineEntity.cs index bbdc7e9..3ba273e 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Entity/TbAreaLineEntity.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路/Entity/TbAreaLineEntity.cs @@ -52,6 +52,13 @@ namespace NCC.Blind.Entitys /// [SugarColumn(ColumnName = "F_Banner")] public string Banner { get; set; } - + + + /// + /// 百分比% + /// + [SugarColumn(ColumnName = "F_Ratio")] + public decimal Ratio { get; set; } + } } \ No newline at end of file diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路节点/Dto/TbAreaLineNodeListOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路节点/Dto/TbAreaLineNodeListOutput.cs index c099cb4..71da3af 100644 --- a/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路节点/Dto/TbAreaLineNodeListOutput.cs +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/地域线路节点/Dto/TbAreaLineNodeListOutput.cs @@ -76,4 +76,80 @@ namespace NCC.Blind.Entitys.Dto.TbAreaLineNode } + + + /// + /// 地域线路节点输入参数自定义 + /// + public class TbAreaLineNodeCustomListOutput + { + /// + /// 主键 + /// + public string id { get; set; } + + /// + /// 地域线路ID + /// + public string areaLineId { get; set; } + /// + /// 地域线路信息 + /// + public TbAreaLineEntity areaLine { get; set; } + + /// + /// 节点标题 + /// + public string title { get; set; } + + /// + /// 节点简介 + /// + public string description { get; set; } + + /// + /// 节点注意事项 + /// + public string remark { get; set; } + + /// + /// 创建时间 + /// + public DateTime? creatorTime { get; set; } + + /// + /// 修改时间 + /// + public DateTime? lastModifyTime { get; set; } + + /// + /// 图片信息 + /// + public string banner { get; set; } + + /// + /// 图片信息 + /// + public List Banner + { + get + { + try + { + return JsonConvert.DeserializeObject>(banner); + } + catch (Exception ex) + { + return new List(); + } + } + } + + /// + /// 排序 + /// + public int? sorts { get; set; } + + + } } diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterCrInput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterCrInput.cs new file mode 100644 index 0000000..7353244 --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterCrInput.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using NCC.Common.Model; + +namespace NCC.Blind.Entitys.Dto.TbPoster +{ + /// + /// 海报管理修改输入参数 + /// + public class TbPosterCrInput + { + /// + /// 图片 + /// + public List banner { get; set; } + + /// + /// 创建时间 + /// + public DateTime? creatorTime { get; set; } + + /// + /// 修改时间 + /// + public DateTime? lastModifyTime { get; set; } + + /// + /// 创建用户 + /// + public string creatorUserId { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterInfoOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterInfoOutput.cs new file mode 100644 index 0000000..abcb91a --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterInfoOutput.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using NCC.Common.Model; + +namespace NCC.Blind.Entitys.Dto.TbPoster +{ + /// + /// 海报管理输出参数 + /// + public class TbPosterInfoOutput + { + /// + /// 主键 + /// + public string id { get; set; } + + /// + /// 图片 + /// + public List banner { get; set; } + + /// + /// 创建时间 + /// + public DateTime? creatorTime { get; set; } + + /// + /// 修改时间 + /// + public DateTime? lastModifyTime { get; set; } + + /// + /// 创建用户 + /// + public string creatorUserId { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListOutput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListOutput.cs new file mode 100644 index 0000000..0ca9bdb --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListOutput.cs @@ -0,0 +1,36 @@ +using System; + +namespace NCC.Blind.Entitys.Dto.TbPoster +{ + /// + /// 海报管理输入参数 + /// + public class TbPosterListOutput + { + /// + /// 主键 + /// + public string id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? creatorTime { get; set; } + + /// + /// 修改时间 + /// + public DateTime? lastModifyTime { get; set; } + + /// + /// 创建用户 + /// + public string creatorUserId { get; set; } + + /// + /// 标题 + /// + public string title { get; set; } + + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListQueryInput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListQueryInput.cs new file mode 100644 index 0000000..0e5e227 --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterListQueryInput.cs @@ -0,0 +1,28 @@ +using NCC.Common.Filter; +using System.Collections.Generic; + +namespace NCC.Blind.Entitys.Dto.TbPoster +{ + /// + /// 海报管理列表查询输入 + /// + public class TbPosterListQueryInput : PageInputBase + { + /// + /// 选择导出数据key + /// + public string selectKey { get; set; } + + /// + /// + /// + public int dataType { get; set; } + + + /// + /// 标题 + /// + public string title { get; set; } + + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterUpInput.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterUpInput.cs new file mode 100644 index 0000000..f28c81b --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Dto/TbPosterUpInput.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace NCC.Blind.Entitys.Dto.TbPoster +{ + /// + /// 海报管理更新输入参数 + /// + public class TbPosterUpInput : TbPosterCrInput + { + /// + /// 主键 + /// + public string id { get; set; } + + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Entity/TbPosterEntity.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Entity/TbPosterEntity.cs new file mode 100644 index 0000000..4ee114e --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Entity/TbPosterEntity.cs @@ -0,0 +1,51 @@ +using NCC.Common.Const; +using SqlSugar; +using System; + +namespace NCC.Blind.Entitys +{ + /// + /// 海报管理 + /// + [SugarTable("tb_Poster")] + [Tenant(ClaimConst.TENANT_ID)] + public class TbPosterEntity + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] + public string Id { get; set; } + + /// + /// 图片 + /// + [SugarColumn(ColumnName = "F_Banner")] + public string Banner { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "F_CreatorTime")] + public DateTime? CreatorTime { get; set; } + + /// + /// 修改时间 + /// + [SugarColumn(ColumnName = "F_LastModifyTime")] + public DateTime? LastModifyTime { get; set; } + + /// + /// 创建用户 + /// + [SugarColumn(ColumnName = "F_CreatorUserId")] + public string CreatorUserId { get; set; } + + /// + /// 标题 + /// + [SugarColumn(ColumnName = "F_Title")] + public string Title { get; set; } + + } +} \ No newline at end of file diff --git a/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Mapper/TbPosterMapper.cs b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Mapper/TbPosterMapper.cs new file mode 100644 index 0000000..6170918 --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Entitys/海报管理/Mapper/TbPosterMapper.cs @@ -0,0 +1,21 @@ +using NCC.Common.Helper; +using NCC.Common.Model; +using NCC.Blind.Entitys.Dto.TbPoster; +using Mapster; +using System.Collections.Generic; + +namespace NCC.Blind.Entitys.Mapper.TbPoster +{ + public class Mapper : IRegister + { + public void Register(TypeAdapterConfig config) + { + config.ForType() + .Map(dest => dest.Banner, src => src.banner.ToJson()) + ; + config.ForType() + .Map(dest => dest.banner, src => src.Banner.ToObject>()) + ; + } + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox.Interfaces/海报管理/ITbPosterService.cs b/antis-ncc-net-core/NCC.BlindBox.Interfaces/海报管理/ITbPosterService.cs new file mode 100644 index 0000000..cc17f55 --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox.Interfaces/海报管理/ITbPosterService.cs @@ -0,0 +1,6 @@ +namespace NCC.Blind.Interfaces.TbPoster +{ + public interface ITbPosterService + { + } +} \ No newline at end of file diff --git a/antis-ncc-net-core/NCC.BlindBox/MBT人格线路节点/TbMbtLineNodeService.cs b/antis-ncc-net-core/NCC.BlindBox/MBT人格线路节点/TbMbtLineNodeService.cs index 242b898..90744a8 100644 --- a/antis-ncc-net-core/NCC.BlindBox/MBT人格线路节点/TbMbtLineNodeService.cs +++ b/antis-ncc-net-core/NCC.BlindBox/MBT人格线路节点/TbMbtLineNodeService.cs @@ -78,6 +78,53 @@ namespace NCC.Blind.TbMbtLineNode return output; } + + + + /// + /// 获取MBT人格线路节点列表自定义 + /// + /// 请求参数 + /// + [HttpPost("GetMbtLineNodeCustomList")] + public async Task GetMbtLineNodeCustomList(TbMbtLineNodeListQueryInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var sidx = input.sidx == null ? "id" : input.sidx; + var data = await _db.Queryable() + .WhereIF(!string.IsNullOrEmpty(input.mbtLineId), p => p.MbtLineId.Equals(input.mbtLineId)) + .WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title)) + .WhereIF(!string.IsNullOrEmpty(input.description), p => p.Description.Contains(input.description)) + .WhereIF(!string.IsNullOrEmpty(input.remark), p => p.Remark.Contains(input.remark)) + .Select(it => new TbMbtLineNodeListOutputCustom + { + id = it.Id, + mbtLineId = it.MbtLineId, + title = it.Title, + description = it.Description, + remark = it.Remark, + creatorTime = it.CreatorTime, + lastModifyTime = it.LastModifyTime, + sorts = it.Sorts, + banner = it.Banner, + }).MergeTable().Mapper(p => + { + p.mbtLine = _db.Queryable().Where(o => o.Id == p.mbtLineId).First(); + }).OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(data); + } + + + /// /// 获取MBT人格线路节点列表 /// @@ -107,12 +154,12 @@ namespace NCC.Blind.TbMbtLineNode id = it.Id, mbtLineId=it.MbtLineId, title=it.Title, - description=it.Description, + //description=it.Description, remark=it.Remark, creatorTime=it.CreatorTime, lastModifyTime=it.LastModifyTime, sorts=it.Sorts, - banner=it.Banner, + //banner=it.Banner, }).MergeTable().Mapper(p => { p.mbtLine = _db.Queryable().Where(o => o.Id == p.mbtLineId).First(); diff --git a/antis-ncc-net-core/NCC.BlindBox/地域线路/TbAreaLineService.cs b/antis-ncc-net-core/NCC.BlindBox/地域线路/TbAreaLineService.cs index 68fddbc..e295b01 100644 --- a/antis-ncc-net-core/NCC.BlindBox/地域线路/TbAreaLineService.cs +++ b/antis-ncc-net-core/NCC.BlindBox/地域线路/TbAreaLineService.cs @@ -124,6 +124,8 @@ namespace NCC.Blind.TbAreaLine creatorTime=it.CreatorTime, lastModifyTime=it.LastModifyTime, banner=it.Banner, + ratio = it.Ratio, + }).MergeTable().Mapper(p => { p.area = _db.Queryable().Where(o => o.Id == p.areaId).First(); @@ -190,6 +192,8 @@ namespace NCC.Blind.TbAreaLine remark=it.Remark, creatorTime=it.CreatorTime, lastModifyTime=it.LastModifyTime, + ratio = it.Ratio, + }).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync(); return data; } @@ -213,7 +217,7 @@ namespace NCC.Blind.TbAreaLine { exportData = await this.GetNoPagingList(input); } - List paramList = "[{\"value\":\"地域\",\"field\":\"areaId\"},{\"value\":\"线路标题\",\"field\":\"title\"},{\"value\":\"线路概况\",\"field\":\"remark\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},]".ToList(); + List paramList = "[{\"value\":\"地域\",\"field\":\"areaId\"},{\"value\":\"线路标题\",\"field\":\"title\"},{\"value\":\"线路概况\",\"field\":\"remark\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},{\"value\":\"百分比%\",\"field\":\"ratio\"},]".ToList(); ExcelConfig excelconfig = new ExcelConfig(); excelconfig.FileName = "地域线路.xls"; excelconfig.HeadFont = "微软雅黑"; diff --git a/antis-ncc-net-core/NCC.BlindBox/地域线路节点/TbAreaLineNodeService.cs b/antis-ncc-net-core/NCC.BlindBox/地域线路节点/TbAreaLineNodeService.cs index 817ba0c..e0b1849 100644 --- a/antis-ncc-net-core/NCC.BlindBox/地域线路节点/TbAreaLineNodeService.cs +++ b/antis-ncc-net-core/NCC.BlindBox/地域线路节点/TbAreaLineNodeService.cs @@ -80,6 +80,60 @@ namespace NCC.Blind.TbAreaLineNode return output; } + + + /// + /// 获取地域线路节点列表自定义 + /// + /// 请求参数 + /// + [HttpPost("GetAreaLineList")] + public async Task GetAreaLineList(TbAreaLineNodeListQueryInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var sidx = input.sidx == null ? "id" : input.sidx; + var data = await _db.Queryable() + .WhereIF(!string.IsNullOrEmpty(input.areaLineId), p => p.AreaLineId.Equals(input.areaLineId)) + .WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title)) + .WhereIF(!string.IsNullOrEmpty(input.description), p => p.Description.Contains(input.description)) + .WhereIF(!string.IsNullOrEmpty(input.remark), p => p.Remark.Contains(input.remark)) + .Select(it => new TbAreaLineNodeCustomListOutput + { + id = it.Id, + areaLineId = it.AreaLineId, + title = it.Title, + description = it.Description, + remark = it.Remark, + creatorTime = it.CreatorTime, + lastModifyTime = it.LastModifyTime, + banner = it.Banner, + sorts = it.Sorts, + + }).MergeTable().Mapper(p => + { + p.areaLine = _db.Queryable().Where(o => o.Id == p.areaLineId).First(); + }).OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(data); + } + + + + + + + + + + /// /// 获取地域线路节点列表 /// @@ -109,11 +163,11 @@ namespace NCC.Blind.TbAreaLineNode id = it.Id, areaLineId=it.AreaLineId, title =it.Title, - description=it.Description, - remark=it.Remark, - creatorTime=it.CreatorTime, + //description=it.Description, + remark = it.Remark, + creatorTime =it.CreatorTime, lastModifyTime=it.LastModifyTime, - banner=it.Banner, + //banner=it.Banner, sorts = it.Sorts, }).MergeTable().Mapper(p => diff --git a/antis-ncc-net-core/NCC.BlindBox/海报管理/TbPosterService.cs b/antis-ncc-net-core/NCC.BlindBox/海报管理/TbPosterService.cs new file mode 100644 index 0000000..72a9ec1 --- /dev/null +++ b/antis-ncc-net-core/NCC.BlindBox/海报管理/TbPosterService.cs @@ -0,0 +1,339 @@ +using NCC.Common.Core.Manager; +using NCC.Common.Enum; +using NCC.Common.Extension; +using NCC.Common.Filter; +using NCC.Dependency; +using NCC.DynamicApiController; +using NCC.FriendlyException; +using NCC.Blind.Interfaces.TbPoster; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NCC.Blind.Entitys; +using NCC.Blind.Entitys.Dto.TbPoster; +using Yitter.IdGenerator; +using NCC.Common.Helper; +using NCC.JsonSerialization; +using NCC.Common.Model.NPOI; +using NCC.Common.Configuration; +using NCC.DataEncryption; +using NCC.ClayObject; +using NCC.System.Interfaces.System; + +namespace NCC.Blind.TbPoster +{ + /// + /// 海报管理服务 + /// + [ApiDescriptionSettings(Tag = "海报管理",Name = "TbPoster", Order = 200)] + [Route("api/Blind/[controller]")] + public class TbPosterService : ITbPosterService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _tbPosterRepository; + private readonly IDbLinkService _dbLinkService; + private readonly IDataBaseService _dataBaseService; + private readonly SqlSugarScope _db; + private readonly IUserManager _userManager; + + /// + /// 初始化一个类型的新实例 + /// + public TbPosterService( + ISqlSugarRepository tbPosterRepository, + IDbLinkService dbLinkService, + IDataBaseService dataBaseService, + IUserManager userManager) + { + _tbPosterRepository = tbPosterRepository; + _db = _tbPosterRepository.Context; + _dbLinkService = dbLinkService; + _dataBaseService = dataBaseService; + _userManager = userManager; + } + + + + + + + /// + /// 获取海报管理 + /// + /// 参数 + /// + [HttpGet("{id}")] + public async Task GetInfo(string id) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var entity = await _db.Queryable().FirstAsync(p => p.Id == id); + var output = entity.Adapt(); + return output; + } + + + /// + /// 随机返回海报 + /// + /// + [HttpPost("GetRandomPoster")] + public async Task GetRandomPoster() + { + var list = _db.Queryable().ToList(); + if (list.Count > 0) + { + List ids = new List(); + foreach (var item in list) + { + ids.Add(item.Id); + } + int r = new Random().Next(ids.Count); + var data = list.Find(o => o.Id == ids[r]); + return data; + } + else + { + return ""; + } + + } + + + + /// + /// 获取海报管理列表 + /// + /// 请求参数 + /// + [HttpGet("")] + public async Task GetList([FromQuery] TbPosterListQueryInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var sidx = input.sidx == null ? "id" : input.sidx; + var data = await _db.Queryable() + .WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title)) + .Select(it=> new TbPosterListOutput + { + id = it.Id, + creatorTime=it.CreatorTime, + lastModifyTime=it.LastModifyTime, + creatorUserId=it.CreatorUserId, + title=it.Title, + }).MergeTable().OrderBy(sidx+" "+input.sort).ToPagedListAsync(input.currentPage, input.pageSize); + return PageResult.SqlSugarPageResult(data); + } + + /// + /// 新建海报管理 + /// + /// 参数 + /// + [HttpPost("")] + public async Task Create([FromBody] TbPosterCrInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var userInfo = await _userManager.GetUserInfo(); + var entity = input.Adapt(); + entity.Id = YitIdHelper.NextId().ToString(); + entity.CreatorTime = DateTime.Now; + entity.CreatorUserId = _userManager.UserId; + var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000); + } + + /// + /// 获取海报管理无分页列表 + /// + /// 请求参数 + /// + [NonAction] + public async Task GetNoPagingList([FromQuery] TbPosterListQueryInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var sidx = input.sidx == null ? "id" : input.sidx; + var data = await _db.Queryable() + .WhereIF(!string.IsNullOrEmpty(input.title), p => p.Title.Contains(input.title)) + .Select(it=> new TbPosterListOutput + { + id = it.Id, + creatorTime=it.CreatorTime, + lastModifyTime=it.LastModifyTime, + creatorUserId=it.CreatorUserId, + title=it.Title, + }).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync(); + return data; + } + + /// + /// 导出海报管理 + /// + /// 请求参数 + /// + [HttpGet("Actions/Export")] + public async Task Export([FromQuery] TbPosterListQueryInput input) + { + var userInfo = await _userManager.GetUserInfo(); + var exportData = new List(); + if (input.dataType == 0) + { + var data = Clay.Object(await this.GetList(input)); + exportData = data.Solidify>().list; + } + else + { + exportData = await this.GetNoPagingList(input); + } + List paramList = "[{\"value\":\"标题\",\"field\":\"title\"},{\"value\":\"创建时间\",\"field\":\"creatorTime\"},{\"value\":\"修改时间\",\"field\":\"lastModifyTime\"},{\"value\":\"创建用户\",\"field\":\"creatorUserId\"},]".ToList(); + ExcelConfig excelconfig = new ExcelConfig(); + excelconfig.FileName = "海报管理.xls"; + excelconfig.HeadFont = "微软雅黑"; + excelconfig.HeadPoint = 10; + excelconfig.IsAllSizeColumn = true; + excelconfig.ColumnModel = new List(); + List selectKeyList = input.selectKey.Split(',').ToList(); + foreach (var item in selectKeyList) + { + var isExist = paramList.Find(p => p.field == item); + if (isExist != null) + { + excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = isExist.field, ExcelColumn = isExist.value }); + } + } + var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName; + ExcelExportHelper.Export(exportData, excelconfig, addPath); + var fileName = _userManager.UserId + "|" + addPath + "|xls"; + var output = new + { + name = excelconfig.FileName, + url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") + }; + return output; + } + + /// + /// 批量删除海报管理 + /// + /// 主键数组 + /// + [HttpPost("batchRemove")] + public async Task BatchRemove([FromBody] List ids) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var entitys = await _db.Queryable().In(it => it.Id, ids).ToListAsync(); + if (entitys.Count > 0) + { + try + { + //开启事务 + _db.BeginTran(); + //批量删除海报管理 + await _db.Deleteable().In(d => d.Id,ids).ExecuteCommandAsync(); + //关闭事务 + _db.CommitTran(); + } + catch (Exception) + { + //回滚事务 + _db.RollbackTran(); + throw NCCException.Oh(ErrorCode.COM1002); + } + } + } + + /// + /// 更新海报管理 + /// + /// 主键 + /// 参数 + /// + [HttpPut("{id}")] + public async Task Update(string id, [FromBody] TbPosterUpInput input) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var entity = input.Adapt(); + entity.LastModifyTime = DateTime.Now; + var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001); + } + + /// + /// 删除海报管理 + /// + /// + [HttpDelete("{id}")] + public async Task Delete(string id) + { + var dbLink = await _dbLinkService.GetInfo("218239598550058245"); + _db.AddConnection(new ConnectionConfig() + { + ConfigId = dbLink.Id, + DbType = _dataBaseService.ToDbType(dbLink.DbType), + ConnectionString = _dataBaseService.ToConnectionString(dbLink), + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + _db.ChangeDatabase(dbLink.Id); + var entity = await _db.Queryable().FirstAsync(p => p.Id == id); + _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); + var isOk = await _db.Deleteable().Where(d => d.Id == id).ExecuteCommandAsync(); + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); + } + } +} diff --git a/antis-ncc-net-core/NCC.BlindBox/盲盒订单/TbBoxOrderService.cs b/antis-ncc-net-core/NCC.BlindBox/盲盒订单/TbBoxOrderService.cs index 01b32ff..1a40f03 100644 --- a/antis-ncc-net-core/NCC.BlindBox/盲盒订单/TbBoxOrderService.cs +++ b/antis-ncc-net-core/NCC.BlindBox/盲盒订单/TbBoxOrderService.cs @@ -342,9 +342,11 @@ namespace NCC.Blind.TbBoxOrder { ids.Add(item.Id); } - int r = new Random().Next(ids.Count); - var data = list.Find(o => o.Id == ids[r]); - if (data.IsNullOrEmpty()) throw NCCException.Oh($"暂无地域路线哦"); + var data = GetRandomItem(list); + Log.Information($"概率值:{JsonConvert.SerializeObject(data)}"); + //int r = new Random().Next(ids.Count); + //var data = list.Find(o => o.Id == ids[r]); + if (data.IsNullOrEmpty()) throw NCCException.Oh($"暂无地域路线或者百分比之和不等于100!"); var logResult = new TbBoxLogEntity { Id = YitIdHelper.NextId().ToString(), @@ -389,6 +391,29 @@ namespace NCC.Blind.TbBoxOrder } + /// + /// 概率算法 + /// + /// + /// + public static TbAreaLineEntity GetRandomItem(List items) + { + double totalPercentage = items.Sum(x => x.Ratio.ToDouble()); + double randomValue = new Random().NextDouble() * totalPercentage; + + foreach (TbAreaLineEntity item in items) + { + randomValue -= item.Ratio.ToDouble(); + if (randomValue <= 0) + { + return item; + } + } + + return null; // 如果总百分比小于100%或列表为空,则返回null + } + + @@ -513,14 +538,19 @@ namespace NCC.Blind.TbBoxOrder // if (areaLine.IsNullOrEmpty()) throw NCCException.Oh($"暂未查询到地域路线"); // } //} - var settingPrice = _db.Queryable().Where(o => o.Type == BlindBoxStatus.BlindBoxSettingPriceType.盲盒价格.GetHashCode().ToString()) -.First(); - if (settingPrice.IsNullOrEmpty()) throw NCCException.Oh($"暂未查询到盲盒价格,请联系管理员!"); + var settingPrice = _db.Queryable().ToList(); + if (settingPrice.IsNullOrEmpty()) throw NCCException.Oh($"暂未查询到价格设定数据,请联系管理员!"); + var manghe = settingPrice.Find(o => o.Type == BlindBoxStatus.BlindBoxSettingPriceType.盲盒价格.GetHashCode().ToString()); + var menpiao = settingPrice.Find(o => o.Type == BlindBoxStatus.BlindBoxSettingPriceType.门票价格.GetHashCode().ToString()); + if (menpiao.IsNullOrEmpty()) throw NCCException.Oh($"暂未查询到门票价格,请联系管理员!"); + if (manghe.IsNullOrEmpty()) throw NCCException.Oh($"暂未查询到盲盒价格,请联系管理员!"); + decimal totalMoneys = manghe.Price + menpiao.Price; + Log.Information($"支付总价:{totalMoneys}"); var entity = input.Adapt(); entity.OrderNumber = ServiceHelper.getTime().ToString(); entity.Status = BlindBoxStatus.BlindBoxOrderStatus.未付款.GetHashCode().ToString(); entity.CreatorTime = DateTime.Now; - entity.TotalPrice = settingPrice.Price; + entity.TotalPrice = totalMoneys; entity.Status = BlindBoxStatus.BlindBoxOrderStatus.未付款.GetHashCode().ToString(); entity.Id = YitIdHelper.NextId().ToString(); entity.CreatorTime = DateTime.Now;