public override bool TakeAction() { HXSCEntities hxsc = new HXSCEntities(); if (hxsc.UserInfo.FirstOrDefault(o => o.Userid == Userid) == null) { return(SetError("用户不存在!")); } OrderH orderH = hxsc.OrderH.FirstOrDefault(o => o.OrderhId == orderid); if (orderH == null) { return(SetError("订单不存在!")); } if (orderH.Start == 0) { SetError("未付款订单不能退货!"); } var orderDlist = (from od in hxsc.OrderD where od.Orderhid == orderid select od).ToList(); foreach (var item in Contenttxt) { if (orderDlist.Find(o => o.Itemid == item.Itemid) == null) { return(SetError("订单图书不存在")); } } ReturnedH returnedH = new ReturnedH() { Amt = Contenttxt.Sum(o => o.Amt), Orderid = orderid, Source = key, State = 0, Userid = Userid, CreateTime = DateTime.Now, }; hxsc.ReturnedH.AddObject(returnedH); hxsc.SaveChanges(); foreach (var item in Contenttxt) { ReturnedD returnedD = new ReturnedD() { Amt = item.Amt, Createtime = DateTime.Now, Itemid = item.Itemid, Returnedid = returnedH.ReturnedId, Serial = "", State = 0 }; hxsc.ReturnedD.AddObject(returnedD); } hxsc.SaveChanges(); return(true); }
private bool GetMath(OrderH o) { if (!string.IsNullOrEmpty(User_id) && createtime == DateTime.MinValue) { return(o.UserId == User_id); } else if (string.IsNullOrEmpty(User_id) && createtime != DateTime.MinValue) { return(o.CreateTime > createtime); } else if (!string.IsNullOrEmpty(User_id) && createtime != DateTime.MinValue) { return(o.CreateTime > createtime && o.UserId == User_id); } return(true); }
public override bool TakeAction() { HXSCEntities hxsc = new HXSCEntities(); var userinfo = hxsc.UserInfo.FirstOrDefault(o => o.Userid == userid); if (userinfo == null) { return(SetError("用户不存在!")); } OrderH orderH = new OrderH() { Amt = itemArr.Sum(o => o.amt), CreateTime = DateTime.Now, UserId = userid, Start = 0, Source = key, Discount = 0, ReceiveAddress = Receiveaddress, Realamt = itemArr.Sum(o => o.price), Phone = Phone, OrderhId = Guid.NewGuid().ToString().Replace("-", "") }; hxsc.OrderH.AddObject(orderH); foreach (var itemn in itemArr) { OrderD orderD = new OrderD() { Amt = itemn.amt, Createtime = DateTime.Now, Discount = itemn.discount, Itemid = itemn.itemid, Start = 0, Serial = itemn.serial, Realamt = itemn.realamt, Price = itemn.price, Number = itemn.number, Orderhid = orderH.OrderhId }; hxsc.OrderD.AddObject(orderD); } hxsc.SaveChanges(); return(true); }
private Layer BuldierLayer(OrderH order) { Layer layer = new Layer() { amt = order.Amt.ToString(), createtime = order.CreateTime.ToString(), discount = order.Discount.ToString(), express = order.Express, expressno = order.ExpressNo, expresstime = order.ExpressTime.ToString(), orderhid = order.OrderhId, phone = order.Phone, realamt = order.Realamt.ToString(), Receiveaddress = order.ReceiveAddress, star = order.Start.ToString(), userid = order.UserId }; return(layer); }
public override bool TakeAction() { HXSCEntities hxsc = new HXSCEntities(); ReturnedH ReturnedH = hxsc.ReturnedH.FirstOrDefault(o => o.ReturnedId == returnedid); if (ReturnedH == null) { return(SetError("退货单不存在!")); } if (ReturnedH.State != 0) { return(SetError("已经退货!")); } OrderH orderH = hxsc.OrderH.FirstOrDefault(o => o.OrderhId == ReturnedH.Orderid); if (orderH == null) { return(SetError("订单不存在!")); } if (orderH.Start == 0) { return(SetError("未付款订单不能退货!")); } var returnedD = (from o in hxsc.ReturnedD where o.Returnedid == returnedid select o).ToList(); ReturnedH.State = state; foreach (var item in returnedD) { item.State = state; OrderD orderD = hxsc.OrderD.FirstOrDefault(o => o.Itemid == item.Itemid); if (orderD != null) { orderD.Start = 3; } } hxsc.SaveChanges(); return(true); }
public override bool TakeAction() { HXSCEntities hxsc = new HXSCEntities(); string[] itemidArr = itemidList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (itemidArr.Length == 0) { return(SetError("图书信息不能为空!")); } foreach (var sitemid in itemidArr) { int itemid = 0; int.TryParse(sitemid, out itemid); Item item = hxsc.Item.FirstOrDefault(o => o.Itemid == itemid); if (item == null) { return(SetError("图书信息不存在!")); } OrderD orderD = new OrderD() { Amt = item.Price, Createtime = DateTime.Now, Discount = 1, Itemid = itemid, Number = 1, Orderhid = "", Price = item.Price, Realamt = item.Price, Serial = 0, Start = 0 }; list.Add(orderD); } OrderH orderH = new OrderH() { Amt = 0, CreateTime = DateTime.Now, Discount = 0, Express = "", ExpressNo = "", ExpressTime = DateTime.Now, Phone = "", Realamt = 0, ReceiveAddress = "", Source = key, Start = 0, UserId = userid }; hxsc.OrderH.AddObject(orderH); hxsc.SaveChanges(); foreach (var item in list) { item.Orderhid = orderH.OrderhId; hxsc.OrderD.AddObject(item); } hxsc.SaveChanges(); return(true); }