Commit 775e2488 authored by liudong1993's avatar liudong1993

1

parent 9a65b332
......@@ -2597,5 +2597,48 @@ namespace Mall.Module.Education
}
#endregion
#region 活动日历表
/// <summary>
/// 获取活动日历
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public object GetEduActivityCalendar(RB_Education_Activity_Extend query)
{
var list = education_ActivityRepository.GetList(query);
list = list.Where(x => !string.IsNullOrEmpty(x.CoverImg)).ToList();//排除没有封面图的
//根据查询日期 开始遍历
DateTime STime = Convert.ToDateTime(query.SelectStartTimeStr);
DateTime ETime = Convert.ToDateTime(query.SelectEndTimeStr);
List<object> RList = new List<object>();
while (true) {
var alist = list.Where(x => Convert.ToDateTime(x.StartTime.ToString("yyyy-MM-dd")) <= STime && Convert.ToDateTime(x.EndTime.ToString("yyyy-MM-dd")) >= STime).ToList();
RList.Add(new
{
Date = STime.ToString("yyyy-MM-dd"),
ActivityList = alist.Select(x => new
{
x.Id,
x.ActivityName,
StartTime = x.StartTime.ToString("MM-dd HH:mm"),
EndTime = x.EndTime.ToString("MM-dd HH:mm"),
x.CoverImg,
x.IsFree,
x.Price,
x.LocationName,
x.ActivityStatus
})
});
if (STime == ETime) {
break;
}
STime = STime.AddDays(1);
}
return RList;
}
#endregion
}
}
......@@ -279,6 +279,14 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0} in({1}) ", nameof(RB_Education_Activity_Extend.Id), query.ActivityIds);
}
if (!string.IsNullOrWhiteSpace(query.SelectStartTimeStr))
{
builder.AppendFormat($" and DATE_FORMAT(a.{ nameof(RB_Education_Activity_Extend.StartTime)},'%Y-%m-%d' )>=DATE_FORMAT('{query.SelectStartTimeStr}','%Y-%m-%d' ) ");
}
if (!string.IsNullOrWhiteSpace(query.SelectEndTimeStr))
{
builder.AppendFormat($" and DATE_FORMAT(a.{nameof(RB_Education_Activity_Extend.StartTime)},'%Y-%m-%d' )<= DATE_FORMAT('{query.SelectEndTimeStr}','%Y-%m-%d' ) ");
}
}
return Get<RB_Education_Activity_Extend>(builder.ToString()).ToList();
}
......
......@@ -3297,6 +3297,48 @@ namespace Mall.WebApi.Controllers.Education
#endregion
#region 活动日历表
/// <summary>
/// 获取教育首页活动日历表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetEduActivityCalendar()
{
JObject jObj = JObject.Parse(RequestParm.msg.ToString());
var query = new RB_Education_Activity_Extend()
{
ActivityName = jObj.GetStringValue("ActivityName"),
SelectStartTimeStr = jObj.GetStringValue("SelectStartTimeStr"),
SelectEndTimeStr = jObj.GetStringValue("SelectEndTimeStr"),
};
if (string.IsNullOrEmpty(query.SelectStartTimeStr) || string.IsNullOrEmpty(query.SelectEndTimeStr)) {
return ApiResult.ParamIsNull();
}
try
{
query.SelectStartTimeStr = Convert.ToDateTime(query.SelectStartTimeStr).ToString("yyyy-MM-dd");
query.SelectEndTimeStr = Convert.ToDateTime(query.SelectEndTimeStr).ToString("yyyy-MM-dd");
}
catch (Exception)
{
return ApiResult.ParamIsNull();
}
if (Convert.ToDateTime(query.SelectStartTimeStr) > Convert.ToDateTime(query.SelectEndTimeStr))
{
return ApiResult.Failed("结束日期不能大于开始日期");
}
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
var robj = activityModule.GetEduActivityCalendar(query);
return ApiResult.Success("", robj);
}
#endregion
#region 会员列表
/// <summary>
......
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