using LifePayment.Application.Contracts;
|
using LifePayment.Domain.Models;
|
using Microsoft.EntityFrameworkCore;
|
using System;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using Volo.Abp;
|
using Volo.Abp.Application.Services;
|
using Volo.Abp.Domain.Repositories;
|
using ZeroD.Util;
|
|
namespace HumanResourcesServices.Application
|
{
|
public class AccountService : ApplicationService, IAccountService
|
{
|
|
|
private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository;
|
|
|
public AccountService(
|
IRepository<LifePayUser, Guid> lifePayUserRepository
|
)
|
{
|
_lifePayUserRepository = lifePayUserRepository;
|
}
|
|
#region 查询
|
|
|
|
#endregion
|
|
#region 操作
|
|
|
|
#region life pay
|
|
/// <summary>
|
/// 手机验证码登录
|
/// 版本说明:使用验证码管理去校验和失效对应业务的验证码
|
/// </summary>
|
/// <param name="input"></param>
|
/// <returns></returns>
|
/// <exception cref="UserFriendlyException"></exception>
|
public async Task<Guid> LifePayPhoneMesssageCodeLogin(LifePayPhoneMesssageCodeLoginInput input)
|
{
|
//var vcodeType = VerificationCodeBusinessTypeEnum.LifePayPhoneMesssageCodeLogin;
|
|
//var checkResult = await _verificationCodeManager.CheckVerificationCodeByBusinessType(vcodeType,
|
// input.PhoneNumber,
|
// input.Code,
|
// true);
|
//CheckExtensions.IfTrueThrowUserFriendlyException(!checkResult,
|
// CustomeErrorMessage.SometingWrongOrSometing, "验证码", "已失效");
|
|
var lifeUser = await _lifePayUserRepository.Where(x => x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync();
|
if (lifeUser == null)
|
{
|
lifeUser = new LifePayUser()
|
{
|
Id = GuidGenerator.Create(),
|
PhoneNumber = input.PhoneNumber,
|
LastLoginTime = DateTime.Now
|
};
|
|
await _lifePayUserRepository.InsertAsync(lifeUser);
|
}
|
else
|
{
|
lifeUser.LastLoginTime = DateTime.Now;
|
await _lifePayUserRepository.UpdateAsync(lifeUser);
|
}
|
|
return lifeUser.Id;
|
}
|
|
#endregion
|
|
#endregion
|
|
|
}
|
}
|