feat: 新增消息Outbox机制、雪花ID配置优化及多项功能完善

1.  新增数据库唯一约束和Message_Outbox表脚本
2.  新增雪花ID、Hangfire存储、MQ重试等配置实体
3.  重构各项目雪花ID生成逻辑,改为从配置读取WorkerId
4.  优化积分服务分页查询、用户背包更新逻辑
5.  新增JWT令牌Redis过期刷新逻辑
6.  完善RabbitMQ死信队列消息头信息
7.  新增可靠MQ消息发布服务和Outbox派发后台服务
8.  替换原有RabbitMQ直接发送为Outbox可靠发布
9.  优化签到服务逻辑,新增重复签到校验和补签卡扣减逻辑
10. 修复自动铺码消费逻辑,新增点阵页预占和释放机制
This commit is contained in:
glz
2026-07-10 10:44:00 +08:00
parent 685a8aeaec
commit cbdee5068a
33 changed files with 693 additions and 152 deletions

View File

@ -11,6 +11,7 @@ using QYZH.InteractiveMagazine.IService;
using QYZH.InteractiveMagazine.Models.Common;
using QYZH.InteractiveMagazine.Models.Dto;
using QYZH.InteractiveMagazine.Models.Dto.Journal;
using QYZH.InteractiveMagazine.Models.Dto.RabbitMQ;
using QYZH.InteractiveMagazine.Models.Entity;
using QYZH.InteractiveMagazine.Models.Enum;
using QYZH.InteractiveMagazine.Repository;
@ -24,7 +25,7 @@ public class JournalPageService(BaseRepository<Journal> JournalRepository,
OssService ossService,
IHttpClientFactory httpClientFactory,
IConfiguration configuration,
IRabbitMQService rabbitMqService,
IMessagePublishService messagePublishService,
ILogger<AiBasePromptService> logger,
BaseRepository<JournalPage> JournalPageRepository,
BaseRepository<JournalPageTask> JournalPageTaskRepository,
@ -135,18 +136,29 @@ public class JournalPageService(BaseRepository<Journal> JournalRepository,
var isPdfExists = ossService.DoesObjectExist(uploadPdfKey);
BusinessException.ThrowIf(!isPdfExists, "获取期刊上传的PDF文件失败请检查PDF文件是否上传成功", ResultCode.GLOBAL_ERROR);
journalEntity.Status = (int)JournalStatusEnum.Codeing;
await JournalRepository.Updateable(journalEntity).UpdateColumns(x => new { x.Status, x.UpdatedAt }).ExecuteCommandAsync();
var data = new JournalPagePrintDto
{
JournalId = JournalId,
JournalPdfUrl = uploadPdfUrl,
PageNum = [.. journalPageList.Select(x => x.PageNum)]
};
var msRes = await rabbitMqService.SendAsync(new RabbitMQSendParam { Exchange = "ex.journal", Queue = "mq.journal.dotcode.auto", RoutingKey = "rk.journal.dotcode.auto", Data = data });//发生消息
return msRes;
return await UseTranAsync(async () =>
{
journalEntity.Status = (int)JournalStatusEnum.Codeing;
journalEntity.UpdatedAt = DateTime.Now;
await JournalRepository.Updateable(journalEntity).UpdateColumns(x => new { x.Status, x.UpdatedAt }).ExecuteCommandAsync();
await messagePublishService.PublishAsync(new MessagePublishInput<JournalPagePrintDto>
{
Exchange = "ex.journal",
Queue = "mq.journal.dotcode.auto",
RoutingKey = "rk.journal.dotcode.auto",
Data = data,
BusinessType = "JournalDotCode",
BusinessId = JournalId
});
return true;
});
}
/// <summary>
/// 回调接口-自动铺码, 书页铺码后回调接口,更新书页的点阵码