/// <summary> /// 查询网上支付情况 /// </summary> /// <param name="sosysno">订单编号</param> /// <returns>true: 已通过网上支付 / false: 未通过网上支付</returns> protected bool IsPayed(int sosysno) { //查询网上支付情况 NetPayInfo netpay = NetPayManager.GetInstance().Load(sosysno); if (netpay == null) { return(false); } else { return(true); } }
protected void btnEnter_Click(object sender, EventArgs e) { if (txtTradeNo.Text != string.Empty) { int Result = 0; bool IsAdd = true; int SOSysNo = Int32.Parse(lblSOID.Text.Substring(1)); SOAlipayInfo oInfo = SaleManager.GetInstance().LoadSOAlipay(SOSysNo); if (oInfo == null) { oInfo = new SOAlipayInfo(); oInfo.SOSysNo = SOSysNo; oInfo.AlipayTradeNo = txtTradeNo.Text.Trim(); Result = SaleManager.GetInstance().InsertSOAlipay(oInfo); lblResult.Text = "输入支付宝交易号完成!"; } else { IsAdd = false; oInfo.AlipayTradeNo = txtTradeNo.Text.Trim(); Result = SaleManager.GetInstance().UpdateSOAlipay(oInfo); lblResult.Text = "更新支付宝交易号完成!"; } if (Result == 1) { SOInfo order = SaleManager.GetInstance().LoadSOMaster(SOSysNo); if (order != null) { if (IsAdd) { NetPayInfo netpay = new NetPayInfo(); netpay.SOSysNo = SOSysNo; netpay.PayTypeSysNo = order.PayTypeSysNo; netpay.InputTime = DateTime.Now; netpay.Source = (int)AppEnum.NetPaySource.Bank; netpay.PayAmount = order.GetTotalAmt(); netpay.Status = (int)AppEnum.NetPayStatus.Origin; netpay.Note = "支付宝即时到帐付款"; NetPayManager.GetInstance().Insert(netpay); } } lblResult.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); //TODO: //上线需要verifyResult==true if (!verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.Form["out_trade_no"]; //支付宝交易号 string trade_no = Request.Form["trade_no"]; //交易状态 string trade_status = Request.Form["trade_status"]; if (Request.Form["trade_status"] == "TRADE_FINISHED") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 //注意: //该种交易状态只在两种情况下出现 //1、开通了普通即时到账,买家付款成功后。 //2、开通了高级即时到账,从该笔交易成功时间算起,过了签约时的可退款时限(如:三个月以内可退款、一年以内可退款等)后。 } else if (Request.Form["trade_status"] == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 //注意: //该种交易状态只在一种情况下出现——开通了高级即时到账,买家付款成功后。 } else { } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— try { //更新自己数据库的订单语句,请自己填写一下 string SOsysno = Request.Form["out_trade_no"]; int sosysno = Int32.Parse(SOsysno); if (NetPayManager.GetInstance().IsPayedForAlipay(sosysno)) { Response.Write("fail"); return; } SOInfo order = SaleManager.GetInstance().LoadSOMaster(sosysno); if (order != null) { NetPayInfo netpay = new NetPayInfo(); netpay.SOSysNo = Int32.Parse(SOsysno); netpay.PayTypeSysNo = order.PayTypeSysNo; netpay.InputTime = DateTime.Now; netpay.Source = (int)AppEnum.NetPaySource.Bank; netpay.PayAmount = decimal.Parse(Request.Form["total_fee"]); netpay.Status = (int)AppEnum.NetPayStatus.Origin; //netpay.Note = Request.QueryString["msg"]; NetPayManager.GetInstance().Insert(netpay); if (netpay.PayAmount >= order.GetTotalAmt()) { //客人通过网上支付后,自动修改订单状态为已付款,默认为ias审核,userSysNo=33 NetPayManager.GetInstance().Verify(netpay.SysNo, 33); Response.Write("success"); } else { Response.Write("success"); } } else { Response.Write("fail"); } } catch { Response.Write("fail"); } } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
/// <summary> /// 获得用户的订单列表 /// </summary> /// <param name="customSysNo"></param> /// <param name="pageNum"></param> /// <returns></returns> public static string GetCustomerOrderList(int customSysNo, int pageNum) { string orderListHTML = String.Empty; int pageCount = int.Parse(YoeJoyConfig.MyOrderProductListPagedCount); List <OrderModuel> orderList = OrderService.GetMyOrder(customSysNo, pageNum, pageCount); if (orderList != null) { StringBuilder strb = new StringBuilder(); string tabRowHTMLTemplate = @" <tr class='orderList'> <td> <img src='{0}'> </td> <td> <p><a href='{1}'>{2}</a></p> <p><b>¥{3}</b>X{4}</p> </td> <th> <a class='reBuy' href='{5}'>再次购买</a><br> <a class='reBuy' href='{6}'>发表评论</a> </th> </tr>"; foreach (var orderListItem in orderList) { strb.Append(@"<table class='order' cellSpacing='0' cellPadding='0'><tbody>"); string orderDetailDeeplink = String.Concat(YoeJoyConfig.SiteBaseURL, "User/MyOrderDetail.aspx?ID=", orderListItem.SysNo); string orderUpdateDeeplink = String.Concat(YoeJoyConfig.SiteBaseURL, "User/MyOrderDetail.aspx?action=update&ID=", orderListItem.SysNo); string orderCancelDeeplink = String.Concat(YoeJoyConfig.SiteBaseURL, "User/MyOrderDetail.aspx?action=cancel&ID=", orderListItem.SysNo); bool IsNet = (orderListItem.IsNet == (int)AppEnum.YNStatus.Yes) ? true : false; bool IsPayWhenRecv = (orderListItem.IsPayWhenEcv == (int)AppEnum.YNStatus.Yes) ? true : false; strb.Append("<tr><th class='orderNum' rowSpan='3'>"); strb.Append("<p>订单编号:<a href='" + orderDetailDeeplink + "'>" + orderListItem.SysNo + "</a></p>"); strb.Append("<p>订购日期:" + orderListItem.OrderDate.ToString("yyyy-mm-dd") + "</p>"); if (IsNet) { strb.Append("<p>付款方式:在线支付</p>"); } if (IsPayWhenRecv) { strb.Append("<p>订单总计:¥" + orderListItem.TotalCash.ToString("#####0.00") + "</p>"); } strb.Append("<p>使用积分:" + orderListItem.PointPay + "</p>"); strb.Append("<p>可获积分:" + orderListItem.Pointamt + "</p>"); strb.Append("<p><a href='" + orderDetailDeeplink + "'>订单详情</a></p>"); strb.Append("</th><td colSpan='3'><h2 class='ordertitlts'><span class='l'><b>"); strb.Append(AppEnum.GetSOStatus(Util.TrimIntNull(orderListItem.Status))); strb.Append("</b></span><span class='r'>"); bool isPayed = NetPayManager.GetInstance().IsPayed(orderListItem.SysNo); if (orderListItem.Status == (int)AppEnum.SOStatus.Origin && !isPayed) { strb.Append("<a href='MyOrderDetail.aspx?action=cancel&ID=" + orderListItem.SysNo + "'>作废订单</a>"); strb.Append("<a href='MyOrderDetail.aspx?action=update&ID=" + orderListItem.SysNo + "'>修改订单</a>"); } if (orderListItem.Status == (int)AppEnum.SOStatus.Origin || orderListItem.Status == (int)AppEnum.SOStatus.WaitingPay || orderListItem.Status == (int)AppEnum.SOStatus.WaitingManagerAudit) { if (Util.TrimNull(orderListItem.PagementPage) != AppConst.StringNull && !isPayed && Util.TrimIntNull(orderListItem.IsNet) == (int)AppEnum.YNStatus.Yes) { strb.Append("<a href='../Shopping/" + Util.TrimNull(orderListItem.PagementPage) + "?id=" + orderListItem.SysNo + "&sono=" + orderListItem.SoId + "&soamt=" + orderListItem.TotalCash.ToString("#####0.00") + "'>支付货款</a>"); } } DataTable dt = RMARequestManager.GetInstance().GetRMABySO(orderListItem.SysNo); if (dt != null) { strb.Append("<a href='../Account/RMAQuery.aspx?Type=single&ID=" + orderListItem.SysNo + "'>查看返修信息</a>"); } strb.Append("<a href='MyOrderDetail.aspx?ID=" + orderListItem.SysNo + "'>查看订单明细</a>"); if (Util.TrimNull(orderListItem.Memo) != String.Empty) { strb.Append("<tr><td height=25px align=right bgcolor=#E7F9F9>备注信息:</td><td colspan=5 bgcolor=#ffffff>" + orderListItem.Memo + "</td></tr>"); } strb.Append(" </span></h2></td>"); strb.Append("</tr>"); if (orderListItem.ProductList != null) { foreach (var productListItem in orderListItem.ProductList) { string deeplink = String.Concat(YoeJoyConfig.SiteBaseURL, "Pages/Product.aspx?c1=", productListItem.C1SysNo, "&c2=", productListItem.C2SysNo, "&c3=", productListItem.C3SysNo, "&pid=", productListItem.ProductSysNo); string image = String.Concat(YoeJoyConfig.ImgVirtualPathBase, productListItem.ImgPath); strb.Append(String.Format(tabRowHTMLTemplate, image, deeplink, productListItem.ProductBriefName, productListItem.Cost, productListItem.Quantity, deeplink, deeplink)); } } strb.Append("</tbody></table>"); } orderListHTML = strb.ToString(); } return(orderListHTML); }