Commit 9d381fe1 authored by 吴春's avatar 吴春

提交代码

parent e96b7af5
......@@ -649,6 +649,8 @@ namespace Mall.WebApi.Controllers.Education
query.MallBaseId = userInfo.MallBaseId;
query.UserId = userInfo.UserId;
bool isUpdate = true;
if (query == null)
{
return ApiResult.Failed("请传入我关注的老师信息");
......@@ -657,6 +659,7 @@ namespace Mall.WebApi.Controllers.Education
{
if (query.ID == 0)
{
isUpdate = false;
query.CreateDate = System.DateTime.Now;
query.UpdateDate = System.DateTime.Now;
if (query.TeacherId <= 0)
......@@ -673,7 +676,7 @@ namespace Mall.WebApi.Controllers.Education
bool result = educationModule.AddOrUpdateFollowTeacher(query);
if (query.ID > 0)
if (isUpdate)
{
if (result)
{
......
......@@ -160,7 +160,8 @@ namespace Mall.WebApi.Controllers.Education
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletCourseCollect(object requestMsg) {
public ApiResult GetAppletCourseCollect(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -419,7 +420,8 @@ namespace Mall.WebApi.Controllers.Education
int Followteacher = 0;
if (query.UserId > 0)
{
Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).Count() : 0;
Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).FirstOrDefault()?.ID ?? 0 : 0;
}
//获取老师对应的课程
......
......@@ -14,7 +14,7 @@ namespace Mall.WindowsService.Helper
private static int inTimer2 = 0;
private static int inTimer3 = 0;
private static int inTimer4 = 0;
private static int inTimer5 = 0;
/// <summary>
/// 收入单子服务开始执行方法
/// </summary>
......@@ -116,8 +116,8 @@ namespace Mall.WindowsService.Helper
{
try
{
string str= Common.Config.GetConnectionString("DefaultConnection");
LogHelper.Write("GoodsShelves=====Start"+ str);
string str = Common.Config.GetConnectionString("DefaultConnection");
LogHelper.Write("GoodsShelves=====Start" + str);
Module.GoodsShelvesModule.ShelvesGoodsModule();
Module.GoodsShelvesModule.DownGoodsModule();
LogHelper.Write("GoodsShelves=====End");
......@@ -129,5 +129,32 @@ namespace Mall.WindowsService.Helper
Interlocked.Exchange(ref inTimer4, 0);
}
}
/// <summary>
/// 资讯定时上架,下架
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void EducationArticleShelves(object sender, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.Exchange(ref inTimer5, 1) == 0)
{
try
{
string str = Common.Config.GetConnectionString("DefaultConnection");
LogHelper.Write("EducationArticleShelves=====Start" + str);
Module.EducationArticleShelvesModule.ShelvesEducationArticleModule();
Module.EducationArticleShelvesModule.DownEducationArticleModule();
LogHelper.Write("EducationArticleShelves=====End");
}
catch (Exception ex)
{
LogHelper.Write("EducationArticleShelves=====ex" + ex.Message);
}
Interlocked.Exchange(ref inTimer5, 0);
}
}
}
}
using Mall.Repository.Product;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Mall.Model.Entity.Product;
using VT.FW.DB;
using Mall.Repository.Education;
using Mall.Model.Entity.Education;
namespace Mall.WindowsService.Module
{
/// <summary>
/// 资讯自动上架下架
/// </summary>
public class EducationArticleShelvesModule
{
/// <summary>
/// 资讯评论信息
/// </summary>
private static readonly RB_Education_ArticleRepository educationArticleRepository = new RB_Education_ArticleRepository();
/// <summary>
/// 商品自动上架时间
/// </summary>
/// <returns></returns>
public static bool ShelvesEducationArticleModule()
{
bool flag = false;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT ID,ArticleStatus,ShelvesDate,DownDate
FROM rb_education_article
WHERE Status=0 AND '{0}'>=ShelvesDate AND '{0}'<=DownDate AND GoodsStatus<>1
", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var list = educationArticleRepository.Get<RB_Education_Article>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Education_Article.ArticleStatus),1 }
};
flag = educationArticleRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Article.ID), item.ID));
}
}
return flag;
}
/// <summary>
/// 商品自动下架
/// </summary>
/// <returns></returns>
public static bool DownEducationArticleModule()
{
bool flag = false;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT ID,ArticleStatus,ShelvesDate,DownDate
FROM rb_education_article
WHERE Status=0 AND DownDate<='{0}' AND GoodsStatus=1 ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var list = educationArticleRepository.Get<RB_Education_Article>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Education_Article.ArticleStatus),2 }
};
flag = educationArticleRepository.Update(fileds, new WhereHelper(nameof(RB_Education_Article.ID), item.ID));
}
}
return flag;
}
}
}
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