diff --git a/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosDto.cs b/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosDto.cs new file mode 100644 index 000000000..dd0da14fe --- /dev/null +++ b/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosDto.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace CAServer.Growth.Dtos; + +public class GetGrowthInfosDto +{ + public long TotalRecordCount { get; set; } + public List Data { get; set; } +} \ No newline at end of file diff --git a/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosRequestDto.cs b/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosRequestDto.cs new file mode 100644 index 000000000..7e0a52b45 --- /dev/null +++ b/src/CAServer.Application.Contracts/Growth/Dtos/GetGrowthInfosRequestDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; + +namespace CAServer.Growth.Dtos; + +public class GetGrowthInfosRequestDto: PagedResultRequestDto +{ + public string ProjectCode { get; set; } + public List ReferralCodes { get; set; } + public DateTime? StartTime { get; set; } + public DateTime? EndTime { get; set; } +} \ No newline at end of file diff --git a/src/CAServer.Application.Contracts/Growth/Dtos/GrowthUserInfoDto.cs b/src/CAServer.Application.Contracts/Growth/Dtos/GrowthUserInfoDto.cs new file mode 100644 index 000000000..16ccf9123 --- /dev/null +++ b/src/CAServer.Application.Contracts/Growth/Dtos/GrowthUserInfoDto.cs @@ -0,0 +1,5 @@ +namespace CAServer.Growth.Dtos; + +public class GrowthUserInfoDto : GrowthBase +{ +} \ No newline at end of file diff --git a/src/CAServer.Application.Contracts/Growth/Dtos/ShortLinkDto.cs b/src/CAServer.Application.Contracts/Growth/Dtos/ShortLinkDto.cs index 2b892b054..c48c6593e 100644 --- a/src/CAServer.Application.Contracts/Growth/Dtos/ShortLinkDto.cs +++ b/src/CAServer.Application.Contracts/Growth/Dtos/ShortLinkDto.cs @@ -3,4 +3,13 @@ namespace CAServer.Growth.Dtos; public class ShortLinkDto { public string ShortLink { get; set; } + public UserGrowthInfo UserGrowthInfo { get; set; } +} + +public class UserGrowthInfo +{ + public string CaHash { get; set; } + public string ProjectCode { get; set; } + public string InviteCode { get; set; } + public string ShortLinkCode { get; set; } } \ No newline at end of file diff --git a/src/CAServer.Application.Contracts/Growth/IGrowthStatisticAppService.cs b/src/CAServer.Application.Contracts/Growth/IGrowthStatisticAppService.cs index ec17cb214..a0eb63f5d 100644 --- a/src/CAServer.Application.Contracts/Growth/IGrowthStatisticAppService.cs +++ b/src/CAServer.Application.Contracts/Growth/IGrowthStatisticAppService.cs @@ -19,4 +19,5 @@ public interface IGrowthStatisticAppService Task RepairHamsterDataAsync(); Task CollectHamsterUserIdsAsync(string userId); Task TonGiftsValidateAsync(); + Task GetGrowthInfosAsync(GetGrowthInfosRequestDto input); } \ No newline at end of file diff --git a/src/CAServer.Application/CAServerApplicationAutoMapperProfile.cs b/src/CAServer.Application/CAServerApplicationAutoMapperProfile.cs index c22740312..45838cf37 100644 --- a/src/CAServer.Application/CAServerApplicationAutoMapperProfile.cs +++ b/src/CAServer.Application/CAServerApplicationAutoMapperProfile.cs @@ -974,5 +974,6 @@ public CAServerApplicationAutoMapperProfile() CreateMap(); CreateMap(); + CreateMap(); } } \ No newline at end of file diff --git a/src/CAServer.Application/Growth/GrowthAppService.cs b/src/CAServer.Application/Growth/GrowthAppService.cs index 76950b899..43eda8495 100644 --- a/src/CAServer.Application/Growth/GrowthAppService.cs +++ b/src/CAServer.Application/Growth/GrowthAppService.cs @@ -83,7 +83,14 @@ public async Task GetShortLinkAsync(string projectCode) var url = $"{_growthOptions.BaseUrl}/api/app/account/{grainDto.ShortLinkCode}"; return new ShortLinkDto() { - ShortLink = url + ShortLink = url, + UserGrowthInfo = new UserGrowthInfo() + { + CaHash = grainDto.CaHash, + ProjectCode = grainDto.ProjectCode, + InviteCode = grainDto.InviteCode, + ShortLinkCode = grainDto.ShortLinkCode + } }; } diff --git a/src/CAServer.Application/Growth/GrowthStatisticAppService.cs b/src/CAServer.Application/Growth/GrowthStatisticAppService.cs index f0727e70e..ae412777a 100644 --- a/src/CAServer.Application/Growth/GrowthStatisticAppService.cs +++ b/src/CAServer.Application/Growth/GrowthStatisticAppService.cs @@ -30,6 +30,7 @@ using Volo.Abp.Auditing; using Volo.Abp.Authorization; using Volo.Abp.Users; +using Volo.Abp.Validation; using Result = CAServer.Growth.Dtos.Result; namespace CAServer.Growth; @@ -861,6 +862,20 @@ public async Task TonGiftsValidateAsync() var result = await response.Content.ReadAsStringAsync(); } + public async Task GetGrowthInfosAsync(GetGrowthInfosRequestDto input) + { + if (input.ReferralCodes.IsNullOrEmpty() && input.ProjectCode.IsNullOrEmpty()) + { + throw new AbpValidationException("referralCodes and projectCode is empty."); + } + var result = await _growthProvider.GetGrowthInfosAsync(input); + return new GetGrowthInfosDto() + { + TotalRecordCount = result.Item1, + Data = ObjectMapper.Map, List>(result.Item2) + }; + } + private async Task> GetNickNameByCaHashes(List caHashes) { var caHolderList = await GetCaHolderByCaHashAsync(caHashes); diff --git a/src/CAServer.Application/Growth/Provider/GrowthProvider.cs b/src/CAServer.Application/Growth/Provider/GrowthProvider.cs index 82c7524fc..df29650ab 100644 --- a/src/CAServer.Application/Growth/Provider/GrowthProvider.cs +++ b/src/CAServer.Application/Growth/Provider/GrowthProvider.cs @@ -36,6 +36,8 @@ Task> GetReferralRecordListAsync(string caHash, string Task GetHamsterScoreListAsync(List addresses, DateTime startTime, DateTime endTime); Task> GetInviteRepairIndexAsync(); + + Task>> GetGrowthInfosAsync(GetGrowthInfosRequestDto input); } public class GrowthProvider : IGrowthProvider, ISingletonDependency @@ -169,7 +171,7 @@ public async Task AddReferralRecordAsync(ReferralRecordIndex referralRecor { var record = await GetReferralRecordListAsync(referralRecordIndex.CaHash, referralRecordIndex.ReferralCaHash, 0, 1, - null, null, new List { referralRecordIndex.ReferralType}); + null, null, new List { referralRecordIndex.ReferralType }); if (!record.IsNullOrEmpty()) { return false; @@ -187,6 +189,36 @@ public async Task> GetInviteRepairIndexAsync() return data; } + public async Task>> GetGrowthInfosAsync(GetGrowthInfosRequestDto input) + { + var mustQuery = new List, QueryContainer>>(); + + mustQuery.Add(q => q.Term(i => i.Field(f => f.ProjectCode).Value(input.ProjectCode))); + + if (!input.ReferralCodes.IsNullOrEmpty()) + { + mustQuery.Add(q => q.Terms(i => i.Field(f => f.InviteCode).Terms(input.ReferralCodes))); + } + + if (input.StartTime.HasValue) + { + mustQuery.Add(q => q.DateRange(i => + i.Field(f => f.CreateTime).LessThanOrEquals(input.StartTime))); + } + + if (input.EndTime.HasValue) + { + mustQuery.Add(q => q.DateRange(i => + i.Field(f => f.CreateTime).LessThanOrEquals(input.EndTime))); + } + + QueryContainer Filter(QueryContainerDescriptor f) => f.Bool(b => b.Must(mustQuery)); + var result = await _growthRepository.GetListAsync(Filter, sortExp: k => k.CreateTime, + sortType: SortOrder.Ascending, skip: input.SkipCount, limit: input.MaxResultCount); + return result ; + } + + public async Task GetHamsterScoreListAsync(List caAddressList, DateTime beginTime, DateTime endTime) { diff --git a/src/CAServer.HttpApi/Controllers/GrowthController.cs b/src/CAServer.HttpApi/Controllers/GrowthController.cs index 2cadb8200..484bf8206 100644 --- a/src/CAServer.HttpApi/Controllers/GrowthController.cs +++ b/src/CAServer.HttpApi/Controllers/GrowthController.cs @@ -95,11 +95,10 @@ public async Task ValidateHamsterScore(string u return await _statisticAppService.ValidateHamsterScoreAsync(userId); } - - - - - - + [HttpGet("growthInfos")] + public async Task GetGrowthInfosAsync(GetGrowthInfosRequestDto input) + { + return await _statisticAppService.GetGrowthInfosAsync(input); + } } \ No newline at end of file