This commit is contained in:
tanglong 2025-07-29 11:24:17 +08:00
parent 7f681c37df
commit 0d8a8d43f8
3 changed files with 23 additions and 14 deletions

View File

@ -142,12 +142,16 @@ namespace YD_WeChatApplet.Api.Services.Impl
var paidCourses = await _sportsContext.CurricularPurchaseRecord.Where(x => x.UserId == userId).ToListAsync();
var res = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).Select(x => new PaidCoursesListDto()
{
Id = x.Id,
Name = x.TaxonomyName,
IsPurchase = paidCourses.Any(x => x.TaxonomyId == x.Id)
}).ToListAsync();
var purchasedIds = paidCourses.Select(x => x.TaxonomyId).ToHashSet();
var res = await _sportsContext.CurricularTaxonomy
.Where(x => x.CurricularType == 2)
.Select(x => new PaidCoursesListDto
{
Id = x.Id,
Name = x.TaxonomyName,
IsPurchase = purchasedIds.Contains(x.Id)
}).ToListAsync();
return res;
}
@ -162,12 +166,14 @@ namespace YD_WeChatApplet.Api.Services.Impl
var paidCourses = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).ToListAsync();
var userId = UserLoginContext.Current.UserId;
foreach (var paidCourse in paidCourses)
{
paidCoursesList.Add(new Y_CurricularPurchaseRecord()
{
TaxonomyId = paidCourse.Id,
UserId = UserLoginContext.Current.UserId,
UserId = userId,
RedeemCode = redeemCode,
Remarks = "",
CreateDate = DateTime.Now

View File

@ -6,6 +6,9 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace YD_WeChatApplet.Api.SmartSportsEntitys
{
/// <summary>
/// 课程购买记录表
/// </summary>
[Table("Y_CurricularPurchaseRecord")]
public class Y_CurricularPurchaseRecord
{

View File

@ -281,13 +281,13 @@ namespace YD_WeChatApplet
//配置HttpContext
app.UseStaticHttpContext();
//app.UseSwagger();
//app.UseSwaggerUI(c =>
//{
// //2个下拉框选项 选择对应的文档
// c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api");
// c.RoutePrefix = "";
//});
app.UseSwagger();
app.UseSwaggerUI(c =>
{
//2个下拉框选项 选择对应的文档
c.SwaggerEndpoint("/swagger/v1/swagger.json", "YD_WeChatApplet.Api");
c.RoutePrefix = "";
});
app.UseRouting();
app.UseCors();