123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using Lottomat.Application.Entity;
- using Lottomat.Application.IService;
- using Lottomat.Data;
- using Lottomat.Data.Repository;
- using Lottomat.Util;
- using Lottomat.Util.Extension;
- using System;
- using System.Data.Common;
- using System.Linq;
- using Lottomat.Application.Code;
- using Lottomat.Utils.Date;
- using Lottomat.Utils.Web;
- namespace Lottomat.Application.Service
- {
-
-
-
-
-
-
-
- public class AccountService : RepositoryFactory<AccountEntity>, IAccountService
- {
-
-
-
-
-
-
- public AccountEntity CheckLogin(string mobileCode, string password)
- {
- var expression = LinqExtensions.True<AccountEntity>();
- expression = expression.And(t => t.MobileCode == mobileCode);
- expression = expression.And(t => t.DeleteMark == (int)DeleteMarkEnum.NotDelete);
- return this.BaseRepository("AccountDb").FindEntity(expression);
- }
-
-
-
-
-
- public string GetSecurityCode(string mobileCode)
- {
- if (!this.BaseRepository("AccountDb").IQueryable(t => t.MobileCode == mobileCode).Any())
- {
-
- if (this.BaseRepository("AccountDb").IQueryable(t => t.IPAddress == NetHelper.Ip).Count() >= 5)
- {
- throw new Exception("获取验证码失败。");
- }
- AccountEntity accountEntity = new AccountEntity
- {
- AccountId = CommonHelper.GetGuid().ToString(),
- MobileCode = mobileCode,
- SecurityCode = CommonHelper.RndNum(6),
- IPAddress = NetHelper.Ip,
- CreateDate = DateTimeHelper.Now,
- EnabledMark = -1
- };
- this.BaseRepository("AccountDb").Insert(accountEntity);
- return accountEntity.SecurityCode;
- }
- else
- {
- throw new Exception("手机号已被注册过了。");
- }
- }
-
-
-
-
- public void Register(AccountEntity accountEntity)
- {
- var data = this.BaseRepository("AccountDb").FindEntity(t => t.MobileCode == accountEntity.MobileCode);
- if (data == null && data.SecurityCode == accountEntity.SecurityCode)
- {
- throw new Exception("短信验证码不正确。");
- }
- if (data.RegisterTime != null)
- {
- throw new Exception("手机号已被注册过了。");
- }
- accountEntity.AccountId = data.AccountId;
- accountEntity.RegisterTime = DateTimeHelper.Now;
- accountEntity.ExpireTime = DateTimeHelper.Now.AddMonths(1);
- accountEntity.DeleteMark = (int)DeleteMarkEnum.NotDelete;
- accountEntity.EnabledMark = 1;
- this.BaseRepository("AccountDb").Update(accountEntity);
- }
-
-
-
-
-
-
-
- public void LoginLimit(string platform, string account, string iPAddress, string iPAddressName)
- {
-
- DbParameter[] parameter =
- {
- DbParameters.CreateDbParameter("@IPAddress",iPAddress),
- DbParameters.CreateDbParameter("@IPAddressName",iPAddressName),
- DbParameters.CreateDbParameter("@Account",account),
- DbParameters.CreateDbParameter("@Platform",platform),
- };
- int IsOk = this.BaseRepository("AccountDb").ExecuteByProc("PROC_verify_IPAddress", parameter);
- }
- }
- }
|