public CardMessage(Golem g) { success = 1; headMessage = new HeadMessage(g.Head); bodyMessage = new BodyMessage(g.Chest); legMessage = new LegMessage(g.Legs); }
/// <summary> /// 代理登录 /// </summary> /// <param name="requestMsg">请求参数</param> /// <param name="head">报文头</param> /// <param name="client">当前连接客户端对象</param> /// <returns></returns> public string Login(string requestMsg, HeadMessage head, ClientOP client) { //ComunicationMsg sendMsg = new ComunicationMsg(); //ErrorMessage error = new ErrorMessage(); //HeadMessage sendHead = new HeadMessage(); try { sendHead.Method = head.Method; sendHead.Token = Guid.NewGuid().ToString().Replace("-", ""); AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); string responseMsg = ""; if (aSearch == null) { error.ErrMsg = "没有接收到登录账号或密码"; error.ErrNo = "0003"; } else { responseMsg = loginDal.Login(aSearch, head, out error); if (error.ErrNo == "0000") { foreach (KeyValuePair <string, ClientOP> kv in WsSocket.dic_Clients) { if (!string.IsNullOrEmpty(aSearch.A_UserID) && kv.Value.LogName == aSearch.A_UserID) { ErrorMessage outErr = new ErrorMessage(); outErr.ErrNo = "0000"; outErr.ErrMsg = "此账号已在别处登录"; HeadMessage outHead = new HeadMessage(); outHead.Method = "GoOut"; ComunicationMsg outSend = new ComunicationMsg(); outSend.Head = JSON.ToJSON(outHead); outSend.Error = JSON.ToJSON(outErr); WsSocket ws = new WsSocket(); ws.Send(JSON.ToJSON(outSend), kv.Value.cSocket, true); } } client.LogName = aSearch.A_UserID; client.Token = sendHead.Token; client.ConTime = DateTime.Now; //将成功登录的客户端添加到字典中 WsSocket.dic_Clients.AddOrUpdate(client.ConID, client, (key, oldv) => client); } } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { LoginAgent = string.IsNullOrEmpty(responseMsg) ? "{}" : responseMsg }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrNo = "0004"; error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(head); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取指定代理今日下单统计 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <param name="client"></param> /// <returns></returns> public string GetATodayBillCount(string requestMsg, HeadMessage head) { //ComunicationMsg sendMsg = new ComunicationMsg(); //ErrorMessage error = new ErrorMessage(); //HeadMessage sendHead = new HeadMessage(); sendHead.Method = head.Method; try { AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); string billCount = ""; if (aSearch == null) { error.ErrMsg = "没有接收到正确的参数"; error.ErrNo = "0003"; } else { billCount = loginDal.GetATodayBillCount(aSearch, head, out error); } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { ATodayBillCount = string.IsNullOrEmpty(billCount) ? "{}" : billCount }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { error.ErrNo = "0004"; error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(head); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取代理洗码费抽水结算统计 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetOddsWashF4Agent(StatisticsModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { string strSql = Common.SqlTemplateCommon.GetSql("GetACOdds4Agent"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到GetACOdds4Agent数据模板,请联系管理员"; return(null); } if (string.IsNullOrEmpty(model.A_ID)) { error.ErrMsg = "没有接收到请求参数"; return(null); } strSql = strSql.Replace("${AgentID}", model.A_ID); error.ErrMsg = "获取数据成功"; error.ErrNo = "0000"; return(JSON.ToJSON(new { JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable()) })); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AStatisticsDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 直属会员清零 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool ClearClnt4Agent(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.C_AID) || string.IsNullOrEmpty(head.LoginID)) { error.ErrMsg = "参数不完整"; return(false); } string strSql = SqlTemplateCommon.GetSql("A_SetAgentClientsClear"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_SetAgentClientsClear数据模板,请联系管理员"; return(false); } strSql = strSql.Replace("${CreateID}", head.LoginID); strSql = strSql.Replace("${AgentID}", model.C_AID); strSql = strSql.Replace("${IP}", head.Ip); strSql = strSql.Replace("${Address}", Common.CommonHelper.ipToAddr(head.Ip)); error.ErrNo = "0000"; error.ErrMsg = "直属会员清零成功"; Db.Context_SqlServer.FromSql(strSql).ToDataTable(); return(true); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(ClientListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(false); } }
/// <summary> /// 获取指定时段内指定代理下会员统计数据 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <returns></returns> public string GetAClientCount(string requestMsg, HeadMessage head) { try { sendHead.Method = head.Method; AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); string onlineList = ""; if (aSearch == null) { error.ErrMsg = "没有接收到正确的参数"; error.ErrNo = "0003"; } else { onlineList = loginDal.GetOnlineClntList(aSearch, head, out error); } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { AgentClntCount = string.IsNullOrEmpty(onlineList) ? "{}" : onlineList }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { error.ErrNo = "0004"; error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(head); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取指定代理下子账号列表数据 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <returns></returns> public string GetAgentSubs(string requestMsg, HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; try { AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); string responseMsg = ""; if (aSearch == null) { error.ErrMsg = "参数不完整"; } else { responseMsg = aSubDal.GetAgentSubs(aSearch, head, out error); } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = string.IsNullOrEmpty(responseMsg) ? "{}" : responseMsg; return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
public CardMessage() { success = 0; headMessage = null; bodyMessage = null; legMessage = null; }
/// <summary> /// 获取指定代理或指定会员所属代理统计数据 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetAorCAgentData(AgentSearchModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.A_ID)) { error.ErrNo = "0003"; error.ErrMsg = "没有接收到参数"; return(null); } string strSql = SqlTemplateCommon.GetSql("AgentData_New"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到AgentData_New数据模板,请联系管理员"; return(null); } string _msg; List <AgentSearchModel> aList; if (!string.IsNullOrEmpty(model.A_UserID)) { string sSql = ""; if (model.A_UserID.Length <= 7) { sSql = "select top 1 AgentID from T_Agent where LogName ='" + model.A_UserID + "'"; } else { sSql = "select top 1 AgentID from T_Client where LogName ='" + model.A_UserID + "'"; } string aid = Db.Context_SqlServer.FromSql(sSql).ToScalar <string>(); strSql = strSql.Replace("${AgentID}", aid); aList = CommonDAL.GetAgentTree(head.LoginID, "id", aid, out _msg); } else { strSql = strSql.Replace("${AgentID}", model.A_ID); aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.A_ID, out _msg); } if (aList == null || aList.Count <= 0) { error.ErrMsg = _msg; return(null); } error.ErrNo = "0000"; error.ErrMsg = "获取数据成功"; return(CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable())); } catch (Exception ex) { LogHelper.WriteLog(typeof(LoginDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 代理登录 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string Login(AgentSearchModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null) { error.ErrNo = "0003"; error.ErrMsg = "没有接收到登录账号或密码"; return(null); } string loginSql = SqlTemplateCommon.GetSql("A_AgentLogin"); if (string.IsNullOrEmpty(loginSql)) { error.ErrMsg = "服务端没有读取到A_AgentLogin数据模板,请联系管理员"; return(null); } loginSql = loginSql.Replace("${LogName}", model.A_UserID); loginSql = loginSql.Replace("${LogPwd}", model.A_Pwd); DataTable agentTable = Db.Context_SqlServer.FromSql(loginSql).ToDataTable(); #region 写登录日志 int userLength = model.A_UserID == null ? 0 : model.A_UserID.Length; T_LoginLog loginLog = new T_LoginLog(); loginLog.LogID = Guid.NewGuid().ToString().Replace("-", ""); loginLog.UserLevel = "代理"; loginLog.LoginIP = head.Ip; loginLog.LoginAddre = CommonHelper.ipToAddr(head.Ip); loginLog.LoginTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); loginLog.LoginUser = model.A_UserID; if (agentTable != null && agentTable.Rows.Count > 0) { error.ErrMsg = loginLog.ReMark = (userLength < 6 ? "子账号" : "代理") + model.A_UserID + "登录成功"; //error.ErrMsg = (userLength < 6 ? "子账号" : "代理") + model.A_UserID + "登录成功"; error.ErrNo = "0000"; } else { error.ErrMsg = loginLog.ReMark = "用户名或密码错误" + (userLength < 6 ? "子账号" : "代理") + model.A_UserID + "登录失败"; //error.ErrMsg = (userLength < 6 ? "子账号" : "代理") + model.A_UserID + "登录成功"; error.ErrNo = "0004"; } if (Db.Context_SqlServer.Insert <T_LoginLog>(loginLog) <= 0) { LogHelper.WriteErrLog(typeof(LoginDAL), "插入登录日志失败"); } #endregion return(CommonHelper.DataTableToJson(agentTable)); } catch (Exception ex) { LogHelper.WriteLog(typeof(LoginDAL), ex); error.ErrMsg = "代理登录异常:" + ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 子账号操作 /// </summary> /// <param name="requsetMsg"></param> /// <param name="head"></param> /// <returns></returns> public string ASubOperates(string requsetMsg, HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; try { AgentSub aSub = JSON.ToObject <AgentSub>(requsetMsg); bool opResult = false; string pId; if (aSub == null) { error.ErrMsg = "参数不完整"; } else if (CommonDAL.IsSubAgent(head.LoginID, out pId)) { head.LoginID = pId; error.ErrMsg = "子账号不具有此操作权限"; } else if (CommonDAL.IsYes(head.LoginID)) { error.ErrMsg = "登录代理未启用,不能进行此操作"; } else { switch (sendHead.Method) { case "InsertAgentSub": //新增子账号 opResult = aSubDal.InsertASub(aSub, head, out error); break; case "UpdateAgentSub": //修改子账号 case "UpdateSubState": //修改子账号状态 opResult = aSubDal.UpdateASub(aSub, head, out error); break; case "DeleteAgentSub": opResult = aSubDal.DeleteASub(aSub, head, out error); break; } } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { JsonData = JSON.ToJSON(new { Result = opResult }) }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取登陆日志 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetLoginLog(LogModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; if (string.IsNullOrEmpty(model.L_PAgent)) { error.ErrMsg = "没有接收到完整的请求参数"; return(null); } try { string strSql = Common.SqlTemplateCommon.GetSql("LoginLog"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到LoginLog数据模板,请联系管理员"; return(null); } string nowDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); strSql = strSql.Replace("${PageSize}", (model.PageSize ?? 20).ToString()); strSql = strSql.Replace("${CurePage}", (model.CurePage ?? 20).ToString()); strSql = strSql.Replace("${StartDate}", model.StartDate ?? nowDate); strSql = strSql.Replace("${EndDate}", model.EndDate ?? nowDate); string msg; List <AgentSearchModel> aList = CommonDAL.GetAgentTree(head.LoginID, "name", model.L_User, out msg); if (aList == null || aList.Count <= 0) { error.ErrMsg = msg; return(null); } string whereSql = ""; if (!string.IsNullOrEmpty(model.L_User)) { whereSql += " and (LoginUser ='******' or ParentAgent = '" + model.L_User + "')"; } if (!string.IsNullOrEmpty(model.L_PAgent)) { whereSql += " and (ParentAgent ='" + model.L_PAgent + "%' or ParentAgent = '" + head.LoginID + "')"; } strSql = strSql.Replace("${WhereSql}", whereSql); error.ErrMsg = "获取数据成功"; error.ErrNo = "0000"; return(JSON.ToJSON(new { JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable()) })); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LogDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
internal void SwitchDomain(MessageDomain newDomain) { if (this != HeadMessage) { HeadMessage.SwitchDomain(newDomain); } MessageDomain = newDomain; foreach (Message descendant in Descendants) { descendant.MessageDomain = newDomain; } }
/// <summary> /// 获取指定代理及它的直属代理列表数据 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <returns></returns> public string GetALists(string requestMsg, HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; try { AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); string responseMsg = ""; string pId; if (CommonDAL.IsSubAgent(head.LoginID, out pId)) { head.LoginID = pId;//如果当前登录代理是子账号则,将此子账号的所属代理ID赋值为当前登录代理ID } if (aSearch == null) { error.ErrMsg = "请求参数不完整"; error.ErrNo = "0003"; } else { switch (sendHead.Method) { case "GetAllAgents": responseMsg = agentListDal.GetALists(aSearch, head, out error); break; case "GetDeletedA": responseMsg = agentListDal.GetDeletedA(aSearch, head, out error); break; case "AgentMatchP": responseMsg = agentListDal.GetAPermission(aSearch, head, out error); break; } } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = string.IsNullOrEmpty(responseMsg) ? "{}" : responseMsg; return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取日志记录 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <returns></returns> public string GetLog(string requestMsg, HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; string responseMsg = ""; string pId; try { if (CommonDAL.IsSubAgent(head.LoginID, out pId)) { head.LoginID = pId;//如果当前登录代理是子账号则,将此子账号的所属代理ID赋值为当前登录代理ID } LogModel sModel = JSON.ToObject <LogModel>(requestMsg); if (sModel == null) { error.ErrMsg = "没有接收到正确的请求参数"; } else { switch (sendHead.Method) { case "GetTransactions": //获取交易记录数据 responseMsg = cDal.GetTransactions(sModel, head, out error); break; case "GetLoginLog": //获取登录日志 responseMsg = lDal.GetLoginLog(sModel, head, out error); break; case "GetOperationLog": //获取操作日志 responseMsg = lDal.GetOperationLog(sModel, head, out error); break; } } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = string.IsNullOrEmpty(responseMsg) ? "{}" : responseMsg; return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 修改指定会员密码 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool UpdateClntPwd(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.C_ID) || string.IsNullOrEmpty(model.C_Pwd) || string.IsNullOrEmpty(head.LoginID)) { error.ErrMsg = "参数不完整,不能修改会员密码"; return(false); } if (CommonDAL.IsH5Clnt(model.C_ID)) { string h5Mger = Db.Context_SqlServer.FromSql("select [value] from T_Cfg where Name ='H5_ManageID'").ToScalar <string>(); if (!string.Equals(h5Mger.Trim(), head.LoginID.Trim(), StringComparison.OrdinalIgnoreCase)) { error.ErrMsg = "当前登录代理不能修改H5会员的密码!"; return(false); } } string strSql = SqlTemplateCommon.GetSql("A_SaveClientModifyPassword"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_SaveClientModifyPassword数据模板,请联系管理员"; return(false); } strSql = strSql.Replace("${ClientID}", model.C_ID); strSql = strSql.Replace("${Pwd}", model.C_Pwd); Db.Context_SqlServer.FromSql(strSql).ToDataSet(); T_OperationLog opLog = new T_OperationLog(); opLog.LogID = Guid.NewGuid().ToString().Replace("-", ""); opLog.LogInfo = DateTime.Now.ToString() + "代理" + head.Account + "修改了下级代理" + model.C_UserID + "的登录密码"; opLog.LogTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); opLog.OpID = head.LoginID; opLog.LogType = "修改代理登录密码"; if (Db.Context_SqlServer.Insert <T_OperationLog>(opLog) <= 0) { Common.LogHelper.WriteErrLog(typeof(AgentListDAL), "插入" + head.Account + "修改会员密码日志失败"); } error.ErrMsg = "会员密码修改成功"; error.ErrNo = "0000"; return(true); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(ClientListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(false); } }
/// <summary> /// 获取指定时段内指定代理下会员统计数据 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetAClntCount(AgentSearchModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.A_ID)) { error.ErrNo = "0003"; error.ErrMsg = "没有接收到参数"; return(null); } string strSql = SqlTemplateCommon.GetSql("A_AgentClientCount"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_AgentClientCount数据模板,请联系管理员"; return(null); } string _msg; List <AgentSearchModel> aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.A_ID, out _msg); if (aList == null || aList.Count <= 0) { error.ErrMsg = _msg; return(null); } if (string.IsNullOrEmpty(model.StartDate)) { model.StartDate = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } if (string.IsNullOrEmpty(model.EndDate)) { model.EndDate = model.StartDate; } strSql = strSql.Replace("${AgentID}", model.A_ID); strSql = strSql.Replace("${StartDate}", model.StartDate); strSql = strSql.Replace("${EndDate}", model.EndDate); error.ErrNo = "0000"; error.ErrMsg = "获取数据成功"; return(CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable())); } catch (Exception ex) { LogHelper.WriteLog(typeof(LoginDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 删除子账号 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool DeleteASub(AgentSub model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (string.IsNullOrEmpty(model.AS_ID)) { error.ErrMsg = "参数不完整"; return(false); } Where <T_AgentSub> whereSql = new Where <T_AgentSub>(); whereSql.And(o => o.AgentSubID == model.AS_ID); bool res = AgentSubDAL.Delete(whereSql) > 0; if (res) { error.ErrMsg = "删除子账号成功"; error.ErrNo = "0000"; } else { error.ErrMsg = "删除子账号失败"; } T_OperationLog opLog = new T_OperationLog(); opLog.LogID = Guid.NewGuid().ToString().Replace("-", ""); opLog.LogTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); opLog.LogType = "删除子账号"; opLog.OpID = head.LoginID; opLog.LogInfo = error.ErrMsg; if (Db.Context_SqlServer.Insert <T_OperationLog>(opLog) <= 0) { Common.LogHelper.WriteErrLog(typeof(AgentListDAL), "插入" + head.Account + "删除子账号日志失败"); } return(res); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AgentSubDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(false); } }
/// <summary> /// 获取指定代理下的子账号列表数据 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetAgentSubs(AgentSearchModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.A_ID)) { error.ErrMsg = "参数不完整";//"服务端没有读取到ClntOdds数据模板,请联系管理员"; error.ErrNo = "0004"; return(null); } string strSql = Common.SqlTemplateCommon.GetSql("A_GetAgentSubByAgentID"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_GetAgentSubByAgentID数据模板,请联系管理员"; return(null); } strSql = strSql.Replace("${AgentID}", model.A_ID); string msg; List <AgentSearchModel> aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.A_ID, out msg); if (aList == null || aList.Count <= 0) { error.ErrMsg = msg; return(null); } error.ErrMsg = "获取数据成功"; error.ErrNo = "0000"; return(JSON.ToJSON(new { JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable()) })); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AgentSubDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 获取会员标准赔率 /// </summary> /// <param name="head"></param> /// <returns></returns> public string GetClntOdds(HeadMessage head) { sendHead.Method = head.Method; error.ErrNo = "0004"; try { string responseMsg = clntDal.GetClntOdds(out error); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = string.IsNullOrEmpty(responseMsg) ? "{}" : responseMsg; return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取公告 /// </summary> /// <returns></returns> public string GetPubInfo(HeadMessage head) { sendHead.Method = head.Method; error.ErrNo = "0004"; try { string pubInfo = loginDal.GetPubInfo(out error); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { JsonData = (string.IsNullOrEmpty(pubInfo)) ? "{}" : pubInfo }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取指定代理今日下单统计 /// </summary> /// <param name="model"></param> /// <param name="error"></param> /// <returns></returns> public string GetATodayBillCount(AgentSearchModel model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (model == null || string.IsNullOrEmpty(model.A_ID)) { error.ErrNo = "0003"; error.ErrMsg = "没有接收到参数"; return(null); } string strSql = SqlTemplateCommon.GetSql("A_GetAgentBetData_Current_New"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_GetAgentBetData_Current_New数据模板,请联系管理员"; return(null); } //判断当前获取的数据是否在当前登录代理分支中 string _msg; List <AgentSearchModel> aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.A_ID, out _msg); if (aList == null || aList.Count <= 0) { error.ErrMsg = _msg; return(null); } strSql = strSql.Replace("${AgentID}", model.A_ID); error.ErrNo = "0000"; error.ErrMsg = "获取数据成功"; return(CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable())); } catch (Exception ex) { LogHelper.WriteLog(typeof(LoginDAL), ex); error.ErrMsg = "获取代理今日下单统计异常:" + ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 登出 /// </summary> /// <param name="requestMsg"></param> /// <param name="head"></param> /// <param name="client"></param> /// <returns></returns> public string SignOut(string requestMsg, HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; try { AgentSearchModel aSearch = JSON.ToObject <AgentSearchModel>(requestMsg); if (aSearch == null || string.IsNullOrEmpty(aSearch.A_UserID)) { error.ErrMsg = "参数不完整"; error.ErrNo = "0003"; } foreach (KeyValuePair <string, ClientOP> kv in WsSocket.dic_Clients) { if (kv.Value.LogName == aSearch.A_UserID) { error.ErrNo = "0000"; error.ErrMsg = aSearch.A_UserID + "登出成功"; ClientOP op; WsSocket.dic_Clients.TryRemove(kv.Key, out op);//将连接移除字典 break; } } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 获取指定代理下逻辑删除会员 /// IsHide = "TRUE" /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetDeletedC(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { string strSql = SqlTemplateCommon.GetSql("deletedClnt"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到deletedClnt数据模板,请联系管理员"; return(null); } strSql = strSql.Replace("${AgentID}", model.C_AID); strSql = strSql.Replace("${PageSize}", (model.PageSize ?? 20).ToString()); strSql = strSql.Replace("${CurePage}", (model.CurePage ?? 1).ToString()); List <AgentSearchModel> aList = new List <AgentSearchModel>(); string messge; aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.C_AID, out messge); if (aList == null || aList.Count <= 0) { error.ErrMsg = messge; return(null); } error.ErrNo = "0000"; error.ErrMsg = "获取数据成功"; return(JSON.ToJSON(new { JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(strSql).ToDataTable()) })); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AgentListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(null); } }
/// <summary> /// 生成代理登录名称 /// </summary> /// <param name="head"></param> /// <returns></returns> public string GetALoginID(HeadMessage head) { sendHead.Method = head.Method ?? ""; error.ErrNo = "0004"; try { string userId = ""; switch (sendHead.Method) { case "GetAgentLogName": userId = agentListDal.GetLoginID(6, out error); break; case "GetClientLogName": userId = agentListDal.GetLoginID(8, out error); break; case "GetSubLogName": userId = agentListDal.GetLoginID(5, out error); break; } sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Error = JSON.ToJSON(error); sendMsg.Reponse = JSON.ToJSON(new { JsonData = JSON.ToJSON(new { UserID = userId }) }); return(JSON.ToJSON(sendMsg)); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(LoginBLL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); sendMsg.Head = JSON.ToJSON(sendHead); sendMsg.Reponse = "{}"; sendMsg.Error = JSON.ToJSON(error); return(JSON.ToJSON(sendMsg)); } }
/// <summary> /// 初步处理接收到的报文 /// </summary> /// <param name="msg"></param> /// <param name="isZ">标记应答报文是否需要Gzip压缩</param> /// <returns></returns> public string StartAnalyze(string msg, ClientOP client, out bool isZ) { ComunicationMsg cmMsg = JSON.ToObject <ComunicationMsg>(msg); ComunicationMsg cMsg = new ComunicationMsg(); HeadMessage hMsg = new HeadMessage(); ErrorMessage error = new ErrorMessage(); RequestMsg reqMsg = new RequestMsg(); bool isGoupRetMsg = true; //是否需要组装应答报文 string methodReturn = ""; bool hasRequestParameters = false; //是否包含请求参数 bool isLoginAuth = false; //是否通过了登录验证 string retMsg = ""; string response = "{}"; isZ = true; HeadMessage head; if (cmMsg != null) { try { reqMsg = cmMsg.Request != null?JSON.ToObject <RequestMsg>(cmMsg.Request) : reqMsg; //判断应答报文是否需要压缩 if (reqMsg != null && !string.IsNullOrEmpty(reqMsg.IsZ) && reqMsg.IsZ == "N") { isZ = false; } //判断是否包含请求参数 if (reqMsg != null && !string.IsNullOrEmpty(reqMsg.RequestParams)) { hasRequestParameters = true; } else { error.ErrNo = "0003"; error.ErrMsg = "请求参数不完整。"; } //解码报文头 head = JSON.ToObject <HeadMessage>(cmMsg.Head); if (head != null) { if (string.IsNullOrEmpty(head.Account) || string.IsNullOrEmpty(head.Token) || string.IsNullOrEmpty(head.LoginID)) { isLoginAuth = false; error.ErrMsg += " 没有通过登录验证,所以无权获取数据。"; error.ErrNo = "0004"; } else { foreach (KeyValuePair <string, ClientOP> kv in WsSocket.dic_Clients) { if (head.Account == kv.Value.LogName && head.Token == kv.Value.Token) { isLoginAuth = true; break; } } if (!isLoginAuth) { error.ErrMsg += " 没有通过登录验证,所以无权获取数据。"; error.ErrNo = "0004"; } } string method = head.Method ?? ""; head.Ip = client.IP; hMsg.Method = method; switch (method) { case "HeartBeat": //心跳 error.ErrNo = "0000"; error.ErrMsg = "连接正常"; break; case "SignOut": //登出 if (hasRequestParameters) { isGoupRetMsg = false; methodReturn = loginBll.SignOut(reqMsg.RequestParams, head); } break; #region 登录部分 case "Login": //登录 if (hasRequestParameters) { isGoupRetMsg = false; methodReturn = loginBll.LoginLogic(reqMsg.RequestParams, head, client); } break; case "GetSelfCenterInfo": //获取指定代理今日下单统计 case "CenterPlayList": //获取指定代理会员在线情况 case "GetLoginACount": //获取指定时段内指定代理统计数据 case "AgentClientCount": //获取指定时段内指定代理下会员统计数据 case "GetAorCAgentData": //获取指定代理或指定会员所属代理统计数据 case "GetAListByID": //根据代理ID获取指定代理数据 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = loginBll.LoginLogic(reqMsg.RequestParams, head, client); } break; case "GetPubInfo": //获取公告 if (isLoginAuth) { isGoupRetMsg = false; methodReturn = loginBll.GetPubInfo(head); } break; #endregion #region 代理列表部分 case "GetAllAgents": //获取指定代理及它的直属代理列表数据 case "GetDeletedA": //获取指定代理下逻辑删除的代理列表数据 case "AgentMatchP": //获取指定代理相关权限 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = aListBll.GetALists(reqMsg.RequestParams, head); } break; case "InsertAgent": //新增代理 case "UpdateAgent": //修改代理 case "AgentModifyPwd": //修改下级代理密码 case "AgentSelfModifyPwd": //修改登录代理密码 case "AgentPoint": //代理上下分 case "AgentClear": //代理清零 case "SettleOdds4Agent": //结算代理抽水 case "SettleWashF4Agent": //结算代理洗码费 case "DeleteAgent": //删除代理 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = aListBll.InsertAgent(reqMsg.RequestParams, head); } break; case "GetAgentLogName": //获取代理登录名称 case "GetClientLogName": //获取会员登录名称 case "GetSubLogName": //获取子账号登录名称 if (isLoginAuth) { isGoupRetMsg = false; methodReturn = aListBll.GetALoginID(head); } break; #endregion #region 会员列表部分 case "GetClntList_Invite": //获取会员列表数据 case "GetDeletedC": //获取逻辑删除的会员 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = clntListBll.GetClntList(reqMsg.RequestParams, head); } break; case "GetClntOdds": //获取会员标准赔率 if (isLoginAuth) { isGoupRetMsg = false; methodReturn = clntListBll.GetClntOdds(head); } break; case "InsertClient": //新增会员 case "AllClientZero": //直属会员清零 case "ClientZero": //会员清零 case "ClearCard4Clnt": //会员清卡 case "UpdateClient": //修改会员 case "ClientModifyPwd": //修改会员密码 case "ClientPoint": //会员上下分 case "SettleWashF4Clnt": //结算会员洗码费 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = clntListBll.ClntOperates(reqMsg.RequestParams, head); } break; #endregion #region 子账号部分 case "GetAgentSubs": //获取指定代理下子账号列表数据 aSubBll.GetAgentSubs(reqMsg.RequestParams, head); break; case "InsertAgentSub": //新增子账号 case "UpdateAgentSub": //修改子账号 case "UpdateSubState": //修改子账号状态 case "DeleteAgentSub": //删除子账号 aSubBll.ASubOperates(reqMsg.RequestParams, head); break; #endregion #region 获取报表数据部分 case "GetAStatistics": //获取代理统计数据 case "GetADayStatistics": //获取代理每日统计数据 case "GetClntStatistics": //获取会员统计 case "GetClntDayStatistics": //获取会员每日统计数据 case "GetClntBetBills": //获取会员下注明细 case "GetPointDetail": //获取上下分明细 case "GetTableResult": //获取游戏结果数据 case "PromotionA_Clnt4A": //获取指定代理下的会员推广统计数据 增量 case "PromotionA_AllClnt4A": //获取指定代理下的会员推广统计数据 存量 case "H5ClntPointDetail": //H5会员第三方上分明细 case "H5ClntPointSum_A": //获取指定代理下所有H5会员第三方上分明细 case "RedEnvelopeSum": //查询指定代理自己及直属代理及直属会员下红包发放合计 case "RedEnvelopeDetail": //查询指定会员下红包发送明细 case "GetSettleAccounts": //获取结算记录 case "GetWashF4Clnt": //获取会员的洗码费统计 case "GetOddsWashF4Agent": //获取代理抽水及洗码费统计 if (hasRequestParameters && isLoginAuth) { methodReturn = sBll.GetStatisticsData(reqMsg.RequestParams, head); } break; #endregion #region 获取日志记录 case "GetTransactions": //获取交易记录 case "GetLoginLog": //获取登录日志 case "GetOperationLog": //获取操作日志 if (hasRequestParameters && isLoginAuth) { isGoupRetMsg = false; methodReturn = sBll.GetLog(reqMsg.RequestParams, head); } break; #endregion default: error.ErrNo = "0005"; error.ErrMsg = "没有对应的接口:" + method; break; } } else { error.ErrNo = "0003"; error.ErrMsg = "报文格式错误,没有收到正确的报文头"; } } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AnalyzeData), ex); error.ErrNo = "0001"; error.ErrMsg = "系统内部错误:" + ex.Message.Replace("\r", "").Replace("\n", ""); } } cMsg.Head = JSON.ToJSON(hMsg); cMsg.Reponse = response; cMsg.Request = "{}"; cMsg.Error = JSON.ToJSON(error); retMsg = isGoupRetMsg ? JSON.ToJSON(cMsg) : methodReturn; return(retMsg); }
/// <summary> /// 结算会员洗码费 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool SettleWashF(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; DbTrans trans = null; try { string strSql = Common.SqlTemplateCommon.GetSql("SetWashFlag"); string opSql = Common.SqlTemplateCommon.GetSql("SettleWashF"); if (string.IsNullOrEmpty(strSql) || string.IsNullOrEmpty(opSql)) { error.ErrMsg = "服务端没有读取到SetWashFlag数据模板,请联系管理员"; return(false); } string billID = Guid.NewGuid().ToString().Replace("-", ""); if (string.IsNullOrEmpty(model.C_ID) || string.IsNullOrEmpty(model.StartDate) || string.IsNullOrEmpty(model.EndDate)) { error.ErrMsg = "没有接收到正确的请求参数"; return(false); } strSql = strSql.Replace("${BillID}", billID); strSql = strSql.Replace("${ClientID}", model.C_ID); strSql = strSql.Replace("${SettleDate}", model.StartDate); strSql = strSql.Replace("${EndDate}", model.StartDate); opSql = opSql.Replace("${CreateID}", head.LoginID); opSql = opSql.Replace("${ClientID}", model.C_ID); opSql = opSql.Replace("${BillID}", billID); opSql = opSql.Replace("${IP}", head.Ip); opSql = opSql.Replace("${Address}", Common.CommonHelper.ipToAddr(head.Ip)); opSql = opSql.Replace("${Operator}", head.Account); opSql = opSql.Replace("${StartDate}", model.StartDate); opSql = opSql.Replace("${EndDate}", model.EndDate); trans = Db.Context_SqlServer.BeginTransaction(); SettleModel settle = trans.FromSql(strSql).ToFirst <SettleModel>(); if (settle != null) { opSql = opSql.Replace("${Counts}", settle.C_Counts.ToString()); opSql = opSql.Replace("${Point}", ((int)settle.C_Amount).ToString()); opSql = opSql.Replace("${WashRate}", settle.C_WashR); opSql = opSql.Replace("${WashSum}", settle.C_WashS.ToString()); error.ErrMsg = "洗码费结算成功"; trans.FromSql(opSql).ToDataSet(); trans.Commit(); return(true); } else { error.ErrMsg = "没有可结算的洗码费"; return(false); } } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(ClientListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); trans.Rollback(); return(false); } finally { if (trans != null) { trans.Close(); trans.Dispose(); } } }
/// <summary> /// 会员上下分 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool ClientPoint(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (string.IsNullOrEmpty(model.C_ID) || model.C_IsAdd == null || model.C_Point == null || string.IsNullOrEmpty(head.LoginID) || string.IsNullOrEmpty(model.C_AID) || string.IsNullOrEmpty(model.C_UserID)) { error.ErrMsg = "参数不完整"; return(false); } bool isH5 = false; string h5MgrId = ""; if (CommonDAL.IsH5Clnt(model.C_ID)) { isH5 = true; h5MgrId = CommonDAL.GetH5MgrID(); if (model.C_IsAdd == true && !string.Equals(h5MgrId.Trim(), head.LoginID.Trim(), StringComparison.OrdinalIgnoreCase)) { error.ErrMsg = "当前代理不能对H5会员下分"; return(false); } } if (model.C_Point <= 0) { error.ErrMsg = "上下分点数不在正确范围"; return(false); } string strSql = SqlTemplateCommon.GetSql("A_SaveClientPoint"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_SaveClientPoint数据模板,请联系管理员"; return(false); } bool hasMatchp = new AgentListDAL().PHasAnyMatchP(head.LoginID, model.C_AID); if (hasMatchp && (string.IsNullOrEmpty(model.C_LevelPoint) || model.C_LevelPoint != "1"))//上级代理链有配分权限,只能登录代理上下分 { error.ErrMsg = "上级代理链有配分权限,只能登录代理上下分"; return(false); } string ownId = (model.C_LevelPoint != null && model.C_LevelPoint == "1") ? model.C_AID : head.LoginID; ownId = (isH5 && model.C_IsAdd == true) ? CommonDAL.GetH5LenderID() : ownId;//如果是H5会员下分则设置收分代理ID为分源代理ID strSql = strSql.Replace("${AgentID}", ownId); strSql = strSql.Replace("${CreateID}", head.LoginID); strSql = strSql.Replace("${Point}", model.C_Point.ToString()); //上下分点数 strSql = strSql.Replace("${IsAdd}", model.C_IsAdd.ToString().ToUpper()); //标记上下分 true=下分 false=上分 strSql = strSql.Replace("${ClientID}", model.C_ID); //登录代理ID strSql = strSql.Replace("${IP}", head.Ip); strSql = strSql.Replace("${Address}", Common.CommonHelper.ipToAddr(head.Ip)); strSql = strSql.Replace("${IPLocal}", Common.CommonHelper.ipToAddr(head.Ip)); string opType = "", memo = ""; if (model.C_LevelPoint != null && model.C_LevelPoint == "1") { memo = head.Account + "进行上级代理" + ((model.C_IsAdd == true) ? "下分" : "上分"); opType = (model.C_IsAdd == true) ? "会员上级代理下分" : "会员上级代理下分"; } else { memo = head.Account + "进行登录代理" + ((model.C_IsAdd == true) ? "下分" : "上分"); opType = (model.C_IsAdd == true) ? "会员登录代理下分" : "会员登录代理下分"; } if (isH5 && model.C_IsAdd == true) { memo = head.Account + "对H5会员下分"; opType = "H5会员下分"; } strSql = strSql.Replace("${OpType}", opType);//登录代理ID strSql = strSql.Replace("${Memo}", memo); Db.Context_SqlServer.FromSql(strSql).ToDataSet(); error.ErrMsg = model.C_IsAdd == true ? "会员下分成功" : "会员上分成功"; error.ErrNo = "0000"; return(true); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(ClientListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(false); } }
/// <summary> /// 修改会员 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public bool UpdateClnt(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { if (string.IsNullOrEmpty(model.C_ID)) { error.ErrMsg = "必须传递需要修改会员的ID"; return(false); } string strSql = SqlTemplateCommon.GetSql("A_UpdateT_Client"); if (string.IsNullOrEmpty(strSql)) { error.ErrMsg = "服务端没有读取到A_UpdateT_Client数据模板,请联系管理员"; return(false); } strSql = strSql.Replace("${ClientID}", model.C_ID); strSql = strSql.Replace("${LogName}", model.C_UserID); StringBuilder clntBuilder = new StringBuilder(); StringBuilder authBuilder = new StringBuilder(); StringBuilder clntExBuilder = new StringBuilder(); T_OperationLog opLog = new T_OperationLog(); StringBuilder logDesc = new StringBuilder(); logDesc.Append(DateTime.Now.ToString() + head.Account + "修改了会员" + model.C_UserID + " 以下信息:"); string pSql = "select a.AgentID A_ID,a.WashRate A_WashR,a.DrawRate A_DrawR,a.IntoRate A_IntoR,[dbo].[Base64Decode](a.F_3) A_Perm,a.Max_Z A_MX_Z,a.Min_Z A_MN_Z from T_Agent a ,T_CLient b where b.ClientID ='" + model.C_ID + "' and a.AgentID = b.AgentID"; AgentSearchModel pAgent = Db.Context_SqlServer.FromSql(pSql).ToFirst <AgentSearchModel>(); if (model.C_WashR != null && model.C_WashR > pAgent.A_WashR) { error.ErrMsg = "洗码率超出父级代理范围"; return(false); } if (pAgent.A_DrawR == 0 && model.C_DrawR != 0) { error.ErrMsg = "父级代理的和局率为0,所以此会员的和局率只能为0"; return(false); } if (pAgent.A_DrawR > 0 && model.C_DrawR <= 0) { error.ErrMsg = "父级代理的和局率不为0,所以此会员的和局率不能为0"; return(false); } if (model.C_DrawR != null && model.C_DrawR > pAgent.A_DrawR) { error.ErrMsg = "和局率超出父级代理范围"; return(false); } if (model.C_MX_Z != null && model.C_MX_Z > pAgent.A_MX_Z) { error.ErrMsg = "最大限红超出父级代理范围"; return(false); } if (model.C_MN_Z != null && model.C_MN_Z < pAgent.A_MN_Z) { error.ErrMsg = "最小限红超出父级范围"; return(false); } #region 组装修改会员Sql clntBuilder.Append("UPDATE T_Client set "); clntBuilder.Append(" ClientID ='" + model.C_ID + "'"); if (!string.IsNullOrEmpty(model.C_UserID)) { clntBuilder.Append(",LogName='" + model.C_UserID + "'"); } if (!string.IsNullOrEmpty(model.C_Name)) { clntBuilder.Append(",ClientName='" + model.C_Name + "'"); } if (model.C_MN_Z != null) { clntBuilder.Append(",Min_Z =" + model.C_MN_Z); clntBuilder.Append(",Min_X =" + model.C_MN_Z); clntBuilder.Append(",Min_XD =" + model.C_MN_Z); clntBuilder.Append(",Min_ZD =" + model.C_MN_Z); clntBuilder.Append(",Min_H =" + model.C_MN_Z); logDesc.Append("把最小限红改为了" + model.C_MN_Z + ";"); } if (model.C_MX_Z != null) { clntBuilder.Append(",Max_Z =" + model.C_MX_Z); clntBuilder.Append(",Max_X =" + model.C_MX_Z); clntBuilder.Append(",Max_XD =" + model.C_MX_Z / 10); clntBuilder.Append(",Max_ZD =" + model.C_MX_Z / 10); clntBuilder.Append(",Max_H =" + model.C_MX_Z / 10); logDesc.Append("把最大限红改为了" + model.C_MX_Z + ";"); } if (!string.IsNullOrEmpty(model.C_F2)) { clntBuilder.Append(",F_2 ='" + model.C_F2 + "'"); } if (model.C_WashT != null) { clntBuilder.Append(",WashType ='" + ((model.C_WashT) == true ? "s" : "d") + "'"); logDesc.Append("把洗码类型修改为了" + ((model.C_WashT == true) ? "双边" : "单边") + ";"); } if (model.C_WashR != null) { clntBuilder.Append(",WashRate =" + model.C_WashR); logDesc.Append("把洗码率修改为" + model.C_WashR + ";"); } if (model.C_DrawR != null) { clntBuilder.Append(",DrawRate =" + model.C_DrawR); logDesc.Append("把和局率修改为" + model.C_DrawR + ";"); } if (!string.IsNullOrEmpty(model.C_State)) { clntBuilder.Append(",State ='" + model.C_State + "'"); logDesc.Append("把状态修改为" + model.C_State + ";"); } clntBuilder.Append(" WHERE ClientID = '" + model.C_ID + "'"); strSql = strSql.Replace("${updateClient}", clntBuilder.ToString()); #endregion #region 组装修改会员限红sql authBuilder.Append("Update T_Authority set Priority='C'"); if (model.C_MX_Z != null && model.C_MX_Z >= 0) { authBuilder.Append(",Max_Z=" + model.C_MX_Z); authBuilder.Append(",Max_X=" + model.C_MX_Z); authBuilder.Append(",Max_H=" + model.C_MX_Z / 10); authBuilder.Append(",Max_XD=" + model.C_MX_Z / 10); authBuilder.Append(",Max_ZD=" + model.C_MX_Z / 10); } if (model.C_MN_Z != null && model.C_MN_Z >= 0) { authBuilder.Append(",Min_Z=" + model.C_MN_Z); authBuilder.Append(",Min_X=" + model.C_MN_Z); authBuilder.Append(",Min_H=" + model.C_MN_Z); authBuilder.Append(",Min_ZD=" + model.C_MN_Z); authBuilder.Append(",Min_XD=" + model.C_MN_Z); } authBuilder.Append(" WHERE [Priority] = 'C' and ClientID = '" + model.C_ID + "' "); strSql = strSql.Replace("${upAuthority}", authBuilder.ToString()); #endregion #region 组装修改会员赔率及显示隐藏洗码 clntExBuilder.Append("update T_ClientEx set "); clntExBuilder.Append(" ClientID ='" + model.C_ID + "'"); if (model.C_HdShow != null) { clntExBuilder.Append(",ClientDataShow=" + ((model.C_HdShow == true) ? 2 : 1)); } if (pAgent != null && !string.IsNullOrEmpty(pAgent.A_Perm) && pAgent.A_Perm.IndexOf("\"SetPV\":true") != -1) //需要所属代理有抽水权限才能修改赔率 { if (model.C_ODF != null) { clntExBuilder.Append(",Odds_Fu_Client=" + model.C_ODF); } if (model.C_ODH != null) { clntExBuilder.Append(",Odds_H_Client=" + model.C_ODH); } if (model.C_ODHe != null) { clntExBuilder.Append(",Odds_He_Client=" + model.C_ODHe); } if (model.C_ODL != null) { clntExBuilder.Append(",Odds_Long_Client=" + model.C_ODL); } if (model.C_ODX != null) { clntExBuilder.Append(",Odds_X_Client=" + model.C_ODX); } if (model.C_ODXD != null) { clntExBuilder.Append(",Odds_XD_Client=" + model.C_ODXD); } if (model.C_ODZ != null) { clntExBuilder.Append(",Odds_Z_Client=" + model.C_ODZ); } if (model.C_ODZD != null) { clntExBuilder.Append(",Odds_ZD_Client=" + model.C_ODZD); } } clntExBuilder.Append(" where ClientID ='" + model.C_ID + "'"); strSql = strSql.Replace("${upClientEx}", clntExBuilder.ToString()); #endregion strSql = strSql.Replace("##'", ""); strSql = strSql.Replace("##\"", ""); strSql = strSql.Replace("'##", ""); strSql = strSql.Replace("\"##", ""); Db.Context_SqlServer.FromSql(strSql).ToDataSet(); opLog.LogID = Guid.NewGuid().ToString().Replace("-", ""); opLog.LogTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); opLog.LogType = "修改会员"; opLog.OpID = head.LoginID; opLog.LogInfo = logDesc.ToString(); if (Db.Context_SqlServer.Insert <T_OperationLog>(opLog) <= 0) { Common.LogHelper.WriteErrLog(typeof(AgentListDAL), "插入" + head.Account + "修改会员日志失败"); } error.ErrMsg = "修改会员成功"; error.ErrNo = "0000"; return(true); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(ClientListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); return(false); } }
/// <summary> /// 获取会员列表数据 /// </summary> /// <param name="model"></param> /// <param name="head"></param> /// <param name="error"></param> /// <returns></returns> public string GetCLists(ClientSearc model, HeadMessage head, out ErrorMessage error) { error = new ErrorMessage(); error.ErrNo = "0004"; try { string sqlStr = SqlTemplateCommon.GetSql("GetClntList_Invite"); string curStr = SqlTemplateCommon.GetSql("CurrentClnt"); if (string.IsNullOrEmpty(sqlStr) || string.IsNullOrEmpty(curStr)) { error.ErrMsg = "服务端没有读取到GetClntList_Invite/CurrentClnt数据模板,请联系管理员"; return(null); } sqlStr = sqlStr.Replace("${pageSize}", (model.PageSize ?? 20).ToString()); sqlStr = sqlStr.Replace("${curePage}", (model.CurePage ?? 1).ToString()); string whereSql = string.Empty; if (!string.IsNullOrEmpty(model.C_Type))//如果不传则默认取H5h和常规会员 { whereSql += " and C_Type ='" + model.C_Type + "'"; } if (!string.IsNullOrEmpty(model.C_InType))//默认查询常规会员和代理直接邀请的会员 { switch (model.C_InType) { case "A": //只过滤指定代理直接邀请会员 whereSql += " and C_InType ='A'"; break; case "C": //只过滤指定代理下会员邀请会员 whereSql += " and C_InType ='C'"; break; case "O": //只过滤常规会员 whereSql += " and C_InType ='O'"; break; case "AC": //只过滤H5会员 whereSql += " and (C_InType ='A' or C_InType ='C')"; break; case "OC": //只过滤H5会员 whereSql += " and (C_InType ='O' or C_InType ='C')"; break; case "AOC": //只过滤H5会员 whereSql += " and (C_InType ='O' or C_InType ='C' or C_InType ='A')"; break; default: whereSql += " and (C_InType ='A' or C_InType ='O')"; break; } } else { if (string.IsNullOrEmpty(model.C_UserID)) { whereSql += " and (C_InType ='A' or C_InType ='O')"; } else { whereSql += " and (C_InType ='A' or C_InType ='O' or C_InType ='C')"; } } sqlStr = sqlStr.Replace("${whereSql}", whereSql); List <AgentSearchModel> aList; string msg; if (string.IsNullOrEmpty(model.C_UserID)) { sqlStr = sqlStr.Replace("${AgentID}", model.C_AID); curStr = curStr.Replace("${AgentID}", model.C_AID); aList = CommonDAL.GetAgentTree(head.LoginID, "id", model.C_AID, out msg); } else { //string id = Db.Context_SqlServer.FromSql("select ClientID from T_Client where LogName ='" + model.C_UserID + "'").ToScalar<string>(); //string aId = Db.Context_SqlServer.FromSql("select AgentID from T_Client where LogName ='" + model.C_UserID + "'").ToScalar<string>(); T_Client clnt = ClientListDAL.First(c => c.LogName == model.C_UserID); curStr = curStr.Replace("${AgentID}", clnt.ClientID); sqlStr = sqlStr.Replace("${AgentID}", clnt.ClientID); aList = CommonDAL.GetAgentTree(head.LoginID, model.C_UserID, out msg); if (aList == null) { aList = CommonDAL.GetAgentTree(head.LoginID, "id", clnt.AgentID, out msg); } } if (aList == null || aList.Count <= 0) { error.ErrMsg = msg; return(null); } error.ErrNo = "0000"; error.ErrMsg = "获取数据成功"; return(JSON.ToJSON(new { JsonData = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(sqlStr).ToDataTable()), AgentNav = JSON.ToJSON(aList), CurrentClnt = Common.CommonHelper.DataTableToJson(Db.Context_SqlServer.FromSql(curStr).ToDataTable()) })); } catch (Exception ex) { Common.LogHelper.WriteLog(typeof(AgentListDAL), ex); error.ErrMsg = ex.Message.Replace("\r", "").Replace("\n", ""); error.ErrNo = "0004"; return(null); } }