/// <summary> /// 设置订单为印制中锁定对应印品防止修改 /// </summary> /// <param name="ordercode"></param> /// <param name="adminname"></param> /// <returns></returns> public static BaseResponse SetOrderMaking(string ordercode, string adminname, bool isMaking) { BaseResponse br = new BaseResponse(); br.IsSuccess = false; try { Inpinke_Order o_model = DBOrderBLL.GetOrderByCode(ordercode); int bookStatus = isMaking ? (int)BookStatus.Making : (int)BookStatus.Create; if (o_model.Inpinke_Order_Products != null) { foreach (Inpinke_Order_Product p in o_model.Inpinke_Order_Products) { //把印品设置为印刷中,防止编辑 if (p.BookID != 0 && p.Inpinke_Book != null) { p.Inpinke_Book.BookStauts = bookStatus; p.Inpinke_Book.SaveWhenSubmit(InpinkeDataContext.Instance); } } } o_model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); br.IsSuccess = true; br.Message = "订单处理成功"; } catch (Exception ex) { Logger.Error(string.Format("SetOrderMaking OrderCode:{0}, Error:{1}", ordercode, ex.ToString())); br.IsSuccess = false; br.Message = "订单处理失败,请稍后再试"; } return(br); }
/// <summary> /// 订单支付成功相关操作 /// </summary> /// <param name="ordercode"></param> /// <returns></returns> public static BaseResponse OrderPaySuccess(string ordercode, decimal totalfee, string buyerinfo) { BaseResponse br = new BaseResponse(); br.IsSuccess = false; try { Inpinke_Order o_model = DBOrderBLL.GetOrderByCode(ordercode); if (o_model.OrderStatus == (int)OrderStatus.Create) { o_model.OrderStatus = (int)OrderStatus.WaitSend; o_model.PayTime = DateTime.Now; o_model.PayMethod = (int)PayMethod.Alipay; o_model.TotalFee = totalfee; o_model.BuyerInfo = buyerinfo; if (o_model.Inpinke_Order_Products != null) { foreach (Inpinke_Order_Product p in o_model.Inpinke_Order_Products) { //把印品设置为印刷中,防止编辑 if (p.BookID != 0 && p.Inpinke_Book != null) { p.Inpinke_Book.BookStauts = (int)BookStatus.Making; p.Inpinke_Book.SaveWhenSubmit(InpinkeDataContext.Instance); } } } o_model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); br.IsSuccess = true; br.Message = "订单处理成功"; } else { br.IsSuccess = false; br.Message = "订单状态异常"; Logger.Info(string.Format("OrderPaySuccess:" + br.Message + "。订单号:" + o_model.OrderCode)); } } catch (Exception ex) { Logger.Error(string.Format("OrderPaySuccess OrderCode:{0}, Error:{1}", ordercode, ex.ToString())); br.IsSuccess = false; br.Message = "订单处理失败,请稍后再试"; } return(br); }
public ActionResult Edit(FormCollection col) { int orderid = int.Parse(col["ID"]); try { Inpinke_Order model = DBOrderBLL.GetOrderByID(orderid); ViewBag.Order = model; IList <Inpinke_Order_Product> prodList = DBOrderBLL.GetOrderProduct(model.ID); ViewBag.ProductList = prodList; decimal totalPrice = 0; foreach (Inpinke_Order_Product p in prodList) { int bookid = p.BookID; if (string.IsNullOrEmpty(col["num_" + bookid])) { totalPrice += p.Price; continue; } p.Num = int.Parse(col["num_" + bookid]); if (p.Num <= 0) { ViewBag.Msg = "印品购买数量不能少于1件"; return(RedirectToAction("edit", new { id = orderid, msg = ViewBag.Msg + DateTime.Now.ToString("yyyy-MM-dd mm:ss") })); } p.CouponID = int.Parse(col["coupon_select_" + bookid]); p.Envelope = int.Parse(col["envelope_" + bookid]); p.Price = DBBookBLL.GetBookPrice(bookid, p.CouponID, p.Num); p.UpdateTime = DateTime.Now; p.SaveWhenSubmit(InpinkeDataContext.Instance); totalPrice += p.Price; } model.OrgPrice = totalPrice; model.TotalPrice = totalPrice; int orgOrderStatus = model.OrderStatus; model.OrderStatus = int.Parse(col["OrderStatus"]); model.UserRemark = col["Remark"]; //收货人信息 model.RecUserName = col["UserName"]; model.RecMobile = col["Mobile"]; model.RecAddress = col["Address"]; model.RecAreaID = int.Parse(col["AreaID"]); model.RecProvID = int.Parse(col["ProvID"]); model.RecCityID = int.Parse(col["CityID"]); model.RecProvName = DBProvinceBLL.GetProvName(model.RecProvID.Value); model.RecCityName = DBProvinceBLL.GetCityName(model.RecCityID.Value); model.RecAreaName = DBProvinceBLL.GetAreaName(model.RecAreaID.Value); model.UpdateTime = DateTime.Now; model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); //锁定印品防止编辑 if (model.OrderStatus == (int)OrderStatus.WaitSend && orgOrderStatus != (int)OrderStatus.WaitSend) { SetOrderMaking(model, "", true); } if (model.OrderStatus != (int)OrderStatus.WaitSend && orgOrderStatus == (int)OrderStatus.WaitSend) { SetOrderMaking(model, "", false); } return(RedirectToAction("edit", new { id = orderid, msg = "编辑成功" + DateTime.Now.ToString("yyyy-MM-dd mm:ss") })); } catch (Exception ex) { ViewBag.Msg = "修改订单信息失败,请稍后再试"; Logger.Error(string.Format("修改订单信息-Edit Error:{0}", ex.ToString())); return(RedirectToAction("edit", new { id = orderid, msg = ViewBag.Msg + DateTime.Now.ToString("yyyy-MM-dd mm:ss") })); } }
public ActionResult Modify(FormCollection col) { try { int orderid = int.Parse(col["ID"]); Inpinke_Order model = DBOrderBLL.GetOrderByID(orderid); ViewBag.Order = model; IList <Inpinke_Order_Product> prodList = DBOrderBLL.GetOrderProduct(model.ID); ViewBag.ProductList = prodList; IList <Inpinke_User_Address> address = DBAddressBLL.GetUserAddress(UserSession.CurrentUser.ID); if (address != null && address.Count() > 0) { ViewBag.UserAddress = address; } model.AddressID = int.Parse(col["AddressID"]); Inpinke_User_Address selAddress = DBAddressBLL.GetAddressByID(model.AddressID); model.RecUserName = selAddress.UserName; model.RecMobile = selAddress.Mobile; model.RecAddress = selAddress.Address; model.RecAreaID = selAddress.AreaID; model.RecProvID = selAddress.ProvID; model.RecCityID = selAddress.CityID; model.RecProvName = selAddress.ProvName; model.RecCityName = selAddress.CityName; model.RecAreaName = selAddress.AreaName; decimal totalPrice = 0; foreach (Inpinke_Order_Product p in prodList) { int bookid = p.BookID; if (string.IsNullOrEmpty(col["num_" + bookid])) { totalPrice += p.Price; continue; } p.Num = int.Parse(col["num_" + bookid]); if (p.Num <= 0) { ViewBag.Msg = "印品购买数量不能少于1件"; return(View()); } p.CouponID = int.Parse(col["coupon_select_" + bookid]); p.Envelope = int.Parse(col["envelope_" + bookid]); p.Price = DBBookBLL.GetBookPrice(bookid, p.CouponID, p.Num); p.UpdateTime = DateTime.Now; p.SaveWhenSubmit(InpinkeDataContext.Instance); totalPrice += p.Price; } model.OrgPrice = totalPrice; model.TotalPrice = totalPrice; model.UserRemark = col["Remark"]; model.UpdateTime = DateTime.Now; model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); return(RedirectToAction("pay", new { orderid = orderid })); } catch (Exception ex) { ViewBag.Msg = "修改订单信息失败,请稍后再试"; Logger.Error(string.Format("修改订单信息-Modify Error:{0}", ex.ToString())); return(View("error")); } }