public int BookOk(int bid) { try { HQ_BookRoom book = new HQ_BookRoom(); book["id"] = bid; book.OStatus = 1; book.LastOperateTime = DateTime.Now; book.Save(); } catch { return 0; } try { SearchModel sm = new SearchModel("uv_bookroom"); sm["id"] = bid; sm.AddSearch("RoomName_G", "PhoneNum_G"); var broom = sm.LoadEntity<HQ_BookRoom>(); if (broom != null) { NM.Util.SendUserInfo _U = new NM.Util.SendUserInfo() { isLog = 1, orgid = 555, username = broom.PhoneNum_G }; NM.Util.MsgSend.DirectSend(string.Format("尊敬的会员您好,您已成功预订 {0} 。", broom.RoomName_G), broom.PhoneNum_G, _U); } } catch { } return 1; }
public JsonResult LoadBenefitDetails(int destinationId) { SearchModel sm = new SearchModel("HQ_DisplayContent"); sm["DPanelID"] = destinationId; sm.AddSearch("ID", "Name"); var result = sm.Load<HQ_DisplayContent>(); return this.JsonNet(result.Data); }
public JsonResult LoadCheaperDetails(int cheaperid) { SearchModel sm = new SearchModel("HQ_DisplayContent"); sm["DPanelID"] = cheaperid; sm.AddSearch("ID", "Name"); var result = sm.Load<HQ_DisplayContent>(); return this.JsonNet(result.Data); }
public void CheckNewAnswer(int uid) { SearchModel sm = new SearchModel("uv_memberask"); sm["MemberID"] = uid; sm.NewAnswerID = 0; sm.AnswerViewed = 0; sm.AddSearch("count(1)"); var newcount = sm.LoadValue<int>(); OutResult(new { ncount = newcount }); }
public static int IsMoneyEnouth(int roomid, long userid, DateTime sdate, DateTime edate, out decimal balance, out int shopUserId, out string phoneNum, out decimal cost,out decimal price) { balance = 0; shopUserId = 0; phoneNum = string.Empty; cost = 0; price = 0; var days = edate.Subtract(sdate).Days; if (days <= 0) { return 0; } var userType = 1; var sm = new SearchModel("uv_MemberWithAmount"); sm["id"] = userid; sm.AddSearch("PhoneNum", "ShopUserID_G", "Balance_G"); var member = sm.LoadEntity<HQ_Member>(); if (member != null) { balance = member.Balance_G; shopUserId = member.ShopUserID_G; phoneNum = member.PhoneNum; userType = member.UserType; } else { return 0; } sm = new SearchModel("hq_room"); sm["id"] = roomid; sm.AddSearch("price", "vipprice"); var room = sm.LoadEntity<HQ_Room>(); if (room != null) { price = userType == 2 ? room.VipPrice : room.Price; } if (price == 0) { return 0; } cost = price * days; balance = balance - cost; if (balance < 0) { return -1; } return 1; }
public JsonResult LoadJsonData() { SearchModel sm=new SearchModel("uv_DisplayContent"); sm.AddSearch("ID","Name"); sm["DPanelType"]=(int)EnumDPanelType.Distination; sm.OrderBy("DPanelID"); var result= sm.Load<HQ_DisplayContent>(); var items= HtmlSelect.GetHtmlSelectByCollection<HQ_DisplayContent>(result.Data,(e)=> { return new HtmlSelectItem(){ k=e.Name,v=(int)e.ID}; }); return ExController.JsonNet(new { Villages=items }); }
public long ImportMember(string fpath) { fpath = Server.MapPath("~/" + fpath); if (!System.IO.File.Exists(fpath)) { return 0; } var list = G.Util.Tool.ExcelHelper.Read<HQ_Member>(fpath, new string[] { "UserName","PhoneNum","MemberMedical" }, 1, (e) => { e.PhoneNum = e.PhoneNum; e.UserPsw = e.PhoneNum.Substring(5); e.UserType = (int)EnumUserType.Normal; e.CreateBy = LoginInfo.Current.UserName; e.CreateOn = DateTime.Now; }); HttpClient _httpClient = new HttpClient(); _httpClient.BaseAddress = new Uri("http://mall.chinalvju.com/"); try { using (var scope = new TransactionScope()) { foreach (var l in list) { SearchModel se = new SearchModel("uv_MemberWithAmount"); se["UserName"] = l.UserName; se.AddSearch("ID", "PhoneNum", "ShopUserID_G"); var member = se.LoadEntity<HQ_Member>(); if (member == null) { se = new SearchModel("HQ_Member"); se["PhoneNum"] = l.PhoneNum; se.AddSearch("count(id)"); var memCount = se.LoadValue<int>(); if (memCount > 0) { continue; } var dic = new Dictionary<string, string>(); dic.Add("UserName", l.PhoneNum); dic.Add("NickName", l.UserName); dic.Add("Password", l.UserPsw); dic.Add("ConfirmPassword", l.UserPsw); _httpClient.PostAsync("Account/Register", new FormUrlEncodedContent(dic)); l.UserPsw = MD5.EncryptString(l.UserPsw); l.ShopPsw = l.UserPsw; l.Save(); } else { if (!l.PhoneNum.Equals(member.PhoneNum)) { //手机号码变化时,修改商城用户手机号码 Shop_Member s_mem = new Shop_Member(); s_mem["UserID"] = member.ShopUserID_G; s_mem["UserName"] = l.PhoneNum; s_mem.Save(); } var mem = new HQ_Member(); mem["id"] = member.ID; mem.PhoneNum = l.PhoneNum; mem.MemberMedical = l.MemberMedical; mem.Save(); } } scope.Complete(); } return 1; } catch { return 0; } }
public static int IsMoneyEnouth(int orderid,out decimal balance, out int shopUserId, out string phoneNum, out decimal cost) { balance = 0; shopUserId = 0; phoneNum = string.Empty; cost = 0; var price = 0; var userid = 0; var sm = new SearchModel("hq_bookroom"); sm["ID"] = orderid; var order = sm.LoadEntity<HQ_BookRoom>(); if (order == null) { return 0; } price = order.Price; userid = order.MemberID; var sdate = order.BookStartTime; var edate = order.BookEndTime; var days = edate.Subtract(sdate).Days; if (days <= 0) { return 0; } sm = new SearchModel("uv_MemberWithAmount"); sm["id"] = userid; sm.AddSearch("PhoneNum", "ShopUserID_G", "Balance_G"); var member = sm.LoadEntity<HQ_Member>(); if (member != null) { balance = member.Balance_G; shopUserId = member.ShopUserID_G; phoneNum = member.PhoneNum; } else { return 0; } cost = price * days; balance = balance - cost; if (balance < 0) { return -1; } return 1; }
public int SendMsgCode(string phone, string type) { if (type == null || type.Length == 0) { return -2;//系统错误 } if (phone != null && phone.Length > 0 && Regex.Match(phone, @"^[1][3,5,8][0-9]{9}$", RegexOptions.Compiled).Success) { var msgKey = string.Empty; if ("1".Equals(type)) { SearchModel se = new SearchModel("hq_member"); se["PhoneNum"] = phone; se.AddSearch("count(1)"); var count = se.LoadValue<int>(); if (count > 0) { return 9; } msgKey = "用户注册短信验证码:"; } if ("3".Equals(type)) { SearchModel se = new SearchModel("hq_member"); se["PhoneNum"] = phone; se.AddSearch("count(1)"); var count = se.LoadValue<int>(); if (count > 0) { return 9; } msgKey = "用户修改手机号码短信验证码:"; } if ("2".Equals(type)) { msgKey = "用户找回密码验证码:"; } var yzm = string.Empty; foreach (var i in Ran.GetRandomArray(6, 0, 9)) { yzm += i.ToString(); } SendUserInfo _U = new SendUserInfo() { isLog = 1, orgid = 555, username = phone }; if (MsgSend.DirectSend(msgKey + yzm, phone, _U)) { base.HttpContext.Cache["msg-" + phone] = yzm; return 1; } else { return 0; } } else { return -1; } }
public int FindPsw(string phone, string psw, string msgcode) { if (phone == null || phone.Length == 0) { return -1; } if (psw == null || psw.Length == 0) { return 0; } var omcode = base.HttpContext.Cache["msg-" + phone]; if (omcode == null || omcode.ToString().Length == 0) { return -2; } if (msgcode == null || msgcode.Length == 0 || !msgcode.Equals(omcode.ToString())) { return -3; } SearchModel sm = new SearchModel("hq_member"); sm["phonenum"] = phone; sm.AddSearch("id"); var id = sm.LoadValue<int>(); if (id > 0) { HQ_Member member = new HQ_Member(); member["id"] = id; member.UserPsw = MD5.EncryptString(psw); if (member.Save() > 0) { return 1; } return 0; } return -4; }
public long ChangeUserPhone(string phone, string yzm) { if (phone == null || phone.Length == 0 || !(Regex.Match(phone, @"^[1][3,5,8][0-9]{9}$", RegexOptions.Compiled).Success)) { return -1;//手机号码错误 } var omcode = base.HttpContext.Cache["msg-" + phone]; if (omcode == null || omcode.ToString().Length == 0) { return -2;//已发送的短信验证码不存在 } if (yzm == null || yzm.Length == 0 || !yzm.Equals(omcode.ToString())) { return -2;//输入的短信验证码错误 } SearchModel sm = new SearchModel("uv_MemberWithAmount"); sm["ID"] = LoginInfo.Current.UserID; sm.AddSearch("PhoneNum", "ShopUserID_G"); var mem = sm.LoadEntity<HQ_Member>(); try { using (var scope = new TransactionScope()) { if (mem.PhoneNum != phone) { Shop_Member s_mem = new Shop_Member(); s_mem["UserID"] = mem.ShopUserID_G; s_mem["UserName"] = phone; s_mem.Save(); } HQ_Member user = new HQ_Member(); user["ID"] = LoginInfo.Current.UserID; user.PhoneNum = phone; user.Save(); scope.Complete(); } } catch { return 0; } return 1; }
public JsonResult ChangeUserName(string newName) { if (newName.Length == 0) { return this.JsonNet(new CommonResult() { ResultID = 0, Message = "新用户名不能为空!" }); } if (newName == LoginInfo.Current.UserName) { return this.JsonNet(new CommonResult() { ResultID = 0, Message = "新用户名不能与旧用户名相同!" }); } try { lock (changeUNameLockObj) { SearchModel sm = new SearchModel("hq_member"); sm["username"] = newName; sm.AddSearch("count(id)"); var mcount = sm.LoadValue<int>(); if (mcount > 0) { return this.JsonNet(new CommonResult() { ResultID = 0, Message = "新用户名已被其他用户使用!" }); } using (var scope = new TransactionScope()) { sm = new SearchModel("uv_MemberWithAmount"); sm["username"] = LoginInfo.Current.UserName; sm.AddSearch("shopuserid_g"); var shopuserid = sm.LoadValue<int>(); Shop_Member smember = new Shop_Member(); smember["UserID"] = shopuserid; smember["NickName"] = newName; smember.Save(); HQ_Member mem = new HQ_Member(); mem["ID"] = LoginInfo.Current.UserID; mem.UserName = newName; mem.Save(); scope.Complete(); } } } catch { return this.JsonNet(new CommonResult() { ResultID = 0, Message = "修改用户名失败,请重试!" }); } return this.JsonNet(new { ResultID = 1 }); }
public static int IsRoomEnough(int roomid, DateTime sdate, DateTime edate) { if (sdate >= edate) { return 0; } SearchModel smroom = new SearchModel("hq_room"); smroom["ID"] = roomid; smroom.AddSearch("RCount"); var rcount = smroom.LoadEntity<HQ_Room>().RCount; SearchEntity sm = SearchEntity.FormSql("select count(1) id from hq_bookroom where roomid=@roomid and isnull(isdelete,0)=0 and bookendtime>=@stime and bookstarttime<=@etime", new SqlParameter("roomid", roomid), new SqlParameter("stime", sdate), new SqlParameter("etime", edate.Subtract(new TimeSpan(1, 0, 0, 0)))); var bcount = sm.LoadValue<Int32>(); if (bcount >= rcount) { return 0; } return 1; }
public void LoadNewCheaper(int page = 1, int psize = 999) { SearchModel sm = new SearchModel("uv_DisplayContent"); sm["DPanelType"] = (int)EnumDPanelType.NewCheaper; sm.OrderBy("id"); sm.PageIndex = page; sm.PageSize = psize; sm.AddSearch("id", "DPanel_G", "Name", "ImgName_G"); var result = sm.Load<HQ_DisplayContent>(); OutResult(result); }
public void LoadArticleDetail(int ptype, int vid) { SearchModel sm = null; if (ptype == 1 || ptype == 3 || ptype == 4 || ptype == 5) { sm = new SearchModel("HQ_DisplayContent"); sm["ID"] = vid; sm.AddSearch("Name", "DContent"); var dcon = sm.LoadEntity<HQ_DisplayContent>(); if (dcon != null) { OutResult(new { Name = dcon.Name, Content = reg.Replace(dcon.DContent, (match) => { return "<img class='uimg' _src='" + match.Groups[1].Value + "' />"; }) }); return; } } else if (ptype == 2) { sm = new SearchModel("HQ_Article"); sm["ID"] = vid; sm.AddSearch("Title", "AContent"); var article = sm.LoadEntity<HQ_Article>(); if (article != null) { OutResult(new { Name = article.Title, Content = reg.Replace(article.AContent, (match) => { return "<img class='uimg' _src='" + match.Groups[1].Value + "' />"; }) }); return; } } OutResult(new { Name = "...", Content = "您要查找的内容不存在!" }); }
public void LoadAllValliages(int page = 1, int psize = 999) { SearchModel sm = new SearchModel("uv_DisplayContent"); sm["DPanelType"] = (int)EnumDPanelType.Distination; sm["DType"] = (int)EnumVillageType.Village; sm.OrderBy("id"); sm.PageIndex = page; sm.PageSize = psize; sm.AddSearch("id", "DPanel_G", "Name", "ImgName_G"); var result = sm.Load<HQ_DisplayContent>(); OutResult(result); }