protected void Page_Load(object sender, EventArgs e) { OnlyWeiXinLook(); MyCommFun.getTotalUrl(); id = MyCommFun.RequestInt("id", 0); wid = MyCommFun.RequestWid(); openid = MyCommFun.RequestOpenid(); string whereStr = " wid=" + wid + " and id=" + id; wx_dati_base baseBll = new wx_dati_base(); Model.wx_dati_base baseDT = baseBll.GetModel(whereStr); //红包设置 bool hbreISopen = false; int reMsg = 0; bool hbISopen = true; //红包是否开启 int hbWhere = 0; //红包参与条件 int hbMTnum = 10; //第天领取人数 int hbMRnum = 5; //每人领取次数 int hbRCnum = 3; //容错次数 if (hbISopen) { hbreISopen = true; } //红包参与条件 //取用户答题记录 // int getUseridCount = baseBll.GetRecordCount(" openid='" + openid + "'"); // if (getUseridCount >= hbRCnum) hbreISopen = false; //用户信息 wx_dati_user userBLL = new wx_dati_user(); Model.wx_dati_user usermodel = userBLL.GetModel(" openid='" + openid + "' "); int getUseridCount = userBLL.GetRecordCount(" openid='" + openid + "'"); if (getUseridCount >= 3) { isusersub = true; } if (usermodel != null) { usersum = usermodel.score.ToString(); } ///end if (id == 0 || wid == 0 || openid.Trim() == "") { Response.Redirect("err.aspx?rev=1"); return; } if (baseDT.starttime > DateTime.Now) { //说明活动未开始 Response.Redirect("err.aspx?rev=2"); return; } if (baseDT.endtime <= DateTime.Now) { //说明活动已经结束 Response.Redirect("err.aspx?rev=3"); return; } htmlTitle = baseDT.title; summary = baseDT.summary; headimg = baseDT.headimg; bjcolor = baseDT.bjcolor; dtime = baseDT.dttime; dxgetnum = int.Parse(baseDT.dxgetnum.ToString()); ////// string dxwhereStr; if (dxgetnum > 0) {//抽取 int count = dxBLL.GetRecordCount(" pid=" + id); //////生成随机题号 string inStr = ""; Hashtable hashtable = new Hashtable(); Random rm = new Random(); int RmNum = dxgetnum; for (int i = 0; hashtable.Count < RmNum; i++) { int nValue = rm.Next(1, count); if (!hashtable.ContainsValue(nValue) && nValue != 0) { hashtable.Add(nValue, nValue); } } foreach (DictionaryEntry de in hashtable) { inStr += de.Value.ToString() + ","; } ///// dxwhereStr = " pid=" + id + " and isshow=1 and sid in (" + inStr.Substring(0, inStr.Length - 1) + ")"; } else { dxwhereStr = " pid=" + id + " and isshow=1 "; } dxDT = dxBLL.GetList(dxwhereStr); }
public void userinfoAdd() { Dictionary <string, string> jsonDict = new Dictionary <string, string>(); //取值 int? wid = MyCommFun.RequestInt("wid", 0); int aid = MyCommFun.RequestInt("aid"); string openid = MyCommFun.RequestOpenid(); string atitle = MyCommFun.QueryString("atitle"); string usersum = MyCommFun.QueryString("usersum"); bool ISnum = true; if (wid == 0 || aid == 0 || openid == "" || usersum == "") { jsonDict.Add("re", "err"); jsonDict.Add("content", "参数错误!"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } BLL.wx_dati_user userBLL = new BLL.wx_dati_user(); // Model.wx_dati_user usermodel = userBLL.GetModel(" openid='" + openid + "' "); int getcont = userBLL.GetRecordCount(" openid='" + openid + "' "); if (getcont == 3) { jsonDict.Add("re", "err"); jsonDict.Add("content", "你已参加过了"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } int sy = 2 - getcont; BLL.wx_dati_base baseBLL = new BLL.wx_dati_base(); Model.wx_dati_base baseModel = baseBLL.GetModel(aid); int?jf = 0; int jftype = baseModel.jftype; int jfval = baseModel.jfval; if (jftype == 0) { jf = 0; } else if (jftype == 1) { jf = jfval; } else if (jftype == 2) { jf = int.Parse(usersum); } BLL.wx_dati_user dxBLL = new BLL.wx_dati_user(); Model.wx_dati_user dxmodel = new Model.wx_dati_user(); dxmodel.wid = wid; dxmodel.openid = openid; dxmodel.aid = aid; dxmodel.atitle = atitle; dxmodel.usersum = usersum; dxmodel.score = jf; dxmodel.addtime = DateTime.Now; dxBLL.Add(dxmodel); //得分 if (jf == 5) { jsonDict.Add("re", "OK"); jsonDict.Add("cjscore", jf.ToString()); jsonDict.Add("content", "你获得了一次红包机会!"); jsonDict.Add("isnum", "false"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } else { jsonDict.Add("re", "OK"); jsonDict.Add("cjscore", jf.ToString()); jsonDict.Add("content", "答卷提交成功!(" + sy + ")次机会"); jsonDict.Add("isnum", "true"); content.Response.Write(MyCommFun.getJsonStr(jsonDict)); return; } }