49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Zxd.Entity.UserCenter;
|
|
|
|
namespace Zxd.Crm.Domain
|
|
{
|
|
internal class UserInfoDomain : IUserInfoDomain
|
|
{
|
|
private readonly IRedisManager _redisManager;
|
|
private readonly IBaseRepository<UserCenterDbContext> _userCenterRepository;
|
|
|
|
public UserInfoDomain(IRedisManager redisManager,
|
|
IBaseRepository<UserCenterDbContext> userCenterRepository)
|
|
{
|
|
_redisManager = redisManager;
|
|
_userCenterRepository = userCenterRepository;
|
|
}
|
|
|
|
public async Task<UserInfoDto> GetUserInfo(string? appid, string? appuserid)
|
|
{
|
|
var userinfos = await _userCenterRepository.GetRepository<UserInfo>().Query()
|
|
.Where(x => x.Appid == appid && x.Appuserid == appuserid)
|
|
.ToListAsync();
|
|
if (userinfos == null || !userinfos.Any())
|
|
{
|
|
return new UserInfoDto();
|
|
}
|
|
var customerid = userinfos[0].Customerid;
|
|
userinfos = await _userCenterRepository.GetRepository<UserInfo>().Query()
|
|
.Where(x => x.Customerid == customerid)
|
|
.ToListAsync();
|
|
if (userinfos == null || !userinfos.Any())
|
|
{
|
|
return new UserInfoDto();
|
|
}
|
|
var data = new UserInfoDto
|
|
{
|
|
Resid = userinfos.Where(x => !string.IsNullOrEmpty(x.Resid)).Select(x => x.Resid).FirstOrDefault(),
|
|
Unionid = userinfos.Where(x => x.Appid == appid && x.Appuserid == appuserid).Select(x => x.Unionid).FirstOrDefault(),
|
|
};
|
|
data.Resid ??= data.Unionid;
|
|
return data;
|
|
}
|
|
}
|
|
}
|