This commit is contained in:
2026-07-15 23:04:46 +08:00
parent 4ef892e15e
commit c94b3ce200
28 changed files with 562 additions and 10 deletions

View File

@@ -10,4 +10,8 @@
<ProjectReference Include="..\Application.Service.Pub\Application.Service.Pub.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="log\" />
</ItemGroup>
</Project>

View File

@@ -26,6 +26,9 @@ public interface IMessageService
Task<List<unit_user_mail>> GetUserMailData(string userId, int page, int limit, RefAsync<int> total);
Task<unit_user_mail> GetMailInfo(string mailId);
Task<bool> SendMaill(string userId, string name, string sign, List<TowerGet> award, int days = 10);
Task<bool> SendMaill(List<string> userIds, string name, string sign, List<TowerGet> award,
int days = 10);
Task<bool> UpdateMaillInfo(unit_user_mail data);
#endregion

View File

@@ -31,7 +31,7 @@ public interface IUnitUserService
#region
Task<int> GetOnlineCount();
Task<List<unit_user_online>> GetOnlineUserByTime(long time);
#endregion

View File

@@ -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<bool> SendMaill(List<string> userIds, string name, string sign, List<TowerGet> award,
int days = 10)
{
List<unit_user_mail> data = new List<unit_user_mail>();
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<unit_user_mail>();
bool result = await db.Insertable(data).ExecuteCommandAsync() > 0;
if (result)
{
await ClearMailCountCache(userIds.ToArray());
}
return result;
}
else
{
return false;
}
}
public async Task<bool> UpdateMaillInfo(unit_user_mail data)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_mail>();

View File

@@ -322,6 +322,12 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni
return await db.Queryable<unit_user_online>().Where(it => it.upTime > time).CountAsync();
}
public async Task<List<unit_user_online>> GetOnlineUserByTime(long time)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
return await db.Queryable<unit_user_online>().Where(it => it.upTime > time).ToListAsync();
}
#endregion
#region

View File

@@ -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

View File

@@ -1,4 +1,4 @@
namespace Application.Domain;
namespace Application.Web;
public interface IGameAutoJobService
{

View File

@@ -186,17 +186,22 @@ public class TradeController : ControllerBase
if (info.code == nameof(GameEnum.PropCode.Equ))
{
unit_user_equ equInfo = JsonConvert.DeserializeObject<unit_user_equ>(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<unit_user_equ>(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)

View File

@@ -1,6 +1,6 @@
using Photon.Core.Timer;
using Quartz;
namespace Application.Domain;
namespace Application.Web;
public class AutoJob: ITimerAutoJob
{

View File

@@ -2,7 +2,7 @@
using Quartz;
using Quartz.Spi;
namespace Application.Domain;
namespace Application.Web;
public class JobStart: ITimerAutoStart
{
private readonly ISchedulerFactory _schedulerFactory;

View File

@@ -1,7 +1,7 @@
using Photon.Core.Timer;
using Quartz;
namespace Application.Domain;
namespace Application.Web;
public class TimerJobManager : ITimerJobManager
{