/// <summary> /// 添加订单 /// </summary> /// <param name="model"></param> /// <returns></returns> public static BaseResponse AddOrder(Inpinke_Order model) { BaseResponse br = new BaseResponse(); br.IsSuccess = false; try { model.CreateTime = DateTime.Now; model.UpdateTime = DateTime.Now; model.Status = (int)RecordStatus.Nomral; model.InsertWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); if (AddOrderProduct(model.ID, model.UserID).IsSuccess) { //清空购物车 DBCartBLL.ClearUserCart(model.UserID); br.IsSuccess = true; br.ResponseObj = model; } else { br.IsSuccess = false; br.Message = "添加订单礼品失败"; br.ResponseObj = model; } return(br); } catch (Exception ex) { Logger.Error(string.Format("AddOrder UserID:{0}, Error:{1}", model.UserID, ex.ToString())); br.IsSuccess = false; br.Message = "添加订单失败,请稍后再试"; return(br); } }
public ActionResult Modify(int orderid) { Inpinke_Order model = DBOrderBLL.GetOrderByID(orderid); if (model == null) { //跳转到出错页面 return(Redirect("/error.htm?msg=对不起没有找到您要修改的订单")); } ViewBag.Order = model; IList <Inpinke_Order_Product> prodList = DBOrderBLL.GetOrderProduct(model.ID); if (prodList == null) { //跳转到出错页面 return(Redirect("/error.htm?msg=对不起没有找到您要修改的订单")); } ViewBag.ProductList = prodList; IList <Inpinke_User_Address> address = DBAddressBLL.GetUserAddress(UserSession.CurrentUser.ID); if (address != null && address.Count() > 0) { ViewBag.UserAddress = address; } return(View()); }
/// <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); }
public ActionResult Edit(int id, string msg) { ViewBag.Msg = msg; Inpinke_Order model = DBOrderBLL.GetOrderByID(id); if (model == null) { return(RedirectToAction("index", new { msg = "未找到要编辑的订单" })); } //获取订单礼品 ViewBag.OrderProducts = DBOrderBLL.GetOrderProduct(model.ID); return(View(model)); }
public ActionResult Detail(int orderid) { Inpinke_Order model = DBOrderBLL.GetOrderByID(orderid); IList <Inpinke_Order_Product> prodList = DBOrderBLL.GetOrderProduct(model.ID); if (prodList == null) { //跳转到出错页面 return(Redirect("/error.htm?msg=对不起没有找到您要支付的订单")); } ViewBag.ProductList = prodList; ViewBag.Order = model; return(View()); }
/// <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); }
/// <summary> /// 设置订单关联印品状态 /// </summary> /// <param name="o_model"></param> /// <param name="adminname"></param> /// <param name="isMaking"></param> private void SetOrderMaking(Inpinke_Order o_model, string adminname, bool isMaking) { 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); } } } }
public ActionResult Index(int orderid) { Inpinke_Order model = DBOrderBLL.GetOrderByID(orderid); if (model == null) { ViewBag.Msg = "对不起,没有找到您要支付的订单,请尝试重新登录下单。"; return(View("error")); } //必填参数// //请与贵网站订单系统中的唯一订单号匹配 string out_trade_no = model.OrderCode; //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。 string subject = "Inpinke-印品客印品"; //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里 string body = "您在Inpinke-印品客网站定制印刷的" + model.Inpinke_Order_Products.Count() + "件印品"; //订单总金额,显示在支付宝收银台里的“应付总额”里 string total_fee = model.TotalPrice.ToString(); //扩展功能参数——默认支付方式// //默认支付方式,代码见“即时到帐接口”技术文档 string paymethod = ""; //默认网银代号,代号列表见“即时到帐接口”技术文档“附录”→“银行列表” string defaultbank = ""; //扩展功能参数——防钓鱼// //防钓鱼时间戳 string anti_phishing_key = ""; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 string exter_invoke_ip = ""; //注意: //请慎重选择是否开启防钓鱼功能 //exter_invoke_ip、anti_phishing_key一旦被设置过,那么它们就会成为必填参数 //建议使用POST方式请求数据 //示例: //exter_invoke_ip = ""; //Service aliQuery_timestamp = new Service(); //anti_phishing_key = aliQuery_timestamp.Query_timestamp(); //获取防钓鱼时间戳函数 //扩展功能参数——其他// //商品展示地址,要用http:// 格式的完整路径,不允许加?id=123这类自定义参数 string show_url = AlipayConfig.Show_Url; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 string extra_common_param = ""; //默认买家支付宝账号 string buyer_email = ""; //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值)// //提成类型,该值为固定值:10,不需要修改 string royalty_type = ""; //提成信息集 string royalty_parameters = ""; //注意: //与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条 //各分润金额的总和须小于等于total_fee //提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2 //示例: //royalty_type = "10"; //royalty_parameters = "[email protected]^0.01^分润备注一|[email protected]^0.01^分润备注二"; //构造即时到帐接口表单提交HTML数据,无需修改 //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("show_url", show_url); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("body", body); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("paymethod", paymethod); sParaTemp.Add("defaultbank", defaultbank); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); sParaTemp.Add("extra_common_param", extra_common_param); sParaTemp.Add("buyer_email", buyer_email); sParaTemp.Add("royalty_type", royalty_type); sParaTemp.Add("royalty_parameters", royalty_parameters); AlipayService ali = new AlipayService(); string sHtmlText = ali.Create_direct_pay_by_user(sParaTemp); return(Content(sHtmlText)); }
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")); } }
public ActionResult OrderInfo(OrderInfoModel orderInfo) { IList <Inpinke_User_Address> addressList = DBAddressBLL.GetUserAddress(UserSession.CurrentUser.ID); if (addressList != null && addressList.Count() > 0) { ViewBag.UserAddress = addressList; } Inpinke_User_Address address = new Inpinke_User_Address(); if (orderInfo.AddressID > 0) { address = addressList.Where(e => e.ID == orderInfo.AddressID).FirstOrDefault(); if (address == null) { ViewBag.Msg = "不存在该收货人信息,请重新填写"; return(View()); } } else { if (!ModelState.IsValid) { ViewBag.Msg = "输入信息有误,麻烦再检查一下"; return(View()); } address = new Inpinke_User_Address() { Address = orderInfo.Address, AreaID = orderInfo.AreaID, ProvID = orderInfo.ProvID, CityID = orderInfo.CityID, Mobile = orderInfo.Mobile, UserID = UserSession.CurrentUser.ID, UserName = orderInfo.Consignee }; BaseResponse br = DBAddressBLL.AddUserAddress(address); if (!br.IsSuccess) { ViewBag.Msg = br.Message; return(View()); } } IList <Inpinke_Cart> cartList = DBCartBLL.GetUserCart(UserSession.CurrentUser.ID); decimal orderPrice = DBCartBLL.GetCartTotalPrices(UserSession.CurrentUser.ID); Inpinke_Order order = new Inpinke_Order() { OrderCode = DBOrderBLL.GetOrderCode(cartList[0].Inpinke_Product.ProductType), AddressID = address.ID, RecUserName = address.UserName, RecMobile = address.Mobile, RecProvID = address.ProvID, RecCityID = address.CityID, RecAreaID = address.AreaID, RecAddress = address.Address, RecAreaName = address.AreaName, RecCityName = address.CityName, RecProvName = address.ProvName, UserID = UserSession.CurrentUser.ID, OrgPrice = orderPrice, TotalPrice = orderPrice, UserRemark = orderInfo.Remark }; BaseResponse br1 = DBOrderBLL.AddOrder(order); if (!br1.IsSuccess) { ViewBag.Msg = br1.Message; return(View()); } return(RedirectToAction("Pay", new { orderid = order.ID })); }