Commit 09c67689 authored by liudong1993's avatar liudong1993

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

parents d468afd0 9d381fe1
using Mall.Common.Enum.GuideCar;
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_FollowTeacher
{
public int ID { 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; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
/// <summary>
/// 老师编号
/// </summary>
public int TeacherId { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using VT.FW.DB;
namespace Mall.Model.Extend.Education
{
/// <summary>
/// 网课-教师扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_FollowTeacher_Extend : Entity.Education.RB_Education_FollowTeacher
{
/// <summary>
/// 标签
/// </summary>
public List<string> LableNameList { get; set; }
/// <summary>
/// 头像
/// </summary>
public string TeacherLogo { get; set; }
public string LableName { get; set; }
public string Name { get; set; }
/// <summary>
/// 专业
/// </summary>
public string Major { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// 简介
/// </summary>
public string Introduction { get; set; }
/// <summary>
/// 用户评分
/// </summary>
public decimal Score { get; set; }
/// <summary>
/// 从业年限
/// </summary>
public decimal WorkYears { get; set; }
}
}
......@@ -10,7 +10,7 @@ namespace Mall.Model.Extend.Education
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Education_Teacher_Extend: Entity.Education.RB_Education_Teacher
public class RB_Education_Teacher_Extend : Entity.Education.RB_Education_Teacher
{
/// <summary>
......@@ -28,11 +28,24 @@ namespace Mall.Model.Extend.Education
/// </summary>
public int OrderGuestNum { get; set; }
/// <summary>
/// 关注人数
/// </summary>
public int FollowteacherNum { get; set; }
/// <summary>
/// 商品数
/// </summary>
public int GoodsNum { get; set; }
/// <summary>
/// 当前登录人id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 关联商品
/// </summary>
......
......@@ -2239,7 +2239,7 @@ namespace Mall.Model.Extend.MarketingCenter
/// <summary>
/// 显示进度
/// </summary>
public bool showProgress { get; set; }
public decimal showProgress { get; set; }
......
......@@ -29,6 +29,12 @@ namespace Mall.Module.Education
/// 教师仓储
/// </summary>
private readonly RB_Education_TeacherRepository educationTeacherRepository = new RB_Education_TeacherRepository();
/// <summary>
/// 我关注的教师仓储
/// </summary>
private readonly RB_Education_FollowTeacherRepository followTeacherRepository = new RB_Education_FollowTeacherRepository();
/// <summary>
/// 小程序
/// </summary>
......@@ -2735,7 +2741,7 @@ namespace Mall.Module.Education
}
}
model.DetailList = dlist;
//是否可以申请售后
model.IsCanApplyForAfterSale = 2;
......@@ -2797,5 +2803,116 @@ namespace Mall.Module.Education
}
#endregion
#region 我关注的老师
/// <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> GetFollowTeacherPageList(int pageIndex, int pageSize, out long rowCount, RB_Education_FollowTeacher_Extend query)
{
List<RB_Education_FollowTeacher_Extend> list = followTeacherRepository.GetFollowPageList(pageIndex, pageSize, out rowCount, query);
return list;
}
/// <summary>
/// 我关注的教师
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Education_FollowTeacher_Extend GetFollowTeacherModel(RB_Education_FollowTeacher_Extend query)
{
RB_Education_FollowTeacher_Extend model = followTeacherRepository.GetFollowTeacherList(query).FirstOrDefault();
return model;
}
/// <summary>
/// 我关注的教师
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Education_FollowTeacher_Extend> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
{
return followTeacherRepository.GetFollowTeacherList(query);
}
/// <summary>
/// 新增/修改我关注的教师配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateFollowTeacher(RB_Education_FollowTeacher model)
{
bool flag = false;
try
{
if (model.ID == 0)
{
flag = followTeacherRepository.Insert(model) > 0;
}
else
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Education_FollowTeacher.UpdateDate),System.DateTime.Now},
{ nameof(RB_Education_FollowTeacher.Status),1}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Education_FollowTeacher.ID),
FiledValue=model.ID,
OperatorEnum=OperatorEnum.Equal
}
};
flag = followTeacherRepository.Update(keyValues, wheres);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateFollowTeacher");
return false;
}
return flag;
}
#endregion
#region 我的收藏
/// <summary>
/// 获取用户收藏商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetCollectEducationGoodsPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetCollectEducationGoodsPageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
foreach (var item in list)
{
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(item.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
}
}
return list;
}
#endregion
}
}
......@@ -448,7 +448,7 @@ namespace Mall.Module.MarketingCenter
{
educationModel.Cover = driveData?.Cover ?? "";
educationModel.Name = driveData?.Name ?? "";
educationModel.showProgress = driveData?.showProgress ?? false;
educationModel.showProgress = driveData?.showProgress ?? 0;
educationModel.BtnPosition = driveData?.BtnPosition ?? "left";
educationModel.PaddingTop = driveData?.PaddingTop ?? "0";
educationModel.PaddingBottom = driveData?.PaddingBottom ?? "0";
......
using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Education
{
public class RB_Education_FollowTeacherRepository : BaseRepository<RB_Education_FollowTeacher>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Education_FollowTeacher); } }
/// <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> GetFollowPageList(int pageIndex, int pageSize, out long rowCount, RB_Education_FollowTeacher_Extend query)
{
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");
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.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 GetPage<RB_Education_FollowTeacher_Extend>(pageIndex, pageSize, out rowCount, 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> GetFollowTeacherList(RB_Education_FollowTeacher_Extend query)
{
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");
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.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();
}
}
}
......@@ -1219,6 +1219,70 @@ LEFT JOIN rb_goods_wk_teacher as b on g.Id=b.GoodsId
LEFT JOIN (SELECT GoodsId,COUNT(*) as CourseNum from rb_goods_wk_course where `Status`=0 GROUP BY GoodsId) as c on c.GoodsId=g.Id where {where} order by {orderBy}";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取会员收藏商品分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetCollectEducationGoodsPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{
string where = $" 1=1 and col.{nameof(RB_Goods_Extend.Status)}=0 and g.GoodsClassify=2";
where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.{nameof(RB_Goods_Extend.Status)}=0 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1";
if (dmodel.TenantId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from
rb_member_collection col
inner join RB_Goods g on col.GoodsId=g.Id
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by col.Id desc";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
#endregion
}
......
......@@ -19,6 +19,7 @@ using Mall.CacheManager.User;
using Microsoft.AspNetCore.Authorization;
using Mall.Module.Education;
using Mall.Model.Extend.Education;
using Mall.Model.Entity.Education;
namespace Mall.WebApi.Controllers.Education
{
......@@ -270,7 +271,7 @@ namespace Mall.WebApi.Controllers.Education
var userInfo = AppletUserInfo;
JObject prams = JObject.Parse(req.msg.ToString());
var query = JsonConvert.DeserializeObject<RB_Education_Coupon_Extend>(RequestParm.msg.ToString());
query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId;
query.UserId = userInfo.UserId;
......@@ -342,7 +343,7 @@ namespace Mall.WebApi.Controllers.Education
deleted_at = "0000-00-00 00:00:00",
receive_type = "",
discount_limit = x.MaxDiscountsPrice,
usehexiao= x.HeXiao- x.UseHeXiao,
usehexiao = x.HeXiao - x.UseHeXiao,
couponIco = x.CouponIco,
coupon_data = new
{
......@@ -669,6 +670,157 @@ namespace Mall.WebApi.Controllers.Education
#endregion
#region 我关注的老师
/// <summary>
/// 我关注的老师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFollowTeacherPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Education_FollowTeacher_Extend demodel = JsonConvert.DeserializeObject<RB_Education_FollowTeacher_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = educationModule.GetFollowTeacherPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
foreach (var item in list)
{
if (!string.IsNullOrWhiteSpace(item.LableName))
{
item.LableNameList = JsonConvert.DeserializeObject<List<string>>(item.LableName);
}
}
pagelist.pageData = list.Select(x => new
{
x.ID,
x.TeacherLogo,
x.Telephone,
x.Major,
x.LableNameList,
x.Name,
CreateDate = x.CreateDate.ToString("yyyy-MM-dd HH:ss:mm"),
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 关注老师
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult FollowTeacher()
{
var parms = RequestParm;
var userInfo = AppletUserInfo;
var query = JsonConvert.DeserializeObject<RB_Education_FollowTeacher>(RequestParm.msg.ToString());
query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId;
query.UserId = userInfo.UserId;
bool isUpdate = true;
if (query == null)
{
return ApiResult.Failed("请传入我关注的老师信息");
}
else
{
if (query.ID == 0)
{
isUpdate = false;
query.CreateDate = System.DateTime.Now;
query.UpdateDate = System.DateTime.Now;
if (query.TeacherId <= 0)
{
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())
{
return ApiResult.Failed("您已关注,请勿重复操作");
}
}
bool result = educationModule.AddOrUpdateFollowTeacher(query);
if (isUpdate)
{
if (result)
{
return ApiResult.Success("取消关注成功");
}
else
{
return ApiResult.Failed("取消关注成功");
}
}
else
{
if (result)
{
return ApiResult.Success("关注成功");
}
else
{
return ApiResult.Failed("关注成功");
}
}
}
}
#endregion
#region 我的收藏
/// <summary>
/// 获取收藏商品分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetUserCollectionPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = educationModule.GetCollectEducationGoodsPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
foreach (var item in list)
{
if (!string.IsNullOrWhiteSpace(item.CourseLable))
{
item.CourseLableList = JsonConvert.DeserializeObject<List<string>>(item.CourseLable);
}
}
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.CoverImage,
x.SellingPrice,
x.SalesNum,
x.CourseLableList
});
return ApiResult.Success("", pagelist);
}
#endregion
}
}
\ No newline at end of file
......@@ -160,7 +160,8 @@ namespace Mall.WebApi.Controllers.Education
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletCourseCollect(object requestMsg) {
public ApiResult GetAppletCourseCollect(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -184,7 +185,8 @@ namespace Mall.WebApi.Controllers.Education
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsCourseList(object requestMsg) {
public ApiResult GetAppletGoodsCourseList(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (req.MallBaseId <= 0)
{
......@@ -197,7 +199,7 @@ namespace Mall.WebApi.Controllers.Education
{
return ApiResult.ParamIsNull();
}
var list = productModule.GetAppletGoodsCourseList(pagelist.pageIndex,pagelist.pageSize,out long count, GoodsId, req.TenantId, req.MallBaseId);
var list = productModule.GetAppletGoodsCourseList(pagelist.pageIndex, pagelist.pageSize, out long count, GoodsId, req.TenantId, req.MallBaseId);
bool IsPay = productModule.GetAppletCourseIsPay(GoodsId, req.UserId);
pagelist.count = Convert.ToInt32(count);
......@@ -230,16 +232,21 @@ namespace Mall.WebApi.Controllers.Education
/// <param name="Number"></param>
/// <param name="Image"></param>
/// <returns></returns>
public List<CourseImageModel> GetCourseImage(int IsTrySee, bool IsPay,int Number, string Image) {
if (string.IsNullOrEmpty(Image) || Image == "[]") {
public List<CourseImageModel> GetCourseImage(int IsTrySee, bool IsPay, int Number, string Image)
{
if (string.IsNullOrEmpty(Image) || Image == "[]")
{
return new List<CourseImageModel>();
}
if (IsPay) {
if (IsPay)
{
return JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
}
if (IsTrySee == 1) {
if (IsTrySee == 1)
{
var list = JsonConvert.DeserializeObject<List<CourseImageModel>>(Image);
if (Number > 0) {
if (Number > 0)
{
list = list.Take(Number).ToList();
}
return list;
......@@ -405,22 +412,37 @@ namespace Mall.WebApi.Controllers.Education
{
oldLogisticsModel.LableNameList = JsonConvert.DeserializeObject<List<string>>(oldLogisticsModel.LableName);
}
//获取老师的关注数
//判断是否已经关注过
var oldList = educationModule.GetFollowTeacherList(new RB_Education_FollowTeacher_Extend { TeacherId = query.ID, MallBaseId = query.MallBaseId, TenantId = query.TenantId });
oldLogisticsModel.FollowteacherNum = oldList.Count();
int Followteacher = 0;
if (query.UserId > 0)
{
Followteacher = (oldList != null && oldList.Any()) ? oldList.Where(x => x.UserId == query.UserId).FirstOrDefault()?.ID ?? 0 : 0;
}
//获取老师对应的课程
var goodsList = educationModule.GetListByTeacherId(1, 4, out long count, new RB_Goods_Extend { TeacherId = oldLogisticsModel.ID, TenantId = oldLogisticsModel.TenantId, MallBaseId = oldLogisticsModel.MallBaseId });
var goodsResult = goodsList.Select(x => new
{
x.CoverImage,
x.Name,
x.CourseNum
x.CourseNum,
x.Id
});
var teacherResult = new {
var teacherResult = new
{
oldLogisticsModel?.WorkYears,
oldLogisticsModel?.Major,
oldLogisticsModel?.LableNameList,
oldLogisticsModel?.Name,
oldLogisticsModel?.TeacherLogo,
oldLogisticsModel?.Introduction
oldLogisticsModel?.Introduction,
oldLogisticsModel.FollowteacherNum,
Followteacher//是否关注该老师,0-没有,1-已关注
};
return ApiResult.Success("", new { teacherResult, goodsResult });
}
......
......@@ -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