public ActionResult Query(string credNo) { QueryViewModel query = new QueryViewModel() { CredNo = credNo }; var db = ConnHelper.CreateDb(); if (!db.Order_Info.Any(s => s.CredNo == credNo)) { ModelState.AddModelError("error", "该身份证不存在!"); return(View(query)); } var list = db.Order_Info.Where(s => s.State == 1 && s.CredNo == credNo).OrderByDescending(s => s.AddTime).ToList(); foreach (var item in list) { var happy_card = db.HappyCard_Class.Single(s => s.State == 1 && s.ClassID == item.ClassID); query.Orders.Add(new OrderInfoViewModel() { AddTime = item.AddTime, ClassId = item.ClassID, ClassName = happy_card.ClassName, DiscountPrice = Convert.ToDecimal(happy_card.DiscountPrice), MunPrice = item.MunPrice, Rtong = item.Rtong, IsLingPiao = item.IsLingPiao }); } return(View(query)); }
public ActionResult ChooseTicket(FormCollection formCollection) { var shopCarViewModel = Session["Car"] as ShopCarViewModel ?? new ShopCarViewModel(); shopCarViewModel.TicketInfo.Clear(); shopCarViewModel.CardInfo.Clear(); var db = ConnHelper.CreateDb(); decimal sum = 0; foreach (var item in formCollection.AllKeys) { var id = Convert.ToInt32(item); var happyCardClass = db.HappyCard_Class.FirstOrDefault(s => s.ClassID == id); if (happyCardClass != null) { shopCarViewModel.TicketInfo.Add(new GoodsMessage { ClassId = happyCardClass.ClassID, ClassName = happyCardClass.ClassName, SumCount = Convert.ToInt32(formCollection[item]), SumPrice = Convert.ToDecimal(Convert.ToInt32(formCollection[item]) * happyCardClass.DiscountPrice) }); sum += Convert.ToDecimal(Convert.ToInt32(formCollection[item]) * happyCardClass.DiscountPrice); } } shopCarViewModel.UserInfo.SumPrice = sum; Session["Car"] = shopCarViewModel; return(RedirectToAction("InformationTicket")); }
public BookingViewModel() { var db = ConnHelper.CreateDb(); Tickets = db.HappyCard_Class.Where(s => s.Type == "门票" && s.State == 1).ToList(); Cards = db.HappyCard_Class.Where(s => s.Type == "年卡" && s.State == 1).ToList(); }
private static string AddOrder(ShopCarViewModel shopCarViewModel) { string str = ""; var db = ConnHelper.CreateDb(); Random random = new Random(); var orderId = DateTime.Now.ToString("yyyyMMddHHmmssfff") + random.Next(0, 9); List <GoodsMessage> items; if (shopCarViewModel.CardInfo.Count == 0) { items = shopCarViewModel.TicketInfo; str = "购买票"; } else { items = shopCarViewModel.CardInfo; str = "购买年卡"; } foreach (var item in items) { if (item.SumCount == 0) { continue; } var orderInfoEntity = new Order_Info(); orderInfoEntity.ClassID = item.ClassId; orderInfoEntity.Cred = "身份证"; orderInfoEntity.CredNo = shopCarViewModel.UserInfo.UserCard; orderInfoEntity.Cren = 0; orderInfoEntity.Email = ""; orderInfoEntity.Isfs = 0; orderInfoEntity.IsLingPiao = 0; orderInfoEntity.Lren = 0; orderInfoEntity.Mobile = shopCarViewModel.UserInfo.Phone; orderInfoEntity.MunPrice = item.SumPrice; orderInfoEntity.OrderID = orderId; orderInfoEntity.RTime = shopCarViewModel.UserInfo.GoDate.ToShortDateString(); orderInfoEntity.Rtong = item.SumCount; orderInfoEntity.State = 0; orderInfoEntity.Ticket = shopCarViewModel.UserInfo.Name; orderInfoEntity.Ticketer = shopCarViewModel.UserInfo.Name; orderInfoEntity.Type = 0; orderInfoEntity.AddTime = DateTime.Now; orderInfoEntity.Detail = "手机网站"; orderInfoEntity.IsPost = 0; orderInfoEntity.IsSMPost = 0; db.Order_Info.Add(orderInfoEntity); } db.SaveChanges(); LogHelper.CreateLog("游客开始在官方网站下订单->当前未支付!(" + str + ")", orderId.ToString()); return(orderId.ToString()); }