//----------------------------订单申请退款 public ActionResult DrawBack() { M_OrderList orderMod = orderBll.SelReturnModel(Mid); if (!DrawBackCheck(orderMod, ref err)) { function.WriteErrMsg(err); return(null); } M_Payment payMod = payBll.SelModelByPayNo(orderMod.PaymentNo); orderMod.Ordersamount = payMod.MoneyTrue; return(View(orderMod)); }
public void WeiXinPay() { //M_OrderList orderMod = new M_OrderList(); //orderMod = orderBll.SelModelByOrderNo(OrderNo); payMod = paymentBll.SelModelByPayNo(PayNo); //function.WriteErrMsg(DataConverter.CLng(payMod.MoneyPay * 100).ToString()); // B_Payment payBll = new B_Payment(); //payMod.PaymentNum = OrderNo; // payMod.PayNo = payBll.CreatePayNo(); //payMod.UserID = mu.UserID; //payMod.Status = (int)M_Payment.PayStatus.NoPay; //payMod.Remark = orderMod.Ordermessage; //payMod.MoneyPay =Convert.ToDecimal(orderMod.Ordersamount); //payMod.MoneyReal = payMod.MoneyPay; //payMod.PaymentID = payBll.Add(payMod); //WXPayData签名存在但不合法,原因:金额为0 //--------------------------------------------- B_WX_APPID appBll = new B_WX_APPID(); string code = Request.QueryString["code"]; //M_WX_APPID appMod = new M_WX_APPID();//自行置入缓存,使用时取出 //appMod.APPID = WxPayConfig.APPID;//"wx8af32f5bf73b2c81"; //appMod.Secret = WxPayConfig.APPSECRET;//61c897f42cd3fcc1131f8f4fbafd3293 //WxAPI wxapi = new WxAPI(); WxAPI wxapi = WxAPI.Code_Get(1); //wxapi.AppId = appMod; string resultStr = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxapi.AppId.APPID + "&secret=" + wxapi.AppId.Secret + "&code=" + code + "&grant_type=authorization_code"); JObject obj = (JObject)JsonConvert.DeserializeObject(resultStr); string urlReq1 = Request.Url.AbsoluteUri.ToString().Substring(0, Request.Url.AbsoluteUri.ToString().LastIndexOf('/')); WxPayData wxdata = new WxPayData(); wxdata.SetValue("out_trade_no", payMod.PayNo); wxdata.SetValue("body", "我点吧"); wxdata.SetValue("total_fee", Convert.ToInt32(payMod.MoneyPay * 100));//DataConverter.CLng(payMod.MoneyPay * 100) wxdata.SetValue("trade_type", "JSAPI"); wxdata.SetValue("notify_url", urlReq1 + "/Return/WxPayReturn.aspx"); wxdata.SetValue("product_id", payMod.PaymentNum); wxdata.SetValue("openid", obj["openid"].ToString()); wxdata.SetValue("nonce_str", nonceStr); WxPayData result = WxPayApi.UnifiedOrder(wxdata); if (result.GetValue("return_code").ToString().Equals("FAIL")) { function.WriteErrMsg("商户" + result.GetValue("return_msg")); } prepay_id = result.GetValue("prepay_id").ToString(); }
public IActionResult PayOnline_Submit() { M_UserInfo mu = buser.GetLogin(false); if (string.IsNullOrEmpty(SiteConfig.SiteInfo.SiteUrl)) { return(WriteErr("错误,管理员未定义网站地址,SiteUrl")); } if (string.IsNullOrEmpty(PayNo)) { return(WriteErr("请传入支付单号")); } M_Payment pinfo = payBll.SelModelByPayNo(PayNo); if (pinfo == null || pinfo.PaymentID < 1) { return(WriteErr("支付单不存在")); } M_PayPlat payPlat = platBll.SelReturnModel(pinfo.PayPlatID); if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { return(WriteErr("支付单不能重复付款")); } if (!string.IsNullOrEmpty(mu.PayPassWord)) { if (!mu.PayPassWord.Equals(StringHelper.MD5(Request.Form["pwd_t"]))) { return(WriteErr("支付密码不正确")); } } DataTable orderDT = new DataTable(); orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum); if (string.IsNullOrEmpty(PayMethod) && !string.IsNullOrEmpty(PayNo))//现金支付,跳转 { } else if (!string.IsNullOrEmpty(PayMethod))//虚拟币支付 { //paymentMod = payBll.SelModelByPayNo(PayNo); PayByVirtualMoney(PayMethod, pinfo); } else { return(WriteErr("支付出错,支付单不存在")); } return(View("Payment_Finish", pinfo)); }
public void WeiXinPay() { M_Payment payMod = payBll.SelModelByPayNo(PayNo); if (string.IsNullOrEmpty(PayNo)) { function.WriteErrMsg("0x53,支付单号或为空"); } else if (payMod == null) { function.WriteErrMsg("支付单号不存在"); } else if (payMod.Status != (int)M_Payment.PayStatus.NoPay) { function.WriteErrMsg("0x14,支付单已付过款,不能重复支付"); } else if (payMod.MoneyReal <= 0) { function.WriteErrMsg("0x56,支付单金额异常"); } string code = Request.QueryString["code"]; string resultStr = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appMod.APPID + "&secret=" + appMod.Secret + "&code=" + code + "&grant_type=authorization_code"); JObject obj = (JObject)JsonConvert.DeserializeObject(resultStr); if (AppID > 1) { notifyUrl = SiteConfig.SiteInfo.SiteUrl + "/payonline/return/WxPayReturn1.aspx"; } WxPayData wxdata = new WxPayData(); wxdata.SetValue("out_trade_no", payMod.PayNo); wxdata.SetValue("body", payMod.Remark); wxdata.SetValue("total_fee", (int)(payMod.MoneyReal * 100)); wxdata.SetValue("trade_type", "JSAPI"); wxdata.SetValue("notify_url", notifyUrl); wxdata.SetValue("product_id", payMod.PayNo); //必填 wxdata.SetValue("openid", obj["openid"].ToString()); //公众号支付必填 wxdata.SetValue("nonce_str", WxAPI.nonce); //获取预支付单号 WxPayData result = WxPayApi.UnifiedOrder(wxdata, appMod); if (result.GetValue("return_code").ToString().Equals("FAIL")) { function.WriteErrMsg("商户" + result.GetValue("return_msg")); } prepay_id = result.GetValue("prepay_id").ToString(); }
public void MyBind() { M_Payment payMod = payBll.SelModelByPayNo(PayNo); if (payMod == null) { function.WriteErrMsg("支付单不存在"); } if (payMod.Status != (int)M_Payment.PayStatus.NoPay) { function.WriteErrMsg("该支付单已经付过款了"); } code_img.Src = "MakeCodeImg.aspx?data=" + Request.QueryString["wxcode"]; }
public static void OrderFinish(M_OrderList mod, M_Payment pinfo) { B_User buser = new B_User(); DataTable prodt = DBCenter.JoinQuery("A.ProID,A.Pronum,B.PointVal", "ZL_CartPro", "ZL_Commodities", "A.ProID=B.ID", "A.OrderListID=" + mod.id); foreach (DataRow dr in prodt.Rows) { double point = DataConvert.CDouble(dr["PointVal"]) * Convert.ToInt32(dr["Pronum"]); if (point > 0) { buser.AddMoney(mod.Userid, point, M_UserExpHis.SType.Point, "购买商品[" + dr["ProID"] + "],赠送积分"); } } }
/// <summary> /// 注意格式顺序,大小写,不能有多余空格和换行 /// </summary> /// <param name="model"></param> /// <param name="merid">商户ID</param> /// <param name="merAcct">商户帐号</param> /// <param name="siteurl">根域名,本地为localhost</param> /// <param name="notifyurl">接受通知的地址</param> /// <returns>XML明文</returns> public string SpliceTranData(M_Payment model, string merid, string merAcct, string siteurl, string notifyurl) { StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>"); sb.Append("<B2CReq>"); sb.Append("<interfaceName>ICBC_PERBANK_B2C</interfaceName>"); sb.Append("<interfaceVersion>1.0.0.11</interfaceVersion>"); sb.Append("<orderInfo>"); sb.Append("<orderDate>" + DateTime.Now.ToString("yyyyMMddHHmmss") + "</orderDate>"); //因为不能与其服务器差太多时间,最好实时生成 sb.Append("<curType>001</curType>"); sb.Append("<merID>" + merid + "</merID>"); //商户ID,1502EC24375838 sb.Append("<subOrderInfoList>"); sb.Append("<subOrderInfo>"); sb.Append("<orderid>" + model.PayNo.Trim() + "</orderid>"); sb.Append("<amount>" + (model.MoneyReal * 100).ToString("f0") + "</amount>"); //以分为单位,所以必须*100,无小数位 sb.Append("<installmentTimes>1</installmentTimes>"); sb.Append("<merAcct>" + merAcct + "</merAcct>"); //帐户:1502200129300005002 sb.Append("<goodsID>776453</goodsID>"); sb.Append("<goodsName>Goods</goodsName>"); sb.Append("<goodsNum>1</goodsNum>"); sb.Append("<carriageAmt>0</carriageAmt>");//已含运费金额 sb.Append("</subOrderInfo>"); sb.Append("</subOrderInfoList>"); sb.Append("</orderInfo>"); sb.Append("<custom>"); sb.Append("<verifyJoinFlag>0</verifyJoinFlag>"); sb.Append("<Language>ZH_CN</Language>"); sb.Append("</custom>"); sb.Append("<message>"); sb.Append("<creditType>2</creditType>"); sb.Append("<notifyType>HS</notifyType>"); sb.Append("<resultType>1</resultType>"); //1只接受成功消息 sb.Append("<merReference>" + siteurl.Trim() + "</merReference>"); //域名必须与用户付款前一页面的根域名一致,不带http,如*.z01.com sb.Append("<merCustomIp></merCustomIp>"); sb.Append("<goodsType>1</goodsType>"); sb.Append("<merCustomID>166</merCustomID>"); sb.Append("<merCustomPhone></merCustomPhone>"); sb.Append("<goodsAddress>hereisnot</goodsAddress>"); sb.Append("<merOrderRemark></merOrderRemark>"); sb.Append("<merHint></merHint>");//商城提示 sb.Append("<remark1></remark1>"); sb.Append("<remark2></remark2>"); sb.Append("<merURL>" + notifyurl.Trim() + "</merURL>");//需要http,80,不能使用https,看是否异步回调,http://localhost:86/pay/paynotify.aspx sb.Append("<merVAR></merVAR>"); sb.Append("</message>"); sb.Append("</B2CReq>"); return(sb.ToString()); }
public string GetTureMoney(string OrderNo) { M_OrderList orderMod = new M_OrderList(); orderMod = orderBll.SelModelByOrderNo(OrderNo); double allamount = orderMod.Ordersamount; DataTable dt1 = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC"); if (dt1.Rows.Count > 0) { payMod = payBll.SelModelByPayNo(dt1.Rows[0]["PayNo"].ToString()); allamount = (double)payMod.MoneyPay; } return(allamount.ToString("f2")); }
//仅负责将邮件再发送出去 public static void OrderFinish(M_OrderList mod, M_Payment pinfo) { //DataTable orderDT = DBCenter.Sel(mod.TbName, "ID=" + mod.id); //DataTable contactDT = DBCenter.Sel("ZL_Order_Contact", "OrderID=" + mod.id); //DataTable cartDT = DBCenter.JoinQuery("A.*,B.PreviewImg", "ZL_CartPro", // "ZL_Logo_Design", "A.Attribute=B.ID", "A.OrderListID="+mod.id+" AND (A.Attribute IS NOT NULL AND A.Attribute !='')"); //string userHtml = Tlp_Read("订单付款后_用户"); //userHtml = TlpDeal(userHtml, contactDT); //userHtml = TlpDeal(userHtml, orderDT); ////替换购物车列表 //string cartHead = "<table><tr><td>Name</td><td>Image</td><td>Unit Price</td><td>Quantity</td><td>Total</td></tr>"; //string cartHtml = ""; //string cartEnd = "</table>"; //foreach (DataRow dr in cartDT.Rows) //{ // var cartTlp = "<tr>" // + "<td>" // + "<div>{Proname}</div>" // + "<div>{ProInfo}</div>" // + "</td>" // + "<td><img src=\"{PreviewImg}\" width=\"160\" height=\"100\"/></td>" // + "<td>{Shijia}</td>" // + "<td>{Pronum}</td>" // + "<td>{AllMoney}</td>" // + "</tr>"; // cartHtml += TlpDeal(cartTlp, cartDT, dr); //} //cartHtml = cartHead + cartHtml + cartEnd; //userHtml = userHtml.Replace("{CartList}", cartHtml); ////发送邮件给双方 //SendToEmail(mod.Email, "Order Prompt", userHtml, mod.id+""); ////----------------------发送邮件通知管理员 //string adminHtml = Tlp_Read("订单付款后_管理员"); //adminHtml = TlpDeal(userHtml, contactDT); //adminHtml = TlpDeal(userHtml, orderDT); //adminHtml = adminHtml.Replace("{CartList}", cartHtml); StringWriter sw = new StringWriter(); HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=" + mod.id, sw); string title = "We received your order!"; string html = sw.ToString(); SendToEmail(mod.Email, title, html, mod.id.ToString()); SendToEmail(SiteConfig.SiteInfo.WebmasterEmail, title, html, mod.id.ToString()); SnsHelper.UpdateOrderField(mod.id, "EMail_Pay", "1"); }
//虚拟币确认 protected void Confirm_Click(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(false); DataTable orderDT = new DataTable(); M_Payment paymentMod = new M_Payment(); orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum); //------------------- #region 扣除附加币,暂注释 //string priceJson = orderCom.GetTotalJson(orderDT); //if (orderCom.HasPrice(priceJson))//扣除附加 //{ // M_LinPrice priceMod = JsonConvert.DeserializeObject<M_LinPrice>(priceJson); // if (mu.Purse < priceMod.Purse) // { // function.WriteErrMsg("你的余额仅有" + mu.Purse + ",不够支付"); // } // if (mu.SilverCoin < priceMod.Sicon) // { // function.WriteErrMsg("你的银币仅有" + mu.Purse + ",不够支付"); // } // if (mu.UserExp < priceMod.Point) // { // function.WriteErrMsg("你的积分仅有" + mu.Purse + ",不够支付"); // } // //将判断与扣减分开,避免出现扣减失误情况 // if (priceMod.Purse > 0) // { buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { score = (int)-priceMod.Purse, ScoreType = 1, detail = pinfo.PaymentNum + "商城购物使用" + priceMod.Purse }); } // if (priceMod.Sicon > 0) // { buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { score = (int)-priceMod.Sicon, ScoreType = 2, detail = pinfo.PaymentNum + "商城购物使用" + priceMod.Sicon }); } // if (priceMod.Point > 0) // { buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { score = (int)-priceMod.Point, ScoreType = 3, detail = pinfo.PaymentNum + "商城购物使用" + priceMod.Point }); } //} #endregion //-------------------------------------------- if (string.IsNullOrEmpty(PayMethod) && !string.IsNullOrEmpty(PayNo))//现金支付,跳转 { } else if (!string.IsNullOrEmpty(PayMethod))//虚拟币支付 { paymentMod = paymentBll.SelModelByPayNo(PayNo); PayByVirtualMoney(PayMethod, paymentMod); } else { function.WriteErrMsg("支付出错,支付单不存在"); } }
//支付成功时执行的操作 private void PayOrder_Success(M_Payment pinfo, WxPayData result) { ZLLog.L(ZLEnum.Log.pay, PayPlat + " 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee")); try { M_Order_PayLog paylogMod = new M_Order_PayLog(); if (pinfo == null) { throw new Exception("支付单不存在"); } //支付单检测合为一个方法 if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { throw new Exception("支付单状态不为未支付"); } pinfo.Status = (int)M_Payment.PayStatus.HasPayed; pinfo.PlatformInfo += PayPlat; pinfo.SuccessTime = DateTime.Now; pinfo.PayTime = DateTime.Now; pinfo.CStatus = true; //1=100, double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100; pinfo.MoneyTrue = tradeAmt; payBll.Update(pinfo); DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum); foreach (DataRow dr in orderDT.Rows) { M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString()); OrderHelper.FinalStep(pinfo, orderMod, paylogMod); //if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse) //{ // M_UserInfo mu = buser.SelReturnModel(orderMod.Userid); // new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]"); //} orderCom.SendMessage(orderMod, paylogMod, "payed"); //orderCom.SaveSnapShot(orderMod); } ZLLog.L(ZLEnum.Log.pay, PayPlat + "成功!支付单:" + result.GetValue("out_trade_no").ToString()); } catch (Exception ex) { ZLLog.L(ZLEnum.Log.pay, new M_Log() { Action = "支付回调报错", Message = PayPlat + ",支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message }); } }
protected void Page_Load(object sender, EventArgs e) { orderMod = orderBll.SelReturnModel(OrderID); conMod = new B_Order_Contact().SelModelByOid(orderMod.id); payMod = payBll.SelModelByOrder(orderMod); expMod = expBll.SelReturnModel(DataConvert.CLng(orderMod.ExpressNum)); if (expMod == null) { expMod = new M_Order_Exp(); } StringWriter sw = new StringWriter(); Server.Execute("/Common/MailTlp/Cart_List.aspx?OrderID=" + orderMod.id, sw); CartList_HTML.Text = sw.ToString(); dateTime = orderMod.AddTime.ToString("MM/dd/yyyy HH:mm:ss EST"); }
private void FinalStep(M_Payment pinfo) { if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { throw new Exception("该支付单已处理过,不可重复执行"); } pinfo = payBll.PaySuccess(pinfo, 0, ""); pinfo.Remark = ""; foreach (string orderNo in pinfo.PaymentNum.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { M_OrderList orderMod = orderBll.SelModelByOrderNo(orderNo); OrderHelper.FinalStep(pinfo, orderMod, null); } payBll.Update(pinfo); Response.Redirect("/User/Order/OrderList"); }
protected void Page_Load(object sender, EventArgs e) { if (function.isAjax()) { string action = Request.Form["action"]; string result = ""; switch (action) { case "getpay": M_Payment paymod = payBll.SelModelByPayNo(PayNo); if (paymod.Status == (int)M_Payment.PayStatus.HasPayed) { DataTable orderDT = orderBll.GetOrderbyOrderNo(paymod.PaymentNum); M_OrderList ordermod = orderBll.SelModelByOrderNo(orderDT.Rows[0]["OrderNo"].ToString()); if ((int)M_OrderList.OrderEnum.Purse == ordermod.Ordertype) { result = "/user/Info/UserInfo"; } else { result = "/User/Order/OrderProList?OrderNo=" + paymod.PaymentNum; } } else { result = "0"; } break; default: break; } Response.Write(result); Response.Flush(); Response.End(); } if (!IsPostBack) { if (string.IsNullOrEmpty(PayNo)) { function.WriteErrMsg("未指定支付单号"); } if (string.IsNullOrEmpty(Request.QueryString["wxcode"])) { function.WriteErrMsg("未指定二维码"); } MyBind(); } }
public void CreateOrder(M_FastOrder model) { M_UserInfo mu = buser.GetLogin(false); M_OrderList Odata = new M_OrderList(); Odata.Ordertype = 10; Odata.OrderNo = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype); Odata.Mobile = DataConverter.CLng(model.Phone); Odata.Rename = mu.UserName; Odata.Ordermessage = model.Jiedao; Odata.Jiedao = model.Proinfo; //-----金额计算 Odata.Balance_price = model.Price; Odata.Ordersamount = Odata.Balance_price + Odata.Freight; //订单金额 Odata.Specifiedprice = Odata.Ordersamount; //订单金额; Odata.AddUser = mu.UserName;; Odata.Userid = mu.UserID; Odata.id = orderBll.Adds(Odata); //-----购物车记录 M_CartPro cartMod = new M_CartPro(); cartMod.Orderlistid = Odata.id; cartMod.Username = mu.UserName; cartMod.Proname = model.ProName; cartMod.Pronum = model.Pronum; cartMod.ProClass = model.ProClass; cartMod.FarePrice = model.Price.ToString("F2"); cartBll.Add(cartMod); //-----支付单 M_Payment payMod = new M_Payment(); payMod.PaymentNum = Odata.OrderNo; payMod.MoneyPay = Odata.Ordersamount; payMod.Remark = model.ProName; payMod.PayNo = payBll.CreatePayNo(); payMod.UserID = mu.UserID; payMod.Status = 1; payMod.PaymentID = payBll.Add(payMod); if (string.IsNullOrEmpty(Method)) { Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); } else { Response.Redirect("/PayOnline/PayOnline.aspx?Method=" + Method + "&PayNo=" + payMod.PayNo); } }
protected void BatReturn_Btn_Click(object sender, EventArgs e) { string ids = Request.Form["idchk"]; if (string.IsNullOrEmpty(ids)) { function.WriteErrMsg("未选择需要归还的伞"); } SafeSC.CheckIDSEx(ids); //计算金额,生成余额充值订单 double money = 0; foreach (string id in ids.Split(',')) { int rid = DataConvert.CLng(Request["repair" + id + "_rad"]); DataRow dr = Conast.Repair_Get(rid); money += DataConvert.CDouble(dr["price"]); string msg = dr["name"] + " " + Convert.ToDouble(dr["price"]) + "元"; DBCenter.UpdateSQL("ZL_OrderInfo", "Internalrecords='" + msg + "',Specifiedprice='" + dr["price"] + "'", "ID=" + id); } if (money < 1) { function.WriteErrMsg("充值金额不正确"); } if ((mu.Purse - 9) >= money) { //余额充足,则直接修改金额 Unbrealla.RepairOrder(ids, mu.UserID, StoreID, money); function.WriteSuccessMsg("报修成功,请等待店主审核"); } else { //缺多少充多少 M_OrderList orderMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); orderMod.Ordersamount = money - (mu.Purse - 9); orderMod.Ordermessage = "报修充值"; orderMod.StoreID = StoreID; //money用于检测充完值后,金额是否达标 orderMod.Freight_remark = JsonHelper.GetJson(new string[] { "type", "ids", "money" }, new string[] { "repair", ids, money.ToString("F2") }); M_Payment payMod = payBll.CreateByOrder(orderMod); orderBll.insert(orderMod); payBll.Add(payMod); Response.Redirect("/Payonline/wxpay_mp.aspx?payno=" + payMod.PayNo); } }
protected void Pay_Btn_Click(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(); double charge = DataConvert.CLng(Request.Form["charge_rad"]); M_OrderList chargeMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); chargeMod.Ordersamount = charge; M_Payment payMod = payBll.CreateByOrder(chargeMod); payMod.Remark += "充值" + chargeMod.Ordersamount.ToString("F2") + "元"; if (payMod.MoneyReal < 1) { function.WriteErrMsg("充值金额错误"); } orderBll.insert(chargeMod); payMod.PaymentID = payBll.Add(payMod); Response.Redirect("/PayOnline/OrderPay.aspx?Payno=" + payMod.PayNo + "&StoreID=" + StoreID); }
//完结订单 protected void CompleteOrder_Btn_Click(object sender, EventArgs e) { M_Order_OPLog logMod = logBll.NewLog(Mid, "完结订单"); //前使用必须修改,只更改状态,不执行FinalStep M_OrderList orderMod = oll.SelReturnModel(Mid); if (string.IsNullOrEmpty(orderMod.PaymentNo))//未支付则生成支付单 { OrderHelper.FinalStep(orderMod); } else { M_Payment payMod = GetPayment(orderinfo); OrderHelper.FinalStep(payMod, orderMod, new M_Order_PayLog()); } logBll.Insert(logMod); Response.Redirect(Request.RawUrl); }
public CommonReturn IsCanPay(M_Payment payMod) { if (payMod == null) { return(CommonReturn.Failed("支付单不存在")); } else if (payMod.Status != (int)M_Payment.PayStatus.NoPay) { return(CommonReturn.Failed("0x14,支付单已付过款,不能重复支付")); } else if (payMod.MoneyReal <= 0) { return(CommonReturn.Failed("0x56,支付单金额异常")); } else { return(CommonReturn.Success()); } }
//如果是充值,则生成充值支付单 private M_Payment CreateChargePay(M_UserInfo mu) { if (Money <= 0) { function.WriteErrMsg(""); } M_OrderList orderMod = orderBll.NewOrder(mu, M_OrderList.OrderEnum.Purse); orderMod.Ordersamount = Money; orderMod.Specifiedprice = Money; orderMod.Balance_price = Money; orderMod.id = orderBll.insert(orderMod); M_Payment payMod = payBll.CreateByOrder(orderMod); payMod.MoneyReal = payMod.MoneyPay; payMod.PaymentID = payBll.Add(payMod); payMod.SysRemark = "用户充值"; return(payMod); }
//支付成功时执行的操作 private void PayOrder_Success(WxPayData result) { ZLLog.L(ZLEnum.Log.pay, PayPlat + " 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee")); try { M_Order_PayLog paylogMod = new M_Order_PayLog(); M_Payment pinfo = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString()); if (pinfo == null) { throw new Exception("支付单不存在"); } //支付单检测合为一个方法 if (pinfo.Status != (int)M_Payment.PayStatus.NoPay) { throw new Exception("支付单状态不为未支付"); } pinfo.Status = (int)M_Payment.PayStatus.HasPayed; pinfo.PlatformInfo = PayPlat; pinfo.SuccessTime = DateTime.Now; pinfo.PayTime = DateTime.Now; pinfo.CStatus = true; //1=100, double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100; pinfo.MoneyTrue = tradeAmt; payBll.Update(pinfo); DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum); foreach (DataRow dr in orderDT.Rows) { M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString()); OrderHelper.FinalStep(pinfo, orderMod, paylogMod); orderCom.SendMessage(orderMod, paylogMod, "payed"); //orderCom.SaveSnapShot(orderMod); } ZLLog.L(ZLEnum.Log.pay, PayPlat + "支付成功,支付单:" + result.GetValue("out_trade_no").ToString()); } catch (Exception ex) { ZLLog.L(ZLEnum.Log.pay, new M_Log() { Action = "支付回调报错", Message = PayPlat + ",支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message }); } }
//宝付用户回调显示页 protected void Page_Load(object sender, EventArgs e) { string MemberID = Request.Params["MemberID"]; //商户号 string TerminalID = Request.Params["TerminalID"]; //商户终端号 string TransID = Request.Params["TransID"]; //商户流水号 string Result = Request.Params["Result"]; //支付结果(1:成功,0:失败) string ResultDesc = Request.Params["ResultDesc"]; //支付结果描述 string FactMoney = Request.Params["FactMoney"]; //实际成交金额 string AdditionalInfo = Request.Params["AdditionalInfo"]; //订单附加消息 string SuccTime = Request.Params["SuccTime"]; //交易成功时间 string Md5Sign = Request.Params["Md5Sign"].ToLower(); //md5签名 M_Payment payMod = payBll.SelModelByPayNo(TransID); M_PayPlat platMod = platBll.SelReturnModel(payMod.PayPlatID); if (platMod.PayClass != (int)M_PayPlat.Plat.BaoFo) { function.WriteErrMsg("回调页面错误"); } //string Md5Key = ConfigurationManager.AppSettings["Md5key"];//密钥 双方约定 //String mark = "~|~";//分隔符 //string _Md5Key = WebConfigurationManager.AppSettings["Md5key"]; //string _WaitSign = "MemberID=" + MemberID + mark + "TerminalID=" + TerminalID + mark + "TransID=" + TransID + mark + "Result=" + Result + mark + "ResultDesc=" + ResultDesc + mark // + "FactMoney=" + FactMoney + mark + "AdditionalInfo=" + AdditionalInfo + mark + "SuccTime=" + SuccTime // + mark + "Md5Sign=" + Md5Key; lbMoney.Text = (float.Parse(FactMoney) / 100).ToString() + " 元"; lbDate.Text = SuccTime; lbFlag.Text = baofa.GetErrorInfo(Result, ResultDesc) + "-===="; lbOrderID.Text = TransID; //if (Md5Sign.ToLower() == StringHelper.MD5(_WaitSign).ToLower()) //{ //} //else //{ // Response.Write("校验失败"); //} }
public static M_Payment GetPaymentByOrderNo(string payno, string orderno, double allmoney) { B_Payment payBll = new B_Payment(); M_Payment payMod = null; if (!string.IsNullOrEmpty(payno)) { payMod = payBll.SelModelByPayNo(payno); } else if (!string.IsNullOrEmpty(orderno)) { payMod = payBll.SelModelByOrderNo(orderno); } if (payMod == null) { payMod = new M_Payment(); payMod.MoneyReal = allmoney; } return(payMod); }
private void Check(M_Payment model) { //?在管理员与所属用户不同密码的情况下,可能会获取不到信息导致报错(因为Cookies写入的关系) //允许为0,考虑到有优惠卷的情况 if (model.MoneyPay < 0) { throw new Exception("支付单金额不正确"); } if (model.UserID < 1) { throw new Exception("支付单未绑定用户"); } if (string.IsNullOrEmpty(model.PaymentNum)) { throw new Exception("支付单未绑定订单"); } if (string.IsNullOrEmpty(model.PayNo)) { throw new Exception("未生成支付单号"); } }
/// <summary> /// 通过订单创建支付单 /// </summary> public M_Payment CreateByOrder(List <M_OrderList> list) { if (list.Count < 1) { throw new Exception("未指定需要生成的订单"); } M_Payment payMod = new M_Payment(); payMod.PayNo = CreatePayNo(); foreach (M_OrderList model in list) { payMod.PaymentNum += model.OrderNo + ","; payMod.MoneyPay += model.Ordersamount; } M_OrderList first = list[0]; payMod.PaymentNum = payMod.PaymentNum.TrimEnd(','); payMod.UserID = first.Userid; payMod.Status = 1; return(payMod); }
//-------------------支付前订单和支付单检测 #endregion /// <summary> /// 订单是否可支付检测,支持支付单与订单,检测状态,过期时间,金额 /// </summary> public static List <M_OrderList> OrdersCheck(M_Payment payMod) { if (payMod.Status != (int)M_Payment.PayStatus.NoPay) { function.WriteErrMsg("支付单付款状态不正确"); return(null); } if (payMod.IsDel == 1) { function.WriteErrMsg("支付单已被删除"); return(null); } string[] orders = payMod.PaymentNum.Split(','); List <M_OrderList> orderList = new List <M_OrderList>(); for (int i = 0; i < orders.Length; i++)//全部检测,支付单中订单有任一不符合条件则不允许购买 { M_OrderList orderMod = orderBll.SelModelByOrderNo(orders[i]); CheckIsCanPay(orderMod); orderList.Add(orderMod); } return(orderList); }
protected void Page_Load(object sender, EventArgs e) { orderMod = orderBll.SelModelByOrderNo(OrderNo); if (orderMod == null) { function.WriteErrMsg("Order does not exist!"); } conMod = new B_Order_Contact().SelModelByOid(orderMod.id); payMod = payBll.SelModelByOrder(orderMod); expMod = expBll.SelReturnModel(DataConvert.CLng(orderMod.ExpressNum)); if (expMod == null) { expMod = new M_Order_Exp(); } StringWriter sw = new StringWriter(); Server.Execute("/Common/MailTlp/Cart_List.aspx?OrderID=" + orderMod.id, sw); CartList_HTML.Text = sw.ToString(); }
protected void Submit_Btn_Click(object sender, EventArgs e) { M_UserInfo mu = buser.GetLogin(); M_Product proMod = proBll.GetproductByid(ProID); DataRow timeMod = idcBll.GetSelTime(proMod, IDCTime_DP.SelectedValue); //----------------------------------- M_OrderList Odata = orderBll.NewOrder(mu, M_OrderList.OrderEnum.IDC); Odata.Balance_price = DataConvert.CDouble(timeMod["price"]);//需付金额 Odata.Ordersamount = Odata.Balance_price; //----------------------------- M_Order_IDC idcMod = new M_Order_IDC(); idcMod.OrderNo = Odata.OrderNo; idcMod.ProID = proMod.ID; idcMod.ProInfo = idcBll.ToProInfoStr(timeMod); idcMod.Domain = BindDomain_T.Text; idcMod.AdminName = "webmater@" + idcMod.Domain; idcMod.AdminPwd = Pwd_T.Text; idcMod.Remind = OPSys_DP.SelectedValue + "|" + ServerPos_DP.SelectedValue + "|" + Record_T.Text; idcMod.ID = idcBll.Insert(idcMod); Odata.id = orderBll.Adds(Odata); //----------------------------- M_CartPro cpMod = new M_CartPro(); cpMod.Orderlistid = Odata.id; cpMod.ProID = proMod.ID; cpMod.Pronum = 1; cpMod.Proname = proMod.Proname; cpMod.Username = mu.UserName; cpMod.Shijia = Convert.ToDouble(timeMod["price"]); cpMod.AllMoney = Convert.ToDouble(timeMod["price"]); cpMod.code = timeMod["time"].ToString(); cartProBll.GetInsert(cpMod); //----------------------------- M_Payment payMod = payBll.CreateByOrder(Odata); payBll.Add(payMod); Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo); }
/// <summary> /// 用户完成支付,更新支付记录信息 /// </summary> public M_Payment PaySuccess(M_Payment payMod, double money, string payPlat) { if (payMod == null) { throw new Exception("支付单不存在"); } if (payMod.Status != (int)M_Payment.PayStatus.NoPay) { throw new Exception("支付单状态不正确"); } if (money < 0) { throw new Exception("金额不正确"); } payMod.Status = (int)M_Payment.PayStatus.HasPayed; payMod.CStatus = true; payMod.SuccessTime = DateTime.Now; payMod.PayTime = DateTime.Now; payMod.PlatformInfo += payPlat; payMod.MoneyTrue = money; return(payMod); }
public IActionResult PaymentInfo() { M_Payment payMod = payBll.SelReturnModel(Mid); if (payMod == null) { return(WriteErr("支付单不存在")); return(null); } M_OrderList orderMod = orderBll.SelModelByOrderNo(payMod.PaymentNum); M_UserInfo mu = buser.SelReturnModel(orderMod.Userid); M_PayPlat platMod = new M_PayPlat(); if (payMod.Status == 3 && payMod.PayPlatID > 0) { platMod = platBll.SelReturnModel(payMod.PayPlatID); } ViewBag.platMod = platMod; ViewBag.orderMod = orderMod; ViewBag.mu = mu; return(View(payMod)); }