diff --git a/Application.Web.Admin/Application.Web.Admin.csproj b/Application.Web.Admin/Application.Web.Admin.csproj new file mode 100644 index 0000000..cf6df79 --- /dev/null +++ b/Application.Web.Admin/Application.Web.Admin.csproj @@ -0,0 +1,25 @@ + + + + net10.0 + enable + enable + + + + + Always + + + + + + + + + + + + + + diff --git a/Application.Web.Admin/Controllers/AccMoneyController.cs b/Application.Web.Admin/Controllers/AccMoneyController.cs new file mode 100644 index 0000000..769786c --- /dev/null +++ b/Application.Web.Admin/Controllers/AccMoneyController.cs @@ -0,0 +1,89 @@ +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 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()); + 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; + } +} \ No newline at end of file diff --git a/Application.Web.Admin/Controllers/IndexController.cs b/Application.Web.Admin/Controllers/IndexController.cs new file mode 100644 index 0000000..dde32d7 --- /dev/null +++ b/Application.Web.Admin/Controllers/IndexController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Admin.Controllers; + +public class IndexController : Controller +{ + // GET + public IActionResult Index() + { + return View(); + } +} \ No newline at end of file diff --git a/Application.Web.Admin/Controllers/SendMailController.cs b/Application.Web.Admin/Controllers/SendMailController.cs new file mode 100644 index 0000000..049f036 --- /dev/null +++ b/Application.Web.Admin/Controllers/SendMailController.cs @@ -0,0 +1,97 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; + +namespace Application.Web.Admin.Controllers; + +public class SendMailController : Controller +{ + private readonly IMessageService _messageService; + private readonly IGameGoodsService _goodsService; + private readonly IUnitUserService _userService; + public SendMailController(IMessageService messageService,IGameGoodsService goodsService,IUnitUserService userService) + { + _messageService = messageService; + _goodsService = goodsService; + _userService = userService; + } + + // GET + public IActionResult Index() + { + return View(); + } + + [HttpPost] + public async Task Send(string id, string name, string sign, string awData, int goods, int count, string remark, int type) + { + string url = "/SendMail/Index"; + List award = new List(); + if (string.IsNullOrEmpty(awData)) + { + if (goods != 0) + { + var goodsInfo = await _goodsService.GetGoodsInfo(goods); + if (goodsInfo == null) + { + TempData["msg"] = "物品不存在!"; + return Redirect(url); + } + TowerGet add = new TowerGet(); + add.code = GameEnum.PropCode.Goods.ToString(); + add.name = goodsInfo.goodsName; + add.parameter = goods.ToString(); + add.count = count; + award.Add(add); + } + } + else + { + award = JsonConvert.DeserializeObject>(awData); + } + int index = 0; + List users = new List(); + if (type == 0) + { + string[] ids = id.Split(','); + foreach (string item in ids) + { + var userInfo = await _userService.GetUserInfoByUserNo(item.Trim()); + if (userInfo == null) + { + continue; + } + index++; + users.Add(userInfo.userId); + } + } + else if (type == 1) + { + DateTime time = TimeAssist.GetDateTimeYMD(0); + var data = await _userService.GetOnlineUserByTime(TimeExtend.GetTimeStampBySeconds(time)); + foreach (var item in data) + { + users.Add(item.userId); + index++; + } + } + else + { + var data = await _userService.GetOnlineUserByTime(0); + foreach (var item in data) + { + users.Add(item.userId); + index++; + } + } + if (await _messageService.SendMaill(users, name, sign, award)) + { + TempData["msg"] = string.Format("发放成功,共完成{0}个!", index); + return Redirect(url); + } + else + { + TempData["msg"] = "发放失败!"; + return Redirect(url); + } + } +} \ No newline at end of file diff --git a/Application.Web.Admin/GlobalUsing.cs b/Application.Web.Admin/GlobalUsing.cs new file mode 100644 index 0000000..d706488 --- /dev/null +++ b/Application.Web.Admin/GlobalUsing.cs @@ -0,0 +1,13 @@ +global using Photon.Core; +global using Photon.Core.Jwt; +global using Photon.Core.Services; +global using Photon.Core.SqlSugar; +global using Photon.Core.Assist; +global using Photon.Core.Timer; +global using SqlSugar; + +global using Application.Service.Pub; +global using Application.Domain; +global using Application.Domain.Entity; +global using Microsoft.AspNetCore.Authorization; +global using Microsoft.AspNetCore.Mvc; \ No newline at end of file diff --git a/Application.Web.Admin/Program.cs b/Application.Web.Admin/Program.cs new file mode 100644 index 0000000..7925b84 --- /dev/null +++ b/Application.Web.Admin/Program.cs @@ -0,0 +1,65 @@ +using Photon.Core.Redis; + + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.Inject(new List { +"Application.Web.Admin","Application.Domain" +});//框架初始化 + +builder.Configuration.RegisterConfig();//注入配置 +builder.Services.InjectRedis(builder.Configuration); +builder.Services.InjectSql(builder.Configuration); + +//日志 +builder.Logging.InjectLog(); +// Add services to the container. + + +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi + +#region 配置跨域处理,允许所有来源 + +builder.Services.AddCors(options => +{ + options.AddPolicy("all", builder => + { + builder.AllowAnyOrigin() //允许任何来源的主机访问 + .AllowAnyMethod() + .AllowAnyHeader(); + }); +}); + +#endregion 配置跨域处理,允许所有来源 + + +builder.Services.AddSignalR(); + +var app = builder.Build(); + +app.Services.UseInject();//启用框架 +app.Configuration.UseConfig();//启用配置 + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Home/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseCors("all"); +app.UseStaticFiles(); +app.UseHttpsRedirection(); + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); +app.MapControllerRoute( + name: "default", + pattern: "{controller=Index}/{action=Index}/{id?}") + .WithStaticAssets(); + +SnowflakeAssist.Initialize(0, 0); +app.Run(); diff --git a/Application.Web.Admin/Properties/launchSettings.json b/Application.Web.Admin/Properties/launchSettings.json new file mode 100644 index 0000000..12e8452 --- /dev/null +++ b/Application.Web.Admin/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5270", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7023;http://localhost:5270", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Application.Web.Admin/Views/AccMoney/Index.cshtml b/Application.Web.Admin/Views/AccMoney/Index.cshtml new file mode 100644 index 0000000..fdc61e7 --- /dev/null +++ b/Application.Web.Admin/Views/AccMoney/Index.cshtml @@ -0,0 +1,24 @@ +
+ ID:
+ 充值账户: +
+ 金额:
+ 充值类型: +
+ 备注:
+ +
+ * @TempData["msg"] +
+
\ No newline at end of file diff --git a/Application.Web.Admin/Views/Index/Index.cshtml b/Application.Web.Admin/Views/Index/Index.cshtml new file mode 100644 index 0000000..52adc0b --- /dev/null +++ b/Application.Web.Admin/Views/Index/Index.cshtml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/Application.Web.Admin/Views/SendMail/Index.cshtml b/Application.Web.Admin/Views/SendMail/Index.cshtml new file mode 100644 index 0000000..7dfab40 --- /dev/null +++ b/Application.Web.Admin/Views/SendMail/Index.cshtml @@ -0,0 +1,26 @@ +
+
+ 发送类型:
+ ID:
+ 邮件主题:
+ 邮件内容:
+ =======附件=====
+ 多附件字符:
+
+ *当只有一个附件时,可以填写以下内容。 +
+ 物品ID:
+ 数量:
+ 说明:
+
+
+ +
+
+ * @TempData["msg"] +
+
\ No newline at end of file diff --git a/Application.Web.Admin/Views/Shared/_Layout.cshtml b/Application.Web.Admin/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..a0e8760 --- /dev/null +++ b/Application.Web.Admin/Views/Shared/_Layout.cshtml @@ -0,0 +1,20 @@ +@using Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + +
+ @RenderBody() +
+ + + + diff --git a/Application.Web.Admin/Views/_ViewStart.cshtml b/Application.Web.Admin/Views/_ViewStart.cshtml new file mode 100644 index 0000000..a5f1004 --- /dev/null +++ b/Application.Web.Admin/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/Application.Web.Admin/applicationsettings.json b/Application.Web.Admin/applicationsettings.json new file mode 100644 index 0000000..7a556ce --- /dev/null +++ b/Application.Web.Admin/applicationsettings.json @@ -0,0 +1,43 @@ +{ + "AutoProgram": 0, + "Redis": { + "connection": "81.70.212.61:6379,password=kx.20260711,defaultdatabase=5" + }, + "SqlData": [ + { + "type": 0, + "name": "Kg.SeaTime.Game", + "connect": "data source=81.70.212.61;database=kg.seatime.game;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" + }, + { + "type": 0, + "name": "Kg.SeaTime.Resource", + "connect": "data source=81.70.212.61;database=kg.seatime.resource;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" + }, + { + "type": 0, + "name": "Kg.SeaTime.Log", + "connect": "data source=81.70.212.61;database=kg.seatime.log;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" + } + ], + "JwtTokenOptions": { + "Issuer": "kx.seatime", + "Audience": "kx.seatime", + "SecurityKey": "46055HR0n7FeNHhDKAYD2i9ZsdsYn4jn" + }, + "ResUrl": { + "local": "http://192.168.0.142:5298", + "resUrl": "http://localhost:12206", + "imgCDN": "/", + "videoCDN": "/" + }, + "Sms": { + "SmsType": 1, + "AccessKey": "AKIDVptgCRP5UcT4PTGm1yf5E6pKYVBajeKn", + "Secret": "FG2atxlKflcEclgKhnc9XeU3LM6YjdGf", + "signName": "探玩驿站", + "TemplateCode": "963929", + "SmsSdkAppId": "1400523979", + "SmsOnTime": 300 + } +} \ No newline at end of file diff --git a/Application.Web.Admin/appsettings.Development.json b/Application.Web.Admin/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Application.Web.Admin/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Application.Web.Admin/appsettings.json b/Application.Web.Admin/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Application.Web.Admin/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Application.Web.Admin/wwwroot/css/table.css b/Application.Web.Admin/wwwroot/css/table.css new file mode 100644 index 0000000..d012ec3 --- /dev/null +++ b/Application.Web.Admin/wwwroot/css/table.css @@ -0,0 +1,25 @@ +table { + border-collapse: collapse; + margin: 0 auto; + text-align: center; + margin-top: 20px; +} + +table td, table th { + border: 1px solid #cad9ea; + color: #666; + height: 30px; +} + +table thead th { + background-color: #CCE8EB; + width: 100px; +} + +table tr:nth-child(odd) { + background: #fff; +} + +table tr:nth-child(even) { + background: #F5FAFA; +} \ No newline at end of file diff --git a/Kx.SeaTime.slnx b/Kx.SeaTime.slnx index 39bca3f..3863627 100644 --- a/Kx.SeaTime.slnx +++ b/Kx.SeaTime.slnx @@ -1,4 +1,5 @@ + diff --git a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj index 8f5e89a..7db6606 100644 --- a/Service/Application.Domain.Entity/Application.Domain.Entity.csproj +++ b/Service/Application.Domain.Entity/Application.Domain.Entity.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs index 07044cc..bf453d8 100644 --- a/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs +++ b/Service/Application.Domain/Services/Interface/Pub/IMessageService.cs @@ -26,6 +26,9 @@ public interface IMessageService Task> GetUserMailData(string userId, int page, int limit, RefAsync total); Task GetMailInfo(string mailId); Task SendMaill(string userId, string name, string sign, List award, int days = 10); + + Task SendMaill(List userIds, string name, string sign, List award, + int days = 10); Task UpdateMaillInfo(unit_user_mail data); #endregion diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs index b89b2a2..0b8ae43 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserService.cs @@ -31,7 +31,7 @@ public interface IUnitUserService #region 其他 Task GetOnlineCount(); - + Task> GetOnlineUserByTime(long time); #endregion diff --git a/Service/Application.Domain/Services/Service/Pub/MessageService.cs b/Service/Application.Domain/Services/Service/Pub/MessageService.cs index 9d0a658..d32322c 100644 --- a/Service/Application.Domain/Services/Service/Pub/MessageService.cs +++ b/Service/Application.Domain/Services/Service/Pub/MessageService.cs @@ -194,7 +194,7 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess return count; } - private async Task ClearMailCountCache(string userId) + private async Task ClearMailCountCache(params string[] userId) { string key = string.Format(UserCache.BaseCacheKeys, "Message", "MailCount"); await redis.DelHashAsync(key, userId); @@ -240,6 +240,42 @@ public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMess return result; } + public async Task SendMaill(List userIds, string name, string sign, List award, + int days = 10) + { + List data = new List(); + foreach (var userId in userIds) + { + unit_user_mail mail = new unit_user_mail(); + mail.mailId = StringAssist.NewGuid; + mail.userId = userId; + mail.name = name; + mail.sign = sign; + mail.isRead = 0; + mail.isGet = award.Count > 0 ? 0 : 1; + mail.award = award; + mail.addTime = DateTime.Now; + mail.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(days)); + data.Add(mail); + } + + if (data.Count > 0) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Insertable(data).ExecuteCommandAsync() > 0; + if (result) + { + await ClearMailCountCache(userIds.ToArray()); + } + + return result; + } + else + { + return false; + } + } + public async Task UpdateMaillInfo(unit_user_mail data) { var db = DbClient.AsTenant().GetConnectionWithAttr(); diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs index 7113b78..6997195 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -322,6 +322,12 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni return await db.Queryable().Where(it => it.upTime > time).CountAsync(); } + public async Task> GetOnlineUserByTime(long time) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.upTime > time).ToListAsync(); + } + #endregion #region 权限配置 diff --git a/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs b/Service/Application.Web/Business/Job/GameAutoJobService.cs similarity index 97% rename from Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs rename to Service/Application.Web/Business/Job/GameAutoJobService.cs index 3cfde59..a9e5221 100644 --- a/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs +++ b/Service/Application.Web/Business/Job/GameAutoJobService.cs @@ -1,6 +1,8 @@ -using Photon.Core.Timer; +using Jaina; +using Photon.Core.Redis; +using Photon.Core.Timer; -namespace Application.Domain; +namespace Application.Web; public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITimerJobManager jobManager) : IGameAutoJobService, ITransient diff --git a/Service/Application.Domain/Services/Interface/Business/IGameAutoJobService.cs b/Service/Application.Web/Business/Job/IGameAutoJobService.cs similarity index 86% rename from Service/Application.Domain/Services/Interface/Business/IGameAutoJobService.cs rename to Service/Application.Web/Business/Job/IGameAutoJobService.cs index e434f19..d152693 100644 --- a/Service/Application.Domain/Services/Interface/Business/IGameAutoJobService.cs +++ b/Service/Application.Web/Business/Job/IGameAutoJobService.cs @@ -1,4 +1,4 @@ -namespace Application.Domain; +namespace Application.Web; public interface IGameAutoJobService { diff --git a/Service/Application.Web/Controllers/Pub/TradeController.cs b/Service/Application.Web/Controllers/Pub/TradeController.cs index 8338f8d..031988e 100644 --- a/Service/Application.Web/Controllers/Pub/TradeController.cs +++ b/Service/Application.Web/Controllers/Pub/TradeController.cs @@ -186,17 +186,22 @@ public class TradeController : ControllerBase if (info.code == nameof(GameEnum.PropCode.Equ)) { + unit_user_equ equInfo = JsonConvert.DeserializeObject(info.content); + if (await _weightService.CheckUserWeight(userId, (int)equInfo.weight)==false) + { + return PoAction.Message("您的负重不足!"); + } + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); if (myAcc < info.price) { return PoAction.Message("您的铜贝不足!"); } - + if (await _accService.UpdateUserCopper(userId, 0, (long)info.price, $"交易支付:{info.name}")) { if (await _tradeService.UpdateTradeCount(info.tradeId, 0, 1, true)) { - unit_user_equ equInfo = JsonConvert.DeserializeObject(info.content); equInfo.userId = userId; await _equService.AddUserEqu(equInfo, "交易获得"); long GetCopper = Convert.ToInt64(info.price * 0.9M); @@ -220,6 +225,12 @@ public class TradeController : ControllerBase } else if (info.code == nameof(GameEnum.PropCode.Goods)) { + var goodsInfo = await _goodsService.GetGoodsInfo(Convert.ToInt32(info.propId)); + int needWeight = (int)goodsInfo.weight * count; + if (await _weightService.CheckUserWeight(userId, needWeight)==false) + { + return PoAction.Message("您的负重不足!"); + } var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); var needCopper = Convert.ToInt64(info.price) * count; if (myAcc < needCopper) diff --git a/Service/Application.Domain/Timer/AutoJob.cs b/Service/Application.Web/Plug/Timer/AutoJob.cs similarity index 95% rename from Service/Application.Domain/Timer/AutoJob.cs rename to Service/Application.Web/Plug/Timer/AutoJob.cs index 9c23e17..3fa4a4e 100644 --- a/Service/Application.Domain/Timer/AutoJob.cs +++ b/Service/Application.Web/Plug/Timer/AutoJob.cs @@ -1,6 +1,6 @@ using Photon.Core.Timer; using Quartz; -namespace Application.Domain; +namespace Application.Web; public class AutoJob: ITimerAutoJob { diff --git a/Service/Application.Domain/Timer/JobStart.cs b/Service/Application.Web/Plug/Timer/JobStart.cs similarity index 98% rename from Service/Application.Domain/Timer/JobStart.cs rename to Service/Application.Web/Plug/Timer/JobStart.cs index da2fb3a..a973109 100644 --- a/Service/Application.Domain/Timer/JobStart.cs +++ b/Service/Application.Web/Plug/Timer/JobStart.cs @@ -2,7 +2,7 @@ using Quartz; using Quartz.Spi; -namespace Application.Domain; +namespace Application.Web; public class JobStart: ITimerAutoStart { private readonly ISchedulerFactory _schedulerFactory; diff --git a/Service/Application.Domain/Timer/TimerJobManager.cs b/Service/Application.Web/Plug/Timer/TimerJobManager.cs similarity index 97% rename from Service/Application.Domain/Timer/TimerJobManager.cs rename to Service/Application.Web/Plug/Timer/TimerJobManager.cs index a275a20..b76150a 100644 --- a/Service/Application.Domain/Timer/TimerJobManager.cs +++ b/Service/Application.Web/Plug/Timer/TimerJobManager.cs @@ -1,7 +1,7 @@ using Photon.Core.Timer; using Quartz; -namespace Application.Domain; +namespace Application.Web; public class TimerJobManager : ITimerJobManager {