//1:支付宝;2:微信支付 public async Task OnGet(int num = 1, int _istype = 2) { await HttpContext.Session.LoadAsync(); UserId = HttpContext.Session.GetString(UserAccountBusiness.UserAccountSessionkey); var dbTable = userAccountBisness.userAccountAccessor.All <PayAPILog>(); var _userId = Guid.Parse(UserId); var sortedCollection = new SortedDictionary <string, string>(); var userInfo = await userAccountBisness.userAccountAccessor.OneAsync <UserAccountEntry>(x => x.Id == _userId, "InviteOrigin"); //是否存在未处理订单 var hasOrder = dbTable.Any(x => x.Statue != PayAPILogStatus.End || x.Statue != PayAPILogStatus.Error && x.UserAccountId == _userId); if (num < 30) { num = 30; } var orderId = Guid.NewGuid(); if (!hasOrder) { dbTable.Add(new PayAPILog { CreateTime = DateTime.Now, Id = orderId, PayNum = num, Statue = PayAPILogStatus.Create, UserAccountId = _userId }); await userAccountBisness.userAccountAccessor.SaveAsync(); } OrderId = orderId.ToString(); GoodsName = "趣漫画会员支付"; price = num; istype = _istype; if (userInfo?.InviteOrigin?.InviteKey == "lnn") { price = 0.01; } sortedCollection.Add("goodsname", GoodsName); sortedCollection.Add("price", price.ToString()); sortedCollection.Add("istype", _istype.ToString()); sortedCollection.Add("orderid", orderId.ToString()); sortedCollection.Add("orderuid", OrderUId); sortedCollection.Add("token", token); sortedCollection.Add("return_url", returnUrl); sortedCollection.Add("notify_url", notifyUrl); sortedCollection.Add("uid", uid); var stringKey = new StringBuilder(); foreach (var item in sortedCollection) { stringKey.Append(item.Value); } var tmpStr = stringKey.ToString(); Key = MD5Tool.GetMD532(tmpStr); }
public async Task RegisterUser(UserAccount userAccount) { var userModel = new UserAccount { Id = Guid.NewGuid(), CreateTime = DateTime.Now, Password = MD5Tool.GetMD532(userAccount.Password), UserName = userAccount.UserName }; await sugarClient.Insertable <UserAccount>(userModel).ExecuteCommandAsync(); var userCount = await sugarClient.Queryable <UserAccount>().CountAsync(); await sugarClient.Insertable <UserInfoEntry>(new UserInfoEntry { Id = Guid.NewGuid(), CreateTime = DateTime.Now, ArthorId = userModel.Id.ToString(), Avarta = "~/images/avarta.png", NicName = "用户" + userCount.ToString().PadLeft(4, '0') }).ExecuteCommandAsync(); }
public async Task <UserAccount> Login(UserAccount userAccount) { try { var userInfo = await sugarClient.Queryable <UserAccount>().FirstAsync(x => x.UserName == userAccount.UserName && x.Password == MD5Tool.GetMD532(userAccount.Password)); if (userInfo != null) { stateHub.SendState(new StateModel { Name = "userlogin", Value = userInfo.Id }); } return(userInfo); } catch (Exception exc) { return(null); } }