public JsonResult LogOffUserById(string userId, string mobile) { int flag = 0; if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(mobile)) { Guid uId = new Guid(userId); try { var existYlh = false; var logoffResult = false; using (var ylhClient = new YLHUserAccountClient()) { var ylhUser = ylhClient.GetYLHUserInfoByMobile(mobile); ylhUser.ThrowIfException(true); if (ylhUser.Result != null && ylhUser.Result.UserId != Guid.Empty) { existYlh = true; } } if (existYlh) { flag = -1; } else { using (var client = new UserAccountClient()) { var logoff = client.LogOffUser(uId); logoff.ThrowIfException(true); logoffResult = logoff.Result; } if (logoffResult) { flag = 1; } using (var useraccoutClient = new UserAccountClient()) { var insertLog = useraccoutClient.LogUserAction(new UserLog { Action = UserActionEnum.LogOff, CreatedTime = DateTime.Now, UserId = uId, ChannelIn = nameof(ChannelIn.H5), Content = ThreadIdentity.Operator.Name + "在Setting站点内手动注销该用户" }); insertLog.ThrowIfException(true); } } } catch (Exception ex) { WebLog.LogException(ex); } } return(Json(flag)); }
public async Task <JsonResult> SubmitChangeBindingRequest(string oldNumber, string newNumber) { try { var fetchOrderResult = 0; using (var client = new UserAccountClient()) { var oldUser = await client.GetUserByMobileAsync(oldNumber); if (!oldUser.Success || oldUser.Result == null) { await client.LogChangeBindMobileActionAsync( new UserChangeBindMobileLog { SourceBindMobile = oldNumber, TargetBindMobile = newNumber, Operator = User.Identity.Name, OperateStatus = false, FailReason = "需解绑手机号不存在", CreatedTime = DateTime.Now }); return(Json(-1)); } var newUser = await client.GetUserByMobileAsync(newNumber); if (!newUser.Success || newUser.Result?.UserId == null || newUser.Result.UserId.Equals(Guid.Empty)) { return(Json(1)); } fetchOrderResult = DownloadAppManager.HasUnOrRecentlyCompletedOrder(newUser.Result.UserId.ToString("D")); if (fetchOrderResult < 0) { await client.LogChangeBindMobileActionAsync( new UserChangeBindMobileLog { SourceBindMobile = oldNumber, TargetBindMobile = newNumber, Operator = User.Identity.Name, OperateStatus = false, FailReason = fetchOrderResult == -4 ? "需绑定手机号有近期完成订单" : "需绑定手机号有未完成订单", CreatedTime = DateTime.Now }); return(Json(fetchOrderResult)); } } using (var client = new YLHUserAccountClient()) { var ylhUser = await client.GetYLHUserInfoByMobileAsync(newNumber); if (ylhUser.Success && ylhUser.Result?.UserId != null && !ylhUser.Result.UserId.Equals(Guid.Empty)) { fetchOrderResult = -2; } } if (fetchOrderResult == -2) { using (var client = new UserAccountClient()) { await client.LogChangeBindMobileActionAsync( new UserChangeBindMobileLog { SourceBindMobile = oldNumber, TargetBindMobile = newNumber, Operator = User.Identity.Name, OperateStatus = false, FailReason = "需绑定手机号已关联永隆行账户", CreatedTime = DateTime.Now }); } } return(Json(fetchOrderResult)); } catch (Exception ex) { WebLog.LogException(ex); return(Json(0)); } }