using BizCom; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SiteCore.wechat; using SQLData; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Web; using TenPay; using Utils; using Utils.ImageUtils; namespace SiteCore.Handler { public partial class app { public void ins_opinion() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("con")) { string con = GetPostString("con"); string formid = GetPostString("formid"); string images = GetPostString("images").Trim(','); string sql = string.Format("insert into s_opinion(userid,summary,images,addtime,formid) values({0},'{1}','{2}',getdate(),'{3}')", uid, con, images,formid); DbHelper.DbConn.ExecuteNonQuery(sql); conSuccess("感谢您的反馈!"); return; } conError("错误的参数"); } public void del_opinion() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("oid")) { int oid = GetPostInt("oid"); string sql = "delete from s_opinion where id=" + oid+" and userid="+uid; DbHelper.DbConn.ExecuteNonQuery(sql); conSuccess("删除成功"); return; } conError("错误的参数"); } public void get_opinion() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } string sql = string.Format("select top 10 * from view_opinion where userid=" + uid+" order by addtime desc"); DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0]; conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); } public void upload_opinionimg() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } string tag = GetPostString("tag"); HttpPostedFile postFile = null; List lstFile = new List(); int c = con.Request.Files.Count; if (c > 0) { for (int i = 0; i < c; i++) { string errMsg = ""; postFile = con.Request.Files[i]; if (!ImageHandler.CheckImage(postFile, out errMsg)) { conError(errMsg); return; } string fileName = uid + DateTime.Now.ToFileTimeUtc() + ".jpg"; string saveFile = Path.Combine(webConfig.opinionPath, fileName); string result = ""; using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream)) { result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 800, "", 9, 3); } lstFile.Add(fileName); } } string fs = ""; if (lstFile.Count > 0) fs = string.Join(",", lstFile.ToArray()); conSuccess("上传成功", "{\"fname\":\"" + fs + "\"}"); } public void wx_loginout() { int uid = getDecodeInt("uid"); if (uid == 0) { //conError("找不到会员"); conSuccess("登出"); return; } SUser entity = SUser.Get(uid); if (entity != null) { entity.miniopenid = ""; //entity.UserName = ""; entity.Update(); } conSuccess("登出"); } public void wx_loginout_xy() { int uid = getDecodeInt("uid"); if (uid == 0) { //conError("找不到会员"); conSuccess("登出"); return; } SUser entity = SUser.Get(uid); entity.openid = ""; entity.Update(); conSuccess("登出"); } static object loginObj = new object(); public void wx_minilogin() { if (UrlPostParmsCheck("openid,data,iv,skey")) { string data = GetPostString("data"); string iv = GetPostString("iv"); string openid = GetPostString("openid"); string skey = GetPostString("skey"); WechatUserInfo info = Decrypt(data, iv, skey); string inviteId = GetPostString("inviteId"); int vuid = 0; if (inviteId.Length > 0) { inviteId = inviteId.Replace("$", "="); vuid = Convert.ToInt32(SecurityHelper.DecodingBase64(inviteId)); } //unionid,headimgurl,sex,nick string nick = info.nickName; int sex = (info.gender == "男" ? 2 : 1); string headimgurl = info.avatarUrl; string unionid = info.unionId; string studentno = GetPostString("studentno"); string uname =GetPostString("uname"); string mobile = GetPostString("mobile"); //XLog.SaveLog(0, openid + "," + nick + "," + sex + "," + province + "," + city + "," + country + "," + headimgurl + "," + unionid); SUser entity = null; lock (loginObj) { //entity = SUser.GetByWeixinMini(uname, studentno); //entity = SUser.GetByWeixinMiniOpenId(unionid, openid); if (entity != null) { if (entity.miniopenid != "" && entity.miniopenid != openid)//不是当前的openid { conError("该账号己在另一个微信上绑定,请先注销解绑才能使用!"); return; } entity.miniopenid = openid; if (entity.Mobile == "") entity.Mobile = mobile; entity.LastTime = DateTime.Now; if (entity.inviteId == 0 && vuid > 0 && vuid != entity.ID) { entity.inviteId = vuid; } if (entity.UserName == "") entity.UserName = nick; entity.Update(); } else { if (uname == "") { conError("姓名不允许为空"); return; } if (studentno == "") { conError("证号不允许为空!"); return; } if (studentno != "830820" && SUser.Exists("StudentNo=?", studentno)) { conError("该学生证或工号对应的姓名不符合!"); return; } //if (mobile != "") //{ // if (SUser.Exists("Mobile=?", mobile)) // { // conError("手机号码己存在!"); // return; // } //} entity = new SUser(); if (studentno != "830820") { DataView dv = new DataView(WebCache.LyxyUserTable); dv.RowFilter = "username='" + uname + "' and UserNo='" + studentno + "'"; if (dv.Count < 1) { conError("该学生证或工号对应的姓名不符合,或找不到相关记录!"); return; } DataRowView drv = dv[0]; if (drv["unit"].ToString() != "") { entity.Faculties = drv["unit"].ToString(); entity.UserType = 1; } else { entity.Faculties = drv["Faculties"].ToString(); entity.ClassName = drv["ClassName"].ToString(); entity.Major = drv["Major"].ToString(); entity.UserType = 0; } entity.Sex = (drv["sex"].ToString() == "女" ? 2 : 1); } else { entity.UserType = 5; entity.Faculties = "火蚁官网"; entity.Sex = sex; } entity.StudentNo = studentno; entity.UserName = nick; entity.NickName = nick; entity.RealName = uname; entity.unionid = unionid; //entity.openid = openid; entity.RegisterTime = DateTime.Now; entity.miniopenid = openid; entity.CreateAndFlush(); if (entity.inviteId == 0 && vuid > 0 && entity.ID != vuid) entity.inviteId = vuid; entity.UserPic = entity.ID + ".jpg"; entity.Update(); if (headimgurl != null) { Thread oThread = new Thread(delegate () { HttpHelper http = new HttpHelper(); HttpItem item = new HttpItem() { KeepAlive = true, Accept = "image/webp,image/*,*/*;q=0.8", URL = headimgurl, ResultType = ResultType.Byte }; HttpResult hResult = http.GetHtml(item); using (MemoryStream ms = new MemoryStream(hResult.ResultByte)) { Bitmap bm = new Bitmap(ms); bm.Save(webConfig.userPicPath + "\\b\\" + entity.ID + ".jpg", ImageFormat.Jpeg); using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(ms)) { ImageMaker.ToThumbnailImages(imgThumb, webConfig.userPicPath + "\\" + entity.ID + ".jpg", 100, "", 9, 3); //result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 600, "", 9, 3); } //bm.Save(webConfig.userPicPath + "\\" + entity.ID + ".jpg", ImageFormat.Jpeg); } }); oThread.Start(); } } } StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"uid\":\"{0}\"", SecurityHelper.EncodingBase64(entity.ID.ToString())); //userStr.AppendFormat(",\"gzh_openid\":\"{0}\"", entity.openid); userStr.AppendFormat(",\"userpic\":\"{0}\"", entity.UserPic); userStr.AppendFormat(",\"isremind\":\"{0}\"", entity.isremind); userStr.AppendFormat(",\"mobile\":\"{0}\"", entity.Mobile); userStr.AppendFormat(",\"username\":\"{0}\"",SecurityHelper.DecodingBase64(entity.UserName)); userStr.AppendFormat(",\"point\":\"{0}\"", entity.UserMoney); userStr.AppendFormat(",\"sex\":\"{0}\"", entity.Sex); userStr.AppendFormat(",\"major\":\"{0}\"", entity.Major); userStr.AppendFormat(",\"qq\":\"{0}\"", entity.QQ); userStr.AppendFormat(",\"ptags\":\"{0}\"", entity.ptTags); userStr.AppendFormat(",\"stags\":\"{0}\"", entity.soTags); userStr.AppendFormat(",\"utype\":\"{0}\"", entity.UserType); userStr.AppendFormat(",\"studentno\":\"{0}\"", entity.StudentNo); userStr.AppendFormat(",\"realname\":\"{0}\"", entity.RealName); userStr.AppendFormat(",\"addressid\":\"{0}\"", entity.addressId); userStr.Append("}"); conSuccess("登录成功", userStr.ToString()); return; } conError("错误的参数"); } public void get_msgremind() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } SUser entity = SUser.Get(uid); if (entity != null) { StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"isremind\":\"{0}\"", entity.isremind); userStr.AppendFormat(",\"gzh_openid\":\"{0}\"", entity.openid); userStr.Append("}"); conSuccess("suc", userStr.ToString()); return; } conError("找不到会员"); } private int getUserType(string v) { switch (v) { case "老师": return 1; case "官方": return 5; default: return 0; } } public void wx_miniserv() { if (UrlPostParmsCheck("code")) { string code = GetPostString("code"); //向微信服务端 使用登录凭证 code 获取 session_key 和 openid string url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + mini_Appid + "&secret=" + mini_Secret + "&js_code=" + code + "&grant_type=" + grant_type; string type = "utf-8"; string json = GetUrltoHtml(url, type);//获取微信服务器返回字符串 JObject jo = (JObject)JsonConvert.DeserializeObject(json); //微信服务器验证成功 try { string openid = jo["openid"].ToString(); string session_key = jo["session_key"].ToString(); SUser entity = SUser.GetByWeixinMiniOpenId(openid); StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"openid\":\"{0}\"", openid); userStr.AppendFormat(",\"session_key\":\"{0}\"", session_key); if (entity != null) { entity.LastTime = DateTime.Now; entity.Update(); userStr.AppendFormat(",\"islogin\":\"1\""); //userStr.AppendFormat(",\"isremind\":\"{0}\"", entity.isremind); //userStr.AppendFormat(",\"gzh_openid\":\"{0}\"", entity.openid); userStr.AppendFormat(",\"isfreeze\":\"{0}\"", entity.IsFreeze ? 1 : 0); userStr.AppendFormat(",\"uid\":\"{0}\"", SecurityHelper.EncodingBase64(entity.ID.ToString())); userStr.AppendFormat(",\"userpic\":\"{0}\"", entity.UserPic); userStr.AppendFormat(",\"mobile\":\"{0}\"", entity.Mobile); userStr.AppendFormat(",\"username\":\"{0}\"", entity.UserName); userStr.AppendFormat(",\"point\":\"{0}\"", entity.UserMoney); userStr.AppendFormat(",\"sex\":\"{0}\"", entity.Sex); userStr.AppendFormat(",\"major\":\"{0}\"", entity.Major); userStr.AppendFormat(",\"qq\":\"{0}\"", entity.QQ); userStr.AppendFormat(",\"ptags\":\"{0}\"", entity.ptTags); userStr.AppendFormat(",\"stags\":\"{0}\"", entity.soTags); userStr.AppendFormat(",\"utype\":\"{0}\"", entity.UserType); userStr.AppendFormat(",\"studentno\":\"{0}\"", entity.StudentNo); userStr.AppendFormat(",\"realname\":\"{0}\"", entity.RealName); userStr.AppendFormat(",\"addressid\":\"{0}\"", entity.addressId); userStr.Append("}"); conSuccess("登录成功", userStr.ToString()); } else { userStr.AppendFormat(",\"islogin\":\"0\""); userStr.Append("}"); conSuccess("新用户", userStr.ToString()); } //conSuccess(openid + "|" + session_key); } catch (Exception) { //微信服务器验证失败 string msg = jo["errcode"].ToString() + "," + jo["errmsg"].ToString(); conError(msg); } return; } conError("错误的参数"); } public void wx_miniserv_xy() { if (UrlPostParmsCheck("code")) { string code = GetPostString("code"); //向微信服务端 使用登录凭证 code 获取 session_key 和 openid string url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + mini_Appid_xy + "&secret=" + mini_Secret_xy + "&js_code=" + code + "&grant_type=" + grant_type; string type = "utf-8"; string json = GetUrltoHtml(url, type);//获取微信服务器返回字符串 JObject jo = (JObject)JsonConvert.DeserializeObject(json); //微信服务器验证成功 try { string openid = jo["openid"].ToString(); string session_key = jo["session_key"].ToString(); SUser entity = SUser.GetByWeixinMiniOpenId(openid); StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"openid\":\"{0}\"", openid); userStr.AppendFormat(",\"session_key\":\"{0}\"", session_key); if (entity != null) { entity.LastTime = DateTime.Now; entity.Update(); userStr.AppendFormat(",\"islogin\":\"1\""); //userStr.AppendFormat(",\"isremind\":\"{0}\"",entity.isremind); //userStr.AppendFormat(",\"gzh_openid\":\"{0}\"", entity.openid); userStr.AppendFormat(",\"isfreeze\":\"{0}\"", entity.IsFreeze ? 1 : 0); userStr.AppendFormat(",\"uid\":\"{0}\"", SecurityHelper.EncodingBase64(entity.ID.ToString())); userStr.AppendFormat(",\"userpic\":\"{0}\"", entity.UserPic); userStr.AppendFormat(",\"mobile\":\"{0}\"", entity.Mobile); userStr.AppendFormat(",\"username\":\"{0}\"", entity.UserName); userStr.AppendFormat(",\"point\":\"{0}\"", entity.UserMoney); userStr.AppendFormat(",\"sex\":\"{0}\"", entity.Sex); userStr.AppendFormat(",\"major\":\"{0}\"", entity.Major); userStr.AppendFormat(",\"qq\":\"{0}\"", entity.QQ); userStr.AppendFormat(",\"ptags\":\"{0}\"", entity.ptTags); userStr.AppendFormat(",\"stags\":\"{0}\"", entity.soTags); userStr.AppendFormat(",\"utype\":\"{0}\"", entity.UserType); userStr.AppendFormat(",\"studentno\":\"{0}\"", entity.StudentNo); userStr.AppendFormat(",\"realname\":\"{0}\"", entity.RealName); userStr.Append("}"); conSuccess("登录成功", userStr.ToString()); } else { userStr.AppendFormat(",\"islogin\":\"0\""); userStr.Append("}"); conSuccess("新用户", userStr.ToString()); } //conSuccess(openid + "|" + session_key); } catch (Exception) { //微信服务器验证失败 string msg = jo["errcode"].ToString() + "," + jo["errmsg"].ToString(); conError(msg); } return; } conError("错误的参数"); } public void get_upot() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } string sql = "select usermoney from s_user where id=" + uid; object result = DbHelper.DbConn.ExecuteScalar(sql); if (result != null) conSuccess(GetDoubleString(result)); else conSuccess("0.0"); } public void upd_user() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } string nickname = GetPostString("username"); string major = GetPostString("major"); string isremind = GetPostString("isremind"); string sex = GetPostString("sex"); string mobile = GetPostString("mobile"); if (nickname == "" && sex=="" && mobile=="" && major == "" && isremind=="" && con.Request.Files.Count < 1) { conError("没有需要修改的数据"); return; } SUser entity = SUser.Get(uid); bool upPic = false; if (con.Request.Files.Count > 0) { HttpPostedFile postFile = con.Request.Files[0]; string errMsg = ""; if (!ImageHandler.CheckImage(postFile, out errMsg)) { conError(errMsg); return; } string fileName = uid + ".jpg"; string saveFile = Path.Combine(webConfig.userPicPath, fileName); string result = ""; using (System.Drawing.Image imgThumb = System.Drawing.Image.FromStream(postFile.InputStream)) { result = ImageMaker.ToThumbnailImages(imgThumb, saveFile, 160, "", 9, 3); } upPic = true; entity.UserPic = fileName; } if (nickname.Length > 0) { entity.NickName = nickname; entity.UserName = nickname; } if (sex.Length>0) entity.Sex = Convert.ToInt32(sex); if (mobile.Length > 0) entity.Mobile =mobile; if (isremind.Length > 0) entity.isremind = Convert.ToInt32(isremind); if (major.Length > 0) entity.Major = major; entity.Update(); if (upPic) conSuccess("修改成功!", "{\"pic\":\"" + entity.UserPic + "\"}"); else conSuccess("修改成功!"); } #region 验证码相关 public static Dictionary MobileCache = new Dictionary(); private static readonly List mobileKeyList = new List(); private static readonly object usercache_Flag = 1; public static void AddMobileCache(string key, int value) { lock (usercache_Flag) { if (MobileCache.Count > 300) { MobileCache.Remove(mobileKeyList[mobileKeyList.Count - 1]); mobileKeyList.RemoveAt(mobileKeyList.Count - 1); } if (!mobileKeyList.Contains(key) && !MobileCache.ContainsKey(key)) { mobileKeyList.Add(key); MobileCache.Add(key, value); } else { MobileCache[key] += value; } } } public static void RemoveMobileCache(string key) { if (mobileKeyList.Contains(key) && MobileCache.ContainsKey(key)) { MobileCache.Remove(key); mobileKeyList.Remove(key); } } private bool checkFirCode(string mobile) { if (!checkMobile(mobile)) { conError("手机号码不正确!"); return false; } if (WebCache.GetCache("interval_" + mobile) != null) { conError("验证码请求过于频繁,请稍后再试!"); return false; } string mkey = "mobile_" + DateTime.Now.ToString("Md"); if (MobileCache.ContainsKey(mkey) && MobileCache[mkey] >= 3) { conError("超出验证码获取次数!"); return false; } return true; } private bool checkSecCode(string mobile,string mc) { if (mc == "") { conError("请求过期,请重试!"); return false; } if (!checkMobile(mobile)) { conError("手机号码不正确!"); return false; } if (WebCache.GetCache("code_" + mobile) == null) { conError("请求过期,请重试!"); return false; } else { string con = WebCache.GetCache("code_" + mobile).ToString(); string rc = SecurityHelper.EncryptMD5(con.Substring(3, 4) + con.Substring(9, 3)); if (mc != rc.ToLower()) { conError("参数不正确!"); return false; } } return true; } Regex mReg = new Regex("^1[0-9]{10}$"); private bool checkMobile(string mobile) { if (!mReg.IsMatch(mobile)) return false; return true; } private bool checkSmsCode(string mobile,string mcode) { if (!checkMobile(mobile)) { conError("手机号码不正确!"); return false; } return true; if (WebCache.GetCache("sms_" + mobile) != null) { string _mcode = WebCache.GetCache("sms_" + mobile).ToString(); if (mcode != _mcode) { conError("短信验证码不正确!"); return false; } } else { conError("短信验证码己过期,请重新获取!"); return false; } return true; } public void get_mobilecode() { } #endregion public void user_login() { if (UrlPostParmsCheck("mobile,pwd")) { string mobile = GetPostString("mobile"); string pwd = GetPostString("pwd"); //string mobile = "13635283686"; //string pwd = "yjsogdsk0820"; SUser entity = SUser.GetUserByPassWord(mobile, SecurityHelper.EncryptSymmetric(pwd)); if (entity == null) { conError("用户名或密码错误"); return; } //entity.LastTime = DateTime.Now; //entity.Update(); StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"uid\":\"{0}\"", SecurityHelper.EncodingBase64(entity.ID.ToString())); userStr.AppendFormat(",\"userpic\":\"{0}\"", entity.UserPic); userStr.AppendFormat(",\"mobile\":\"{0}\"", entity.Mobile); userStr.AppendFormat(",\"username\":\"{0}\"", entity.UserName); userStr.AppendFormat(",\"point\":\"{0}\"", entity.UserMoney); userStr.AppendFormat(",\"sex\":\"{0}\"", entity.Sex); userStr.AppendFormat(",\"major\":\"{0}\"", entity.Major); userStr.AppendFormat(",\"qq\":\"{0}\"", entity.QQ); userStr.Append("}"); conSuccess("登录成功", userStr.ToString()); return; } conError("错误的参数"); } public void get_regmc() { if (UrlPostParmsCheck("mobile")) { string mobile = GetPostString("mobile"); if (!checkFirCode(mobile)) return; if (SUser.CheckExits("Mobile", mobile)) { conError("该手机号码己存在!"); return; } string con = CommonHelper.GetRnd(20, true, true, true, false, ""); //string con = "gxSHXL4NDa12wPn7UmNx"; WebCache.RemoveCache("code_" + mobile); WebCache.AddCacheTime("code_" + mobile, con, 2); conSuccess(con); return; } conError("错误的参数"); } public void ins_register() { if(UrlPostParmsCheck("mobile,pwd,nick,major")) { string mobile = GetPostString("mobile"); string email = GetPostString("email"); string mcode = GetPostString("mcode"); string pwd = GetPostString("pwd"); string nick = GetPostString("nick"); string major = GetPostString("major"); if (!checkSmsCode(mobile, mcode)) return; if(SUser.CheckExits("Mobile",mobile)) { conError("该手机号码己存在!"); return; } if(email!="" && SUser.CheckExits("Email", email)) { conError("该邮箱己存在!"); return; } SUser entity = new SUser(); entity.PassWord = SecurityHelper.EncryptSymmetric(pwd); entity.RegisterTime = DateTime.Now; entity.Mobile = mobile; entity.Email = email; entity.NickName = nick; entity.UserName = nick; entity.Major = major; entity.Create(); StringBuilder userStr = new StringBuilder(); userStr.Append("{"); userStr.AppendFormat("\"uid\":\"{0}\"",SecurityHelper.EncodingBase64(entity.ID.ToString())); userStr.AppendFormat(",\"userpic\":\"{0}\"", entity.UserPic); userStr.AppendFormat(",\"mobile\":\"{0}\"", entity.Mobile); userStr.AppendFormat(",\"username\":\"{0}\"", entity.UserName); userStr.AppendFormat(",\"point\":\"{0}\"", entity.UserMoney); userStr.AppendFormat(",\"sex\":\"{0}\"", entity.Sex); userStr.AppendFormat(",\"major\":\"{0}\"", entity.Major); userStr.AppendFormat(",\"qq\":\"{0}\"", entity.QQ); userStr.Append("}"); conSuccess("注册成功",userStr.ToString()); return; } conError("错误的参数"); } public void upd_userpwd() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("oldpwd,newpwd")) { string oldpwd = GetPostString("oldpwd"); string newpwd = GetPostString("newpwd"); if (newpwd == "" || !pwdReg.IsMatch(newpwd)) { conError("输入的新密码不符合要求,最少6位字母数字!"); return; } SUser entity = SUser.GetUserByUserId(uid.ToString(),SecurityHelper.EncryptSymmetric(oldpwd)); if (entity != null) { entity.PassWord = SecurityHelper.EncryptSymmetric(newpwd); entity.RKey = ""; entity.Update(); conSuccess("密码修改成功"); } else { conError("无法修改密码!"); } return; } conError("错误的参数"); } public void get_forgotmc() { if (UrlPostParmsCheck("mobile")) { string mobile = GetPostString("mobile"); if (!checkFirCode(mobile)) return; if (!SUser.CheckExits("Mobile", mobile)) { conError("手机号码不存在!"); return; } string con = CommonHelper.GetRnd(20, true, true, true, true, ""); WebCache.RemoveCache("code_" + mobile); WebCache.AddCacheTime("code_" + mobile, con, 2); conSuccess(con); return; } conError("错误的参数"); } public void upd_forgotpwd() { if (UrlPostParmsCheck("mobile,mcode,newpwd,newpwd2")) { string mobile = GetPostString("mobile"); string mcode = GetPostString("mcode"); string newpwd = GetPostString("newpwd"); string newpwd2 = GetPostString("newpwd2"); if (newpwd == "" || !pwdReg.IsMatch(newpwd)) { conError("输入的新密码不符合要求!"); return; } if(newpwd!=newpwd2) { conError("两次输入的密码不一致!"); return; } if (!checkSmsCode(mobile, mcode)) return; SUser entity = SUser.GetUserByMobile(mobile); if (entity != null) { entity.PassWord = SecurityHelper.EncryptSymmetric(newpwd); entity.RKey = ""; entity.Update(); conSuccess("密码修改成功"); } else { conError("找不到该手机号!"); } return; } conError("错误的参数"); } public void ins_userallege() { if (UrlPostParmsCheck("name,code,idnumber,phone,summary,openid,formid")) { string name = GetPostString("name"); string code = GetPostString("code"); string idnumber = GetPostString("idnumber"); string phone = GetPostString("phone"); string summary = GetPostString("summary"); string formid = GetPostString("formid"); string openid = GetPostString("openid"); StringBuilder sql = new StringBuilder(); sql.AppendFormat("insert into s_userallege(name,usercode,phone,summary,addtime,openid,formid,idnumber) values('{0}','{1}','{2}','{3}',getdate(),'{4}','{5}','{6}') ;", name, code, phone, summary, openid,formid, idnumber); DbHelper.DbConn.ExecuteNonQuery(sql.ToString()); conSuccess("提交完成,平台处理后,将发送微信服务消息通知予您!"); return; } conError("错误的参数"); } public void get_userinfo() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if (UrlPostParmsCheck("tid")) { int tid = GetPostInt("tid") - 98; string sql = "select top 1 username,userpic,'' as realname,sex,'' as Mobile,Major,Faculties,left(studentno,4) as grade from s_user where id=" + tid; DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0]; conGridJson(dt.Rows.Count, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } conError("错误的参数"); } public void get_myamount() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } string sql = "select usermoney from s_user where id=" + uid; object result = DbHelper.DbConn.ExecuteScalar(sql); if (result != null) { conSuccess(result.ToString()); return; } conError("错误的参数"); } public void get_useramount() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("找不到会员"); return; } if(UrlPostParmsCheck("st,et")) { DataStruct dStruct = GetPostStruct(); List lw = new List(); lw.Add("userid=" + uid); dStruct.Order = "addtime desc"; dStruct.MainWhere = string.Join(" and ", lw.ToArray()); dStruct.Fileds = "amount,summary,addtime"; DataTable dt = WebCache.GetData("S_UserAmount", dStruct); conGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2LowerAjaxJson(dt)); return; } conError("错误的参数"); } public void ckug() { int uid = getDecodeInt("uid"); if (uid == 0) { conError("错误的参数"); return; } if (UrlPostParmsCheck("u")) { string u = GetPostString("u"); string[] uArr = u.Split('|'); string sql = string.Format("insert into s_usergps(userid,lng,lat,gtime) values({0},'{1}','{2}',getdate()) ;",uid,uArr[0],uArr[1]); DbHelper.DbConn.ExecuteNonQuery(sql); conSuccess("60"); return; } conError("错误的参数"); } } }