1111
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
@@ -30,19 +31,30 @@ public class MessageController : ControllerBase
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
RefAsync<int> total = 0;
|
||||
List<int> msgCount = await _messageService.GetNoReadCount(userId);
|
||||
if (type == 0)
|
||||
{
|
||||
var data = await _messageService.GetUserMessage(userId, 0, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value });
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
var data = await _messageService.GetUserMessage(userId, 1, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value });
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
var data = await _messageService.GetUserEventMessage(userId, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else if (type == 3)
|
||||
{
|
||||
var data = await _messageService.GetUserMailData(userId, page, 10, total);
|
||||
return PoAction.Ok(new { data, total = total.Value, msgCount });
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Ok(new { data = new List<string>(), total = total.Value });
|
||||
return PoAction.Ok(new { data = new List<string>(), total = total.Value, msgCount });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,4 +205,134 @@ public class MessageController : ControllerBase
|
||||
return PoAction.Message("删除失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取邮件详情
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMailInfo(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _messageService.GetMailInfo(no);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.endTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("邮件已过期!");
|
||||
}
|
||||
|
||||
if (data.isRead == 0)
|
||||
{
|
||||
data.isRead = 1;
|
||||
await _messageService.UpdateMaillInfo(data);
|
||||
}
|
||||
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 领取附件
|
||||
/// </summary>
|
||||
/// <param name="no"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetAward(string no)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _messageService.GetMailInfo(no);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("邮件不存在!");
|
||||
}
|
||||
|
||||
if (data.endTime < TimeExtend.GetTimeStampSeconds)
|
||||
{
|
||||
return PoAction.Message("邮件已过期!");
|
||||
}
|
||||
|
||||
if (data.isGet == 1)
|
||||
{
|
||||
return PoAction.Message("邮件附件已领取!");
|
||||
}
|
||||
|
||||
data.isGet = 1;
|
||||
data.isRead = 1;
|
||||
if (await _messageService.UpdateMaillInfo(data))
|
||||
{
|
||||
await GameBus.UpdateBag(userId, 1, data.award, $"邮件领取:{data.name}");
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("领取失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理事件消息
|
||||
/// </summary>
|
||||
/// <param name="eventId"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> EventHandle(string eventId, int state)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var eventInfo = await _messageService.GetEventMessageInfo(eventId);
|
||||
if (eventInfo == null)
|
||||
{
|
||||
return PoAction.Message("通知消息不存在!");
|
||||
}
|
||||
|
||||
if (eventInfo.userId != userId)
|
||||
{
|
||||
return PoAction.Message("通知消息不存在!");
|
||||
}
|
||||
|
||||
if (eventInfo.state != 0)
|
||||
{
|
||||
return PoAction.Message("消息已处理!");
|
||||
}
|
||||
|
||||
if (eventInfo.btns.All(it => it.status != state))
|
||||
{
|
||||
return PoAction.Message("无法进行当前处理,请重试!");
|
||||
}
|
||||
|
||||
eventInfo.state = state;
|
||||
if (await _messageService.UpdateEventData(eventInfo))
|
||||
{
|
||||
MessageHandle handle = new MessageHandle();
|
||||
var result = await handle.HandleMsg(eventInfo, state);
|
||||
if (result.success)
|
||||
{
|
||||
return PoAction.Ok(true, result.msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventInfo.state = 0;
|
||||
await _messageService.UpdateEventData(eventInfo);
|
||||
return PoAction.Message(result.msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("处理失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user