示例#1
0
        /// <summary>
        /// 修改代理信息接口
        /// </summary>
        /// <param name="address"></param>
        /// <param name="phone"></param>
        /// <param name="qq"></param>
        private static void UpdateAgentInfo(string address, string phone, string qq)
        {
            if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(phone) ||
                string.IsNullOrEmpty(qq))
            {
                _ajv.code = (int)ApiCode.VertyParamErrorCode;
                _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode),
                                          " address、phone、qq 缺失");
                return;
            }
            if (!Validate.IsMobileCode(phone))
            {
                _ajv.msg = "抱歉,联系电话格式不正确";
                return;
            }
            Entity.Agent.AgentInfo uiAgent = new Entity.Agent.AgentInfo()
            {
                UserID         = UserId,
                ContactAddress = address,
                ContactPhone   = phone,
                QQAccount      = qq
            };
            int uiResult = FacadeManage.aideAgentFacade.UpdateAgentInfo(uiAgent);

            if (uiResult > 0)
            {
                _ajv.SetValidDataValue(true);
                _ajv.msg = "修改代理信息成功";
            }
            else
            {
                _ajv.msg = "修改代理信息失败";
            }
        }
示例#2
0
        /// <summary>
        /// 代理账号+安全密码认证 换取 Token
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="pass"></param>
        private static void AgentAuth(string mobile, string pass)
        {
            if (string.IsNullOrEmpty(mobile) || string.IsNullOrEmpty(pass))
            {
                _ajv.code = (int)ApiCode.VertyParamErrorCode;
                _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode),
                                          " mobile、pass 缺失");
                return;
            }
            Message msg = FacadeManage.aideAgentFacade.AgentMobileLogin(mobile, pass, GameRequest.GetUserIP());

            if (msg.Success)
            {
                Entity.Agent.AgentInfo info = msg.EntityList[0] as Entity.Agent.AgentInfo;
                if (info != null)
                {
                    string token =
                        Fetch.SHA256Encrypt(
                            $"<{info.UserID}>,<{info.AgentID}>,<{info.AgentDomain}>,<{Fetch.ConvertDateTimeToUnix(DateTime.Now)}>");

                    FacadeManage.aideAgentFacade.SaveAgentToken(info, token);

                    _ajv.SetValidDataValue(true);
                    _ajv.SetDataItem("token", token);
                    _ajv.SetDataItem("expirtAt", DateTime.Now.AddDays(1));
                    return;
                }
            }

            _ajv.code = (int)ApiCode.Unauthorized;
            _ajv.msg  = EnumHelper.GetDesc(ApiCode.Unauthorized);
        }
示例#3
0
        /// <summary>
        /// 添加下级代理接口
        /// </summary>
        /// <param name="gameId"></param>
        /// <param name="agentDomain"></param>
        /// <param name="compllation"></param>
        /// <param name="note"></param>
        /// <param name="address"></param>
        /// <param name="phone"></param>
        /// <param name="qq"></param>
        /// <param name="wcNickName"></param>
        private static void AddBelowAgent(int gameId, string agentDomain, string compllation,
                                          string address, string phone, string note)
        {
            if (gameId <= 0)
            {
                _ajv.msg = "抱歉,添加代理游戏ID不能为空";
                return;
            }
            if (string.IsNullOrEmpty(compllation))
            {
                _ajv.msg = "抱歉,真实姓名不能为空";
                return;
            }
            if (string.IsNullOrEmpty(phone))
            {
                _ajv.msg = "抱歉,联系电话不能为空";
                return;
            }
            if (!Validate.IsMobileCode(phone))
            {
                _ajv.msg = "抱歉,联系电话格式不正确";
                return;
            }
            if (string.IsNullOrEmpty(agentDomain))
            {
                _ajv.msg = "抱歉,代理域名不能为空";
                return;
            }

            AccountsInfo account = FacadeManage.aideAccountsFacade.GetAccountsInfoByGameID(gameId);

            if (account == null)
            {
                _ajv.msg = "抱歉,添加代理异常,请稍后重试";
                return;
            }

            Entity.Agent.AgentInfo info = new Entity.Agent.AgentInfo
            {
                AgentDomain    = agentDomain,
                AgentNote      = note,
                Compellation   = compllation,
                ContactAddress = address,
                ContactPhone   = phone,
                WCNickName     = account.NickName
            };

            Message msg = FacadeManage.aideAgentFacade.AddAgent(UserId, info, gameId);

            if (msg.Success)
            {
                _ajv.SetValidDataValue(true);
                _ajv.msg = "添加下级代理成功";
            }
            else
            {
                _ajv.msg = msg.Content;
            }
        }
示例#4
0
        /// <summary>
        /// 获取代理信息汇总
        /// </summary>
        private static void GetAgentInfo()
        {
            Entity.Agent.SystemStatusInfo diamondSave =
                FacadeManage.aideAgentFacade.GetSystemStatusInfo(AppConfig.AgentConfig.ReceiveDiamondSave.ToString());
            Entity.Agent.SystemStatusInfo goldSave =
                FacadeManage.aideAgentFacade.GetSystemStatusInfo(AppConfig.AgentConfig.ReceiveGoldSave.ToString());

            AccountsInfo userInfo = FacadeManage.aideAccountsFacade.GetAccountsInfoByUserID(UserId);

            //AccountsFace face = FacadeManage.aideAccountsFacade.GetAccountsFace(userInfo.CustomID);
            Entity.Agent.AgentInfo agentInfo =
                FacadeManage.aideAgentFacade.GetAgentInfo(AgentId, UserId);

            DataStruct.AgentInfo info = new DataStruct.AgentInfo
            {
                //来源用户表
                UserID  = userInfo.UserID,
                GameID  = userInfo.GameID,
                AgentID = AgentId,
                //FaceUrl = "",
                NickName = userInfo.NickName,
                //来源代理表
                AgentLevel     = agentInfo.AgentLevel == 1 ? "一级代理" : (agentInfo.AgentLevel == 2 ? "二级代理" : "三级代理"),
                AgentDomain    = agentInfo.AgentDomain,
                Compellation   = agentInfo.Compellation,
                ContactAddress = agentInfo.ContactAddress,
                ContactPhone   = agentInfo.ContactPhone,
                WCNickName     = agentInfo.WCNickName,
                QQAccount      = agentInfo.QQAccount,
                //来源各种统计
                BelowAgent        = FacadeManage.aideAgentFacade.GetBelowAgentsAgent(AgentId),
                BelowUser         = FacadeManage.aideAgentFacade.GetBelowAgentsUser(AgentId),
                DiamondAward      = agentInfo.DiamondAward,
                GoldAward         = agentInfo.GoldAward,
                TotalDiamondAward = FacadeManage.aideAgentFacade.GetTotalDiamondAward(UserId),
                TotalGoldAward    = FacadeManage.aideAgentFacade.GetTotalGoldAward(UserId),
                BelowAgentsUser   = FacadeManage.aideAgentFacade.GetBelowAgentsAllUser(AgentId),
                BelowAgentsAgent  = FacadeManage.aideAgentFacade.GetBelowAgentsAllAgent(AgentId) - 1,
                IsHasPassword     = !agentInfo.Password.Equals(""),
                Diamond           = FacadeManage.aideTreasureFacade.GetUserWealth(UserId).Diamond
            };
            _ajv.SetValidDataValue(true);
            _ajv.SetDataItem("info", info);
            _ajv.SetDataItem("DiamondSave", diamondSave?.StatusValue ?? 0);
            _ajv.SetDataItem("GoldSave", goldSave?.StatusValue ?? 0);
        }
示例#5
0
        protected void btnAuth_OnClick(object sender, EventArgs e)
        {
            //if (AppConfig.Mode == AppConfig.CodeMode.Dev)
            //{
            #region Version 2.0 Dev

            string  mobile = CtrlHelper.GetText(txtGameid);
            string  pass   = Utility.MD5(CtrlHelper.GetText(txtPassword));
            Message msg    =
                FacadeManage.aideAgentFacade.AgentMobileLogin(mobile, pass, GameRequest.GetUserIP());
            if (msg.Success)
            {
                Entity.Agent.AgentInfo info = msg.EntityList[0] as Entity.Agent.AgentInfo;
                if (info != null)
                {
                    string token =
                        Fetch.SHA256Encrypt(
                            $"<{info.UserID}>,<{info.AgentID}>,<{info.AgentDomain}>,<{Fetch.ConvertDateTimeToUnix(DateTime.Now)}>");

                    FacadeManage.aideAgentFacade.SaveAgentToken(info, token);
                    HttpRuntime.Cache.Insert("token", token);
                    Response.Redirect($"v2/#/");
                    return;
                }
            }
            else
            {
                Response.Write(
                    $"<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">{msg.Content}</div>");
                return;
            }

            Response.Write(
                "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">账号或密码错误。</div>");

            #endregion
            //}
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (AppConfig.Mode != AppConfig.CodeMode.Dev)
                {
                    if (Fetch.isWeChat(Request))
                    {
                        //演示和通用平台
                        if (string.IsNullOrEmpty(wxparam))
                        {
//                        string domain = "http://" + (string.IsNullOrEmpty(AppConfig.FrontSiteDomain)
//                                            ? GameRequest.GetCurrentFullHost()
//                                            : AppConfig.FrontSiteDomain);
                            Response.Redirect(AppConfig.AuthorizeURL + "?url=http://" +
                                              GameRequest.GetCurrentFullHost() + "/Card/Index.aspx?code=1001");
                        }
                        else
                        {
                            WxUser wu = Fetch.GetWxUser(wxparam);
                            if (wu == null)
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">参数异常,请稍后尝试。</div>");
                                return;
                            }
                            Message msg =
                                FacadeManage.aideAgentFacade.AgentWXLogin(wu.unionid, GameRequest.GetUserIP());
                            if (msg.Success)
                            {
                                Entity.Agent.AgentInfo ui = msg.EntityList[0] as Entity.Agent.AgentInfo;
                                if (ui != null)
                                {
                                    //for Version 2.0 跳转
                                    string token = Fetch.SHA256Encrypt(
                                        $"<{ui.UserID}>,<{ui.AgentID}>,<{ui.AgentDomain}>,<{Fetch.ConvertDateTimeToUnix(DateTime.Now)}>");
                                    FacadeManage.aideAgentFacade.SaveAgentToken(ui, token);
                                    HttpRuntime.Cache.Insert("token", token);
                                    Response.Redirect($"v2/#/");
                                }
                                else
                                {
                                    Response.Write(
                                        "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">登录失败,请稍后尝试</div>");
                                }
                            }
                            else
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">" +
                                    wu.nickname + "," +
                                    msg.Content + "</div>");
                            }
                        }
                    }
                    else
                    {
                        //if (version == 1)
                        //    // for Version 1.0 非微信提示
                        //    Response.Write(
                        //        "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">请在微信内打开</div>");
                        //else if (version == 2)
                        // for Version 2.0 跳转到手机+安全密码登录页面
                        if (!string.IsNullOrEmpty(Gameid))
                        {
                            AccountsInfo user = FacadeManage.aideAccountsFacade.GetAccountsInfoByGameID(Convert.ToInt32(Gameid));
                            if (user == null)
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">抱歉,您为非代理玩家。</div>");
                                return;
                            }

                            if (user.AgentID > 0)
                            {
                                AgentInfo agent = FacadeManage.aideAgentFacade.GetAgentInfo(user.AgentID, 0);
                                if (agent != null && string.IsNullOrEmpty(agent.Password))
                                {
                                    Response.Redirect("setPassword.aspx?gameid=" + Gameid);
                                }
                                else
                                {
                                    Response.Redirect("v2/#/Login?gameid=" + Gameid);
                                }
                            }
                            else
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">抱歉,您为非代理玩家。</div>");
                                return;
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(Gameid))
                {
                    AccountsInfo user = FacadeManage.aideAccountsFacade.GetAccountsInfoByGameID(Convert.ToInt32(Gameid));
                    if (user.AgentID > 0)
                    {
                        AgentInfo agent = FacadeManage.aideAgentFacade.GetAgentInfo(user.AgentID, 0);
                        if (agent != null && string.IsNullOrEmpty(agent.Password))
                        {
                            Response.Redirect("setPassword.aspx?gameid=" + Gameid);
                        }
                        else
                        {
                            txtGameid.Text = Gameid;
                        }
                    }
                }
            }
        }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action  = GameRequest.GetString("action").ToLower();
            int    version = GameRequest.GetInt("version", 2);

            #region Version 2.0 Router

            if (version == 2)
            {
                try
                {
                    //不需要认证的action
                    string[] unNeedAuthActions = { "agentauth", "gettoken" };

                    string token      = GameRequest.GetString("token");
                    string gameid     = GameRequest.GetString("gameid");
                    string authheader = context.Request.Headers["Authorization"];
                    _ajv = new AjaxJsonValid();
                    _ajv.SetDataItem("apiVersion", 20180316);
                    if (!string.IsNullOrEmpty(gameid))
                    {
                        unNeedAuthActions[1] = "setpassword";
                    }

                    //排除不需要认证后判断认证是否正确
                    if (!unNeedAuthActions.Contains(action))
                    {
                        if (string.IsNullOrEmpty(token) &&
                            (string.IsNullOrEmpty(authheader) || !authheader.Contains("Bearer")))
                        {
                            _ajv.code = (int)ApiCode.VertyParamErrorCode;
                            _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " token 缺失");
                            context.Response.Write(_ajv.SerializeToJson());
                            return;
                        }
                        string         authToken = !string.IsNullOrEmpty(token) ? token : authheader.Replace("Bearer ", "");
                        AgentTokenInfo authInfo  = FacadeManage.aideAgentFacade.VerifyAgentToken(authToken);
                        if (authInfo == null)
                        {
                            _ajv.code = (int)ApiCode.Unauthorized;
                            _ajv.msg  = EnumHelper.GetDesc(ApiCode.Unauthorized);
                            context.Response.Write(_ajv.SerializeToJson());
                            return;
                        }
                        //认证完成后 设置到全局
                        _agentInfo = FacadeManage.aideAgentFacade.GetAgentInfo(authInfo.AgentID, authInfo.UserID);
                    }

                    switch (action)
                    {
                    case "agentauth":     //1.0
                        AgentAuth(GameRequest.GetString("gameid"), GameRequest.GetString("pass"));
                        break;

                    case "getinfo":     //1.1
                        GetAgentInfo();
                        break;

                    case "gettoken":     //1.0
                        Gettoken();
                        break;

                    case "getnicknamebygameid":     //1.2
                        GetNickNameByGameID(GameRequest.GetInt("gameid", 0));
                        break;

                    case "getrecord":     //1.3
                        GetRecord(GameRequest.GetString("type"));
                        break;

                    case "getbelowlist":     //1.4
                        GetBelowList(GameRequest.GetString("type"), GameRequest.GetString("query"));
                        break;

                    case "getawardinfo":     //1.5
                        GetAwardInfo();
                        break;

                    case "presentscore":     //1.6
                        TakeScoreORDiamond(GameRequest.GetInt("gameid", 0), GameRequest.GetString("password"),
                                           GameRequest.GetInt("count", 0), Convert.ToByte(GameRequest.GetInt("type", 0)));
                        break;

                    case "presentdiamondorscore":
                        PresentDiamondOrScore(GameRequest.GetInt("gameid", 0), GameRequest.GetString("password"),
                                              GameRequest.GetInt("count", 0), Convert.ToByte(GameRequest.GetInt("type", 0)));
                        break;

                    case "setpassword":     //1.7
                        SetSafePass(GameRequest.GetString("password"));
                        break;

                    case "updatepassword":     //1.8
                        UpdateSafePass(GameRequest.GetString("oldPassword"), GameRequest.GetString("newPassword"));
                        break;

                    case "updateinfo":     //1.9
                        UpdateAgentInfo(GameRequest.GetString("address"), GameRequest.GetString("phone"),
                                        GameRequest.GetString("qq"));
                        break;

                    case "addagent":     //1.10
                        AddBelowAgent(GameRequest.GetInt("gameid", 0), GameRequest.GetString("agentDomain"),
                                      GameRequest.GetString("compellation"),
                                      "", GameRequest.GetString("phone"),
                                      ""
                                      );
                        break;

                    default:
                        _ajv.code = (int)ApiCode.VertyParamErrorCode;
                        _ajv.msg  = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode),
                                                  " action 对应接口不存在");
                        break;
                    }

                    context.Response.Write(_ajv.SerializeToJson());
                }
                catch (Exception ex)
                {
                    Log4Net.WriteInfoLog("下面一条为接口故障信息", "Agent_DataHandler");
                    Log4Net.WriteErrorLog(ex, "Agent_DataHandler");
                    _ajv = new AjaxJsonValid
                    {
                        code = (int)ApiCode.LogicErrorCode,
                        msg  = EnumHelper.GetDesc(ApiCode.LogicErrorCode)
                    };
                    context.Response.Write(_ajv.SerializeToJson());
                }
            }

            #endregion
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (AppConfig.Mode != AppConfig.CodeMode.Dev)
                {
                    if (Fetch.isWeChat(Request))
                    {
                        //演示和通用平台
                        if (string.IsNullOrEmpty(wxparam))
                        {
//                        string domain = "http://" + (string.IsNullOrEmpty(AppConfig.FrontSiteDomain)
//                                            ? GameRequest.GetCurrentFullHost()
//                                            : AppConfig.FrontSiteDomain);
                            Response.Redirect(AppConfig.AuthorizeURL + "?url=http://" +
                                              GameRequest.GetCurrentFullHost() + "/Card/Index.aspx?code=1001");
                        }
                        else
                        {
                            WxUser wu = Fetch.GetWxUser(wxparam);
                            if (wu == null)
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">参数异常,请稍后尝试。</div>");
                                return;
                            }
                            Message msg =
                                FacadeManage.aideAgentFacade.AgentWXLogin(wu.unionid, GameRequest.GetUserIP());
                            if (msg.Success)
                            {
                                Entity.Agent.AgentInfo ui = msg.EntityList[0] as Entity.Agent.AgentInfo;
                                if (ui != null)
                                {
                                    //for Version 2.0 跳转
                                    string token = Fetch.SHA256Encrypt(
                                        $"<{ui.UserID}>,<{ui.AgentID}>,<{ui.AgentDomain}>,<{Fetch.ConvertDateTimeToUnix(DateTime.Now)}>");
                                    FacadeManage.aideNativeWebFacade.SaveAgentToken(ui, token);
                                    Response.Redirect($"v2/#/?token={token}");
                                }
                                else
                                {
                                    Response.Write(
                                        "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">登录失败,请稍后尝试</div>");
                                }
                            }
                            else
                            {
                                Response.Write(
                                    "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">" +
                                    wu.nickname + "," +
                                    msg.Content + "</div>");
                            }
                        }
                    }
                    else
                    {
                        if (version == 1)
                        {
                            // for Version 1.0 非微信提示
                            Response.Write(
                                "<div style=\"font-size:1.2rem; color:red; text-align:center; margin-top:3rem;\">请在微信内打开</div>");
                        }
                        else if (version == 2)
                        {
                            // for Version 2.0 跳转到手机+安全密码登录页面
                            Response.Redirect("v2/#/Login");
                        }
                    }
                }
            }
        }