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()); }
public ActionResult Index(OrderQueryModels query, string msg) { ViewBag.Msg = msg; IList <Inpinke_Order> list = DBOrderBLL.GetOrderByQueryModels(PageInfo, query); ViewBag.QueryModel = query; return(View(list)); }
/// <summary> /// 阿里支付成功同步回调地址 /// </summary> /// <returns></returns> public ActionResult CallBack() { SortedDictionary <string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { AlipayNotify aliNotify = new AlipayNotify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 string trade_no = Request.QueryString["trade_no"]; //支付宝交易号 string order_no = Request.QueryString["out_trade_no"]; //获取订单号 string total_fee = Request.QueryString["total_fee"]; //获取总金额 string subject = Request.QueryString["subject"]; //商品名称、订单名称 string body = Request.QueryString["body"]; //商品描述、订单备注、描述 string buyer_email = Request.QueryString["buyer_email"]; //买家支付宝账号 string trade_status = Request.QueryString["trade_status"]; //交易状态 if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 BaseResponse br = DBOrderBLL.OrderPaySuccess(order_no, decimal.Parse(total_fee), buyer_email); if (br.IsSuccess) { return(RedirectToAction("success", "order", new { ordercode = order_no })); } else { ViewBag.Msg = "对不起未能成功处理您的订单[" + order_no + "],原因是:" + br.Message; return(View("error")); } } else { ViewBag.Msg = "对不起您的订单[" + order_no + "]支付失败了,交易状态:" + trade_status; Logger.Info(ViewBag.Msg); return(View("error")); } } else//验证失败 { ViewBag.Msg = "对不起您的订单[" + Request.QueryString["trade_no"] + "]支付失败了,支付返回数据异常"; Logger.Info(ViewBag.Msg); return(View("error")); } } else { ViewBag.Msg = "对不起您的订单[" + Request.QueryString["trade_no"] + "]订单支付失败了,支付返回参数为空"; Logger.Info(ViewBag.Msg); return(View("error")); } }
public ActionResult Order() { IList <Inpinke_Order> list = DBOrderBLL.GetUserOrder(PageInfo, UserSession.CurrentUser.ID); if (list != null && list.Count() > 0) { ViewBag.OrderList = list; int[] orderID = list.Select(e => e.ID).ToArray(); IList <Inpinke_Order_Product> pList = DBOrderBLL.GetOrderProduct(orderID); ViewBag.OrderProductList = pList; } return(View()); }
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> /// <returns></returns> public ActionResult Notify() { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { AlipayNotify aliNotify = new AlipayNotify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 string trade_no = Request.Form["trade_no"]; //支付宝交易号 string order_no = Request.Form["out_trade_no"]; //获取订单号 string total_fee = Request.Form["total_fee"]; //获取总金额 string subject = Request.Form["subject"]; //商品名称、订单名称 string body = Request.Form["body"]; //商品描述、订单备注、描述 string buyer_email = Request.Form["buyer_email"]; //买家支付宝账号 string trade_status = Request.Form["trade_status"]; //交易状态 if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 BaseResponse br = DBOrderBLL.OrderPaySuccess(order_no, decimal.Parse(total_fee), buyer_email); Logger.Info("Notify-1收到alipay的通知更新订单:" + order_no + "交易状态:" + trade_status); } else { Logger.Info("Notify-2收到alipay的通知更新订单:" + order_no + "交易状态:" + trade_status); } return(Content("success")); //请不要修改或删除 } else//验证失败 { return(Content("fail")); } } else { Logger.Info("Notify-3收到alipay的通知更新订单参数为空"); return(Content("无通知参数")); } }
public ActionResult Receive() { //人民币网关账号,该账号为11位人民币网关商户编号+01,该值与提交时相同。 string merchantAcctId = Request.QueryString["merchantAcctId"].ToString(); //网关版本,固定值:v2.0,该值与提交时相同。 string version = Request.QueryString["version"].ToString(); //语言种类,1代表中文显示,2代表英文显示。默认为1,该值与提交时相同。 string language = Request.QueryString["language"].ToString(); //签名类型,该值为4,代表PKI加密方式,该值与提交时相同。 string signType = Request.QueryString["signType"].ToString(); //支付方式,一般为00,代表所有的支付方式。如果是银行直连商户,该值为10,该值与提交时相同。 string payType = Request.QueryString["payType"].ToString(); //银行代码,如果payType为00,该值为空;如果payType为10,该值与提交时相同。 string bankId = Request.QueryString["bankId"].ToString(); //商户订单号,,该值与提交时相同。 string orderId = Request.QueryString["orderId"].ToString(); //订单提交时间,格式:yyyyMMddHHmmss,如:20071117020101,该值与提交时相同。 string orderTime = Request.QueryString["orderTime"].ToString(); //订单金额,金额以“分”为单位,商户测试以1分测试即可,切勿以大金额测试,该值与支付时相同。 string orderAmount = Request.QueryString["orderAmount"].ToString(); // 快钱交易号,商户每一笔交易都会在快钱生成一个交易号。 string dealId = Request.QueryString["dealId"].ToString(); //银行交易号 ,快钱交易在银行支付时对应的交易号,如果不是通过银行卡支付,则为空 string bankDealId = Request.QueryString["bankDealId"].ToString(); //快钱交易时间,快钱对交易进行处理的时间,格式:yyyyMMddHHmmss,如:20071117020101 string dealTime = Request.QueryString["dealTime"].ToString(); //商户实际支付金额 以分为单位。比方10元,提交时金额应为1000。该金额代表商户快钱账户最终收到的金额。 string payAmount = Request.QueryString["payAmount"].ToString(); //费用,快钱收取商户的手续费,单位为分。 string fee = Request.QueryString["fee"].ToString(); //扩展字段1,该值与提交时相同。 string ext1 = Request.QueryString["ext1"].ToString(); //扩展字段2,该值与提交时相同。 string ext2 = Request.QueryString["ext2"].ToString(); //处理结果, 10支付成功,11 支付失败,00订单申请成功,01 订单申请失败 string payResult = Request.QueryString["payResult"].ToString(); //错误代码 ,请参照《人民币网关接口文档》最后部分的详细解释。 string errCode = Request.QueryString["errCode"].ToString(); //签名字符串 string signMsg = Request.QueryString["signMsg"].ToString(); string signMsgVal = ""; signMsgVal = appendParam(signMsgVal, "merchantAcctId", merchantAcctId); signMsgVal = appendParam(signMsgVal, "version", version); signMsgVal = appendParam(signMsgVal, "language", language); signMsgVal = appendParam(signMsgVal, "signType", signType); signMsgVal = appendParam(signMsgVal, "payType", payType); signMsgVal = appendParam(signMsgVal, "bankId", bankId); signMsgVal = appendParam(signMsgVal, "orderId", orderId); signMsgVal = appendParam(signMsgVal, "orderTime", orderTime); signMsgVal = appendParam(signMsgVal, "orderAmount", orderAmount); signMsgVal = appendParam(signMsgVal, "dealId", dealId); signMsgVal = appendParam(signMsgVal, "bankDealId", bankDealId); signMsgVal = appendParam(signMsgVal, "dealTime", dealTime); signMsgVal = appendParam(signMsgVal, "payAmount", payAmount); signMsgVal = appendParam(signMsgVal, "fee", fee); signMsgVal = appendParam(signMsgVal, "ext1", ext1); signMsgVal = appendParam(signMsgVal, "ext2", ext2); signMsgVal = appendParam(signMsgVal, "payResult", payResult); signMsgVal = appendParam(signMsgVal, "errCode", errCode); ///UTF-8编码 GB2312编码 用户可以根据自己网站的编码格式来选择加密的编码方式 ///byte[] bytes = Encoding.GetEncoding("GB2312").GetBytes(signMsgVal); byte[] bytes = System.Text.Encoding.UTF8.GetBytes(signMsgVal); byte[] SignatureByte = Convert.FromBase64String(signMsg); X509Certificate2 cert = new X509Certificate2(AppDomain.CurrentDomain.BaseDirectory + "Content\\KQBill\\99bill.cert.rsa.20140728.cer", ""); RSACryptoServiceProvider rsapri = (RSACryptoServiceProvider)cert.PublicKey.Key; rsapri.ImportCspBlob(rsapri.ExportCspBlob(false)); RSAPKCS1SignatureDeformatter f = new RSAPKCS1SignatureDeformatter(rsapri); byte[] result; f.SetHashAlgorithm("SHA1"); SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider(); result = sha.ComputeHash(bytes); if (f.VerifySignature(result, SignatureByte)) { //支付成功 //在这里商户可以写上自己的业务逻辑 //逻辑处理 写入数据库 if (payResult == "10") { BaseResponse br = DBOrderBLL.OrderPaySuccess(orderId, decimal.Parse(orderAmount), payerName); if (br.IsSuccess) { return(Content("<result>1</result><redirecturl>http://inpinke.com/order/success?ordercode=" + orderId + "</redirecturl>")); } else { ViewBag.Msg = "对不起未能成功处理您的订单[" + orderId + "],原因是:" + br.Message; return(View("error")); } } else { ViewBag.Msg = string.Format("订单{0},支付失败,失败编号:{1},支付结果:{2}", orderId, errCode, payResult); log.Info(ViewBag.Msg); //以下是我们快钱设置的show页面,商户需要自己定义该页面。 return(View("error")); } } ViewBag.Msg = string.Format("订单{0},支付失败,失败编号:{1},支付结果:{2}", orderId, errCode, payResult); log.Info(ViewBag.Msg); //以下是我们快钱设置的show页面,商户需要自己定义该页面。 return(View("error")); }
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 })); }