自动发放积分,新增回写至学习记录上

master
xiaochanghai 2 weeks ago
parent 48a77d5114
commit 80a043837e
  1. 12
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

@ -2255,6 +2255,7 @@ ORDER BY {filter.orderBy}";
{ {
var now = DateTime.Now; var now = DateTime.Now;
//抓取当天提交考试的数据 //抓取当天提交考试的数据
var records = await Db.Queryable<Ghre_StudyRecord>() var records = await Db.Queryable<Ghre_StudyRecord>()
.Where(x => x.StudyProgress == 100 && (x.IsIssueCredit == null || x.IsIssueCredit == false)) .Where(x => x.StudyProgress == 100 && (x.IsIssueCredit == null || x.IsIssueCredit == false))
.Take(100) .Take(100)
@ -2285,9 +2286,9 @@ ORDER BY {filter.orderBy}";
if (courseCreditPoints <= 0) if (courseCreditPoints <= 0)
continue; continue;
record.CreditPoints = 0;
if (creditRuleId != null) if (creditRuleId != null)
{ {
record.CreditPoints = 0;
var creditRule = await Db.Queryable<Ghre_CreditRule>().Where(x => x.Id == creditRuleId).Select(x => new var creditRule = await Db.Queryable<Ghre_CreditRule>().Where(x => x.Id == creditRuleId).Select(x => new
{ {
x.RuleType, x.RuleType,
@ -2314,8 +2315,9 @@ ORDER BY {filter.orderBy}";
{ {
if (record.ExamId != null) if (record.ExamId != null)
{ {
if (await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.IsPass == true && x.Status == "ExamEnd").AnyAsync()) if (await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.IsPass == true && x.Status == "ExamEnd").AnyAsync()) { }
creditPoint.CreditPoints = ((courseCreditPoints * creditRule.ExamPassPercent) / 100).ObjToInt(); creditPoint.CreditPoints = ((courseCreditPoints * creditRule.ExamPassPercent) / 100).ObjToInt();
record.IsIssueCredit = true;
} }
} }
else if (creditRule.RuleType == "ScoreRanges")//分数段 else if (creditRule.RuleType == "ScoreRanges")//分数段
@ -2324,6 +2326,7 @@ ORDER BY {filter.orderBy}";
if (record.ExamId != null) if (record.ExamId != null)
{ {
record.IsIssueCredit = true;
var examRecord = await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.ScoreStatus == "HasScore" && x.IsPass == true && x.Status == "ExamEnd").FirstAsync(); var examRecord = await Db.Queryable<Ghre_ExamRecord>().Where(x => x.StudyRecordId == record.Id && x.ScoreStatus == "HasScore" && x.IsPass == true && x.Status == "ExamEnd").FirstAsync();
if (examRecord != null && examRecord.Score > 0) if (examRecord != null && examRecord.Score > 0)
{ {
@ -2355,12 +2358,13 @@ ORDER BY {filter.orderBy}";
} }
} }
} }
record.IsIssueCredit = true;
} }
await Db.Insertable(creditPoints).ExecuteReturnSnowflakeIdListAsync(); await Db.Insertable(creditPoints).ExecuteReturnSnowflakeIdListAsync();
records = records.Where(x => x.IsIssueCredit == true).ToList();
await Db.Updateable(records) await Db.Updateable(records)
.UpdateColumns(it => new { it.IsIssueCredit, it.CreditPoints }, true) .UpdateColumns(it => new { it.IsIssueCredit, it.CreditPoints }, true)
.ExecuteCommandAsync(); .ExecuteCommandAsync();
return ServiceResult.OprateSuccess("发放成功!"); return ServiceResult.OprateSuccess("发放成功!");
} }

Loading…
Cancel
Save