/// <summary> /// 获取下单信息 /// </summary> /// <param name="context"></param> private void GetOrderAwardInfo(HttpContext context) { int id = GameRequest.GetQueryInt("id", 0); int userid = GameRequest.GetQueryInt("uid", 0); AjaxJsonValid _ajv = new AjaxJsonValid(); if (id == 0) { _ajv.msg = "缺少参数奖品ID"; context.Response.Write(_ajv.SerializeToJson()); return; } UserCurrency Currency = FacadeManage.aideTreasureFacade.GetUserCurrency(userid); _ajv.msg = "获取数据成功"; _ajv.SetValidDataValue(true); DataSet ds = FacadeManage.aideNativeWebFacade.GetOrderAwardInfo(userid, id); _ajv.SetDataItem("award", ds.Tables[0]); _ajv.SetDataItem("uinfo", ds.Tables[1]); _ajv.SetDataItem("AwardTicket", Currency.AwardTicket); context.Response.Write(_ajv.SerializeToJson()); }
/// <summary> /// 获取商品类型 /// </summary> /// <param name="context"></param> private void GetShopHome(HttpContext context) { AjaxJsonValid _ajv = new AjaxJsonValid(); int typeid = GameRequest.GetQueryInt("typeid", 0); int userid = GameRequest.GetQueryInt("userid", 0); _ajv.msg = "获取数据成功"; _ajv.SetValidDataValue(true); DataSet ds = FacadeManage.aideNativeWebFacade.GetAwardHomeList(typeid); UserCurrency Currency = FacadeManage.aideTreasureFacade.GetUserCurrency(userid); IList <AwardInfo> list = DataHelper.ConvertDataTableToObjects <AwardInfo>(ds.Tables[1]); foreach (AwardInfo Info in list) { Info.AwardImg = Info.AwardImg.IndexOf("http://", StringComparison.Ordinal) < 0 ? Fetch.GetUploadFileUrl(Info.AwardImg) : Info.AwardImg; } _ajv.SetDataItem("type", ds.Tables[0]); _ajv.SetDataItem("list", list); _ajv.SetDataItem("AwardTicket", Currency == null?0: Currency.AwardTicket); context.Response.Write(_ajv.SerializeToJson()); }
public void ProcessRequest(HttpContext context) { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); context.Response.ContentType = "application/json"; int userid = GameRequest.GetQueryInt("userid", 0); int customId = GameRequest.GetInt("customid", 0); string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); //签名验证 AjaxJsonValid ajv = Fetch.VerifySignData(userid + AppConfig.MoblieInterfaceKey + time, sign); ////接口版本号 //ajv.SetDataItem("apiVersion", 20171106); //if (ajv.code == (int) ApiCode.VertySignErrorCode) //{ // context.Response.Write(ajv.SerializeToJson()); // return; //} //参数验证 if (userid <= 0 || customId <= 0) { ajv.code = (int)ApiCode.VertyParamErrorCode; ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), ""); context.Response.Write(ajv.SerializeToJson()); return; } AccountsFace faceModel = FacadeManage.aideAccountsFacade.GetAccountsFace(customId); if (faceModel == null || faceModel.UserID != userid) { ajv.msg = "抱歉,头像参数无效"; context.Response.Write(ajv.SerializeToJson()); return; } ConfigInfo webCfg = FacadeManage.aideNativeWebFacade.GetConfigInfo(AppConfig.SiteConfigKey.WebSiteConfig.ToString()); string imageServerHost = webCfg.Field2; ajv.SetValidDataValue(true); ajv.SetDataItem("UserID", faceModel.UserID); ajv.SetDataItem("FaceUrl", string.IsNullOrEmpty(faceModel.FaceUrl) ? "" : (faceModel.FaceUrl.IndexOf("http://", StringComparison.Ordinal) > -1 ? faceModel.FaceUrl : $"{imageServerHost}{faceModel.FaceUrl}")); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取用户昵称 /// </summary> /// <param name="context"></param> protected void GetNickNameByGameID(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); int gameid = GameRequest.GetFormInt("gameid", 0); AccountsInfo info = FacadeManage.aideAccountsFacade.GetAccountsInfoByGameID(gameid); ajv.SetDataItem("nickname", info != null ? info.NickName : ""); ajv.SetDataItem("compellation", info != null ? info.Compellation : ""); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取代理赠送钻石记录 /// </summary> /// <param name="context"></param> protected void GetPresentDiamondList(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); //判断登录 UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } StringBuilder sb = new StringBuilder(); int number = GameRequest.GetQueryInt("pageSize", 10); int page = GameRequest.GetQueryInt("page", 1); string where = string.Format("WHERE SourceUserID = {0}", uti.UserID); PagerSet pagerSet = FacadeManage.aideRecordFacade.GetAgentPresentDiamondRecord(where, page, number); string html = string.Empty; if (pagerSet.PageSet.Tables[0].Rows.Count > 0) { foreach (DataRow item in pagerSet.PageSet.Tables[0].Rows) { AccountsInfo info = FacadeManage.aideAccountsFacade.GetAccountsInfoByUserID(Convert.ToInt32(item["TargetUserID"])); sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", Fetch.FormatTimeWrap(Convert.ToDateTime(item["CollectDate"]))); sb.AppendFormat("<td>{0}</td>", info != null ? info.GameID.ToString() : ""); sb.AppendFormat("<td>({0}){1}</td>", item["SourceDiamond"], item["PresentDiamond"]); sb.AppendFormat("<td>{0}</td>", item["CollectNote"]); sb.Append("</tr>"); } html = sb.ToString(); } else { html = "<tr><td colspan=\"4\">暂无记录!</td></tr>"; } ajv.SetDataItem("html", html); ajv.SetDataItem("total", pagerSet.RecordCount); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取钻石创建房间记录 /// </summary> /// <param name="context"></param> protected void GetCostDiamondList(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); //判断登录 UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } StringBuilder sb = new StringBuilder(); int number = GameRequest.GetQueryInt("pageSize", 10); int page = GameRequest.GetQueryInt("page", 1); string where = $"WHERE UserID = {uti.UserID}"; PagerSet pagerSet = FacadeManage.aidePlatformFacade.GetCreateRoomCost(where, page, number); string html; if (pagerSet.PageSet.Tables[0].Rows.Count > 0) { foreach (DataRow item in pagerSet.PageSet.Tables[0].Rows) { sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", Fetch.FormatTimeWrap(Convert.ToDateTime(item["CreateDate"]))); sb.AppendFormat("<td>{0}</td>", item["RoomID"]); sb.AppendFormat("<td>{0}</td>", item["CreateTableFee"]); sb.AppendFormat("<td>{0}</td>", !item["DissumeDate"].ToString().Equals("") ? Fetch.FormatTimeWrap(Convert.ToDateTime(item["DissumeDate"])) : ""); sb.Append("</tr>"); } html = sb.ToString(); } else { html = "<tr><td colspan=\"4\">暂无记录!</td></tr>"; } ajv.SetDataItem("html", html); ajv.SetDataItem("total", pagerSet.RecordCount); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取充值钻石记录 /// </summary> /// <param name="context"></param> protected void GetPayDiamondList(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); //判断登录 UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } StringBuilder sb = new StringBuilder(); int number = GameRequest.GetQueryInt("pageSize", 10); int page = GameRequest.GetQueryInt("page", 1); string where = string.Format(" WHERE UserID = {0} AND OrderStatus = 1 ", uti.UserID); PagerSet pagerSet = FacadeManage.aideTreasureFacade.GetPayDiamondRecord(where, page, number); string html = string.Empty; if (pagerSet.PageSet.Tables[0].Rows.Count > 0) { foreach (DataRow item in pagerSet.PageSet.Tables[0].Rows) { sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", Fetch.FormatTimeWrap(Convert.ToDateTime(item["PayDate"]))); sb.AppendFormat("<td>{0}</td>", item["BeforeDiamond"]); sb.AppendFormat("<td>{0}</td>", Convert.ToInt32(item["Diamond"]) + Convert.ToInt32(item["OtherPresent"])); sb.AppendFormat("<td>{0}</td>", item["Amount"]); sb.Append("</tr>"); } html = sb.ToString(); } else { html = "<tr><td colspan=\"4\">暂无记录!</td></tr>"; } ajv.SetDataItem("html", html); ajv.SetDataItem("total", pagerSet.RecordCount); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取代理推广人 /// </summary> /// <param name="context"></param> protected void GetSpreadRegisterList(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); //判断登录 UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } StringBuilder sb = new StringBuilder(); int number = GameRequest.GetQueryInt("pageSize", 10); int page = GameRequest.GetQueryInt("page", 1); DataSet ds = FacadeManage.aideAccountsFacade.GetAgentSpreadList(uti.UserID, page, number); string html = string.Empty; if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { sb.Append("<tr>"); sb.AppendFormat("<td>{0}</td>", Fetch.FormatTimeWrap(Convert.ToDateTime(item["RegisterDate"]))); sb.AppendFormat("<td>{0}</td>", item["GameID"]); sb.AppendFormat("<td>{0}</td>", Fetch.RegisterOrigin(Convert.ToInt32(item["RegisterOrigin"]))); sb.AppendFormat("<td>{0}</td>", Convert.ToInt32(item["AgentID"]) > 0 ? "代理商" : "非代理商"); sb.Append("</tr>"); } html = sb.ToString(); } else { html = "<tr><td colspan=\"4\">暂无记录!</td></tr>"; } ajv.SetDataItem("html", html); ajv.SetDataItem("total", FacadeManage.aideAccountsFacade.GetAgentSpreadCount(uti.UserID)); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取兑换记录信息 /// </summary> /// <param name="context"></param> private void GetAwardRecord(HttpContext context) { int userid = GameRequest.GetQueryInt("uid", 0); AjaxJsonValid _ajv = new AjaxJsonValid(); _ajv.msg = "获取数据成功"; _ajv.SetValidDataValue(true); DataSet ds = FacadeManage.aideNativeWebFacade.GetAwardOrderList(userid); _ajv.SetDataItem("list", ds.Tables[0]); context.Response.Write(_ajv.SerializeToJson()); }
public void ProcessRequest(HttpContext context) { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); //接口返回数据格式 context.Response.ContentType = "application/json"; string action = GameRequest.GetFormString("action"); string userid = GameRequest.GetFormString("userid"); AjaxJsonValid _ajv = new AjaxJsonValid(); if (string.IsNullOrEmpty(action) && string.IsNullOrEmpty(userid)) { _ajv.msg = "获取数据为空!"; context.Response.Write(_ajv.SerializeToJson()); return; } _ajv.msg = "请求数据成功"; _ajv.SetValidDataValue(true); _ajv.SetDataItem("action", action); _ajv.SetDataItem("userid", userid); context.Response.Write(_ajv.SerializeToJson()); }
/// <summary> /// 接口主路由 /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); context.Response.ContentType = "application/json"; string action = GameRequest.GetString("action"); //签名验证 //接口版本号 _ajv = new AjaxJsonValid(); _ajv.SetDataItem("apiVersion", 20171120); if (_userId <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " userid 为空"); _ajv.SetValidDataValue(false); context.Response.Write(_ajv.SerializeToJson()); return; } switch (action) { case "userspreadhome": UserSpreadHome(); break; case "userspreadreceive": int num = GameRequest.GetInt("num", 0); if (num <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " num(领取数量)"); _ajv.SetValidDataValue(false); context.Response.Write(_ajv.SerializeToJson()); return; } UserSpreadReveice(num); break; default: _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " action"); _ajv.SetValidDataValue(false); break; } context.Response.Write(_ajv.SerializeToJson()); }
/// <summary> /// 获取商品列表 /// </summary> /// <param name="context"></param> private void GetAwardInfoList(HttpContext context) { int typeid = GameRequest.GetQueryInt("typeid", 0); AjaxJsonValid _ajv = new AjaxJsonValid(); _ajv.msg = "获取数据成功"; _ajv.SetValidDataValue(true); DataSet ds = FacadeManage.aideNativeWebFacade.GetAwardInfoByType(typeid); IList <AwardInfo> list = DataHelper.ConvertDataTableToObjects <AwardInfo>(ds.Tables[0]); foreach (AwardInfo Info in list) { Info.AwardImg = Info.AwardImg.IndexOf("http://", StringComparison.Ordinal) < 0 ? Fetch.GetUploadFileUrl(Info.AwardImg) : Info.AwardImg; } _ajv.SetDataItem("list", list); context.Response.Write(_ajv.SerializeToJson()); }
private static void GetUnderDetail(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); //判断登录 UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } int userid = GameRequest.GetQueryInt("userid", 0); AccountsInfo ai = FacadeManage.aideAccountsFacade.GetAccountsInfoByUserID(userid); if (ai.AgentID > 0) { AccountsAgentInfo aai = FacadeManage.aideAccountsFacade.GetAccountsAgentInfoByAgentID(ai.AgentID); UnderDetail underDetail = new UnderDetail() { UserID = ai.UserID, GameID = ai.GameID, NickName = ai.NickName, Compellation = aai.Compellation, QQAccount = aai.QQAccount, ContactAddress = aai.ContactAddress, ContactPhone = aai.ContactPhone, AgentID = ai.AgentID, Diamond = FacadeManage.aideTreasureFacade.GetUserCurrency(ai.UserID)?.Diamond ?? 0 }; ajv.SetDataItem("info", underDetail.ToString()); ajv.SetValidDataValue(true); } context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 统一处理入口(主要验证) /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); //接口返回数据格式 context.Response.ContentType = "application/json"; //接口请求类型 string action = GameRequest.GetQueryString("action").ToLower(); //获取参数 _userid = GameRequest.GetQueryInt("userid", 0); _ajv = new AjaxJsonValid(); #if !DEBUG //DEBUG情况下不验证 string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); //签名验证 _ajv = Fetch.VerifySignData((context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time, sign); // Log4Net.WriteInfoLog("signStr:"+(context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time + " sign:"+sign); if (_ajv.code == (int)ApiCode.VertySignErrorCode) { context.Response.Write(_ajv.SerializeToJson()); return; } #endif //参数验证 if (context.Request.QueryString["userid"] != null && _userid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " userid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } //获取其他参数 int configid = GameRequest.GetQueryInt("configid", 0); int typeid = GameRequest.GetQueryInt("typeid", 0); switch (action) { //获取手机端登录数据 case "getmobilelogindata": _ajv.SetDataItem("apiVersion", 20171017); GetMobileLoginData(); break; //获取手机端登录后数据 case "getmobileloginlater": GetMobileLoginLater(); break; //获取充值产品列表 case "getpayproduct": _ajv.SetDataItem("apiVersion", 20171028); //获取参数 int typeId = GameRequest.GetQueryInt("typeid", 0); GetPayProduct(typeId); break; //领取推广有效好友奖励 case "receivespreadaward": //参数验证 if (configid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " configid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } ReceiveSpreadAward(configid); break; case "getgameintrolist": _ajv.SetDataItem("apiVersion", 20171107); GetGameIntroList(); break; //钻石充值下单 case "createpayorder": _ajv.SetDataItem("apiVersion", 20171123); //获取参数 string paytype = GameRequest.GetQueryString("paytype"); string openid = GameRequest.GetQueryString("openid"); string subtype = GameRequest.GetQueryString("subtype"); //参数验证 if (configid <= 0 || paytype.Equals("")) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), ""); context.Response.Write(_ajv.SerializeToJson()); return; } context.Response.Write(CreatePayOrder(configid, paytype, openid, subtype).SerializeToJson()); return; //获取排行榜数据 case "getrankingdata": //参数验证 if (typeid <= 0 || typeid > 7) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " typeid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } GetRankingData(typeid); break; //获取财富信息 case "getuserwealth": GetUserWealth(); break; //领取排行奖励 case "receiverankingaward": //获取参数 int dateid = GameRequest.GetQueryInt("dateid", 0); //参数验证 if (dateid <= 0 || typeid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), ""); context.Response.Write(_ajv.SerializeToJson()); return; } ReceiveRankingAward(dateid, typeid); break; //获取游戏列表 case "getgamelist": GetGameList(); break; //领取注册赠送奖励 case "receiveregistergrant": ReceiveRegisterGrant(); break; //金币流水记录 case "recordtreasuretrade": RecordTreasureTrade(); break; //钻石流水记录 case "recorddiamondstrade": RecordDiamondsTrade(); break; //钻石兑换金币 case "diamondexchgold": if (configid <= 0 || typeid < 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " configid或typeid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } DiamondExchGold(configid, typeid); break; // case "getlqnopwdloginurl": // _ajv.SetDataItem("apiVersion", 20171116); // string name = GameRequest.GetString("name"); // if (string.IsNullOrEmpty(name)) // { // _ajv.code = (int) ApiCode.VertyParamErrorCode; // _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), // " name 错误"); // context.Response.Write(_ajv.SerializeToJson()); // return; // } // GetLqNoPwdLoginUrl(name); // break; case "getpayorderstatus": _ajv.SetDataItem("apiVersion", 20171127); string orderid = GameRequest.GetString("orderid"); if (string.IsNullOrEmpty(orderid)) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " orderid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } GetPayOrderStatus(orderid); break; default: _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " action 错误"); break; } context.Response.Write(_ajv.SerializeToJson()); }
/// <summary> /// 购买商品 /// </summary> /// <param name="context"></param> private void BuyAward(HttpContext context) { Message msg = new Message(); AjaxJsonValid ajaxJson = new AjaxJsonValid(); int userid = GameRequest.GetQueryInt("userid", 0); //判断登录 //if (!Fetch.IsUserOnline()) //{ // ajaxJson.code = 1; // ajaxJson.msg = "请先登录"; // context.Response.Write(ajaxJson.SerializeToJson()); // return; //} //获取参数 // int typeID = GameRequest.GetQueryInt("TypeID", 0); int awardID = GameRequest.GetQueryInt("awardID", 0); //商品ID int counts = GameRequest.GetQueryInt("counts", 0); //购买数量 AccountsInfo userinfo = FacadeManage.aideAccountsFacade.GetAccountsInfoByUserID(userid); //验证奖品 if (awardID == 0) { ajaxJson.msg = "非常抱歉,你所选购的商品不存在!"; context.Response.Write(ajaxJson.SerializeToJson()); return; } //验证数量 if (counts <= 0) { ajaxJson.msg = "请输入正确的兑换数量!"; context.Response.Write(ajaxJson.SerializeToJson()); return; } if (counts > 100) { ajaxJson.msg = "兑换数量不能超过100!"; context.Response.Write(ajaxJson.SerializeToJson()); return; } AwardInfo awardInfo = FacadeManage.aideNativeWebFacade.GetAwardInfo(awardID); AwardUser awardUser = FacadeManage.aideNativeWebFacade.GetAwardUser(userid); //验证用户 UserCurrency Currency = FacadeManage.aideTreasureFacade.GetUserCurrency(userid); //验证余额 int totalAmount = awardInfo.UnitPrice * counts; //总金额 if (totalAmount <= 0) { ajaxJson.msg = "很抱歉!兑换的奖品配置额度太大或为零"; context.Response.Write(ajaxJson.SerializeToJson()); return; } if (totalAmount > (Currency == null?0:Currency.AwardTicket)) { ajaxJson.msg = "很抱歉!您的奖券数不足,不能兑换该奖品"; ajaxJson.code = -1; context.Response.Write(ajaxJson.SerializeToJson()); return; } //验证库存 if (awardInfo.Inventory <= 0 && awardInfo.AwardType != 1) { ajaxJson.msg = "很抱歉!奖品的库存数不足,请更新其他奖品或者等待补充库存"; context.Response.Write(ajaxJson.SerializeToJson()); return; } //扣除奖牌 Currency.AwardTicket = Currency.AwardTicket - totalAmount; //更新奖牌 AwardOrder awardOrder = new AwardOrder(); awardOrder.OrderID = Fetch.GetOrderIDByPrefix("XT"); awardOrder.UserID = Currency.UserID; awardOrder.GameID = userinfo.GameID; awardOrder.AwardID = awardID; awardOrder.AwardType = awardInfo.AwardType; awardOrder.AwardName = awardInfo.AwardName; awardOrder.UnitPrice = awardInfo.UnitPrice; awardOrder.BuyNum = counts; awardOrder.PayTicket = totalAmount; awardOrder.Gold = awardInfo.Gold; awardOrder.Diamond = awardInfo.Diamond; awardOrder.Compellation = awardUser == null?"": awardUser.Compellation; awardOrder.MobilePhone = awardUser == null ? "" : awardUser.MobilePhone; awardOrder.Province = awardUser == null ? "" : awardUser.Province; awardOrder.City = awardUser == null ? "" : awardUser.City; awardOrder.Area = awardUser == null ? "" : awardUser.Area; awardOrder.DetailAddress = awardUser == null ? "" : awardUser.DetailAddress; awardOrder.ClinetIP = Utility.UserIP; msg = FacadeManage.aideNativeWebFacade.BuyAward(awardOrder); if (msg.Success) { ajaxJson.SetValidDataValue(true); ajaxJson.msg = "兑换成功!实物商品请注意查收"; if (awardInfo.AwardType == 1) { ajaxJson.msg = "兑换成功!将在5分钟内发放至游戏中"; } awardOrder = msg.EntityList[0] as AwardOrder; ajaxJson.SetDataItem("rs", 1); context.Response.Write(ajaxJson.SerializeToJson()); } else { ajaxJson.msg = msg.Content; ajaxJson.SetDataItem("rs", -1); context.Response.Write(ajaxJson.SerializeToJson()); } }
private void SetAwardUser(HttpContext context) { AjaxJsonValid ajaxJson = new AjaxJsonValid(); Message msg = new Message(); int userid = GameRequest.GetQueryInt("userid", 0); string settype = TextFilter.FilterScript(GameRequest.GetQueryString("settype")); //设置类型update修改insert添加 string compellation = TextFilter.FilterScript(GameRequest.GetQueryString("name")); //真实姓名 string mobilePhone = TextFilter.FilterScript(GameRequest.GetQueryString("phone")); //移动电话 string province = GameRequest.GetQueryString("province"); //省份 string city = GameRequest.GetQueryString("city"); //城市 string area = GameRequest.GetQueryString("area"); //地区 string dwellingPlace = TextFilter.FilterScript(GameRequest.GetQueryString("address")); //详细地址 //验证真实姓名 msg = CheckingRealNameFormat(compellation, false); if (!msg.Success) { ajaxJson.msg = "请输入正确的收件人"; context.Response.Write(ajaxJson.SerializeToJson()); return; } //验证手机号 msg = CheckingMobilePhoneNumFormat(mobilePhone, false); if (!msg.Success) { ajaxJson.msg = "请输入正确的手机号码"; context.Response.Write(ajaxJson.SerializeToJson()); return; } //验证地址邮编 if (province.Length < 1) { ajaxJson.msg = "请选择省份"; context.Response.Write(ajaxJson.SerializeToJson()); return; } if (city.Length < 1) { ajaxJson.msg = "请选择城市"; context.Response.Write(ajaxJson.SerializeToJson()); return; } if (area.Length < 1) { ajaxJson.msg = "请选择地区"; context.Response.Write(ajaxJson.SerializeToJson()); return; } if (string.IsNullOrEmpty(dwellingPlace)) { ajaxJson.msg = "请输入详细地址"; context.Response.Write(ajaxJson.SerializeToJson()); return; } AwardUser awardUser = new AwardUser(); awardUser.UserID = userid; awardUser.Compellation = compellation; awardUser.MobilePhone = mobilePhone; awardUser.Province = province; awardUser.City = city; awardUser.Area = area; awardUser.DetailAddress = dwellingPlace; if (settype == "update") { int rs = FacadeManage.aideNativeWebFacade.updateAwardUser(awardUser); if (rs > 0) { ajaxJson.msg = "修改成功"; ajaxJson.SetValidDataValue(true); ajaxJson.SetDataItem("rs", 1); context.Response.Write(ajaxJson.SerializeToJson()); return; } else { ajaxJson.msg = "修改失败"; ajaxJson.SetDataItem("rs", -1); context.Response.Write(ajaxJson.SerializeToJson()); return; } } if (settype == "insert") { int rs = FacadeManage.aideNativeWebFacade.insertAwardUser(awardUser); if (rs > 0) { ajaxJson.msg = "提交成功"; ajaxJson.SetValidDataValue(true); ajaxJson.SetDataItem("rs", 1); context.Response.Write(ajaxJson.SerializeToJson()); return; } else { ajaxJson.msg = "提交失败"; ajaxJson.SetDataItem("rs", -1); context.Response.Write(ajaxJson.SerializeToJson()); return; } } }
/// <summary> /// 页面加载 /// </summary> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (AppConfig.Mode == AppConfig.CodeMode.Production) { #region 客户版本 Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); //签名验证 AjaxJsonValid ajv = Fetch.VerifySignData((AppConfig.MoblieInterfaceKey + time), sign); if (ajv.code == (int)ApiCode.VertySignErrorCode) { Response.Write(ajv.SerializeToJson()); return; } object obj = WHCache.Default.Get <AspNetCache>(AppConfig.WxTicket); TicketCache tc = obj as TicketCache; if (tc == null) { try { string url = $"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={WxAuthorize.Appid}&secret={WxAuthorize.Appsecret}"; string result = WxHttpService.Get(url); JavaScriptSerializer js = new JavaScriptSerializer(); AccessToken at = js.Deserialize <AccessToken>(result); if (at.errcode > 0) { ajv.msg = at.errmsg; Response.Write(ajv.SerializeToJson()); return; } url = $"https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={at.access_token}&type=jsapi"; result = WxHttpService.Get(url); JsapiTicket jt = js.Deserialize <JsapiTicket>(result); if (jt.errcode > 0) { ajv.msg = at.errmsg; Response.Write(ajv.SerializeToJson()); return; } tc = new TicketCache(); tc.access_token = at.access_token; tc.ticket = jt.ticket; int timeout = (at.expires_in / 60) - 3; WHCache.Default.Save <AspNetCache>(AppConfig.WxTicket, tc, timeout); } catch (Exception) { Response.Write(ajv.SerializeToJson()); return; } } ajv.SetValidDataValue(true); ajv.SetDataItem("access_token", tc.access_token); ajv.SetDataItem("ticket", tc.ticket); Response.Write(ajv.SerializeToJson()); #endregion } else { #region 演示版本 string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); Response.Redirect("http://ry.foxuc.net/JJTicket.aspx?time=" + time + "&sign=" + sign); #endregion } } }
public void GetUnderList(HttpContext context) { AjaxJsonValid ajv = new AjaxJsonValid(); UserTicketInfo uti = Fetch.GetUserCookie(); if (uti == null || uti.UserID <= 0) { ajv.code = 0; ajv.msg = "登录已失效,请重新打开页面"; context.Response.Write(ajv.SerializeToJson()); return; } string type = GameRequest.GetQueryString("type"); string range = GameRequest.GetQueryString("range"); int number = GameRequest.GetQueryInt("pageSize", 10); int page = GameRequest.GetQueryInt("page", 1); string sqlMonth = " AND CollectDate >= '" + new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString("yyyy-MM-dd HH:mm:ss") + "'"; string sqlRange = range == "month" ? sqlMonth : ""; number = range == "all" ? 10 : 50; string sqlWhere; long pCount = 0; UnderList list = new UnderList(); PagerSet ps; switch (type) { case "user": sqlWhere = $" WHERE SourceUserID = {uti.UserID} AND TargetUserID NOT IN (SELECT UserID FROM WHJHAccountsDBLink.WHJHAccountsDB.dbo.AccountsAgentInfo) {sqlRange} GROUP BY TargetUserID,SourceUserID "; ps = FacadeManage.aideRecordFacade.GetAgentBelowUserPresentDiamondRecord(sqlWhere, page, number); list.PageCount = ps.PageCount; list.RecordCount = ps.RecordCount; list.PageIndex = ps.PageIndex; list.PageSize = ps.PageSize; if (ps.RecordCount > 0) { foreach (DataRow row in ps.PageSet.Tables[0].Rows) { UnderData data = new UnderData() { UserID = Convert.ToInt32(row["UserID"]), RankID = Convert.ToInt32(row["PageView_RowNo"]) }; data.GameID = FacadeManage.aideAccountsFacade.GetGameIDByUserID(data.UserID); data.NickName = FacadeManage.aideAccountsFacade.GetNickNameByUserID(data.UserID); data.Diamond = FacadeManage.aideTreasureFacade.GetUserCurrency(data.UserID)?.Diamond ?? 0; if (type == "month") { data.MonthDiamond = Convert.ToInt64(row["SumDiamond"]); data.TotalDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID); } else { data.TotalDiamond = Convert.ToInt64(row["SumDiamond"]); data.MonthDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID, sqlMonth); } list.dataList.Add(data); } } pCount = FacadeManage.aideRecordFacade.GetAgentBelowAccountsCount(uti.UserID); break; case "agent": list.Link = true; if (range == "all") { IList <AccountsAgentInfo> belowList = FacadeManage.aideAccountsFacade.GetAgentBelowAgentList(uti.UserID); list.PageCount = 1; list.RecordCount = belowList?.Count ?? 0; list.PageIndex = 1; list.PageSize = belowList?.Count ?? 0; var iCount = 0; if (belowList != null) { foreach (AccountsAgentInfo agentInfo in belowList) { iCount++; UnderData data = new UnderData() { UserID = agentInfo.UserID, RankID = iCount }; data.GameID = FacadeManage.aideAccountsFacade.GetGameIDByUserID(data.UserID); data.NickName = FacadeManage.aideAccountsFacade.GetNickNameByUserID(data.UserID); data.Diamond = FacadeManage.aideTreasureFacade.GetUserCurrency(data.UserID)?.Diamond ?? 0; data.TotalDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID, sqlMonth); data.MonthDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID, sqlMonth); list.dataList.Add(data); } } } else { sqlWhere = $" WHERE SourceUserID IN ( SELECT UserID FROM WHJHAccountsDBLink.WHJHAccountsDB.dbo.AccountsAgentInfo WHERE ParentAgent = {uti.AgentID} ) {sqlRange} GROUP BY SourceUserID "; ps = FacadeManage.aideRecordFacade .GetAgentBelowAgentPresentDiamondRecord(sqlWhere, page, number); list.PageCount = ps.PageCount; list.RecordCount = ps.RecordCount; list.PageIndex = ps.PageIndex; list.PageSize = ps.PageSize; if (ps.RecordCount > 0) { foreach (DataRow row in ps.PageSet.Tables[0].Rows) { UnderData data = new UnderData() { UserID = Convert.ToInt32(row["UserID"]), RankID = Convert.ToInt32(row["PageView_RowNo"]) }; data.GameID = FacadeManage.aideAccountsFacade.GetGameIDByUserID(data.UserID); data.NickName = FacadeManage.aideAccountsFacade.GetNickNameByUserID(data.UserID); data.Diamond = FacadeManage.aideTreasureFacade.GetUserCurrency(data.UserID)?.Diamond ?? 0; if (type == "month") { data.MonthDiamond = Convert.ToInt64(row["SumDiamond"]); data.TotalDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID); } else { data.TotalDiamond = Convert.ToInt64(row["SumDiamond"]); data.MonthDiamond = FacadeManage.aideRecordFacade.GetTotalPresentCount(uti.UserID, data.UserID, sqlMonth); } list.dataList.Add(data); } } } pCount = FacadeManage.aideAccountsFacade.GetAgentBelowAgentCount(uti.UserID); break; default: ajv.msg = "类型参数丢失!"; context.Response.Write(ajv.SerializeToJson()); return; } ajv.SetDataItem("list", list.dataList); ajv.SetDataItem("total", list.RecordCount); if (list.Link) { ajv.SetDataItem("link", true); } ajv.SetDataItem("count", pCount); ajv.SetValidDataValue(true); context.Response.Write(ajv.SerializeToJson()); }
/// <summary> /// 获取token /// </summary> private static void Gettoken() { string token = ""; if (HttpRuntime.Cache.Get("token") != null) { token = HttpRuntime.Cache.Get("token").ToString(); HttpRuntime.Cache.Remove("token"); _ajv.SetValidDataValue(true); _ajv.SetDataItem("token", token); return; } _ajv.code = (int)ApiCode.Unauthorized; _ajv.msg = EnumHelper.GetDesc(ApiCode.Unauthorized); }
public void ProcessRequest(HttpContext context) { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", "*"); context.Response.ContentType = "application/json"; string url = GameRequest.GetQueryString("url"); string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); //数据验证 AjaxJsonValid ajv = new AjaxJsonValid(); if (string.IsNullOrEmpty(url)) { ajv.code = (int)ApiCode.VertyParamErrorCode; ajv.msg = "参数请求错误"; context.Response.Write(ajv.SerializeToJson()); return; } //ajv = Fetch.VerifySignData(url + AppConfig.MoblieInterfaceKey + time, sign); //if(ajv.code == (int)ApiCode.VertySignErrorCode) //{ // context.Response.Write(ajv.SerializeToJson()); // return; //} //资源下载 string base64 = string.Empty; GC.Collect(); WebRequest request = null; WebResponse response = null; //请求url以获取数据 try { //设置最大连接数 ServicePointManager.DefaultConnectionLimit = 200; //设置https验证方式 if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult; } request = WebRequest.Create(context.Server.UrlDecode(url)); request.Method = "GET"; //获取服务器返回 response = request.GetResponse(); using (Stream stream = response.GetResponseStream()) { Image image = Image.FromStream(stream); Bitmap bitmap = new Bitmap(image); using (MemoryStream ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Png); byte[] arr = new byte[ms.Length]; ms.Position = 0; ms.Read(arr, 0, (int)ms.Length); ms.Close(); base64 = Convert.ToBase64String(arr); } } ajv.SetValidDataValue(true); ajv.SetDataItem("Image", base64); context.Response.Write(ajv.SerializeToJson()); } catch (Exception) { ajv.msg = "操作异常"; ajv.SetValidDataValue(false); ajv.SetDataItem("Image", ""); context.Response.Write(ajv.SerializeToJson()); } finally { //关闭连接和流 response?.Close(); request?.Abort(); } }
/// <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.aideNativeWebFacade.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); }
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 }
/// <summary> /// 获取手机端登录数据 /// </summary> private static void GetMobileLoginData() { ConfigInfo webConfig = Fetch.GetWebSiteConfig(); string imageServerHost = webConfig.Field2; //获取登录数据 DataSet ds = FacadeManage.aideNativeWebFacade.GetMobileLoginInfo(); //获取系统配置信息 MobileSystemConfig config = GetMobileSystemConfig(ds.Tables[0]); //大喇叭道具信息由道具表提供 GameProperty prop = FacadeManage.aidePlatformFacade.GetGameProperty(306); config.DiamondBuyPropCount = prop.ExchangeRatio; config.GoldBuyPropCount = 0; //获取客服界面配置 MobileCustomerService mcs = DataHelper.ConvertRowToObject <MobileCustomerService>(ds.Tables[1].Rows[0]); //获取系统公告配置 IList <NoticeMobile> noticelist = DataHelper.ConvertDataTableToObjects <NoticeMobile>(ds.Tables[2]); //获取手机广告图 IList <AdsMobile> plate = DataHelper.ConvertDataTableToObjects <AdsMobile>(ds.Tables[3]); IList <AdsMobile> alert = DataHelper.ConvertDataTableToObjects <AdsMobile>(ds.Tables[4]); foreach (AdsMobile ads in plate) { ads.ResourceURL = ads.ResourceURL.IndexOf("http://", StringComparison.Ordinal) < 0 ? imageServerHost + ads.ResourceURL : ads.ResourceURL; } foreach (AdsMobile ads in alert) { ads.ResourceURL = ads.ResourceURL.IndexOf("http://", StringComparison.Ordinal) < 0 ? imageServerHost + ads.ResourceURL : ads.ResourceURL; } //输出数据 _ajv.SetValidDataValue(true); _ajv.SetDataItem("systemConfig", config); _ajv.SetDataItem("customerService", mcs); _ajv.SetDataItem("systemNotice", noticelist); _ajv.SetDataItem("adsList", plate); _ajv.SetDataItem("adsAlertList", alert); }
/// <summary> /// 玩家推广中心数据 /// </summary> private void UserSpreadHome() { byte spreadReturnType = 0; SystemStatusInfo spreadTypeConfig = FacadeManage.aideAccountsFacade.GetSystemStatusInfo(AppConfig.ConfigInfoKey.SpreadReturnType .ToString()); if (spreadTypeConfig != null) { spreadReturnType = Convert.ToByte(spreadTypeConfig.StatusValue); } DataSet ds = FacadeManage.aideAccountsFacade.GetUserSpreadHomeDataSet(_userId); Dictionary <string, object> info = new Dictionary <string, object> { { "GameID", Convert.ToInt32(ds.Tables[0].Rows[0]["GameID"]) }, { "Lv1Count", Convert.ToInt32(ds.Tables[0].Rows[0]["Lv1Count"]) }, { "Lv2Count", Convert.ToInt32(ds.Tables[0].Rows[0]["Lv2Count"]) }, { "Lv3Count", Convert.ToInt32(ds.Tables[0].Rows[0]["Lv3Count"]) }, { "TotalReturn", Convert.ToInt64(ds.Tables[0].Rows[0]["TotalReturn"]) }, { "TotalReceive", Convert.ToInt64(ds.Tables[0].Rows[0]["TotalReceive"]) } }; _ajv.SetDataItem("info", info); ArrayList arrayList = new ArrayList(); if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { int userId = Convert.ToInt32(dr["UserID"]); Dictionary <string, object> belowUser = new Dictionary <string, object>() { { "UserID", userId }, { "GameID", FacadeManage.aideAccountsFacade.GetGameIDByUserID(userId) }, { "NickName", FacadeManage.aideAccountsFacade.GetNickNameByUserID(userId) }, { "Level", GetLevelDesc(dr["LevelID"].ToString()) } }; arrayList.Add(belowUser); } } _ajv.SetDataItem("belowList", arrayList); arrayList = new ArrayList(); if (ds.Tables[2].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[2].Rows) { Dictionary <string, object> record = new Dictionary <string, object>() { { "GameID", FacadeManage.aideAccountsFacade.GetGameIDByUserID(Convert.ToInt32(dr["SourceUserID"])) }, { "SourceDiamond", Convert.ToInt32(dr["SourceDiamond"]) }, { "SpreadLevel", GetLevelDesc(dr["SpreadLevel"].ToString()) }, { "ReturnType", spreadReturnType == 0 ? "金币" : "钻石" }, { "ReturnNum", Convert.ToInt32(dr["ReturnNum"]) }, { "CollectDate", Convert.ToDateTime(dr["CollectDate"]).ToString("yyyy-MM-dd HH:mm:ss") }, }; arrayList.Add(record); } } _ajv.SetDataItem("returnRecord", arrayList); arrayList = new ArrayList(); if (ds.Tables[3] != null && ds.Tables[3].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[3].Rows) { Dictionary <string, object> record = new Dictionary <string, object>() { { "CollectDate", Convert.ToDateTime(dr["CollectDate"]).ToString("yyyy-MM-dd HH:mm:ss") }, { "ReceiveType", spreadReturnType == 0 ? "金币" : "钻石" }, { "ReceiveNum", Convert.ToInt32(dr["ReceiveNum"]) }, { "ReceiveBefore", Convert.ToInt64(dr["ReceiveBefore"]) } }; arrayList.Add(record); } } _ajv.SetDataItem("receiveRecord", arrayList); _ajv.SetValidDataValue(true); }
/// <summary> /// 统一处理入口(主要验证) /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { try { //允许跨站请求域名 context.Response.AddHeader("Access-Control-Allow-Origin", AppConfig.MoblieInterfaceDomain); //接口返回数据格式 context.Response.ContentType = "application/json"; //接口请求类型 string action = GameRequest.GetQueryString("action").ToLower(); //获取参数 _userid = GameRequest.GetQueryInt("userid", 0); _device = GameRequest.GetString("device"); _ajv = new AjaxJsonValid(); #if !DEBUG //DEBUG情况下不验证 string time = GameRequest.GetQueryString("time"); string sign = GameRequest.GetQueryString("sign"); //签名验证 _ajv = Fetch.VerifySignData((context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time, sign); // Log4Net.WriteInfoLog("signStr:"+(context.Request.QueryString["userid"] == null ? "" : _userid.ToString()) + AppConfig.MoblieInterfaceKey + time + " sign:"+sign); if (_ajv.code == (int)ApiCode.VertySignErrorCode) { context.Response.Write(_ajv.SerializeToJson()); return; } #endif //参数验证 if (context.Request.QueryString["userid"] != null && _userid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " userid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } //获取其他参数 int configid = GameRequest.GetQueryInt("configid", 0); int typeid = GameRequest.GetQueryInt("typeid", 0); switch (action) { case "webversion": _ajv.SetDataItem("apiVersion", 20171220); _ajv.SetDataItem("webVersion", "V1.1.8"); _ajv.SetDataItem("updateAt", "2018/02/03"); _ajv.SetValidDataValue(true); break; //获取手机端登录数据 case "getmobilelogindata": _ajv.SetDataItem("apiVersion", 20171017); GetMobileLoginData(); break; //获取手机端登录后数据 case "getmobileloginlater": _ajv.SetDataItem("apiVersion", 20171213); GetMobileLoginLater(); break; //获取充值产品列表 case "getpayproduct": _ajv.SetDataItem("apiVersion", 20171028); //获取参数 int typeId = GameRequest.GetQueryInt("typeid", 0); GetPayProduct(typeId); break; //领取推广有效好友奖励 case "receivespreadaward": //参数验证 if (configid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " configid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } ReceiveSpreadAward(configid); break; case "getgameintrolist": _ajv.SetDataItem("apiVersion", 20171107); GetGameIntroList(); break; //钻石充值下单 case "createpayorder": _ajv.SetDataItem("apiVersion", 20171123); //获取参数 string paytype = GameRequest.GetQueryString("paytype"); string openid = GameRequest.GetQueryString("openid"); string subtype = GameRequest.GetQueryString("subtype"); //参数验证 if (configid <= 0 || paytype.Equals("")) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), ""); context.Response.Write(_ajv.SerializeToJson()); return; } context.Response.Write(CreatePayOrder(configid, paytype, openid, subtype).SerializeToJson()); return; //获取排行榜数据 case "getrankingdata": _ajv.SetDataItem("apiVersion", 20171129); //参数验证 if (typeid <= 0 || typeid > 7) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " typeid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } GetRankingData(typeid); break; //获取财富信息 case "getuserwealth": GetUserWealth(); break; //获取玩家信息 case "getuserinfo": _ajv.SetDataItem("apiVersion", 20171208); GetUserInfo(); break; //领取排行奖励 case "receiverankingaward": _ajv.SetDataItem("apiVersion", 20171213); //获取参数 int dateid = GameRequest.GetQueryInt("dateid", 0); //参数验证 if (dateid <= 0 || typeid <= 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), ""); context.Response.Write(_ajv.SerializeToJson()); return; } ReceiveRankingAward(dateid, typeid); break; //获取游戏列表 case "getgamelist": GetGameList(); break; //领取注册赠送奖励 case "receiveregistergrant": _ajv.SetDataItem("apiVersion", 20171213); ReceiveRegisterGrant(); break; //金币流水记录 case "recordtreasuretrade": RecordTreasureTrade(); break; //钻石流水记录 case "recorddiamondstrade": RecordDiamondsTrade(); break; //钻石兑换金币 case "diamondexchgold": _ajv.SetDataItem("apiVersion", 20171213); //for 响应规范 if (configid <= 0 || typeid < 0) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " configid或typeid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } DiamondExchGold(configid, typeid); break; case "getpayorderstatus": _ajv.SetDataItem("apiVersion", 20171127); string orderid = GameRequest.GetString("orderid"); if (string.IsNullOrEmpty(orderid)) { _ajv.code = (int)ApiCode.VertyParamErrorCode; _ajv.msg = string.Format(EnumHelper.GetDesc(ApiCode.VertyParamErrorCode), " orderid 错误"); context.Response.Write(_ajv.SerializeToJson()); return; } GetPayOrderStatus(orderid); break; case "getquestionandanswerlist": _ajv.SetDataItem("apiVersion", 20180125); GetQuestionAndAnswerList(); 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("下面一条为手机接口故障信息", "MobileInterface"); Log4Net.WriteErrorLog(ex); _ajv = new AjaxJsonValid { code = 500, msg = "手机接口短暂故障,请联系管理员!" }; context.Response.Write(_ajv.SerializeToJson()); } context.Response.End(); }