Merge branch 'master' of http://8.137.159.94:3000/glz/QYZH.InteractiveMagazine
This commit is contained in:
@ -172,29 +172,18 @@ public class UserAnswerTaskService(
|
||||
|
||||
// ============================================
|
||||
// 【积分和成长值计算】
|
||||
// 1. totalGrowthPoints:从已完成作答记录中,按 JournalPageTaskGroupId 查询主任务(Id=GroupId)的 GrowthPoint
|
||||
// 2. totalPoints:统计该期刊下已完成任务的 Points 总数
|
||||
// totalGrowthPoints:当前期刊下所有主任务(Id == GroupId)的成长值总和
|
||||
// totalPoints:当前期刊下所有主任务(Id == GroupId)的积分总和
|
||||
// ============================================
|
||||
// 该期刊下用户已完成的作答记录
|
||||
// 【已完成判断逻辑】
|
||||
// Status: 0=未批阅,1=已批阅
|
||||
var completedAnswers = userAnswers
|
||||
.Where(a => a.JournalId == journal.Id && a.Status == (int)UserAnswerStatusEnum.Complete)
|
||||
.ToList();
|
||||
// 筛选当前期刊下的主任务:Id == GroupId
|
||||
|
||||
var allMainTasks = journalTasks.Where(t => t.Id == t.GroupId).ToList();
|
||||
|
||||
// 按 JournalPageTaskGroupId 去重,获取已完成的主任务 ID 列表
|
||||
var completedGroupIdsSet = completedAnswers.Select(a => a.JournalPageTaskGroupId).Distinct().ToList();
|
||||
// 累计成长值(所有主任务的 GrowthPoint 总和)
|
||||
var totalGrowthPoints = allMainTasks.Sum(t => t.GrowthPoint);
|
||||
|
||||
// 从主任务表查询这些 GroupId 对应的 GrowthPoint 和 Points
|
||||
var mainTasks = allTasks
|
||||
.Where(t => completedGroupIdsSet.Contains(t.GroupId) && t.Id == t.GroupId)
|
||||
.ToList();
|
||||
|
||||
// 累计成长值(从主任务的 GrowthPoint 累加)
|
||||
var totalGrowthPoints = mainTasks.Sum(t => t.GrowthPoint);
|
||||
|
||||
// 累计积分(从已完成任务的 Points 累加,每个 GroupId 只计算一次)
|
||||
var totalPoints = mainTasks.Sum(t => t.Points);
|
||||
// 累计积分(所有主任务的 Points 总和)
|
||||
var totalPoints = allMainTasks.Sum(t => t.Points);
|
||||
|
||||
// 【进度百分比计算】按篇数统计
|
||||
// 只计算有题目的页面,进度 = 已答篇数 / 有题目的总篇数 × 100
|
||||
|
||||
Reference in New Issue
Block a user