|
@@ -1,12 +1,71 @@
|
|
|
-using System;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using ZhonTai.Admin.Core.Consts;
|
|
|
+using ZhonTai.Admin.Core.Dto;
|
|
|
+using ZhonTai.Admin.Domain.Org;
|
|
|
+using ZhonTai.Admin.Domain.Platform;
|
|
|
+using ZhonTai.Admin.Domain.Tenant;
|
|
|
+using ZhonTai.Admin.Repositories.Platform;
|
|
|
+using ZhonTai.Admin.Services.Platform.Dto;
|
|
|
+using ZhonTai.DynamicApi;
|
|
|
+using ZhonTai.DynamicApi.Attributes;
|
|
|
|
|
|
namespace ZhonTai.Admin.Services.Platform
|
|
|
-{
|
|
|
- internal class PlatformUserService
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 平台用户服务
|
|
|
+ /// </summary>
|
|
|
+ [DynamicApi(Area = AdminConsts.AreaName)]
|
|
|
+ public class PlatformUserService : BaseService, IPlatformUserService, IDynamicApi
|
|
|
{
|
|
|
+ private IPlatformUserRepository _platformUserRepository => LazyGetRequiredService<PlatformUserRepository>();
|
|
|
+ private IUserBillsRepository _userBillsRepository => LazyGetRequiredService<UserBillsRepository>();
|
|
|
+
|
|
|
+ public PlatformUserService()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询分页
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="input"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ public async Task<PageOutput<PlatformUserListOutput>> GetPageAsync(PageInput<PlatformUserGetPageDto> input)
|
|
|
+ {
|
|
|
+
|
|
|
+ var TenantId = input.Filter?.TenantId;
|
|
|
+ var Keyword = input.Filter?.Keyword;
|
|
|
+
|
|
|
+
|
|
|
+ var list = await _platformUserRepository.Select.From<TenantEntity,OrgEntity>()
|
|
|
+ .LeftJoin((u,t,o)=>u.TenantId==t.Id)
|
|
|
+ .LeftJoin((u, t, o) => t.OrgId == o.Id)
|
|
|
+ .WhereIf(TenantId.HasValue && TenantId >= 0, (u, t, o) => u.TenantId == TenantId)
|
|
|
+ .WhereIf(!string.IsNullOrEmpty(Keyword), (u, t, o) => u.Name == Keyword||u.Phone.Contains(Keyword))
|
|
|
+ .Count(out var total)
|
|
|
+ .OrderByDescending((u, t, o) => u.Id)
|
|
|
+ .Page(input.CurrentPage, input.PageSize)
|
|
|
+ .ToListAsync((u, t, o)=>new PlatformUserListOutput() {
|
|
|
+ OrgName = o.Name,
|
|
|
+ Name =u.Name,
|
|
|
+ Phone=u.Phone,
|
|
|
+ WechatAccount=u.Phone,
|
|
|
+ TotalAmount= _userBillsRepository.Select.DisableGlobalFilter(FilterNames.Tenant).Where(m=>m.UserId==u.Id).Sum(m=>m.Commission),
|
|
|
+ CreatedTime=u.CreatedTime.Value
|
|
|
+ });
|
|
|
+
|
|
|
+ var data = new PageOutput<PlatformUserListOutput>()
|
|
|
+ {
|
|
|
+ List = list,
|
|
|
+ Total = total
|
|
|
+ };
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
+}
|