protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 线控制 string txt = WebFramework.GeneralMethodBase.CheckStartOrEnd(); if (string.IsNullOrEmpty(txt) == false) { this.lbErr.Text = txt; } #endregion #region 系统维护开关 string WhTxt = WebFramework.GeneralMethodBase.IsCheckWH(); if (string.IsNullOrEmpty(WhTxt) == false) { this.lbErr.Text = WhTxt; return; } #endregion string OpenId = orderSession.OpenId; string Code = orderSession.Code; string IP = Common.ClientIP.GetIp(); #region 验证OpenId if (Common.ValidateHelper.IsOpenid(OpenId) == false) { ESLogMethod.ESLogInstance.Debug("OpenId异常", OpenId, Code); Response.Redirect("/default.aspx"); Response.End(); return; } #endregion #region 检查IP if (Db.Security.IpAccessControlDal.CheckIpIsOK(false, CacheBase.IPSettingModel, IP, "", "") == false) { ESLogMethod.ESLogInstance.Debug("IP模型限制超限", IP, Code); WebFramework.GeneralMethodBase.Ero(); Response.End(); return; } #endregion #region 验证Code #region 验证Code格式 if (Common.ValidateHelper.IsCode(Code) == false) { ESLogMethod.ESLogInstance.Debug("激活码格式错误", Code); WebFramework.GeneralMethodBase.Ero(); Response.End(); return; } #endregion #region 验证Code状态 Model.PassCodeInfoModel PassCodeModel = PassCodeInfoDal.GetModelByCode(Code); if (PassCodeModel.Id <= 0) { ESLogMethod.ESLogInstance.Debug("激活码不存在", Code); WebFramework.GeneralMethodBase.Ero(); Response.End(); return; } if (PassCodeModel.StatusId != 0) { //实际情况按项目需求来 //Response.Redirect("SubmitOk.aspx"); //Response.End(); //return; } #endregion #endregion } }
public Model.ReturnValue ProcessCode(HttpContext context) { Model.ReturnValue result = new Model.ReturnValue(); #region 验证Session result = CheckSession(); if (result.Success == false) { ESLogMethod.ESLogInstance.Debug("Session不通过", ""); return(result); } #endregion string OpenId = orderSession.OpenId; string Mobile = context.Request["mob"]; string Code = context.Request["code"]; #region 验证OpenId if (Common.ValidateHelper.IsOpenid(OpenId) == false) { ESLogMethod.ESLogInstance.Debug("Openid格式异常", OpenId, Code); result.ErrMessage = "系统繁忙,请稍后再试"; result.Success = false; return(result); } #endregion #region 验证手机号 if (Common.ValidateHelper.IsMobile(Mobile) == false) { ESLogMethod.ESLogInstance.Debug("手机号错误", Mobile, Code); result.ErrMessage = "请填写正确手机号"; result.Success = false; return(result); } #endregion string Ip = Common.ClientIP.GetIp(); #region 检查IP if (Db.Security.IpAccessControlDal.CheckIpIsOK(false, CacheBase.IPSettingModel, Ip, "", "") == false) { ESLogMethod.ESLogInstance.Debug("IP模型超过限制", Ip, Code); result.ErrMessage = "系统繁忙,请稍后再试"; result.Success = false; return(result); } #endregion #region 验证激活码 if (Common.ValidateHelper.IsCode(Code, 13) == false) { #region 登记IP Db.Security.IpAccessControlDal.CheckIpIsOK(true, CacheBase.IPSettingModel, Ip, Code, "激活码格式错误"); #endregion ESLogMethod.ESLogInstance.Debug("激活码格式错误", Code, Mobile); result.ErrMessage = "请填写正确的激活码"; result.Success = false; return(result); } #endregion lock (_SyncLock) { Model.PassCodeInfoModel PassCodeModel = PassCodeDal.GetModelByCode(Code); #region 验证激活码状态 if (PassCodeModel.Id <= 0) { #region 登记IP Db.Security.IpAccessControlDal.CheckIpIsOK(true, CacheBase.IPSettingModel, Ip, Code, "库无此激活码"); #endregion ESLogMethod.ESLogInstance.Debug("激活码不存在", Code, Mobile); result.ErrMessage = "请填写正确的激活码"; result.Success = false; return(result); } if (PassCodeModel.StatusId == 1) { Model.OrderInfoModel orderdel = OrderDal.GetModelByCode(Code); if (orderdel.Id <= 0) { #region 登记IP Db.Security.IpAccessControlDal.CheckIpIsOK(true, CacheBase.IPSettingModel, Ip, Code, "订单无此串码"); #endregion ESLogMethod.ESLogInstance.Debug("激活码已激活无订单", Code, Mobile); result.ErrMessage = "请填写正确的激活码"; result.Success = false; return(result); } if (orderdel.OpenId != OpenId) { ESLogMethod.ESLogInstance.Debug("激活码已绑定其他微信号", OpenId, Code); result.ErrMessage = "激活码已绑定其他微信号"; result.Success = false; return(result); } result.ErrMessage = "提交成功"; result.Success = true; return(result); } #endregion #region 检查手机号-openid-IP 参与次数是否超限 string maxcont = WebFramework.OrderService.OrderMethod.OrderInstance.CheckMobOpidIp(Mobile, OpenId, Ip); if (string.IsNullOrEmpty(maxcont) == false) { ESLogMethod.ESLogInstance.Debug("参与次数超限", Code, maxcont); result.ErrMessage = maxcont; result.Success = false; return(result); } #endregion #region 抽奖-保存订单 int goid = WebFramework.GeneralMethodBase.GenerationOrderId(0); #region 抽奖 Model.AwardsStatisticsModel PrizeModel = WebFramework.GeneralMethodBase.GetPrize(7, 1); #endregion Model.OrderInfoModel model = new Model.OrderInfoModel(); model.OrderCode = WebFramework.GeneralMethodBase.CreateOrderCode(goid); model.Jx = PrizeModel.AwardsName; model.Jp = PrizeModel.PrizeName; model.DateStamp = DateTime.Now.ToString("yyyyMMdd"); model.Ip = Ip; model.IpAddress = string.Join("-", Common.ClientIP.GetArrayAdds(model.Ip)); model.CreateTime = DateTime.Now; model.OpenId = OpenId; model.Mob = Mobile; model.Code = Code; model.States = 0; #region 抽取红包奖项 Model.AwardsStatisticsModel RedPackPrizeModel = new Model.AwardsStatisticsModel(); if (model.Jp == "微信红包") { //RedPackPrizeModel = WebFramework.GeneralMethodBase.GetPrize(7, 2); //model.HbOrderCode = WebFramework.GeneralMethodBase.CreateHbCode(goid);//创建红包单号 //model.RedPackMoney = Common.TypeHelper.ObjectToInt(RedPackPrizeModel.PrizeName, 0);//获取红包金额 } #endregion #region 节流 if (WebFramework.PrivacyDemand.PrivacyMethod.PrivacyInstance.Throttling()) { model.States = 1; } #endregion PassCodeModel.Mob = Mobile; PassCodeModel.StatusId = 1; PassCodeModel.ActiveTime = DateTime.Now; PassCodeModel.OpenId = model.OpenId; Model.OrderLogModel mdlog = new Model.OrderLogModel(); mdlog.OId = 0; mdlog.OrderCode = model.OrderCode; mdlog.Mob = Mobile; mdlog.UpTime = DateTime.Now; mdlog.LStatus = 0; mdlog.Status = 1; mdlog.Notes = ""; int OrderId = 0;//插入订单ID //此方法不可替换更改,因与抽奖查询关联 if (OrderDal.AddOrderInfo_UpdatePassCodeInfo_AddOrderLog(model, PassCodeModel, mdlog, PrizeModel.Id, RedPackPrizeModel.Id, ref OrderId) > 0) { #region 虚拟订单 WebFramework.PrivacyDemand.PrivacyMethod.PrivacyInstance.AddFictitiousOrder(model); #endregion result.ErrMessage = "提交成功"; result.Success = true; return(result);; } #endregion } ESLogMethod.ESLogInstance.Error("添加订单失败", Code, Mobile); result.ErrMessage = "系统繁忙,请稍后再试"; result.Success = false; return(result); }
protected void Button1_Click(object sender, EventArgs e) { int qty = Common.TypeHelper.ObjectToInt(this.txtQty.Text, 1000); for (int i = 1; i <= qty; i++) { if (this.DropDownList1.SelectedValue == "19") { byte[] buffer = Guid.NewGuid().ToByteArray(); long l = BitConverter.ToInt64(buffer, 0); Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = l.ToString(); m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else if (this.DropDownList1.SelectedValue == "4+2") { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = ""; int one = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); int two = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); while (one == two) { two = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); } for (int ii = 0; ii < 6; ii++) { if (ii == one || ii == two) { code += GetCode(1); } else { code += GetCode2(1); } } while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = ""; one = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); two = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); while (one == two) { two = Common.TypeHelper.ObjectToInt(GetCodeWxz(1), 0); } for (int ii = 0; ii < 6; ii++) { if (ii == one || ii == two) { code += GetCode(1); } else { code += GetCode2(1); } } } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); //Response.Write(code); } else if (this.DropDownList1.SelectedValue == "6") { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = GetCode3(6); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCode3(6); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else if (this.DropDownList1.SelectedValue == "16(4+4+4+4)") { string code = GetCoden(4) + GetCode2n(4) + GetCoden(4) + GetCode2n(4); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCoden(4) + GetCode2n(4) + GetCoden(4) + GetCode2n(4); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else if (this.DropDownList1.SelectedValue == "8英文") { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = GetCoden(8); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCoden(8); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else if (this.DropDownList1.SelectedValue == "9英文") { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = GetCoden(9); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCoden(9); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else if (this.DropDownList1.SelectedValue == "8+4") { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = GetCoden(8) + GetCode2n(4); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCoden(4) + GetCode2n(4); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } else { // byte[] buffer = Guid.NewGuid().ToByteArray(); //long l = BitConverter.ToInt64(buffer, 0); string code = GetCode(4) + GetCode2(6); while (dal.CheckCount(" and Codes='" + code + "'") > 0) { code = GetCode(4) + GetCode2(6); } Model.PassCodeInfoModel m = new Model.PassCodeInfoModel(); m.Notes = this.txtNotes.Text; m.Codes = code; m.CreateTime = DateTime.Now; m.CustomerId = 0; m.EventId = 0; m.ActiveIp = this.ddlCity.SelectedValue; m.StatusId = 0; m.OpenId = ""; dal.Add(m); } } Common.JScript.alert("a", "操作成功", "AdminPassCode.aspx", this.Page); }