public PartialViewResult LogOffUserByMobileInfo(string mobileNumber) { User info = new Service.UserAccount.Models.User(); if (!string.IsNullOrWhiteSpace(mobileNumber)) { try { using (var client = new UserAccountClient()) { var result = client.GetUserByMobile(mobileNumber); result.ThrowIfException(true); if (result.Success && result.Result != null) { info = result.Result; } } } catch (Exception ex) { WebLog.LogException(ex); } } return(PartialView(info)); }
/// <summary> /// 查询或者创建用户 /// </summary> /// <param name="mobile"></param> /// <param name="userName"></param> /// <param name="nickName"></param> /// <param name="headUrl"></param> /// <returns></returns> public static User GetOrCreateUser(string mobile, string userName = null, string nickName = null, string headUrl = null) { User user = null; if (!string.IsNullOrEmpty(mobile)) { using (var client = new UserAccountClient()) { var result = client.GetUserByMobile(mobile); result.ThrowIfException(true); user = result.Result; if (user == null) { var createResult = client.CreateUserRequest( new CreateUserRequest { MobileNumber = mobile, Profile = new UserProfile { UserName = userName, NickName = nickName, HeadUrl = headUrl }, ChannelIn = nameof(ChannelIn.None), UserCategoryIn = nameof(UserCategory.Tuhu), }); createResult.ThrowIfException(true); user = createResult.Result; } } } return(user); }
/// <summary> /// 根据手机号查询用户信息 /// </summary> /// <param name="phone"></param> /// <returns></returns> public static User GetUserByMobile(string phone) { using (var client = new UserAccountClient()) { var serviceResult = client.GetUserByMobile(phone); serviceResult.ThrowIfException(true); return(serviceResult.Result); } }
public static User GetUserByMobile(string mobile) { User result = null; using (var client = new UserAccountClient()) { var serviceResult = client.GetUserByMobile(mobile); serviceResult.ThrowIfException(true); result = serviceResult.Result; return(result); } }
/// <summary> /// 查询或者创建用户 /// </summary> /// <param name="mobile"></param> /// <param name="userName"></param> /// <param name="nickName"></param> /// <param name="headUrl"></param> /// <returns></returns> public static async Task <User> GetOrCreateUser(string mobile, string userName = null, string nickName = null, string headUrl = null) { User user = null; try { if (!string.IsNullOrEmpty(mobile)) { using (var client = new UserAccountClient()) { var result = client.GetUserByMobile(mobile); user = result.Result; } if (user == null) { using (var client = new UserAccountClient()) { var createResult = client.CreateUserRequest( new CreateUserRequest { MobileNumber = mobile, Profile = new UserProfile { UserName = userName, NickName = nickName, HeadUrl = headUrl }, ChannelIn = nameof(ChannelIn.ThirdPartyDiversion), UserCategoryIn = nameof(UserCategory.Tuhu), }); createResult.ThrowIfException(true); user = createResult.Result; } } } } catch (Exception ex) { Logger.Warn("创建用户失败", ex); } return(user); }
public async Task TaskMethod() { try { var list = new List <UserApplyActivityModel>(); var noRepeatList = new List <string>(); using (var client = new ActivityClient()) { var result = await client.GetUserApplyActivityRangeByScoreAsync(); if (result.Success) { using (var activityClient = new ActivityClient()) { foreach (var item in result.Result) { if (await CheckApplyUserCountAsync(item.ActivityId)) { //检查用户手机号、车牌号、驾驶证号是否已经使用 var isExist = await activityClient.CheckUserApplyActivityInfoIsExistAsync(item.ActivityId, item.Mobile, item.CarNum, item.DriverNum); if (isExist.Success && !isExist.Result) { User user = null; using (var userClient = new UserAccountClient()) { try { var userResult = userClient.GetUserByMobile(item.Mobile); userResult.ThrowIfException(true); user = userResult.Result; if (user == null) { var createResult = userClient.CreateUserRequest( new CreateUserRequest { MobileNumber = item.Mobile, Profile = new UserProfile { UserName = item.UserName, NickName = null, HeadUrl = null }, ChannelIn = nameof(ChannelIn.None), UserCategoryIn = nameof(UserCategory.Tuhu), }); createResult.ThrowIfException(true); user = createResult.Result; } } catch (Exception ex) { Logger.Error("用户创建失败。" + ex.Message, ex); } } //添加到待审核集合中 if (!noRepeatList.Contains(item.CarNum) && !noRepeatList.Contains(item.Mobile) && !noRepeatList.Contains(item.DriverNum)) { list.Add(item); noRepeatList.AddRange(new[] { item.Mobile, item.CarNum, item.DriverNum }); } //从SortedSet中移除 var removeResult = await client .RemoveOneUserApplyActivitySortedSetCacheAsync(item); if (!removeResult.Success) { Logger.Error(removeResult.ErrorMessage, removeResult.Exception); } item.UserId = user.UserId; } else { Logger.Error(isExist.ErrorMessage, isExist.Exception); } } } } } } if (list.Any()) { await WashCarActivityMinHangAutoAuditAsync(list); } list.Clear(); noRepeatList.Clear(); } catch (Exception ex) { Logger.Error(ex.Message, ex); } }