付费课程
This commit is contained in:
parent
893fe217a5
commit
7f681c37df
@ -45,6 +45,7 @@ namespace YD_WeChatApplet.Context
|
|||||||
public DbSet<Y_Curricular> Curricular { get; set; }
|
public DbSet<Y_Curricular> Curricular { get; set; }
|
||||||
public DbSet<Y_StadiumVisiting> StadiumVisiting { get; set; }
|
public DbSet<Y_StadiumVisiting> StadiumVisiting { get; set; }
|
||||||
public DbSet<Y_SchoolAccountApplication> SchoolAccountApplication { get; set; }
|
public DbSet<Y_SchoolAccountApplication> SchoolAccountApplication { get; set; }
|
||||||
|
public DbSet<Y_CurricularPurchaseRecord> CurricularPurchaseRecord { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,28 @@ namespace YD_WeChatApplet.Api.Controllers
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程分类
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("PaidCoursesList")]
|
||||||
|
public async Task<List<PaidCoursesListDto>> PaidCoursesList()
|
||||||
|
{
|
||||||
|
var res = await _clientSideService.PaidCoursesList();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 课程兑换
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("PaidCoursesBuy")]
|
||||||
|
public async Task<bool> PaidCoursesBuy(string redeemCode)
|
||||||
|
{
|
||||||
|
var res = await _clientSideService.PaidCoursesBuy(redeemCode);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 教学列表
|
/// 教学列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -123,7 +123,7 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<ComboBoxDto>> CurricularTaxonomyList()
|
public async Task<List<ComboBoxDto>> CurricularTaxonomyList()
|
||||||
{
|
{
|
||||||
var res = await _sportsContext.CurricularTaxonomy.Select(x => new ComboBoxDto()
|
var res = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 1).Select(x => new ComboBoxDto()
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
Name = x.TaxonomyName
|
Name = x.TaxonomyName
|
||||||
@ -132,6 +132,52 @@ namespace YD_WeChatApplet.Api.Services.Impl
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<PaidCoursesListDto>> PaidCoursesList()
|
||||||
|
{
|
||||||
|
var userId = UserLoginContext.Current.UserId;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程购买
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> PaidCoursesBuy(string redeemCode)
|
||||||
|
{
|
||||||
|
var paidCoursesList = new List<Y_CurricularPurchaseRecord>();
|
||||||
|
|
||||||
|
var paidCourses = await _sportsContext.CurricularTaxonomy.Where(x => x.CurricularType == 2).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var paidCourse in paidCourses)
|
||||||
|
{
|
||||||
|
paidCoursesList.Add(new Y_CurricularPurchaseRecord()
|
||||||
|
{
|
||||||
|
TaxonomyId = paidCourse.Id,
|
||||||
|
UserId = UserLoginContext.Current.UserId,
|
||||||
|
RedeemCode = redeemCode,
|
||||||
|
Remarks = "",
|
||||||
|
CreateDate = DateTime.Now
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await _sportsContext.AddRangeAsync(paidCoursesList);
|
||||||
|
return await _sportsContext.SaveChangesAsync() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 教学列表
|
/// 教学列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -38,6 +38,18 @@ namespace YD_WeChatApplet.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<ComboBoxDto>> CurricularTaxonomyList();
|
Task<List<ComboBoxDto>> CurricularTaxonomyList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程分类
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<PaidCoursesListDto>> PaidCoursesList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程购买
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> PaidCoursesBuy(string redeemCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 课程列表
|
/// 课程列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace YD_WeChatApplet.Api.SmartSportsEntitys
|
||||||
|
{
|
||||||
|
[Table("Y_CurricularPurchaseRecord")]
|
||||||
|
public class Y_CurricularPurchaseRecord
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
[Display(Description = "主键Id")]
|
||||||
|
[Comment("Id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///用户Id
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "用户Id")]
|
||||||
|
[Comment("用户Id")]
|
||||||
|
[Column(TypeName = "int)")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///分类Id
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "分类Id")]
|
||||||
|
[Comment("分类Id")]
|
||||||
|
[Column(TypeName = "int)")]
|
||||||
|
public int TaxonomyId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///兑换码
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "兑换码")]
|
||||||
|
[Comment("兑换码")]
|
||||||
|
[Column(TypeName = "nvarchar(1000)")]
|
||||||
|
public string RedeemCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///备注
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "备注")]
|
||||||
|
[Comment("备注")]
|
||||||
|
[Column(TypeName = "text")]
|
||||||
|
public string Remarks { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///创建时间
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "创建时间")]
|
||||||
|
[Comment("创建时间")]
|
||||||
|
[Column(TypeName = "datetime")]
|
||||||
|
public DateTime CreateDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -23,5 +23,13 @@ namespace YD_WeChatApplet.Api.SmartSportsEntitys
|
|||||||
[Comment("分类名称")]
|
[Comment("分类名称")]
|
||||||
[Column(TypeName = "nvarchar(100)")]
|
[Column(TypeName = "nvarchar(100)")]
|
||||||
public string TaxonomyName { get; set; }
|
public string TaxonomyName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///课程类型
|
||||||
|
/// </summary>
|
||||||
|
[Display(Name = "课程类型")]
|
||||||
|
[Comment("课程类型")]
|
||||||
|
[Column(TypeName = "int)")]
|
||||||
|
public int CurricularType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
YD_WeChatApplet.Commons/Dto/ClientSide/PaidCoursesListDto.cs
Normal file
20
YD_WeChatApplet.Commons/Dto/ClientSide/PaidCoursesListDto.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YD_WeChatApplet.Commons.Dto.HomeWork;
|
||||||
|
|
||||||
|
namespace YD_WeChatApplet.Commons.Dto.ClientSide
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 付费课程列表
|
||||||
|
/// </summary>
|
||||||
|
public class PaidCoursesListDto : ComboBoxDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否购买
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPurchase { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user