You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
5.4 KiB
141 lines
5.4 KiB
using System.Linq;
|
|
using Sog;
|
|
using LitJson;
|
|
using SimpleHttpServer;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Operation
|
|
{
|
|
[MenuMapping(refc = typeof(SendEmail))]
|
|
public static class SelectActivity
|
|
{
|
|
[RequestMapping("活动排期", PermissionCode.ACTIVITY_SEARCH, toLog: false, isMenu = true)]
|
|
public static int OnSelectActivityHttpReq(string httpApiCmd, JsonData jsonData, HttpResponse rsp,
|
|
HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
var now = OperationServerUtils.GetTimeSecond();
|
|
var dayStartTime = AppTime.GetTodayStartTime(now); //今天开始
|
|
var dayEndTime = dayStartTime + AppTime.SECONDS_ADAY; //今天结束
|
|
|
|
var beginTime = query.GetValue("beginTime", "");
|
|
var endTime = query.GetValue("endTime", "");
|
|
|
|
var reamIds = query.GetValue("realmId", "").Split(","); //查询某个服
|
|
|
|
|
|
var uid = query.GetValue("uid", "0").Toint32(); //查询某个人
|
|
if (string.IsNullOrEmpty(beginTime))
|
|
{
|
|
beginTime = AppTime.ConvertUnixTimeToString(dayStartTime, AppTime.TIME_FORMAT_STYLE_SHORT);
|
|
}
|
|
|
|
var startDate = AppTime.ConvertStringToDateTime(beginTime, AppTime.TIME_FORMAT_STYLE_SHORT); //查询开始时间
|
|
|
|
|
|
if (string.IsNullOrEmpty(endTime))
|
|
{
|
|
endTime = AppTime.ConvertUnixTimeToString(dayEndTime, AppTime.TIME_FORMAT_STYLE_SHORT);
|
|
}
|
|
|
|
var endDate = AppTime.ConvertStringToDateTime(endTime, AppTime.TIME_FORMAT_STYLE_SHORT); //查询结束时间
|
|
|
|
var result = new JsonData();
|
|
|
|
foreach (var kv in ActivityDescMgr.Instance.ItemTable)
|
|
{
|
|
var item = new JsonData();
|
|
var desc = kv.Value;
|
|
switch (desc.timeType)
|
|
{
|
|
case ActivityTimeType.UnlockTime:
|
|
{
|
|
break;
|
|
}
|
|
case ActivityTimeType.SeverTime:
|
|
{
|
|
if (reamIds.Length == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
var mk = OperationServerUtils.GetOperationServerData().m_allRealm;
|
|
foreach (var reamId in reamIds)
|
|
{
|
|
if (string.IsNullOrEmpty(reamId))
|
|
{
|
|
break;
|
|
}
|
|
|
|
var m = mk[int.Parse(reamId)];
|
|
if (m == null)
|
|
{
|
|
break;
|
|
}
|
|
|
|
var openSerTime = m.openTime;
|
|
|
|
var startDay = openSerTime + int.Parse(desc.fixedStartTimeStr) * AppTime.SECONDS_ADAY;
|
|
var endDay = openSerTime + int.Parse(desc.fixedOverTimeStr) * AppTime.SECONDS_ADAY;
|
|
|
|
var start = AppTime.ConvertUnixTimeToDateTime1(startDay); //活动开始
|
|
var end = AppTime.ConvertUnixTimeToDateTime1(endDay);
|
|
|
|
if (startDate < start && end < endDate) //在查询范围之内
|
|
{
|
|
item["id"] = desc.id;
|
|
item["start"] =
|
|
AppTime.ConvertUnixTimeToString(startDay, AppTime.TIME_FORMAT_STYLE_SHORT);
|
|
item["end"] = AppTime.ConvertUnixTimeToString(endDay, AppTime.TIME_FORMAT_STYLE_SHORT);
|
|
item["name"] = "活动:" + GetName(desc) + "|" + item["start"] + "至" + item["end"];
|
|
result.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
}
|
|
case ActivityTimeType.FixedTime:
|
|
{
|
|
var start = AppTime.ConvertStringToDateTime(desc.fixedStartTimeStr); //活动开始
|
|
|
|
if (desc.fixedOverTimeStr.Contains("2050")) //排除这种长时间活动,在前端显示没有意义
|
|
{
|
|
break;
|
|
}
|
|
|
|
var end = AppTime.ConvertStringToDateTime(desc.fixedOverTimeStr); //活动结束
|
|
|
|
if (startDate < start && end < endDate) //在查询范围之内
|
|
{
|
|
item["id"] = desc.id;
|
|
item["name"] = "活动:" + GetName(desc) + "|" + desc.fixedStartTimeStr + "至" +
|
|
desc.fixedOverTimeStr;
|
|
item["start"] = desc.fixedStartTimeStr;
|
|
item["end"] = desc.fixedOverTimeStr;
|
|
result.Add(item);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
jsonData["data"] = result;
|
|
return 0;
|
|
}
|
|
|
|
private static string GetName(ActivityDesc desc)
|
|
{
|
|
//@fixme this is not set name default value
|
|
var name = "";
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
var language = LanguageDescMgr.Instance.GetConfig(name);
|
|
|
|
return desc.id + "_" + language.ZH;
|
|
}
|
|
|
|
return desc.id + "";
|
|
}
|
|
}
|
|
}
|