Commit 4d93b5b1 authored by 吴春's avatar 吴春

提交代码

parent 46e979a2
......@@ -10,7 +10,7 @@ namespace Mall.Model.Extend.Education
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Teacher_Extend: Entity.Education.RB_Education_Teacher
public class RB_Education_Teacher_Extend : Entity.Education.RB_Education_Teacher
{
/// <summary>
......@@ -28,11 +28,24 @@ namespace Mall.Model.Extend.Education
/// </summary>
public int OrderGuestNum { get; set; }
/// <summary>
/// 关注人数
/// </summary>
public int FollowteacherNum { get; set; }
/// <summary>
/// 商品数
/// </summary>
public int GoodsNum { get; set; }
/// <summary>
/// 当前登录人id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 关联商品
/// </summary>
......
......@@ -2694,5 +2694,35 @@ namespace Mall.Module.Education
}
#endregion
#region 我的收藏
/// <summary>
/// 获取用户收藏商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetCollectEducationGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetCollectEducationGoodsPageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
foreach (var item in list)
{
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
}
}
return list;
}
#endregion
}
}
......@@ -1219,6 +1219,70 @@ LEFT JOIN rb_goods_wk_teacher as b on g.Id=b.GoodsId
LEFT JOIN (SELECT GoodsId,COUNT(*) as CourseNum from rb_goods_wk_course where `Status`=0 GROUP BY GoodsId) as c on c.GoodsId=g.Id where {where} order by {orderBy}";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取会员收藏商品分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetCollectEducationGoodsPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{
string where = $" 1=1 and col.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=2";
where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.{nameof(RB_Goods_Extend.Status)}=0 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1";
if (dmodel.TenantId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from
rb_member_collection col
inner join RB_Goods g on col.GoodsId=g.Id
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by col.Id desc";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
#endregion
}
......
......@@ -702,6 +702,39 @@ namespace Mall.WebApi.Controllers.Education
}
#endregion
#region 我的收藏
/// <summary>
/// 获取收藏商品分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetUserCollectionPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = educationModule.GetCollectEducationGoodsPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.CoverImage,
x.SellingPrice,
x.SalesNum
});
return ApiResult.Success("", pagelist);
}
#endregion
}
}
\ No newline at end of file
......@@ -160,7 +160,8 @@ namespace Mall.WebApi.Controllers.Education
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsCourseList(object requestMsg) {
public ApiResult GetAppletGoodsCourseList(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -173,7 +174,7 @@ namespace Mall.WebApi.Controllers.Education
{
return ApiResult.ParamIsNull();
}
var list = productModule.GetAppletGoodsCourseList(pagelist.pageIndex,pagelist.pageSize,out long count, GoodsId, req.TenantId, req.MallBaseId);
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);
......@@ -206,16 +207,21 @@ namespace Mall.WebApi.Controllers.Education
/// <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 == "[]") {
public List<CourseImageModel> GetCourseImage(int IsTrySee, bool IsPay, int Number, string Image)
{
if (string.IsNullOrEmpty(Image) || Image == "[]")
{
return new List<CourseImageModel>();
}
if (IsPay) {
if (IsPay)
{
return JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
}
if (IsTrySee == 1) {
if (IsTrySee == 1)
{
var list = JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
if (Number > 0) {
if (Number > 0)
{
list = list.Take(Number).ToList();
}
return list;
......@@ -381,22 +387,36 @@ namespace Mall.WebApi.Controllers.Education
{
oldLogisticsModel.LableNameList = JsonConvert.DeserializeObject<List<string>>(oldLogisticsModel.LableName);
}
//获取老师的关注数
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { TeacherId = query.ID, MallBaseId = query.MallBaseId, TenantId = query.TenantId });
oldLogisticsModel.FollowteacherNum = oldList.Count();
int Followteacher = 0;
if (query.UserId > 0)
{
Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).Count() : 0;
}
//获取老师对应的课程
var goodsList = educationModule.GetListByTeacherId(1, 4, out long count, new RB_Goods_Extend { TeacherId = oldLogisticsModel.ID, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId });
var goodsResult = goodsList.Select(x => new
{
x.CoverImage,
x.Name,
x.CourseNum
x.CourseNum,
x.Id
});
var teacherResult = new {
var teacherResult = new
{
oldLogisticsModel?.WorkYears,
oldLogisticsModel?.Major,
oldLogisticsModel?.LableNameList,
oldLogisticsModel?.Name,
oldLogisticsModel?.TeacherLogo,
oldLogisticsModel?.Introduction
oldLogisticsModel?.Introduction,
oldLogisticsModel.FollowteacherNum,
Followteacher//是否关注该老师,0-没有,1-已关注
};
return ApiResult.Success("", new { teacherResult, goodsResult });
}
......
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