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
/// </summary>
public int UserId { get; set; }
/// 用户店铺id
/// </summary>
public int SmallShopId { get; set; }
/// 用户对应的老师id
/// </summary>
public int UserTeacher { get; set; }
/// <summary>
......
......@@ -51,6 +51,61 @@ namespace Mall.Common.Plugin
#endregion
#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>
......
......@@ -87,5 +87,11 @@ namespace Mall.Model.Entity.Education
/// 国家图片
/// </summary>
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;
}
}
}
......@@ -11,7 +11,7 @@ namespace Mall.Model.Entity.User
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_MiniProgram
public class RB_MiniProgram
{
/// <summary>
/// 小程序主键Id
......@@ -438,10 +438,17 @@ namespace Mall.Model.Entity.User
/// 菜单栏json格式 多组模式
/// </summary>
public string MenuNavJson { get; set; }
/// <summary>
/// 老师发动态后给关注的人发消息
/// </summary>
public string EducationDynamicTpl { get; set; }
}
public class MenuNavMoreModel {
public class MenuNavMoreModel
{
/// <summary>
/// 排序
/// </summary>
......
......@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education
/// 从业年限
/// </summary>
public decimal WorkYears { get; set; }
/// <summary>
/// openId
/// </summary>
public string OpenId { get; set; }
}
}
......@@ -54,5 +54,11 @@ namespace Mall.Model.Extend.Education
/// 关联商品
/// </summary>
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
}
}
This diff is collapsed.
......@@ -1769,6 +1769,7 @@ namespace Mall.Module.Education
{ nameof(RB_Education_Teacher_Extend.WorkYears),model.WorkYears},
{ nameof(RB_Education_Teacher_Extend.Nationality),model.Nationality},
{ nameof(RB_Education_Teacher_Extend.ForeignersUrl),model.ForeignersUrl},
{ nameof(RB_Education_Teacher_Extend.UserId),model.UserId},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
......@@ -3141,15 +3142,28 @@ namespace Mall.Module.Education
return model;
}
/// <summary>
/// 我关注的教师
/// 网课-我关注的老师列表
/// </summary>
/// <param name="query"></param>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
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>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
{
return followTeacherRepository.GetFollowTeacherList(query);
}
......@@ -3172,7 +3186,7 @@ namespace Mall.Module.Education
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ 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>() {
new WhereHelper(){
......
......@@ -179,7 +179,7 @@ namespace Mall.Module.User
JObject jo = (JObject)JsonConvert.DeserializeObject(wenXinResult);
int errcode = Convert.ToInt32(jo["errcode"].ToString());
if (errcode == 0)
{
{
//成功
return true;
}
......@@ -382,7 +382,7 @@ namespace Mall.Module.User
},
amount2 = new
{
value = OrderMoney+ "元"
value = OrderMoney + "元"
},
thing1 = new
{
......@@ -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
......
......@@ -192,6 +192,12 @@ namespace Mall.Module.User
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 基础配置
/// <summary>
......@@ -6750,5 +6756,19 @@ namespace Mall.Module.User
{
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)}=
{
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
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.TenantId > 0)
......
......@@ -71,32 +71,36 @@ namespace Mall.Repository.Education
public List<RB_Education_Teacher_Extend> GetTeacherList(RB_Education_Teacher_Extend query)
{
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.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)
{
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)
{
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))
{
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))
{
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)
{
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();
......
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));
}
}
}
This diff is collapsed.
......@@ -419,6 +419,15 @@ namespace Mall.WebApi.Controllers.AppletWeChat
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()
{
......
......@@ -27,7 +27,7 @@ namespace Mall.WebApi.Controllers.Education
private readonly EducationModule educationModule = new EducationModule();
private readonly ProductModule productModule = new ProductModule();
private Module.User.UserModule UserModule = new Module.User.UserModule();
private readonly DynamicModule dynamicModule = new DynamicModule();
#region 课程
/// <summary>
......@@ -406,7 +406,7 @@ namespace Mall.WebApi.Controllers.Education
query.TenantId = parms.TenantId;
query.MallBaseId = parms.MallBaseId;
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)
{
oldLogisticsModel = new RB_Education_Teacher_Extend();
......@@ -421,12 +421,42 @@ namespace Mall.WebApi.Controllers.Education
oldLogisticsModel.FollowteacherNum = oldList.Count();
int Followteacher = 0;
int DynamicStatus = 0;//登录查看更多
if (query.UserId > 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 goodsResult = goodsList.Select(x => new
......@@ -436,6 +466,8 @@ namespace Mall.WebApi.Controllers.Education
x.CourseNum,
x.Id
});
var teacherResult = new
{
oldLogisticsModel?.WorkYears,
......@@ -445,7 +477,9 @@ namespace Mall.WebApi.Controllers.Education
oldLogisticsModel?.TeacherLogo,
oldLogisticsModel?.Introduction,
oldLogisticsModel.FollowteacherNum,
Followteacher//是否关注该老师,0-没有,1-已关注
Followteacher,//是否关注该老师,0-没有,1-已关注
DynamicStatus,
DynamicList = list
};
return ApiResult.Success("", new { teacherResult, goodsResult });
}
......@@ -511,6 +545,51 @@ namespace Mall.WebApi.Controllers.Education
}
#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
if (couponResult != null && couponResult.ID > 0)
{
couponName = couponName + "," + couponResult.Name ;
couponName = couponName + "," + couponResult.Name;
isGiveCoupon = true;
}
}
......@@ -227,7 +227,8 @@ namespace Mall.WebApi.Controllers.User
SmallShopId = 0,
UserSmallShopId = demodel.SmallShopId,
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);
if (isGiveCoupon)
......@@ -292,7 +293,7 @@ namespace Mall.WebApi.Controllers.User
var mmodel = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend() { MallBaseId = umodel.MallBaseId });
//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 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()
{
MallBaseId = umodel.MallBaseId,
......@@ -310,7 +311,8 @@ namespace Mall.WebApi.Controllers.User
SmallShopId = (smallShopsInfoModle != null && smallShopsInfoModle.AuditStatus == DistributorAuditStatusEnum.Audited) ? smallShopsInfoModle.Id : 0,
UserSmallShopId = umodel.SmallShopId,
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);
if (isGiveCoupon)
......@@ -319,11 +321,12 @@ namespace Mall.WebApi.Controllers.User
}
else {
else
{
return ApiResult.CouponSuccess(ResultCode.Fail, 1, "", "", appletUserInfo);
}
// return ApiResult.CouponSuccess(ResultCode.Fail, 1, "", "", appletUserInfo);
// return ApiResult.CouponSuccess(ResultCode.Fail, 1, "", "", appletUserInfo);
//return ApiResult.Success("", 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