Ver Fonte

公告上下架

qinchaoyue há 4 meses atrás
pai
commit
247ab67830

+ 8 - 0
src/Hotline.Api/Controllers/Snapshot/RedPackController.cs

@@ -34,6 +34,14 @@ public class RedPackController : BaseController
     public async Task<PagedDto<SnapshotOrderAuditItemsOutDto>> GetRedPackAuditItemsAsync([FromQuery] SnapshotOrderAuditItemsInDto dto)
         => (await _redPackApplication.GetRedPackAuditItemsAsync(dto).ToPagedListAsync(dto)).ToPaged();
 
+    /// <summary>
+    /// 获取审核短信模板
+    /// </summary>
+    /// <returns></returns>
+    [HttpGet("audit/sms_template")]
+    public async Task<IList<GetRedPackAuditSMSTemplateOutDto>> GetRedPackAuditSMSTemplateAsync([FromQuery]GetRedPackAuditSMSTemplateInDto dto)
+        => await _redPackApplication.GetRedPackAuditSMSTemplateAsync(dto);
+
     /// <summary>
     /// 红包审批页面基础数据
     /// </summary>

+ 28 - 0
src/Hotline.Api/Controllers/Snapshot/SnapshotBulletinController.cs

@@ -76,6 +76,34 @@ public class SnapshotBulletinController : BaseController
         return model.Adapt<SnapshotBulletinDetailOutDto>();
     }
 
+    /// <summary>
+    /// 公告上架或者下架
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("bulletin-arrive")]
+    public async Task BulletinArrive([FromBody] BulletinArriveDto dto)
+    {
+        var bulletin = await _bulletinRepository.GetAsync(dto.Id, HttpContext.RequestAborted);
+        if (bulletin == null)
+            throw UserFriendlyException.SameMessage("无效数据");
+
+        if (bulletin.BulletinState != EBulletinState.ReviewPass)
+            throw UserFriendlyException.SameMessage("当前状态不能操作上架或下架");
+
+        bulletin.IsArrive = dto.IsArrive;
+        if (bulletin.IsArrive == false)
+        {
+            bulletin.ExaminTime = null;
+            bulletin.ExaminManId = null;
+            bulletin.ExaminOpinion = null;
+            bulletin.CommitTime = null;
+            bulletin.BulletinState = EBulletinState.Draft;
+        }
+        await _bulletinRepository.UpdateAsync(bulletin, HttpContext.RequestAborted);
+    }
+
+
     /// <summary>
     /// 公告审核
     /// </summary>

+ 7 - 0
src/Hotline.Application/Snapshot/IRedPackApplication.cs

@@ -14,4 +14,11 @@ public interface IRedPackApplication
     /// </summary>
     /// <returns></returns>
     ISugarQueryable<SnapshotOrderAuditItemsOutDto> GetRedPackAuditItemsAsync(SnapshotOrderAuditItemsInDto dto);
+
+    /// <summary>
+    /// 获取审核短信模板
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    Task<IList<GetRedPackAuditSMSTemplateOutDto>> GetRedPackAuditSMSTemplateAsync(GetRedPackAuditSMSTemplateInDto dto);
 }

+ 22 - 1
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -4,6 +4,7 @@ using Hotline.Share.Enums.Order;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
+using Senparc.Weixin.MP;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -16,10 +17,12 @@ namespace Hotline.Application.Snapshot;
 public class RedPackApplication : IRedPackApplication, IScopeDependency
 {
     private readonly IOrderSnapshotRepository _orderSnapshotRepository;
+    private readonly ISnapshotSMSTemplateRepository _snapshotSMSTemplateRepository;
 
-    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository)
+    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository)
     {
         _orderSnapshotRepository = orderSnapshotRepository;
+        _snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
     }
 
     public ISugarQueryable<SnapshotOrderAuditItemsOutDto> GetRedPackAuditItemsAsync(SnapshotOrderAuditItemsInDto dto)
@@ -46,6 +49,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             .WhereIF(dto.Status.HasValue, (s, o, r, j) => r.Status == dto.Status)
             .Select((s, o, r, j) => new SnapshotOrderAuditItemsOutDto
             {
+                Id = s.Id,
                 No = o.No,
                 Title = o.Title,
                 IndustryName = s.IndustryName,
@@ -80,4 +84,21 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             });
         return query;
     }
+
+    /// <summary>
+    /// 获取审核短信模板
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public async Task<IList<GetRedPackAuditSMSTemplateOutDto>> GetRedPackAuditSMSTemplateAsync(GetRedPackAuditSMSTemplateInDto dto)
+    {
+        var items = await _snapshotSMSTemplateRepository.Queryable(includeDeleted: true)
+            .LeftJoin<Industry>((sms, industry) => sms.IndustryId == industry.Id)
+            .LeftJoin<OrderSnapshot>((sms, industry, snapshot) => snapshot.IndustryId == industry.Id)
+            .Where((sms, industry, snapshot) => 
+            snapshot.Id == dto.OrderId && sms.Status == dto.Status && sms.IsEnable == true)
+            .Select<GetRedPackAuditSMSTemplateOutDto>()
+            .ToListAsync();
+        return items;
+    }
 }

+ 31 - 0
src/Hotline.Share/Dtos/Snapshot/OrderDto.cs

@@ -222,6 +222,11 @@ public record SnapshotOrderAuditItemsInDto(string? No, string? Title,
 
 public class SnapshotOrderAuditItemsOutDto
 {
+    /// <summary>
+    /// Id
+    /// </summary>
+    public string Id { get; set; }
+
     /// <summary>
     /// No
     /// </summary>
@@ -405,3 +410,29 @@ public class SnapshotOrderAuditItemsOutDto
     /// </summary>
     public string? OpenBank { get; set; }
 }
+
+public class GetRedPackAuditSMSTemplateOutDto
+{
+    /// <summary>
+    /// Id
+    /// </summary>
+    public string Id { get; set; }
+
+    /// <summary>
+    /// 内容
+    /// </summary>
+    public string Content { get; set; }
+}
+
+public class GetRedPackAuditSMSTemplateInDto
+{
+    /// <summary>
+    /// OrderId
+    /// </summary>
+    public string OrderId { get; set; }
+
+    /// <summary>
+    /// 状态
+    /// </summary>
+    public ERedPackAuditStatus Status { get; set; }
+}

+ 9 - 0
src/Hotline.Share/Dtos/Snapshot/SnapshotBulletinDto.cs

@@ -125,6 +125,11 @@ public class SnapshotBulletinItemsOutDto
     /// 微信公开
     /// </summary>
     public bool? IsWeChat { get; set; }
+
+    /// <summary>
+    /// 上下架
+    /// </summary>
+    public bool IsArrive { get; set; }
 }
 
 public class SnapshotBulletinDetailOutDto : UpdateSnapshotBulletinInDto
@@ -154,6 +159,10 @@ public class SnapshotBulletinDetailOutDto : UpdateSnapshotBulletinInDto
     /// </summary>
     public EBulletinState BulletinState { get; set; }
 
+    /// <summary>
+    /// 上下架
+    /// </summary>
+    public bool IsArrive { get; set; }
 }
 
 public class UpdateSnapshotBulletinInDto : AddSnapshotBulletinInDto

+ 6 - 0
src/Hotline/Snapshot/SnapshotBulletin.cs

@@ -162,6 +162,12 @@ public class SnapshotBulletin : CreationEntity
     [SugarColumn(ColumnDescription = "来源方式")]
     public string? SourceMode { get; set; }
 
+    /// <summary>
+    /// 上下架
+    /// </summary>
+    [SugarColumn(ColumnDescription = "上下架")]
+    public bool IsArrive { get; set; }
+
     /// <summary>
     /// 阅读量+1
     /// </summary>

+ 1 - 1
src/Hotline/Snapshot/SnapshotSMSTemplate.cs

@@ -26,7 +26,7 @@ public class SnapshotSMSTemplate : FullStateEntity
     /// 审核状态
     /// </summary>
     [SugarColumn(ColumnDescription = "审核状态")]
-    public ESnapshotSMSStatus Status { get; set; }
+    public ERedPackAuditStatus Status { get; set; }
 
     /// <summary>
     /// 是否启用