Commit 6909084e authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq-ld

parents 6af9ac34 9773ac18
...@@ -30,9 +30,14 @@ namespace Mall.Common ...@@ -30,9 +30,14 @@ namespace Mall.Common
/// </summary> /// </summary>
public int UserId { get; set; } public int UserId { get; set; }
/// 用户店铺id /// 用户店铺id
/// </summary> /// </summary>
public int SmallShopId { get; set; } public int SmallShopId { get; set; }
/// 用户对应的老师id
/// </summary>
public int UserTeacher { get; set; }
/// <summary> /// <summary>
......
...@@ -51,6 +51,61 @@ namespace Mall.Common.Plugin ...@@ -51,6 +51,61 @@ namespace Mall.Common.Plugin
#endregion #endregion
#region "日期相关" #region "日期相关"
public static string DateFormatToString(DateTime dt)
{
//TimeSpan表示时间间隔
TimeSpan span = (DateTime.Now - dt).Duration();//表示取timespan绝对值
//if (span.TotalDays > 60)
//{
// return dt.ToString("yyyy-MM-dd");
//}
//else if (span.TotalDays > 30)
//{
// return "1个月前";
//}
//else if (span.TotalDays > 14)
//{
// return "2周前";
//}
if (dt.Year == DateTime.Now.Year)
{
if (span.TotalDays > 7)
{
return dt.ToString("yyyy-MM-dd");
}
else if (span.TotalDays > 2)
{
return string.Format("{0}天前", (int)Math.Floor(span.TotalDays));
}
else if (span.TotalDays ==1)
{
return string.Format("昨天", (int)Math.Floor(span.TotalDays));
}
else if (span.TotalHours > 1)
{
return string.Format("{0}小时前", (int)Math.Floor(span.TotalHours));
}
else if (span.TotalMinutes > 1)
{
return string.Format("{0}分钟前", (int)Math.Floor(span.TotalMinutes));
}
else if (span.TotalSeconds >= 1)
{
return string.Format("{0}秒前", (int)Math.Floor(span.TotalSeconds));
}
else
{
return "1秒前";
}
}
else
{
return dt.ToString("yyyy-MM-dd");
}
}
/// <summary> /// <summary>
/// 获取星期的字符串 /// 获取星期的字符串
/// </summary> /// </summary>
......
...@@ -87,5 +87,11 @@ namespace Mall.Model.Entity.Education ...@@ -87,5 +87,11 @@ namespace Mall.Model.Entity.Education
/// 国家图片 /// 国家图片
/// </summary> /// </summary>
public string ForeignersUrl { get; set; } public string ForeignersUrl { get; set; }
/// <summary>
/// 用户id
/// </summary>
public int UserId { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-老师动态管理表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_Dynamic
{
/// <summary>
/// 动态文章id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 文章内容
/// </summary>
public string Content
{
get;
set;
}
/// <summary>
/// 文件
/// </summary>
public string Files
{
get;
set;
}
/// <summary>
/// 发布位置经纬度(纬度,经度)
/// </summary>
public string LatAndLong
{
get;
set;
}
/// <summary>
/// 发布位置
/// </summary>
public string Address
{
get;
set;
}
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 教师id
/// </summary>
public int UserTeacher { get; set; }
/// <summary>
/// 老师对应的用户id
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime
{
get;
set;
}
/// <summary>
/// 状态 0:正常,1:删除
/// </summary>
public int Status
{
get;
set;
}
/// <summary>
/// 封面图片
/// </summary>
public string CoverPhoto
{
get;
set;
}
/// <summary>
/// 是否公开1-是,2-关注可见
/// </summary>
public int IsOpen { get; set; }
/// <summary>
/// 文件类型(1:图片,2:视频,3音频)
/// </summary>
public int? FileType
{
get;
set;
}
/// <summary>
/// 秒数
/// </summary>
public int Seconds { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-老师动态评论管理实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_DynamicComment
{
/// <summary>
/// 评论id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 文章id
/// </summary>
public int ArticleId
{
get;
set;
}
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 评论创建人Id
/// </summary>
public int UserId
{
get;
set;
}
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime
{
get;
set;
}
/// <summary>
/// 评论回复id
/// </summary>
public int? CommentId
{
get;
set;
}
/// <summary>
/// 评论内容
/// </summary>
public string Content
{
get;
set;
}
/// <summary>
/// 状态 0:正常,1:删除
/// </summary>
public int? Status
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-资讯管理实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_DynamicLike
{
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 点赞id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 点赞文章id
/// </summary>
public int ArticleId
{
get;
set;
}
/// <summary>
/// 点赞人id
/// </summary>
public int UserId
{
get;
set;
}
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime
{
get;
set;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Entity.Education
{
/// <summary>
/// 教育-老师动态消息管理表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_DynamicMessage
{
/// <summary>
/// 动态文章消息id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 动态id
/// </summary>
public int? ArticleId
{
get;
set;
}
/// <summary>
/// 消息类型(1评论,2点赞)
/// </summary>
public int? MessageType
{
get;
set;
}
/// <summary>
/// 消息id
/// </summary>
public int? MessageId
{
get;
set;
}
/// <summary>
/// 会员id
/// </summary>
public int? UserId
{
get;
set;
}
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreateTime
{
get;
set;
}
}
}
...@@ -438,10 +438,17 @@ namespace Mall.Model.Entity.User ...@@ -438,10 +438,17 @@ namespace Mall.Model.Entity.User
/// 菜单栏json格式 多组模式 /// 菜单栏json格式 多组模式
/// </summary> /// </summary>
public string MenuNavJson { get; set; } public string MenuNavJson { get; set; }
/// <summary>
/// 老师发动态后给关注的人发消息
/// </summary>
public string EducationDynamicTpl { get; set; }
} }
public class MenuNavMoreModel { public class MenuNavMoreModel
{
/// <summary> /// <summary>
/// 排序 /// 排序
/// </summary> /// </summary>
......
...@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education ...@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education
/// 从业年限 /// 从业年限
/// </summary> /// </summary>
public decimal WorkYears { get; set; } public decimal WorkYears { get; set; }
/// <summary>
/// openId
/// </summary>
public string OpenId { get; set; }
} }
} }
...@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education ...@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education
/// 关联商品 /// 关联商品
/// </summary> /// </summary>
public List<Product.RB_Goods_Extend> GoodsList { get; set; } public List<Product.RB_Goods_Extend> GoodsList { get; set; }
/// <summary>
/// 会员名称
/// </summary>
public string UserName { get; set; }
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Education;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 教育-老师动态评论管理扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_DynamicComment_Extend: Rb_Education_DynamicComment
{
#region 扩展字段
/// <summary>
/// 评论员工姓名
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 被回复用户姓名
/// </summary>
public string ByReplyEmName { get; set; }
/// <summary>
/// 被回复用户Id
/// </summary>
public int ByReplyEmpId { get; set; }
/// <summary>
/// 动态ids
/// </summary>
public string ArticleIds { get; set; }
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Education;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 教育-资讯管理实体表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_DynamicLike_Extend : Rb_Education_DynamicLike
{
/// <summary>
/// 点赞员工姓名
/// </summary>
public string EmName { get; set; }
/// <summary>
/// 动态ids
/// </summary>
public string ArticleIds { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Education;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 教育-老师动态管理扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class Rb_Education_Dynamic_Extend : Rb_Education_Dynamic
{
#region 扩展字段
/// <summary>
/// 操作人
/// </summary>
public List<string> FileList { get; set; }
/// <summary>
/// 是否点赞
/// </summary>
public bool HasLike { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 创建人头像
/// </summary>
public string CrearteByPhoto { get; set; }
/// <summary>
/// 点赞列表信息
/// </summary>
public List<Rb_Education_DynamicLike_Extend> LikeList { get; set; }
/// <summary>
/// 评论列表信息
/// </summary>
public List<Rb_Education_DynamicComment_Extend> CommentList { get; set; }
/// <summary>
/// 评论内容
/// </summary>
public string CommentContent { get; set; }
/// <summary>
/// 相关类型 1评论,2点赞
/// </summary>
public int RealtionType { get; set; }
/// <summary>
/// 评论id
/// </summary>
public int CommentId { get; set; }
/// <summary>
/// 当前登录人id
/// </summary>
public int UserId { get; set; }
public string ReplyName { get; set; }
public string ReplyPhoto { get; set; }
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using Mall.Repository.Education;
using VT.FW.DB;
namespace Mall.Module.Education
{
/// <summary>
/// app动态模块
/// </summary>
public class DynamicModule
{
private readonly Rb_Education_DynamicRepository articleRepository = new Rb_Education_DynamicRepository();
private readonly Rb_Education_DynamicLikeRepository likeRepository = new Rb_Education_DynamicLikeRepository();
private readonly Rb_Education_DynamicCommentRepository commentRepository = new Rb_Education_DynamicCommentRepository();
private readonly Rb_Education_DynamicMessageRepository messageRepository = new Rb_Education_DynamicMessageRepository();
/// <summary>
/// 获取消息未读数
/// </summary>
/// <param name="empId">员工id</param>
/// <returns></returns>
public int GetDynamicMessageCount(Rb_Education_DynamicMessage model)
{
return messageRepository.GetDynamicMessageCount(model);
}
/// <summary>
/// 发布动态文章
/// </summary>
/// <param name="article">动态文章</param>
/// <returns></returns>
public bool PublishDynamic(Rb_Education_Dynamic article)
{
return articleRepository.Insert(article) > 0 ? true : false;
}
///// <summary>
///// 我的动态记录
///// </summary>
///// <param name="empId">员工id</param>
///// <param name="pageIndex">当前页</param>
///// <param name="pageSize">分页大小</param>
///// <param name="count">总条数</param>
///// <returns></returns>
//public List<Rb_Education_Dynamic_Extend> MyDynamicList(int empId, int pageIndex, int pageSize, out long count)
//{
// List<Rb_Education_Dynamic_Extend> articleList = articleRepository.MyDynamicList(empId, pageIndex, pageSize, out count);
// return articleList;
//}
/// <summary>
///// Web端我的动态记录
///// </summary>
///// <param name="empId">员工id</param>
///// <param name="groupId">集团id</param>
///// <param name="pageIndex">当前页</param>
///// <param name="pageSize">分页大小</param>
///// <param name="count">总条数</param>
///// <returns></returns>
//public List<Rb_Education_Dynamic_Extend> WebMyDynamicList(int empId, int groupId, int pageIndex, int pageSize, out long count)
//{
// List<Rb_Education_Dynamic_Extend> articleList = articleRepository.WebMyDynamicList(empId, groupId, pageIndex, pageSize, out count);
// DecoratorDynameicArticle(articleList);
// return articleList;
//}
/// <summary>
/// 集团动态列表
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="groupId">集团id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> DynamicList(int pageIndex, int pageSize, out long count, Rb_Education_Dynamic_Extend model)
{
List<Rb_Education_Dynamic_Extend> articleList = new List<Rb_Education_Dynamic_Extend>();
if (model.UserId > 0)//关注并公开
{
articleList = articleRepository.DynamicOpenList(pageIndex, pageSize, out count, model);
}
else
{//公开的
articleList = articleRepository.DynamicList(pageIndex, pageSize, out count, model);
}
DecoratorDynameicArticle(articleList);
return articleList;
}
/// <summary>
/// 我的动态列表
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="groupId">集团id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> MyDynamicList(int pageIndex, int pageSize, out long count, Rb_Education_Dynamic_Extend model)
{
List<Rb_Education_Dynamic_Extend> articleList = articleRepository.MyDynamicList(pageIndex, pageSize, out count, model);
DecoratorDynameicArticle(articleList);
return articleList;
}
/// <summary>
/// 与我相关的动态
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> AboutMeDynamicList(Rb_Education_Dynamic_Extend model, int pageIndex, int pageSize, out long count)
{
if (pageIndex == 1)
{
IList<WhereHelper> messageWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.UserId),
FiledValue = model.CreateBy,
OperatorEnum = OperatorEnum.Equal
}
};
messageRepository.Delete(messageWhereHelpers);
}
return articleRepository.AboutMeDynamicList(model, pageIndex, pageSize, out count);
}
/// <summary>
/// 装饰动态文章
/// </summary>
/// <param name="articleList"></param>
private void DecoratorDynameicArticle(List<Rb_Education_Dynamic_Extend> articleList)
{
List<Rb_Education_DynamicLike_Extend> likeList = new List<Rb_Education_DynamicLike_Extend>();
List<Rb_Education_DynamicComment_Extend> commentList = new List<Rb_Education_DynamicComment_Extend>();
if (articleList != null && articleList.Any())
{
string articleIds = string.Join(",", articleList.Where(x => x.Id > 0).Select(x => x.Id));
if (!string.IsNullOrWhiteSpace(articleIds))
{
likeList = likeRepository.GetDynamicLikeList(new Rb_Education_DynamicLike_Extend { ArticleIds = articleIds });
commentList = commentRepository.GetDynamicCommentList(new Rb_Education_DynamicComment_Extend { ArticleIds = articleIds });
}
}
foreach (var item in articleList)
{
item.LikeList = likeList.Where(x => x.ArticleId == item.Id).ToList();
item.CommentList = commentList.Where(x => x.ArticleId == item.Id).ToList();
foreach (var common in item.CommentList)
{
if (common.CommentId != null && common.CommentId > 0)
{
Rb_Education_DynamicComment_Extend byReplayCommon = item.CommentList.Where(t => t.Id == common.CommentId.Value).FirstOrDefault();
if (byReplayCommon != null)
{
common.ByReplyEmName = byReplayCommon.UserName;
common.ByReplyEmpId = byReplayCommon.UserId;
}
}
}
}
}
/// <summary>
/// 获取动态点赞
/// </summary>
/// <param name="articleId">动态文章id</param>
/// <returns></returns>
public List<Rb_Education_DynamicLike_Extend> GetDynamicLikeList(Rb_Education_DynamicLike_Extend model)
{
return likeRepository.GetDynamicLikeList(model);
}
/// <summary>
/// 获取动态详情
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="articleId">动态id</param>
/// <returns></returns>
public Rb_Education_Dynamic_Extend GetDynamicDetial(Rb_Education_Dynamic_Extend model)
{
Rb_Education_Dynamic_Extend article = articleRepository.GetDynamicDetial(model);
if (article == null)
{
return article;
}
article.LikeList = likeRepository.GetDynamicLikeList(new Rb_Education_DynamicLike_Extend { ArticleId = article.Id });
article.CommentList = commentRepository.GetDynamicCommentList(new Rb_Education_DynamicComment_Extend { ArticleId = article.Id });
foreach (var common in article.CommentList)
{
if (common.CommentId != null && common.CommentId > 0)
{
Rb_Education_DynamicComment_Extend byReplayCommon = article.CommentList.Where(t => t.Id == common.CommentId.Value).FirstOrDefault();
if (byReplayCommon != null)
{
common.ByReplyEmName = byReplayCommon.UserName;
common.ByReplyEmpId = byReplayCommon.UserId;
}
}
}
return article;
}
/// <summary>
/// 删除动态
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="articleId">动态id</param>
/// <returns></returns>
public bool DeleteDynamic(int createBy, int articleId, int tenantId, int mallBaseId)
{
IDictionary<string, object> fileds = new Dictionary<string, object>
{
{ nameof(Rb_Education_Dynamic.Status), 1 }
};
IList<WhereHelper> auditrecordWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_Dynamic.Id),
FiledValue = articleId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_Dynamic.TenantId),
FiledValue = tenantId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_Dynamic.MallBaseId),
FiledValue = mallBaseId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_Dynamic.CreateBy),
FiledValue = createBy,
OperatorEnum = OperatorEnum.Equal
}
};
return articleRepository.Update(fileds, auditrecordWhereHelpers);
}
/// <summary>
/// 动态点赞
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="articleId">文章id</param>
/// <returns></returns>
public bool DynamicLike(Rb_Education_DynamicLike model)
{
var trans = likeRepository.DbTransaction;
try
{
IList<WhereHelper> auditrecordWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.ArticleId),
FiledValue = model.ArticleId,
OperatorEnum = OperatorEnum.Equal
}, new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.TenantId),
FiledValue = model.TenantId,
OperatorEnum = OperatorEnum.Equal
}, new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.MallBaseId),
FiledValue = model.MallBaseId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper(){
FiledName = nameof(Rb_Education_DynamicLike.UserId),
FiledValue = model.UserId,
OperatorEnum = OperatorEnum.Equal
}
};
likeRepository.Delete(auditrecordWhereHelpers, trans);
Rb_Education_DynamicLike like = new Rb_Education_DynamicLike
{
CreateTime = DateTime.Now,
ArticleId = model.ArticleId,
UserId = model.UserId,
TenantId = model.TenantId,
MallBaseId = model.MallBaseId
};
int likeId = likeRepository.Insert(like, trans);
Rb_Education_Dynamic article = articleRepository.GetEntity(model.ArticleId);
if (article != null)
{
Rb_Education_DynamicMessage message = new Rb_Education_DynamicMessage
{
UserId = article.CreateBy,
CreateTime = DateTime.Now,
ArticleId = model.ArticleId,
MessageId = likeId,
MessageType = 2,
TenantId = article.TenantId,
MallBaseId = article.MallBaseId
};
messageRepository.Insert(message, trans);
}
likeRepository.DBSession.Commit();
return true;
}
catch (Exception)
{
likeRepository.DBSession.Rollback("DynamicLike");
return false;
}
}
/// <summary>
/// 动态取消点赞
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="articleId">文章id</param>
/// <returns></returns>
public void DynamicCancelLike(Rb_Education_DynamicLike model)
{
IList<WhereHelper> auditrecordWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.Id),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.TenantId),
FiledValue = model.TenantId,
OperatorEnum = OperatorEnum.Equal
}, new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicLike.MallBaseId),
FiledValue = model.MallBaseId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper(){
FiledName = nameof(Rb_Education_DynamicLike.UserId),
FiledValue = model.UserId,
OperatorEnum = OperatorEnum.Equal
}
};
likeRepository.Delete(auditrecordWhereHelpers);
IList<WhereHelper> messageWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.MessageId),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.TenantId),
FiledValue = model.TenantId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.MallBaseId),
FiledValue = model.MallBaseId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper(){
FiledName = nameof(Rb_Education_DynamicMessage.MessageType),
FiledValue = 2,
OperatorEnum = OperatorEnum.Equal
}
};
messageRepository.Delete(messageWhereHelpers);
}
/// <summary>
/// 添加动态评论
/// </summary>
/// <param name="comment">评论信息</param>
/// <returns></returns>
public bool DynamicCommemt(Rb_Education_DynamicComment comment)
{
int commentId = commentRepository.Insert(comment);
if (commentId > 0)
{
Rb_Education_Dynamic article = articleRepository.GetEntity(comment.ArticleId);
if (article != null)
{
Rb_Education_DynamicMessage message = new Rb_Education_DynamicMessage
{
UserId = article.CreateBy,
CreateTime = DateTime.Now,
ArticleId = comment.ArticleId,
MessageId = commentId,
MessageType = 1,
TenantId = article.TenantId,
MallBaseId = article.MallBaseId
};
messageRepository.Insert(message);
}
return true;
}
else
{
return false;
}
}
/// <summary>
/// 删除动态评论
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="commentId">评论id</param>
/// <returns></returns>
public bool DynamicDeleteComment(Rb_Education_DynamicComment_Extend model)
{
if (commentRepository.DynamicDeleteComment(model) > 0)
{
IList<WhereHelper> messageWhereHelpers = new List<WhereHelper>
{
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.MessageId),
FiledValue = model.Id,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.TenantId),
FiledValue = model.TenantId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper()
{
FiledName = nameof(Rb_Education_DynamicMessage.MallBaseId),
FiledValue = model.MallBaseId,
OperatorEnum = OperatorEnum.Equal
},
new WhereHelper(){
FiledName = nameof(Rb_Education_DynamicMessage.MessageType),
FiledValue = 1,
OperatorEnum = OperatorEnum.Equal
}
};
messageRepository.Delete(messageWhereHelpers);
return true;
}
else
{
return false;
}
}
}
}
...@@ -1769,6 +1769,7 @@ namespace Mall.Module.Education ...@@ -1769,6 +1769,7 @@ namespace Mall.Module.Education
{ nameof(RB_Education_Teacher_Extend.WorkYears),model.WorkYears}, { nameof(RB_Education_Teacher_Extend.WorkYears),model.WorkYears},
{ nameof(RB_Education_Teacher_Extend.Nationality),model.Nationality}, { nameof(RB_Education_Teacher_Extend.Nationality),model.Nationality},
{ nameof(RB_Education_Teacher_Extend.ForeignersUrl),model.ForeignersUrl}, { nameof(RB_Education_Teacher_Extend.ForeignersUrl),model.ForeignersUrl},
{ nameof(RB_Education_Teacher_Extend.UserId),model.UserId},
}; };
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
...@@ -3141,7 +3142,20 @@ namespace Mall.Module.Education ...@@ -3141,7 +3142,20 @@ namespace Mall.Module.Education
return model; return model;
} }
/// <summary>
/// 网课-我关注的老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowUserList(RB_Education_FollowTeacher_Extend query)
{
List<RB_Education_FollowTeacher_Extend> list = followTeacherRepository.GetFollowUserList( query);
return list;
}
/// <summary> /// <summary>
...@@ -3172,7 +3186,7 @@ namespace Mall.Module.Education ...@@ -3172,7 +3186,7 @@ namespace Mall.Module.Education
{ {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now}, { nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now},
{ nameof(RB_Education_FollowTeacher.Status),1} { nameof(RB_Education_FollowTeacher.Status),model.Status}
}; };
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
......
...@@ -382,7 +382,7 @@ namespace Mall.Module.User ...@@ -382,7 +382,7 @@ namespace Mall.Module.User
}, },
amount2 = new amount2 = new
{ {
value = OrderMoney+ "元" value = OrderMoney + "元"
}, },
thing1 = new thing1 = new
{ {
...@@ -808,6 +808,96 @@ namespace Mall.Module.User ...@@ -808,6 +808,96 @@ namespace Mall.Module.User
/// <summary>
/// 老师发布动态发送订阅消息
/// </summary>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <param name="OpenId"></param>
/// <param name="Remark">退款原因</param>
/// <param name="OrderNo">订单号</param>
/// <param name="OrderMoney">退款金额</param>
/// <param name="GoodsName">商品名称</param>
/// <returns></returns>
public bool SendEducationDynamicMsg(int TenantId, int MallBaseId, List<string> OpenIds, string Title, string UserName, string CreateTime)
{
var appletWeChatModel = programRepository.GetListRepository(new RB_MiniProgram_Extend { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault();
string token = WeiXinReidsCache.Get(appletWeChatModel.MiniAppId);
if (string.IsNullOrEmpty(token))
{
token = Mall.Common.Pay.WeChatPat.TokenHelper.GetLXYToken(token, appletWeChatModel.MiniAppId, appletWeChatModel.MiniAppSecret);
System.Threading.Tasks.Task.Run(() => WeiXinReidsCache.Set(appletWeChatModel.MiniAppId, token));
}
if (string.IsNullOrEmpty(token))
{
return false;
}
string wenXinResult = string.Empty;
int successCount = 0;
if (!string.IsNullOrWhiteSpace(token))
{
try
{
foreach (var item in OpenIds)
{
if (!string.IsNullOrWhiteSpace(item))
{
string Url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + token;
var postdata = new
{
touser = item,
template_id = appletWeChatModel.EducationDynamicTpl,
page = "pages/order/index/index",
data = new
{
thing1 = new
{
value = Title
},
thing2 = new
{
value = UserName
},
time3 = new
{
value = CreateTime
}
}
};
wenXinResult = HttpHelper.HttpPost(Url, JsonHelper.Serialize(postdata), "");
LogHelper.WriteInfo("老师发布动态发送订阅消息:" + wenXinResult);
JObject jo = (JObject)JsonConvert.DeserializeObject(wenXinResult);
int errcode = Convert.ToInt32(jo["errcode"].ToString());
if (errcode == 0)
{
successCount += 1;
}
else
{
LogHelper.Write(string.Format("SendEducationDynamicMsg:wenXinResult:{0}", wenXinResult));
}
}
}
}
catch (Exception ex)
{
LogHelper.Write(string.Format("SendEducationDynamicMsg:wenXinResult:{0}", wenXinResult));
}
if (successCount == OpenIds.Count())
{
return true;
}
else {
return false;
}
}
return false;
}
#endregion #endregion
......
...@@ -192,6 +192,12 @@ namespace Mall.Module.User ...@@ -192,6 +192,12 @@ namespace Mall.Module.User
private readonly RB_SmallShops_CustomRepository smallShopsCustomRepository = new RB_SmallShops_CustomRepository(); private readonly RB_SmallShops_CustomRepository smallShopsCustomRepository = new RB_SmallShops_CustomRepository();
/// <summary>
/// 教师仓储
/// </summary>
private readonly Repository.Education.RB_Education_TeacherRepository educationTeacherRepository = new Repository.Education.RB_Education_TeacherRepository();
#region 基础配置 #region 基础配置
/// <summary> /// <summary>
...@@ -6750,5 +6756,19 @@ namespace Mall.Module.User ...@@ -6750,5 +6756,19 @@ namespace Mall.Module.User
{ {
return member_UserRepository2.GetMemberUserListExtRepository(dmodel); return member_UserRepository2.GetMemberUserListExtRepository(dmodel);
} }
/// <summary>
/// 教师配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public Model.Extend.Education.RB_Education_Teacher_Extend GetTeacherModel(Model.Extend.Education.RB_Education_Teacher_Extend query)
{
Model.Extend.Education.RB_Education_Teacher_Extend model = educationTeacherRepository.GetTeacherList(query).FirstOrDefault();
return model;
}
} }
} }
...@@ -65,7 +65,51 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}= ...@@ -65,7 +65,51 @@ on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.Append(@$" SELECT a.*,b.Introduction,b.Major,b.LableName,b.`Name`,b.Score,b.TeacherLogo,b.Telephone FROM rb_education_followteacher as a LEFT JOIN rb_education_teacher as b builder.Append(@$" SELECT a.*,b.Introduction,b.Major,b.LableName,b.`Name`,b.Score,b.TeacherLogo,b.Telephone FROM rb_education_followteacher as a LEFT JOIN rb_education_teacher as b
on a.TeacherId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}=1"); on a.TeacherId=b.ID WHERE 1=1 and b.{nameof(RB_Education_Teacher_Extend.Status)}=0 and b.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}=1");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.Status >= 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.Status)}={query.Status}");
}
if (query.ID > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.ID)}={query.ID}");
}
if (query.UserId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.UserId)}={query.UserId}");
}
if (query.TeacherId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_FollowTeacher_Extend.TeacherId)}={query.TeacherId}");
}
}
return Get<RB_Education_FollowTeacher_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 网课-我关注的老师列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowUserList(RB_Education_FollowTeacher_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append(@$" SELECT a.*,b.OpenId FROM rb_education_followteacher as a LEFT JOIN rb_member_user as b
on a.UserId=b.ID WHERE a.{nameof(RB_Education_FollowTeacher_Extend.Status)}=0 ");
if (query != null) if (query != null)
{ {
if (query.TenantId > 0) if (query.TenantId > 0)
......
...@@ -71,32 +71,36 @@ namespace Mall.Repository.Education ...@@ -71,32 +71,36 @@ namespace Mall.Repository.Education
public List<RB_Education_Teacher_Extend> GetTeacherList(RB_Education_Teacher_Extend query) public List<RB_Education_Teacher_Extend> GetTeacherList(RB_Education_Teacher_Extend query)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Education_Teacher_Extend.Status)}=0"); builder.Append($" SELECT a.*,b.`Name` as UserName from {TableName} as a LEFT JOIN rb_member_user as b on a.UserId=b.Id WHERE a.{nameof(RB_Education_Teacher_Extend.Status)}=0");
if (query != null) if (query != null)
{ {
if (query.TenantId > 0) if (query.TenantId > 0)
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TenantId)}={query.TenantId}"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.TenantId)}={query.TenantId}");
} }
if (query.TenantId > 0) if (query.TenantId > 0)
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.MallBaseId)}={query.MallBaseId}"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.MallBaseId)}={query.MallBaseId}");
} }
if (query.ID > 0) if (query.ID > 0)
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.ID)}={query.ID}"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.ID)}={query.ID}");
}
if (query.UserId > 0)
{
builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.UserId)}={query.UserId}");
} }
if (!string.IsNullOrWhiteSpace(query.Name)) if (!string.IsNullOrWhiteSpace(query.Name))
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Name)} like '%{query.Name}%'"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.Name)} like '%{query.Name}%'");
} }
if (!string.IsNullOrWhiteSpace(query.Telephone)) if (!string.IsNullOrWhiteSpace(query.Telephone))
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.Telephone)} like '%{query.Telephone}%'"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.Telephone)} like '%{query.Telephone}%'");
} }
if (query.TeacherStatus > 0) if (query.TeacherStatus > 0)
{ {
builder.Append($" AND {nameof(RB_Education_Teacher_Extend.TeacherStatus)}={query.TeacherStatus}"); builder.Append($" AND a.{nameof(RB_Education_Teacher_Extend.TeacherStatus)}={query.TeacherStatus}");
} }
} }
return Get<RB_Education_Teacher_Extend>(builder.ToString()).ToList(); return Get<RB_Education_Teacher_Extend>(builder.ToString()).ToList();
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
namespace Mall.Repository.Education
{
public class Rb_Education_DynamicCommentRepository : BaseRepository<Rb_Education_DynamicComment>
{
/// <summary>
/// 获取动态评论
/// </summary>
/// <param name="articleId">动态文章id</param>
/// <returns></returns>
public List<Rb_Education_DynamicComment_Extend> GetDynamicCommentList(Rb_Education_DynamicComment_Extend model)
{
string where = " where c.`Status`=0 ";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and c.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and c.MallBaseId = {model.MallBaseId} ";
}
if (model.UserId > 0)
{
where += $@" and c.UserId = {model.UserId} ";
}
if (model.ArticleId > 0)
{
where += $@" and c.ArticleId = {model.ArticleId} ";
}
if (!string.IsNullOrWhiteSpace(model.ArticleIds))
{
where += $@" and c.ArticleId in({model.ArticleIds} ) ";
}
}
string sql = $@"SELECT c.*,e.`Name` as UserName from Rb_Education_DynamicComment c
LEFT JOIN rb_member_user e on c.UserId = e.Id
{where} order by c.CreateTime desc";
return Get<Rb_Education_DynamicComment_Extend>(sql).ToList();
}
/// <summary>
/// 删除动态评论
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int DynamicDeleteComment(Rb_Education_DynamicComment_Extend model)
{
string sql = $@"UPDATE Rb_Education_DynamicComment set `Status` =1 where Id ={model.Id} and TenantId = {model.TenantId} and MallBaseId = {model.MallBaseId} and (UserId = {model.UserId} or ArticleId in (
SELECT a.Id from Rb_Education_Dynamic a where a.CreateBy = {model.UserId} and a.`Status` =0
))";
return Execute(sql);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
namespace Mall.Repository.Education
{
public class Rb_Education_DynamicLikeRepository : BaseRepository<Rb_Education_DynamicLike>
{
/// <summary>
/// 获取动态点赞
/// </summary>
/// <param name="articleId">动态文章id</param>
/// <returns></returns>
public List<Rb_Education_DynamicLike_Extend> GetDynamicLikeList(Rb_Education_DynamicLike_Extend model)
{
string where = " where 1=1 ";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and l.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and l.MallBaseId = {model.MallBaseId} ";
}
if (model.UserId > 0)
{
where += $@" and l.UserId = {model.UserId} ";
}
if (model.ArticleId > 0)
{
where += $@" and l.ArticleId = {model.ArticleId} ";
}
if (!string.IsNullOrWhiteSpace(model.ArticleIds))
{
where += $@" and l.ArticleId in({model.ArticleIds} ) ";
}
}
string sql = $@"SELECT l.*,e.`Name` as EmName from rb_education_dynamiclike l
INNER JOIN rb_member_user e on e.Id = l.UserId
{where} order by l.CreateTime desc";
return Get<Rb_Education_DynamicLike_Extend>(sql).ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.Education;
namespace Mall.Repository.Education
{
public class Rb_Education_DynamicMessageRepository:BaseRepository<Rb_Education_DynamicMessage>
{
/// <summary>
/// 获取消息未读数
/// </summary>
/// <param name="empId">员工id</param>
/// <returns></returns>
public int GetDynamicMessageCount(Rb_Education_DynamicMessage model)
{
string sql = $@"SELECT COUNT(*) from rb_education_dynamicmessage m where m.UserId ={model.UserId} and m.TenantId ={model.TenantId} and m.MallBaseId ={model.MallBaseId}";
return Convert.ToInt32(ExecuteScalar(sql));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
namespace Mall.Repository.Education
{
/// <summary>
/// 老师动态仓储
/// </summary>
public class Rb_Education_DynamicRepository : BaseRepository<Rb_Education_Dynamic>
{
/// <summary>
/// 老师动态列表
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="groupId">集团id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> DynamicList(int pageIndex, int pageSize, out long count, Rb_Education_Dynamic_Extend model)
{
string where = " where a.`Status`=0 and a.IsOpen=1";
string likeWhere = "";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and a.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and a.MallBaseId = {model.MallBaseId} ";
}
if (model.UserTeacher > 0)
{
where += $@" and a.UserTeacher = {model.UserTeacher} ";
}
if (model.Id > 0)
{
where += $@" and a.Id = {model.Id} ";
}
if (model.CreateBy > 0)
{
where += $@" and a.CreateBy = {model.CreateBy} ";
}
if (model.UserId>0)
{
likeWhere += $@" and l.UserId = {model.UserId} ";
}
}
string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a {where} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_education_teacher e on e.Id = t.UserTeacher
ORDER BY t.CreateTime DESC";
return GetPage<Rb_Education_Dynamic_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 老师动态列表
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="groupId">集团id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> DynamicOpenList(int pageIndex, int pageSize, out long count, Rb_Education_Dynamic_Extend model)
{
string where = " and a.`Status`=0 ";
string likeWhere = "";
string followWhere = "";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and a.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and a.MallBaseId = {model.MallBaseId} ";
}
if (model.Id > 0)
{
where += $@" and a.Id = {model.Id} ";
}
if (model.UserTeacher > 0)
{
where += $@" and a.UserTeacher = {model.UserTeacher} ";
}
if (model.CreateBy > 0)
{
where += $@" and a.CreateBy = {model.CreateBy} ";
}
if (model.UserId > 0)
{
likeWhere += $@" and l.UserId = {model.UserId} ";
followWhere += $@" and b.UserId = {model.UserId} and b.`Status`=0 ";
}
}
string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a where a.IsOpen=1 {where}
union all SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a LEFT JOIN rb_education_followteacher as b on a.UserTeacher=b.TeacherId where a.IsOpen=2 {where} {followWhere} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_education_teacher e on e.Id = t.UserTeacher
ORDER BY t.CreateTime DESC";
return GetPage<Rb_Education_Dynamic_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 我的动态列表
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="groupId">集团id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> MyDynamicList(int pageIndex, int pageSize, out long count, Rb_Education_Dynamic_Extend model)
{
string where = " where a.`Status`=0 ";
string likeWhere = "";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and a.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and a.MallBaseId = {model.MallBaseId} ";
}
if (model.UserTeacher > 0)
{
where += $@" and a.UserTeacher = {model.UserTeacher} ";
}
if (model.CreateBy > 0)
{
where += $@" and a.CreateBy = {model.CreateBy} ";
}
if (model.IsOpen > 0)
{
where += $@" and a.IsOpen = {model.IsOpen} ";
}
if (model.UserId > 0)
{
likeWhere += $@" and l.UserId = {model.UserId} ";
}
}
string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a {where} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_education_teacher e on e.Id = t.UserTeacher
ORDER BY t.CreateTime DESC";
return GetPage<Rb_Education_Dynamic_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 动态详情
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="articleId">动态id</param>
/// <returns></returns>
public Rb_Education_Dynamic_Extend GetDynamicDetial(Rb_Education_Dynamic_Extend model)
{
string where = " where a.`Status`=0 ";
string likeWhere = "";
if (model != null)
{
if (model.TenantId > 0)
{
where += $@" and a.TenantId = {model.TenantId} ";
}
if (model.MallBaseId > 0)
{
where += $@" and a.MallBaseId = {model.MallBaseId} ";
}
if (model.Id > 0)
{
where += $@" and a.Id = {model.Id} ";
}
if (model.IsOpen > 0)
{
where += $@" and a.IsOpen = {model.IsOpen} ";
}
if (model.UserTeacher > 0)
{
where += $@" and a.UserTeacher = {model.UserTeacher} ";
}
//if (model.CreateBy > 0)
//{
// where += $@" and a.CreateBy = {model.CreateBy} ";
//}
if (model.UserId > 0)
{
// where += $@" and a.CreateBy = {model.CreateBy} ";
likeWhere += $@" and l.UserId = {model.UserId} ";
}
}
string sql = $@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.TeacherLogo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a {where} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_education_teacher e on e.Id = t.UserTeacher
ORDER BY t.CreateTime DESC";
return Get<Rb_Education_Dynamic_Extend>(sql).FirstOrDefault();
}
/// <summary>
/// 与我相关的动态
/// </summary>
/// <param name="empId">员工id</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">分页大小</param>
/// <param name="count">总条数</param>
/// <returns></returns>
public List<Rb_Education_Dynamic_Extend> AboutMeDynamicList(Rb_Education_Dynamic_Extend model, int pageIndex, int pageSize, out long count)
{
string sql = $@"SELECT * from ((SELECT a.Id,a.Content,a.CoverPhoto,a.FileType,a.Files,c.CreateTime,c.UserId,
c.Content as CommentContent,1 as RealtionType,e.`Name` as CreateByName,e.Photo as CrearteByPhoto,mu.`Name` as ReplyName,mu.Photo as ReplyPhoto,c.Id as CommentId
from rb_education_dynamiccomment c INNER JOIN rb_education_dynamic a on a.Id = c.ArticleId and
a.CreateBy={model.CreateBy} and a.TenantId={model.TenantId} and a.MallBaseId={model.MallBaseId}
and a.`Status` =0 and c.`Status` =0 and c.TenantId={model.TenantId} and c.MallBaseId={model.MallBaseId}
LEFT JOIN rb_member_user e on e.Id = c.UserId LEFT JOIN rb_education_dynamiccomment as edc on edc.Id=c.CommentId
LEFT JOIN rb_member_user as mu on mu.Id=edc.UserId)
UNION ALL
(SELECT a.Id,a.Content,a.CoverPhoto,a.FileType,a.Files,l.CreateTime,l.UserId,
'' as CommentContent,2 as RealtionType,e.`Name` as CreateByName,e.Photo as CrearteByPhoto,'' as ReplyName ,'' as ReplyPhoto,0 as CommentId
from rb_education_dynamiclike l JOIN rb_education_dynamic a on a.Id = l.ArticleId and
a.CreateBy={model.CreateBy} and a.TenantId={model.TenantId} and a.MallBaseId={model.MallBaseId}
and a.`Status` =0 and l.TenantId={model.TenantId} and l.MallBaseId={model.MallBaseId}
LEFT JOIN rb_member_user e on e.Id = l.UserId)) as t
ORDER BY t.CreateTime DESC";
return GetPage<Rb_Education_Dynamic_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
}
}
...@@ -419,6 +419,15 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -419,6 +419,15 @@ namespace Mall.WebApi.Controllers.AppletWeChat
return ApiResult.Success("", Robj); return ApiResult.Success("", Robj);
} }
//public ApiResult TestSendEducationDynamicMsg()
//{
// List<string> openIds = new List<string>();
// openIds.Add("oshxs5I-6uR1J91Rs3QVyi2rJIm4");
// openIds.Add("oshxs5I-6uR1J91Rs3QVyi2rJIm4");
// new MiniProgramMsgModule().SendEducationDynamicMsg(15,5, openIds, "您关注的老师发布又有新动态了", "李琴",System.DateTime.Now.ToString("yyyy年MM月dd日"));
// return ApiResult.Success("");
//}
public ApiResult TestWeChatPay() public ApiResult TestWeChatPay()
{ {
......
...@@ -33,6 +33,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -33,6 +33,7 @@ namespace Mall.WebApi.Controllers.Education
public class AppletEducationController : BaseController public class AppletEducationController : BaseController
{ {
private readonly EducationModule educationModule = new EducationModule(); private readonly EducationModule educationModule = new EducationModule();
private readonly DynamicModule dynamicModule = new DynamicModule();
private Module.User.UserModule UserModule = new Module.User.UserModule(); private Module.User.UserModule UserModule = new Module.User.UserModule();
private Module.Product.ProductModule productModule = new Module.Product.ProductModule(); private Module.Product.ProductModule productModule = new Module.Product.ProductModule();
private readonly Module.User.MiniProgramModule programModule = new Module.User.MiniProgramModule(); private readonly Module.User.MiniProgramModule programModule = new Module.User.MiniProgramModule();
...@@ -947,7 +948,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -947,7 +948,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ApiResult FollowTeacher() public ApiResult GetFollowTeacher()
{ {
var parms = RequestParm; var parms = RequestParm;
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
...@@ -964,6 +965,8 @@ namespace Mall.WebApi.Controllers.Education ...@@ -964,6 +965,8 @@ namespace Mall.WebApi.Controllers.Education
} }
else else
{ {
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { Status = -1, UserId = query.UserId, TeacherId = query.TeacherId, MallBaseId = query.MallBaseId, TenantId = query.TenantId }); ;
if (query.ID == 0) if (query.ID == 0)
{ {
isUpdate = false; isUpdate = false;
...@@ -973,14 +976,24 @@ namespace Mall.WebApi.Controllers.Education ...@@ -973,14 +976,24 @@ namespace Mall.WebApi.Controllers.Education
{ {
return ApiResult.Failed("请传入我关注的老师信息"); return ApiResult.Failed("请传入我关注的老师信息");
} }
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { UserId = query.UserId, TeacherId = query.TeacherId, MallBaseId = query.MallBaseId, TenantId = query.TenantId }); if (oldList != null && oldList.Any(x => x.Status == 0))
if (oldList != null && oldList.Any())
{ {
return ApiResult.Failed("您已关注,请勿重复操作"); return ApiResult.Failed("您已关注,请勿重复操作");
} }
else
{
if (oldList != null && oldList.Any())
{
query.ID = oldList.OrderByDescending(x => x.CreateDate).FirstOrDefault().ID;
}
query.Status = 0;
}
}
else
{
query.Status = 1;
} }
bool result = educationModule.AddOrUpdateFollowTeacher(query); bool result = educationModule.AddOrUpdateFollowTeacher(query);
if (isUpdate) if (isUpdate)
...@@ -996,18 +1009,27 @@ namespace Mall.WebApi.Controllers.Education ...@@ -996,18 +1009,27 @@ namespace Mall.WebApi.Controllers.Education
} }
else else
{ {
//获取订阅消息
var miniModel = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
List<string> template_message_list = new List<string>();
if (miniModel != null)
{
if (!string.IsNullOrWhiteSpace(miniModel.EducationDynamicTpl))
{
template_message_list.Add(miniModel.EducationDynamicTpl);
}
}
if (result) if (result)
{ {
return ApiResult.Success("关注成功"); return ApiResult.Success("关注成功", template_message_list);
} }
else else
{ {
return ApiResult.Failed("关注成功"); return ApiResult.Failed("关注成功");
} }
} }
} }
} }
#endregion #endregion
...@@ -1061,6 +1083,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -1061,6 +1083,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public ApiResult SetGuestSurvey() public ApiResult SetGuestSurvey()
{ {
var req = RequestParm; var req = RequestParm;
...@@ -1191,6 +1214,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -1191,6 +1214,7 @@ namespace Mall.WebApi.Controllers.Education
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public ApiResult GetSurveyShowList() public ApiResult GetSurveyShowList()
{ {
var req = RequestParm; var req = RequestParm;
...@@ -1235,12 +1259,346 @@ namespace Mall.WebApi.Controllers.Education ...@@ -1235,12 +1259,346 @@ namespace Mall.WebApi.Controllers.Education
activeSurueyModel.PrizeType, activeSurueyModel.PrizeType,
activeSurueyModel.ID, activeSurueyModel.ID,
FillInNum = GuestSurvey.Where(x => x.UserId == userInfo.UserId).Count(), FillInNum = GuestSurvey.Where(x => x.UserId == userInfo.UserId).Count(),
BaseList = list.Where(x => x.FormType == FormTypeEnum.Base).OrderBy(x => x.Sort).Select(x => new { x.ID, x.IsRequired,x.ActivitySurveyId, SurveyType = (int)x.SurveyType, x.FormType, x.Title, x.Sort, SurveyTypeStr = EnumHelper.GetEnumName(x.SurveyType), FormTypeStr = EnumHelper.GetEnumName(x.FormType), x.SurveyOptionsList, ScoreNum = (x.SurveyType.HasValue&& x.SurveyType == SurveyTypeEnum.Score) ? 5 : 0, TextContent = "" }).ToList(), BaseList = list.Where(x => x.FormType == FormTypeEnum.Base).OrderBy(x => x.Sort).Select(x => new { x.ID, x.IsRequired, x.ActivitySurveyId, SurveyType = (int)x.SurveyType, x.FormType, x.Title, x.Sort, SurveyTypeStr = EnumHelper.GetEnumName(x.SurveyType), FormTypeStr = EnumHelper.GetEnumName(x.FormType), x.SurveyOptionsList, ScoreNum = (x.SurveyType.HasValue && x.SurveyType == SurveyTypeEnum.Score) ? 5 : 0, TextContent = "" }).ToList(),
SurveyList = list.Where(x => x.FormType == FormTypeEnum.Survey).OrderBy(x => x.Sort).Select(x => new { x.ID, x.IsRequired, x.ActivitySurveyId, SurveyType = (int)x.SurveyType, x.FormType, x.Title, x.Sort, SurveyTypeStr = EnumHelper.GetEnumName(x.SurveyType), FormTypeStr = EnumHelper.GetEnumName(x.FormType), x.SurveyOptionsList, ScoreNum = (x.SurveyType.HasValue && x.SurveyType == SurveyTypeEnum.Score) ? 5 : 0, TextContent = "" }).ToList() SurveyList = list.Where(x => x.FormType == FormTypeEnum.Survey).OrderBy(x => x.Sort).Select(x => new { x.ID, x.IsRequired, x.ActivitySurveyId, SurveyType = (int)x.SurveyType, x.FormType, x.Title, x.Sort, SurveyTypeStr = EnumHelper.GetEnumName(x.SurveyType), FormTypeStr = EnumHelper.GetEnumName(x.FormType), x.SurveyOptionsList, ScoreNum = (x.SurveyType.HasValue && x.SurveyType == SurveyTypeEnum.Score) ? 5 : 0, TextContent = "" }).ToList()
}; };
return ApiResult.Success("", result); return ApiResult.Success("", result);
} }
#endregion #endregion
#region 老师动态
/// <summary>
/// 我的动态列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetMyDynamicList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
Rb_Education_Dynamic_Extend demodel = JsonConvert.DeserializeObject<Rb_Education_Dynamic_Extend>(req.msg.ToString());
demodel.CreateBy = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
demodel.UserId = userInfo.UserId;
List<Rb_Education_Dynamic_Extend> myArticleList = dynamicModule.MyDynamicList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
List<object> list = new List<object>();
foreach (var item in myArticleList)
{
list.Add(DecoratorDynameicResult(item));
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 我的动态列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAboutMeDynamicList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
Rb_Education_Dynamic_Extend demodel = JsonConvert.DeserializeObject<Rb_Education_Dynamic_Extend>(req.msg.ToString());
demodel.CreateBy = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
List<Rb_Education_Dynamic_Extend> myArticleList = dynamicModule.AboutMeDynamicList(demodel, pagelist.pageIndex, pagelist.pageSize, out long count);
List<object> list = new List<object>();
foreach (var item in myArticleList)
{
List<string> fileList = new List<string>();
if (!string.IsNullOrEmpty(item.Files))
{
fileList = JsonConvert.DeserializeObject<List<string>>(item.Files);
}
var resultData = new { id = item.Id, content = StringHelper.FromUnicodeString(item.Content), coverPhoto = item.CoverPhoto, fileType = item.FileType, fileList, realtionType = item.RealtionType, commentContent = StringHelper.FromUnicodeString(item.CommentContent), createEmpId = item.CreateBy, createEmName = item.CreateByName, crearteEmPhoto = item.CrearteByPhoto, replyName = item.ReplyName ?? "", replyPhoto = item.ReplyPhoto ?? "", createTime = StringHelper.DateFormatToString(item.CreateTime.Value), commentId = item.CommentId };
list.Add(resultData);
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 发布动态
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetPublishDynamic()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
if (userInfo == null)
{
return ApiResult.Failed("请重新登录");
}
if (userInfo.UserTeacher == 0)
{
return ApiResult.Failed("您暂无绑定老师账户");
}
Rb_Education_Dynamic_Extend article = JsonConvert.DeserializeObject<Rb_Education_Dynamic_Extend>(req.msg.ToString());
var teacherModel = educationModule.GetTeacherModel(new RB_Education_Teacher_Extend { ID = userInfo.UserTeacher, MallBaseId = userInfo.MallBaseId, TenantId = userInfo.TenantId });
if (teacherModel.TeacherStatus == 2)
{
return ApiResult.Failed("您暂时无法发布动态");
}
article.Content = StringHelper.UrlDecode(article.Content);
if (string.IsNullOrWhiteSpace(article.Content) && (article.FileList == null || !article.FileList.Any()))
{
return ApiResult.Failed("文字和文件不能同时为空");
}
article.CreateTime = DateTime.Now;
article.CreateBy = userInfo.UserId;
article.TenantId = userInfo.TenantId;
article.MallBaseId = userInfo.MallBaseId;
article.UserTeacher = userInfo.UserTeacher;
article.CoverPhoto = "";
if (article.FileList != null && article.FileList.Count() > 0)
{
article.Files = JsonConvert.SerializeObject(article.FileList);
article.CoverPhoto = article.FileList[0];
}
else
{
article.FileType = 0;
}
article.Content = StringHelper.ToUnicodeString(article.Content);
article.Status = 0;
if (dynamicModule.PublishDynamic(article))
{
var oldList = educationModule.GetFollowUserList(new RB_Education_FollowTeacher_Extend { TeacherId = userInfo.UserTeacher, MallBaseId = userInfo.MallBaseId, TenantId = userInfo.TenantId });
if (oldList != null && oldList.Any())//有关注的人
{
List<string> openIds = oldList.Select(x => x.OpenId).ToList();
new MiniProgramMsgModule().SendEducationDynamicMsg(userInfo.TenantId, userInfo.MallBaseId, openIds, "您关注的老师又有新动态了", teacherModel.Name, article.CreateTime.Value.ToString("yyyy年MM月dd日"));
}
return ApiResult.Success("发布成功");
}
else
{
return ApiResult.Failed("发布失败");
}
}
/// <summary>
/// 动态列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicDetial()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parm = JObject.Parse(req.msg.ToString());
int articleId = parm.GetInt("articleId");
if (articleId == 0)
{
return ApiResult.Failed("动态id不为空");
}
Rb_Education_Dynamic_Extend articele = dynamicModule.GetDynamicDetial(new Rb_Education_Dynamic_Extend { UserId = userInfo.UserId, Id = articleId });
if (articele != null)
{
var data = DecoratorDynameicResult(articele);
return ApiResult.Success(data: data);
}
else
{
return ApiResult.Failed("动态不存在");
}
}
/// <summary>
/// 返回动态详情
/// </summary>
/// <param name="article">动态内容</param>
/// <returns></returns>
public object DecoratorDynameicResult(Rb_Education_Dynamic_Extend article)
{
List<string> fileList = new List<string>();
if (!string.IsNullOrEmpty(article.Files))
{
fileList = JsonConvert.DeserializeObject<List<string>>(article.Files);
}
//StringHelper.UrlEncode(StringHelper.FromUnicodeString(article.Content))
var resultData = new { id = article.Id, createEmpId = article.CreateBy, createEmName = article.CreateByName, crearteEmPhoto = article.CrearteByPhoto, YearTime = article.CreateTime.HasValue ? (article.CreateTime.Value.Year == System.DateTime.Now.Year ? "" : article.CreateTime.Value.ToString("yyyy")) : "", MonthTime = article.CreateTime.HasValue ? article.CreateTime.Value.ToString("MM") : "", DayTime = article.CreateTime.HasValue ? article.CreateTime.Value.ToString("dd") : "", createTime = article.CreateTime.HasValue ? StringHelper.DateFormatToString(article.CreateTime.Value) : "", content = StringHelper.FromUnicodeString(article.Content), coverPhoto = article.CoverPhoto, fileType = article.FileType, latAndLong = article.LatAndLong, address = article.Address, files = fileList, hasLike = article.HasLike, likeList = article.LikeList.Select(t => new { empId = t.UserId, empName = t.EmName, t.Id }), commentList = article.CommentList.Select(t => new { commentId = t.Id, empId = t.UserId, empName = t.UserName, byReplayEmpId = t.ByReplyEmpId, byReplayEmpName = t.ByReplyEmName, content = StringHelper.FromUnicodeString(t.Content) }) };
return resultData;
}
/// <summary>
/// 删除动态
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDeleteDynamic()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parm = JObject.Parse(req.msg.ToString());
int articleId = parm.GetInt("articleId");
if (articleId == 0)
{
return ApiResult.Failed("动态id不为空");
}
if (dynamicModule.DeleteDynamic(userInfo.UserId, articleId, userInfo.TenantId, userInfo.MallBaseId))
{
return ApiResult.Success("删除成功");
}
else
{
return ApiResult.Failed("动态不存在");
}
}
/// <summary>
/// 动态点赞
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicLike()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parm = JObject.Parse(req.msg.ToString());
int articleId = parm.GetInt("articleId");
if (articleId == 0)
{
return ApiResult.Failed("动态id不为空");
}
var likeList = dynamicModule.GetDynamicLikeList(new Rb_Education_DynamicLike_Extend { UserId = userInfo.UserId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, ArticleId = articleId });
if (likeList != null && likeList.Any())
{
return ApiResult.Failed("请勿重复点赞");
}
if (dynamicModule.DynamicLike(new Rb_Education_DynamicLike { UserId = userInfo.UserId, ArticleId = articleId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId }))
{
return ApiResult.Success("点赞成功");
}
else
{
return ApiResult.Failed("点赞失败");
}
}
/// <summary>
/// 动态取消点赞
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicCancelLike()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parm = JObject.Parse(req.msg.ToString());
int articleId = parm.GetInt("articleId");
if (articleId == 0)
{
return ApiResult.Failed("动态id不能为空");
}
var likeModel = dynamicModule.GetDynamicLikeList(new Rb_Education_DynamicLike_Extend { UserId = userInfo.UserId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, ArticleId = articleId }).FirstOrDefault();
if (likeModel != null && likeModel.Id > 0)
{
dynamicModule.DynamicCancelLike(new Rb_Education_DynamicLike { UserId = userInfo.UserId, Id = likeModel.Id, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
}
return ApiResult.Success("取消成功");
}
/// <summary>
/// 动态评论
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicComment()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
Rb_Education_DynamicComment comment = JsonConvert.DeserializeObject<Rb_Education_DynamicComment>(req.msg.ToString());
comment.Content = StringHelper.UrlDecode(comment.Content);
string str = comment.Validate();
if (!str.Equals("ok"))
{
return ApiResult.Failed(str);
}
comment.Content = StringHelper.ToUnicodeString(comment.Content);
comment.Status = 0;
comment.CreateTime = DateTime.Now;
comment.UserId = userInfo.UserId;
comment.TenantId = userInfo.TenantId;
comment.MallBaseId = userInfo.MallBaseId;
if (dynamicModule.DynamicCommemt(comment))
{
return ApiResult.Success("评论成功");
}
else
{
return ApiResult.Failed("评论失败");
}
}
/// <summary>
/// 动态评论删除
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicDeleteComment()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parm = JObject.Parse(req.msg.ToString());
int commentId = parm.GetInt("commentId");
if (commentId == 0)
{
return ApiResult.Failed("评论id不为空");
}
if (dynamicModule.DynamicDeleteComment(new Rb_Education_DynamicComment_Extend { UserId = userInfo.UserId, Id = commentId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId }))
{
return ApiResult.Success("删除成功");
}
else
{
return ApiResult.Failed("删除失败");
}
}
/// <summary>
/// 获取未读消息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicMessageCount()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
int messageCount = 0;
if (userInfo != null && userInfo.UserId > 0)
{
messageCount = dynamicModule.GetDynamicMessageCount(new Rb_Education_DynamicMessage { UserId = userInfo.UserId, TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
}
return ApiResult.Success("", messageCount);
}
#endregion
} }
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -27,7 +27,7 @@ namespace Mall.WebApi.Controllers.Education
private readonly EducationModule educationModule = new EducationModule(); private readonly EducationModule educationModule = new EducationModule();
private readonly ProductModule productModule = new ProductModule(); private readonly ProductModule productModule = new ProductModule();
private Module.User.UserModule UserModule = new Module.User.UserModule(); private Module.User.UserModule UserModule = new Module.User.UserModule();
private readonly DynamicModule dynamicModule = new DynamicModule();
#region 课程 #region 课程
/// <summary> /// <summary>
...@@ -406,7 +406,7 @@ namespace Mall.WebApi.Controllers.Education ...@@ -406,7 +406,7 @@ namespace Mall.WebApi.Controllers.Education
query.TenantId = parms.TenantId; query.TenantId = parms.TenantId;
query.MallBaseId = parms.MallBaseId; query.MallBaseId = parms.MallBaseId;
query.TeacherStatus = 1; query.TeacherStatus = 1;
var oldLogisticsModel = educationModule.GetTeacherModel(query); var oldLogisticsModel = educationModule.GetTeacherModel(new RB_Education_Teacher_Extend { ID = query.ID, TenantId = parms.TenantId, MallBaseId = parms.MallBaseId, TeacherStatus = 1 });
if (oldLogisticsModel == null) if (oldLogisticsModel == null)
{ {
oldLogisticsModel = new RB_Education_Teacher_Extend(); oldLogisticsModel = new RB_Education_Teacher_Extend();
...@@ -421,12 +421,42 @@ namespace Mall.WebApi.Controllers.Education ...@@ -421,12 +421,42 @@ namespace Mall.WebApi.Controllers.Education
oldLogisticsModel.FollowteacherNum = oldList.Count(); oldLogisticsModel.FollowteacherNum = oldList.Count();
int Followteacher = 0; int Followteacher = 0;
int DynamicStatus = 0;//登录查看更多
if (query.UserId > 0) if (query.UserId > 0)
{ {
Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).FirstOrDefault()?.ID ?? 0 : 0; Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).FirstOrDefault()?.ID ?? 0 : 0;
} }
List<Rb_Education_Dynamic_Extend> myArticleList = new List<Rb_Education_Dynamic_Extend>();
if (Followteacher > 0)//关注了
{
DynamicStatus = 1;//关注了
myArticleList = dynamicModule.MyDynamicList(1, 3, out long dynammicCount, new Rb_Education_Dynamic_Extend { UserId = query.UserId, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId, UserTeacher = query.ID });
}
else if (query.UserId > 0)
{
//没有关注的情况下
var openList = dynamicModule.MyDynamicList(1, 3, out long dynammicCount, new Rb_Education_Dynamic_Extend { IsOpen = 1, UserId = query.UserId, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId, UserTeacher = query.ID });
var followList = dynamicModule.MyDynamicList(1, 3, out long dynammicOpenCount, new Rb_Education_Dynamic_Extend { IsOpen = 2, UserId = query.UserId, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId, UserTeacher = query.ID });
if ((openList == null || !openList.Any()) && (followList == null || !followList.Any()))
{
DynamicStatus = 2;//暂无动态
}
else if ((openList != null && openList.Any()) && (followList == null || !followList.Any()))
{
myArticleList = openList;
DynamicStatus = 3;//查看更多
}
else
{
myArticleList = openList;
DynamicStatus = 4;//关注查看更多
}
}
List<object> list = new List<object>();
foreach (var item in myArticleList)
{
list.Add(DecoratorDynameicResult(item));
}
//获取老师对应的课程 //获取老师对应的课程
var goodsList = educationModule.GetListByTeacherId(1, 4, out long count, new RB_Goods_Extend { TeacherId = oldLogisticsModel.ID, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId }); 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 var goodsResult = goodsList.Select(x => new
...@@ -436,6 +466,8 @@ namespace Mall.WebApi.Controllers.Education ...@@ -436,6 +466,8 @@ namespace Mall.WebApi.Controllers.Education
x.CourseNum, x.CourseNum,
x.Id x.Id
}); });
var teacherResult = new var teacherResult = new
{ {
oldLogisticsModel?.WorkYears, oldLogisticsModel?.WorkYears,
...@@ -445,7 +477,9 @@ namespace Mall.WebApi.Controllers.Education ...@@ -445,7 +477,9 @@ namespace Mall.WebApi.Controllers.Education
oldLogisticsModel?.TeacherLogo, oldLogisticsModel?.TeacherLogo,
oldLogisticsModel?.Introduction, oldLogisticsModel?.Introduction,
oldLogisticsModel.FollowteacherNum, oldLogisticsModel.FollowteacherNum,
Followteacher//是否关注该老师,0-没有,1-已关注 Followteacher,//是否关注该老师,0-没有,1-已关注
DynamicStatus,
DynamicList = list
}; };
return ApiResult.Success("", new { teacherResult, goodsResult }); return ApiResult.Success("", new { teacherResult, goodsResult });
} }
...@@ -511,6 +545,51 @@ namespace Mall.WebApi.Controllers.Education ...@@ -511,6 +545,51 @@ namespace Mall.WebApi.Controllers.Education
} }
#endregion #endregion
#region 老师动态
/// <summary>
/// 老师动态列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetDynamicList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
Rb_Education_Dynamic_Extend demodel = JsonConvert.DeserializeObject<Rb_Education_Dynamic_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
List<Rb_Education_Dynamic_Extend> myArticleList = dynamicModule.DynamicList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
List<object> list = new List<object>();
foreach (var item in myArticleList)
{
list.Add(DecoratorDynameicResult(item));
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list;
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 返回动态详情
/// </summary>
/// <param name="article">动态内容</param>
/// <returns></returns>
[HttpPost]
public object DecoratorDynameicResult(Rb_Education_Dynamic_Extend article)
{
List<string> fileList = new List<string>();
if (!string.IsNullOrEmpty(article.Files))
{
fileList = JsonConvert.DeserializeObject<List<string>>(article.Files);
}
//StringHelper.UrlEncode(StringHelper.FromUnicodeString(article.Content))
var resultData = new { id = article.Id, createEmpId = article.CreateBy, createEmName = article.CreateByName, crearteEmPhoto = article.CrearteByPhoto, YearTime = article.CreateTime.HasValue ? (article.CreateTime.Value.Year == System.DateTime.Now.Year ? "" : article.CreateTime.Value.ToString("yyyy")) : "", MonthTime = article.CreateTime.HasValue ? article.CreateTime.Value.ToString("MM") : "", DayTime = article.CreateTime.HasValue ? article.CreateTime.Value.ToString("dd") : "", createTime = article.CreateTime.HasValue ? StringHelper.DateFormatToString(article.CreateTime.Value) : "", content = StringHelper.FromUnicodeString(article.Content), coverPhoto = article.CoverPhoto, fileType = article.FileType, latAndLong = article.LatAndLong, address = article.Address, files = fileList, hasLike = article.HasLike, likeList = article.LikeList.Select(t => new { empId = t.UserId, empName = t.EmName, t.Id }), commentList = article.CommentList.Select(t => new { commentId = t.Id, empId = t.UserId, empName = t.UserName, byReplayEmpId = t.ByReplyEmpId, byReplayEmpName = t.ByReplyEmName, content = StringHelper.FromUnicodeString(t.Content) }) };
return resultData;
}
#endregion
} }
} }
\ No newline at end of file
...@@ -171,7 +171,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -171,7 +171,7 @@ namespace Mall.WebApi.Controllers.User
if (couponResult != null && couponResult.ID > 0) if (couponResult != null && couponResult.ID > 0)
{ {
couponName = couponName + "," + couponResult.Name ; couponName = couponName + "," + couponResult.Name;
isGiveCoupon = true; isGiveCoupon = true;
} }
} }
...@@ -227,7 +227,8 @@ namespace Mall.WebApi.Controllers.User ...@@ -227,7 +227,8 @@ namespace Mall.WebApi.Controllers.User
SmallShopId = 0, SmallShopId = 0,
UserSmallShopId = demodel.SmallShopId, UserSmallShopId = demodel.SmallShopId,
IsOpenSchool = mmodel.IsOpenSchool, IsOpenSchool = mmodel.IsOpenSchool,
UserPageType = mmodel.IsOpenSchool == 1 ? demodel.UserPageType : Common.Enum.Goods.GoodsPageTypeEnum.All UserPageType = mmodel.IsOpenSchool == 1 ? demodel.UserPageType : Common.Enum.Goods.GoodsPageTypeEnum.All,
UserTeacher = 0
}; };
UserReidsCache.AppletUserInfoSet(UserModuleCacheKeyConfig.Applet_Login_Info + UserId, appletUserInfo, Config.JwtExpirTime); UserReidsCache.AppletUserInfoSet(UserModuleCacheKeyConfig.Applet_Login_Info + UserId, appletUserInfo, Config.JwtExpirTime);
if (isGiveCoupon) if (isGiveCoupon)
...@@ -292,7 +293,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -292,7 +293,7 @@ namespace Mall.WebApi.Controllers.User
var mmodel = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend() { MallBaseId = umodel.MallBaseId }); var mmodel = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend() { MallBaseId = umodel.MallBaseId });
//2020-08-12 Add By:W //2020-08-12 Add By:W
var smallShopsInfoModle = userModule.GetSmallShopsInfoList(new RB_SmallShops_Info_Extend { TenantId = umodel.TenantId, MallBaseId = umodel.MallBaseId, UserId = umodel.Id }).OrderByDescending(x => x.CreateDate).FirstOrDefault(); var smallShopsInfoModle = userModule.GetSmallShopsInfoList(new RB_SmallShops_Info_Extend { TenantId = umodel.TenantId, MallBaseId = umodel.MallBaseId, UserId = umodel.Id }).OrderByDescending(x => x.CreateDate).FirstOrDefault();
var teacher = userModule.GetTeacherModel(new Model.Extend.Education.RB_Education_Teacher_Extend { TeacherStatus = 1, TenantId = umodel.TenantId, MallBaseId = umodel.MallBaseId, UserId = umodel.Id });
AppletUserInfo appletUserInfo = new AppletUserInfo() AppletUserInfo appletUserInfo = new AppletUserInfo()
{ {
MallBaseId = umodel.MallBaseId, MallBaseId = umodel.MallBaseId,
...@@ -310,7 +311,8 @@ namespace Mall.WebApi.Controllers.User ...@@ -310,7 +311,8 @@ namespace Mall.WebApi.Controllers.User
SmallShopId = (smallShopsInfoModle != null && smallShopsInfoModle.AuditStatus == DistributorAuditStatusEnum.Audited) ? smallShopsInfoModle.Id : 0, SmallShopId = (smallShopsInfoModle != null && smallShopsInfoModle.AuditStatus == DistributorAuditStatusEnum.Audited) ? smallShopsInfoModle.Id : 0,
UserSmallShopId = umodel.SmallShopId, UserSmallShopId = umodel.SmallShopId,
IsOpenSchool = mmodel.IsOpenSchool, IsOpenSchool = mmodel.IsOpenSchool,
UserPageType = mmodel.IsOpenSchool == 1 ? umodel.UserPageType : Common.Enum.Goods.GoodsPageTypeEnum.All UserPageType = mmodel.IsOpenSchool == 1 ? umodel.UserPageType : Common.Enum.Goods.GoodsPageTypeEnum.All,
UserTeacher = (teacher != null && teacher.ID > 0) ? teacher.ID : 0
}; };
UserReidsCache.AppletUserInfoSet(UserModuleCacheKeyConfig.Applet_Login_Info + umodel.Id, appletUserInfo, Config.JwtExpirTime); UserReidsCache.AppletUserInfoSet(UserModuleCacheKeyConfig.Applet_Login_Info + umodel.Id, appletUserInfo, Config.JwtExpirTime);
if (isGiveCoupon) if (isGiveCoupon)
...@@ -319,7 +321,8 @@ namespace Mall.WebApi.Controllers.User ...@@ -319,7 +321,8 @@ namespace Mall.WebApi.Controllers.User
} }
else { else
{
return ApiResult.CouponSuccess(ResultCode.Fail, 1, "", "", appletUserInfo); return ApiResult.CouponSuccess(ResultCode.Fail, 1, "", "", appletUserInfo);
} }
......
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