You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.7 KiB
110 lines
4.7 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Znyc.Cloudcar.Admin.Commons.Entitys;
|
|
using Znyc.Cloudcar.Admin.Commons.Enums;
|
|
using Znyc.Cloudcar.Admin.Commons.Extensions;
|
|
using Znyc.Cloudcar.Admin.Commons.Mapping;
|
|
using Znyc.Cloudcar.Admin.Commons.Pages;
|
|
using Znyc.Cloudcar.Admin.Commons.Services;
|
|
using Znyc.Cloudcar.Admin.Security.Dtos;
|
|
using Znyc.Cloudcar.Admin.Security.Entitys;
|
|
using Znyc.Cloudcar.Admin.Security.IRepositories;
|
|
using Znyc.Cloudcar.Admin.Security.IServices;
|
|
|
|
namespace Znyc.Cloudcar.Admin.Security.Services
|
|
{
|
|
public class CallFeedbackService : BaseService<CallFeedbackEntity, CallFeedbackOutputDto, long>, ICallFeedbackService
|
|
{
|
|
private readonly ICallFeedbackRepository _callFeedbackRepository;
|
|
private readonly IUserRepository _userRepository;
|
|
private readonly IWxUnifyUserRepository _wxUnifyUserRepository;
|
|
|
|
public CallFeedbackService(ICallFeedbackRepository repository,
|
|
IUserRepository userRepository,
|
|
IWxUnifyUserRepository wxUnifyUserRepository
|
|
) : base(repository)
|
|
{
|
|
_callFeedbackRepository = repository;
|
|
_userRepository = userRepository;
|
|
_wxUnifyUserRepository = wxUnifyUserRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通话评价分页查询
|
|
/// </summary>
|
|
/// <param name="search">查询条件</param>
|
|
/// <returns></returns>
|
|
public async Task<PageResult<CallFeedbackOutputDto>> FindWithPagerSearchAsync(SearchCallFeedbackModel search)
|
|
{
|
|
bool order = search.Order == "asc" ? false : true;
|
|
string where = GetDataPrivilege(false);
|
|
if (search.Filter.ProductId > 0)
|
|
{
|
|
@where += $" and ProductId={search.Filter.ProductId}";
|
|
}
|
|
if (search.Filter.ProductType > 0)
|
|
{
|
|
@where += $" and ProductType={search.Filter.ProductType}";
|
|
}
|
|
if (search.Filter.State > 0)
|
|
{
|
|
@where += $" and State={search.Filter.State}";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(search.StartTime))
|
|
{
|
|
@where += $" and CreatedTime >='{search.StartTime} 00:00:00'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(search.EndTime))
|
|
{
|
|
@where += $" and CreatedTime <='{search.EndTime} 23:59:59'";
|
|
}
|
|
PagerInfo pagerInfo = new PagerInfo
|
|
{
|
|
CurrenetPageIndex = search.CurrenetPageIndex,
|
|
PageSize = search.PageSize
|
|
};
|
|
List<CallFeedbackOutputDto> list = (await repository.FindWithPagerAsync(where, pagerInfo, search.Sort, order)).MapTo<CallFeedbackOutputDto>();
|
|
List<long> uIds = list.Select(x => x.UserId).ToList();
|
|
List<UserOutputDto> usersList = (await _userRepository.GetListWhereAsync($" `State`=10 and Id in ({string.Join(", ", uIds.ToArray())})")).MapTo<UserOutputDto>();
|
|
//云平台统一用户信息
|
|
List<string> uninIds = usersList.Select(x => x.UnionId).ToList();
|
|
List<WxUnifyUserOutputDto> wxUnifyUsers = (await _wxUnifyUserRepository.GetListWhereAsync($" IsDeleted=0 AND UnionId IN ('{string.Join("','", uninIds.ToArray())}')"))
|
|
.MapTo<WxUnifyUserOutputDto>();
|
|
foreach (var item in list)
|
|
{
|
|
var user = usersList.Find(x => x.Id == item.UserId);
|
|
item.Phone = user.Phone;
|
|
item.NickName = wxUnifyUsers.Find(x => x.UnionId == user.UnionId).NickName;
|
|
item.WxAvatarUrl = wxUnifyUsers.Find(x => x.UnionId == user.UnionId).AvatarUrl;
|
|
item.Content = EnumExtensions
|
|
.ParseEnum(typeof(CallFeedbackStatusEnum), item.State.ToString()).ToDescription();
|
|
}
|
|
|
|
PageResult<CallFeedbackOutputDto> pageResult = new PageResult<CallFeedbackOutputDto>
|
|
{
|
|
CurrentPage = pagerInfo.CurrenetPageIndex,
|
|
Items = list,
|
|
ItemsPerPage = pagerInfo.PageSize,
|
|
TotalItems = pagerInfo.RecordCount
|
|
};
|
|
return pageResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改通话反馈已读
|
|
/// </summary>
|
|
/// <param name="productId"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public async Task<CommonResult> UpdateIsReadAsync(long userId, long productId, int productType)
|
|
{
|
|
CommonResult result = new CommonResult();
|
|
await _callFeedbackRepository.UpdateIsReadAsync(userId, productId, productType);
|
|
result.Success = true;
|
|
return result;
|
|
}
|
|
}
|
|
}
|