LifePayment/LifePayment.Application.Contracts/LogRecord/ILogService.cs
New file @@ -0,0 +1,19 @@ using LifePayment.Domain.Shared; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LifePayment.Application.Contracts { public interface ILogService { /// <summary> /// 记录前端日志 /// </summary> /// <param name="input"></param> /// <returns></returns> Task LogFront(LogFrontInput input); } } LifePayment/LifePayment.Application/LifePay/StatisticsService.cs
@@ -347,8 +347,13 @@ /// 昨日活跃用户 var yesterdayActiveUsers = await (from a in _lifePayUserRepository join b in _lifePayOrderRepository on a.Id equals b.UserId where b.CreationTime >= today.AddDays(-1) && b.CreationTime < today && (b.ACOOLYStatus == ACOOLYStatusEnum.充值中 || b.ACOOLYStatus == ACOOLYStatusEnum.充值成功 || b.ACOOLYStatus == ACOOLYStatusEnum.已完成 || b.ACOOLYStatus == ACOOLYStatusEnum.部分充值成功) where b.CreationTime >= today.AddDays(-1) && b.CreationTime < today && (channleId == null || channleId == "" || a.CreationChannleNum == channleId) && (b.ACOOLYStatus == ACOOLYStatusEnum.充值成功 || b.ACOOLYStatus == ACOOLYStatusEnum.已完成 || b.ACOOLYStatus == ACOOLYStatusEnum.部分充值成功) select b).Distinct().CountAsync(); /// 累计佣金 var accumulatedChannlesRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.FinishTime < today) LifePayment/LifePayment.Application/LifePaymentServicesApplicationModuleAutoMapperProfile.cs
@@ -4,6 +4,7 @@ using LifePayment.Domain; using LifePayment.Domain.LifePay; using LifePayment.Domain.Models; using LifePayment.Domain.Shared; namespace LifePayment.Application { @@ -37,6 +38,8 @@ CreateMap<CreateChannelConsultationInput, LifePayChannelConsultation>(MemberList.None); CreateMap<CreateChannelConsultationFollowupInput, LifePayChannelConsultationFollowup>(MemberList.None); CreateMap<LogFrontInput, LogFrontRecord>(MemberList.None); } } } LifePayment/LifePayment.Application/LogRecord/LogService.cs
New file @@ -0,0 +1,51 @@ using LifePayment.Application.Contracts; using LifePayment.Domain; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using System; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; namespace LifePayment.Application { public class LogService : ApplicationService, ILogService { private readonly ILogger<LogService> logger; private readonly IHttpContextAccessor httpContextAccessor; private readonly IRepository<LogFrontRecord, Guid> logFrontRepository; public LogService( ILogger<LogService> logger, IHttpContextAccessor httpContextAccessor, IRepository<LogFrontRecord, Guid> logFrontRepository) { this.logger = logger; this.httpContextAccessor = httpContextAccessor; this.logFrontRepository = logFrontRepository; } /// <summary> /// 记录前端日志 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task LogFront(LogFrontInput input) { var log = new LogFrontRecord(); ObjectMapper.Map(input, log); if (log.UserId == null) { log.UserId = CurrentUser?.Id; } log.IpAddress = httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); logger.LogInformation($"前端日志:{log.IpAddress}-{log.UserId}-{log.Url}-{log.RequestTime}-{log.Message}"); //await logFrontRepository.InsertAsync(log); } } } LifePayment/LifePayment.Domain/LogRecord/LogFrontRecord.cs
New file @@ -0,0 +1,41 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Domain.Entities.Auditing; namespace LifePayment.Domain { /// <summary> /// 前端日志 /// </summary> public class LogFrontRecord : FullAuditedEntity<Guid>, IDataUserFilter { /// <summary> /// 用户Id /// </summary> public Guid? UserId { get; set; } /// <summary> /// 消息 /// </summary> public string Message { get; set; } /// <summary> /// 地址 /// </summary> public string Url { get; set; } /// <summary> /// 请求时间 /// </summary> public DateTime? RequestTime { get; set; } /// <summary> /// IP地址 /// </summary> public string IpAddress { get; set; } } } LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs
@@ -17,6 +17,8 @@ { } public virtual DbSet<LogFrontRecord> LogFrontRecord { get; set; } public virtual DbSet<LifePayPromoter> LifePayPromoter { get; set; } public virtual DbSet<LifePayChannelConsultation> LifePayChannelConsultation { get; set; } LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -513,7 +513,7 @@ <param name="input"></param> <returns></returns> </member> <member name="M:LifePayment.HttpApi.LifePay.LogController.LogFront(LifePayment.Domain.Shared.LogFrontInput)"> <member name="M:LifePayment.HttpApi.LogController.LogFront(LifePayment.Domain.Shared.LogFrontInput)"> <summary> 记录前端日志 </summary> LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -2239,6 +2239,13 @@ 结算时间 </summary> </member> <member name="M:LifePayment.Application.Contracts.ILogService.LogFront(LifePayment.Domain.Shared.LogFrontInput)"> <summary> 记录前端日志 </summary> <param name="input"></param> <returns></returns> </member> <member name="P:LifePayment.Application.Contracts.GetChannelConsultationsInput.StartDate"> <summary> 创建的开始时间 LifePayment/LifePayment.Host/appsettings.Development.json
@@ -3,7 +3,9 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information", "Microsoft.EntityFrameworkCore": "Debug", "Microsoft.EntityFrameworkCore.Database.Command": "Trace" } } } LifePayment/LifePayment.HttpApi/LifePay/LogController.cs
@@ -1,31 +1,19 @@ using Castle.Core.Logging; using LifePayment.Application.Sync; using LifePayment.Application.Contracts; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc; using ZeroD.Util; namespace LifePayment.HttpApi.LifePay namespace LifePayment.HttpApi { [Route("api/[controller]/[action]")] [ApiController] public class LogController : AbpController { private readonly ILogger<LogController> logger; private readonly IHttpContextAccessor httpContextAccessor; private readonly ILogService logService; public LogController( ILogger<LogController> logger, IHttpContextAccessor httpContextAccessor) public LogController(ILogService logService) { this.logger = logger; this.httpContextAccessor = httpContextAccessor; this.logService = logService; } /// <summary> @@ -33,10 +21,9 @@ /// </summary> /// <returns></returns> [HttpPost] public void LogFront(LogFrontInput message) public async void LogFront(LogFrontInput message) { string ip = httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); logger.LogInformation($"前端日志(IP-{ip}):{message.ToJson()}"); await logService.LogFront(message); } } }