lingling
2025-03-17 a6325d1a9bd8d5a9b9c6424b3cb6d0c898309d30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using LifePayment.Application.Contracts;
using LifePayment.Domain;
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 LifePayment.Application
{
    public class AccountService : ApplicationService, IAccountService
    {
 
        private readonly IWxManager _wxManager;
        private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository;
 
 
        public AccountService(
               IWxManager wxManager,
               IRepository<LifePayUser, Guid> lifePayUserRepository
)
        {
            _wxManager = wxManager;
            _lifePayUserRepository = lifePayUserRepository;
        }
 
        #region 查询
 
        public async Task<WxMiniAppIndentityInfo> GetLifePayWxIndentity(string code)
        {
            var res = await _wxManager.GetWxOauth2AccessToken(code);
            var result = new WxMiniAppIndentityInfo
            {
                SessionKey = res.SessionKey,
                OpenId = res.OpenId,
                UnionId = res.UnionId
            };
 
            return result;
        }
 
        #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
 
     
    }
}