Commit 4895595e authored by liudong1993's avatar liudong1993

课程章节调整

parent 2a033fd1
......@@ -3401,6 +3401,27 @@ namespace Mall.Module.Product
//查询观看数量
return list;
}
/// <summary>
/// 获取课程是否购买
/// </summary>
/// <param name="goodsId"></param>
/// <param name="UserId"></param>
/// <returns></returns>
public bool GetAppletCourseIsPay(int goodsId, int UserId) {
if (UserId <= 0) {
return false;
}
var omodel = goods_OrderRepository.GetCourseOrderIsPay(GoodsIds: goodsId.ToString(), UserId: UserId).FirstOrDefault();
if (omodel != null)
{
if (omodel.PaymentTime.HasValue)
{
return true;
}
}
return false;
}
#endregion
#region 素材管理
......
......@@ -175,6 +175,7 @@ namespace Mall.WebApi.Controllers.Education
}
var list = productModule.GetAppletGoodsCourseList(pagelist.pageIndex,pagelist.pageSize,out long count, GoodsId, req.TenantId, req.MallBaseId);
bool IsPay = productModule.GetAppletCourseIsPay(GoodsId, req.UserId);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
......@@ -187,15 +188,41 @@ namespace Mall.WebApi.Controllers.Education
x.IsTrySee,
x.Number,
x.IsCache,
x.FilePath,
FilePath = x.IsTrySee == 1 || IsPay ? x.FilePath : "",
x.IsImageOK,
x.VideoImage,
x.VideoTime,
ImageList = !string.IsNullOrEmpty(x.Image) && x.Image != "[]" ? JsonConvert.DeserializeObject<List<CourseImageModel>>(x.Image) : new List<CourseImageModel>()
IsPay,
ImageList = GetCourseImage(x.IsTrySee ?? 0, IsPay, x.Number ?? 0, x.Image)
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取课程图片
/// </summary>
/// <param name="IsTrySee"></param>
/// <param name="IsPay"></param>
/// <param name="Number"></param>
/// <param name="Image"></param>
/// <returns></returns>
public List<CourseImageModel> GetCourseImage(int IsTrySee, bool IsPay,int Number, string Image) {
if (string.IsNullOrEmpty(Image) || Image == "[]") {
return new List<CourseImageModel>();
}
if (IsPay) {
return JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
}
if (IsTrySee == 1) {
var list = JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
if (Number > 0) {
list = list.Take(Number).ToList();
}
return list;
}
return new List<CourseImageModel>();
}
#endregion
#region 资讯
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment