89 lines
2.3 KiB
C#
89 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Application.Web.Admin.Controllers;
|
|
|
|
public class AccMoneyController : Controller
|
|
{
|
|
private readonly IUnitUserAccService _accService;
|
|
private readonly IUnitUserService _userService;
|
|
private readonly IMessageService _messageService;
|
|
|
|
public AccMoneyController(IUnitUserAccService accService, IUnitUserService userService,
|
|
IMessageService messageService)
|
|
{
|
|
_accService = accService;
|
|
_userService = userService;
|
|
_messageService = messageService;
|
|
}
|
|
|
|
// GET
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> UpAcc(string u, long c, string t, string r, string p)
|
|
{
|
|
string url = "/AccMoney/Index";
|
|
|
|
var user = await _userService.GetUserInfoByUserNo(u);
|
|
if (user == null)
|
|
{
|
|
TempData["msg"] = "用户不存在!";
|
|
return Redirect(url);
|
|
}
|
|
|
|
if (await _accService.UpdateUserAccBath(user.userId, 1, t, c, p, r))
|
|
{
|
|
TempData["msg"] = "发放成功!";
|
|
string accName = GetCurrName(t);
|
|
string msg =$"亲爱的玩家,您的【{accName}】账户有变动,账户额度+{c},备注:[{r}];祝您驰骋四海,纵横天下!";
|
|
await _messageService.SendMaill(user.userId, "账户操作通知", msg, new List<TowerGet>());
|
|
return Redirect(url);
|
|
}
|
|
else
|
|
{
|
|
TempData["msg"] = "发放失败!";
|
|
return Redirect(url);
|
|
}
|
|
}
|
|
|
|
public static string GetCurrName(string accType)
|
|
{
|
|
string result = string.Empty;
|
|
switch (accType)
|
|
{
|
|
case "copper":
|
|
result = "铜贝";
|
|
break;
|
|
|
|
case "cowry":
|
|
result = "金贝";
|
|
break;
|
|
|
|
case "gold":
|
|
result = "金元";
|
|
break;
|
|
|
|
|
|
case "teach":
|
|
result = "师德";
|
|
break;
|
|
|
|
case "renown":
|
|
result = "声望";
|
|
break;
|
|
|
|
case "charm":
|
|
result = "魅力";
|
|
break;
|
|
|
|
case "enemy":
|
|
result = "罪恶值";
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
} |