/// <summary> /// 根据第三方账号id获取绑定实体 /// </summary> /// <param name="userIdentity"></param> /// <param name="sellerId"></param> /// <returns></returns> public static AccountBinding GetAccountBindingByIdentity(string userIdentity, int sellerId) { var cmdText = string.Format("select * from AccountBinding where UserIdentity='{0}' and SellerId={1} and Status=0 limit 0,1;", userIdentity, sellerId); try { using (var conn = Utility.ObtainConn(Utility._gameDbConn)) { MySqlDataReader reader = MySqlHelper.ExecuteReader(conn, CommandType.Text, cmdText); if (reader.HasRows) { if (reader.Read()) { AccountBinding accountBinding = new AccountBinding(); accountBinding.Id = reader.GetInt32(0); accountBinding.UserIdentity = reader["UserIdentity"].ToString(); accountBinding.AccountType = (AccountType)reader["AccountType"]; return(accountBinding); } } } } catch (System.Exception ex) { throw; } return(null); }
/// <summary> /// 绑定第三方帐号提示信息 /// </summary> /// <param name="accountTypeKey"></param> /// <returns></returns> public ActionResult _BindThirdAccount(string accountTypeKey) { var accountBindingService = new AccountBindingService(); AccountType accountType = accountBindingService.GetAccountType(accountTypeKey); var currentUserId = UserContext.CurrentUser != null ? UserContext.CurrentUser.UserId : 0; AccountBinding accountBinding = accountBindingService.GetAccountBinding(currentUserId, accountType.AccountTypeKey); ViewData["isExpired"] = accountBinding != null && accountBinding.ExpiredDate.CompareTo(DateTime.UtcNow) < 0; return(View(accountType)); }
public async Task <InvokedResult> CreateAccountBinding(AccountBinding accountBinding) { var isBindIng = DbContext.Set <AccountBinding>().Any(a => a.WxAccount == accountBinding.WxAccount); if (isBindIng) { return(InvokedResult.SucceededResult); } DbContext.Set <AccountBinding>().AddOrUpdate(accountBinding); await DbContext.SaveChangesAsync(); return(InvokedResult.SucceededResult); }
/// <summary> /// 保存绑定账号 /// </summary> /// <param name="accountBinding"></param> /// <returns></returns> public static bool AddAccountBinding(AccountBinding accountBinding) { var cmdText = string.Empty; List <MySqlParameter> parameters = new List <MySqlParameter>(); cmdText = @"insert into AccountBinding(Id,UserIdentity,AccountType,SellerId) values (?Id,?UserIdentity,?AccountType,?SellerId)"; parameters.Add(new MySqlParameter("?Id", accountBinding.Id)); parameters.Add(new MySqlParameter("?UserIdentity", accountBinding.UserIdentity)); parameters.Add(new MySqlParameter("?AccountType", accountBinding.AccountType)); parameters.Add(new MySqlParameter("?SellerId", accountBinding.SellerId)); try { var num = MySqlHelper.ExecuteNonQuery(Utility._gameDbConn, CommandType.Text, cmdText, parameters.ToArray()); return(num > 0); } catch (System.Exception ex) { throw; } return(false); }