/// <summary> /// 短信支付 /// </summary> /// <param name="id">订单id</param> /// <param name="payWay">支付方式</param> /// <param name="code">网银银行代码</param> private void SmsOrderPay(string id, string payWay, string code, string prices) { string url = string.Empty; string strFromValue = ""; PbProject.Logic.Pay.DataAction data = new PbProject.Logic.Pay.DataAction(); Tb_Ticket_OrderBLL ticket_Order = new Tb_Ticket_OrderBLL(); string orderId = id; //订单编号 string price = prices; //订单金额 //string payCpyNo = mCompany.UninCode; //付款公司编号 string payId = mUser != null?mUser.id.ToString() : ""; //付款公司编号 string act = UseAct(payWay, mUser.CpyNo); //收款账号 try { //PayWay 支付方式:1支付宝、2快钱、3汇付、4财付通、5支付宝网银、6快钱网银 、7汇付网银、8财付通网银、 //9支付宝pos、10快钱pos、11汇付pos、12财付通pos、13易宝pos、14账户支付、15收银 if (payWay == "1" || payWay == "5")//支付宝 { #region 支付宝 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 string detail = act + "^" + actPrice.ToString("F2") + "^充值收款"; #endregion AliPayParam aliPayParam = new AliPayParam(); aliPayParam.Out_trade_no = orderId; //内部订单号 aliPayParam.Subject = "在线充值"; //商品名称 aliPayParam.Body = "在线充值"; //商品描述 aliPayParam.Total_fee = total.ToString(); //订单总价 aliPayParam.Royalty_parameters = detail; //分润参数 aliPayParam.Extend_param = ""; //公用业务扩展参数,支付宝用于 显示 PNR (格式:参数名1^参数值1|参数名2^参数值2|......) aliPayParam.Extra_common_param = payId; //自定义字段 aliPayParam.DefaultBank = code; //网银标示 strFromValue = new PbProject.Logic.Pay.AliPay().GetPay(aliPayParam); #endregion } else if (payWay == "2" || payWay == "6")//快钱 { #region 快钱 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 int totalInt = int.Parse((total * 100).ToString().Split('.')[0]); int paySXFInt = int.Parse((paySXF * 100).ToString().Split('.')[0]); int actPriceInt = int.Parse((actPrice * 100).ToString().Split('.')[0]); string detail = "1^" + act + "^" + actPriceInt.ToString() + "^0^充值收款"; #endregion _99BillParam billParam = new _99BillParam(); billParam.Orderid = orderId; //0.订单编号 billParam.Price = totalInt.ToString(); //1.订单金额,单位“分” billParam.Money = paySXFInt.ToString();; //2.手续费,单位“分” billParam.Pname = "在线充值"; //3.商品名称 billParam.Ext = payId; //4.自定义字段 billParam.Detail = detail; //5.分润数据集 billParam.Ptype = "1"; //6.分润类别,1 立刻分润 0 异步分润 billParam.Payid = "*****@*****.**";; //7.付款帐户 billParam.Paytype = (string.IsNullOrEmpty(code)) ? "00" : "10"; //8. 00:组合支付,10:银行卡支付 billParam.Bankcode = code; //9: 银行代码 strFromValue = new PbProject.Logic.Pay._99Bill().GetPay(billParam); #endregion } else if (payWay == "3" || payWay == "7")//汇付天下 { #region 汇付天下 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 string detail = "Agent:" + act + ":" + actPrice; #endregion ChinaPnrParam chinaPnrParam = new ChinaPnrParam(); chinaPnrParam.Orderid = orderId; //订单号 chinaPnrParam.Price = total.ToString("f2"); //订单总价 chinaPnrParam.Merpriv = payId; //自定义字段 chinaPnrParam.Details = detail; strFromValue = new PbProject.Logic.Pay.ChinaPnr().Buy(chinaPnrParam); #endregion } else if (payWay == "4" || payWay == "8")// 财付通 { #region 财付通 #region 参数赋值 string actXSF = UseAct(payWay, mUser.CpyNo.Substring(0, 12)); //手续费收款账号 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 total = total * 100; string busdesc = string.Empty; if (paySXF > 0) { busdesc = string.Format("{0}^{1}^1|{2}^{3}^2", act, (actPrice * 100).ToString("F0"), actXSF, (paySXF * 100).ToString("F0")); } else { busdesc = string.Format("{0}^{1}^1", act, (actPrice * 100).ToString("F0")); } //TenPayParam tenPayParam = new TenPayParam(); //tenPayParam.Bus_Args = act + "^" + actPrice + "^1|"; //// tenPayParam.Bus_Desc = "12345^深圳-上海^1^fady^庄^13800138000";///业务描述,特定格式的字符串,格式为:PNR^航程^机票张数^机票销售商在机票平台的id^联系人姓名^联系电话 //tenPayParam.Bus_Desc = "测试"; //tenPayParam.Desc = "在线充值"; //tenPayParam.Orderid = orderId; //tenPayParam.Total_Tee = total.ToString("F0"); //tenPayParam.UserHostAddress = Page.Request.UserHostAddress; //strFromValue = new PbProject.Logic.Pay.TenPay().SplitPayRequest(tenPayParam); string queryParam = string.Format("orderid={0}&total_tee={1}&userhostaddress={2}&attach={3}&busargs={4}&busdesc={5}", orderId, total.ToString("F0"), Request.UserHostAddress, mUser.id.ToString(), busdesc, "短信支付");//,string.Format("{0}^{1}^{2}^{3}^{4}^{5}", mOrder.PNR, mOrder.Travel, mOrder.PassengerNumber, mUser.id.ToString(), mOrder.CreateUserName, "13800000000")); url = string.Format("http://lzh.mypb.cn/Pay/TenPay.aspx?{0}", queryParam); #endregion #endregion } else if (payWay == "14")//账户余额 { #region 账户余额 if (mCompany != null) { List <User_Company> listSmsUser = baseDataManage.CallMethod("User_Company", "GetList", null, new Object[] { "UninCode='" + mCompany.UninCode + "'" }) as List <User_Company>; decimal maxMoney = listSmsUser[0].MaxDebtMoney; //最大欠款额度 decimal oldAccountMoney = listSmsUser[0].AccountMoney; // 支付前 decimal newAccountMoney = oldAccountMoney + maxMoney - decimal.Parse(prices); // 支付后 if (newAccountMoney >= 0) { PbProject.Logic.Pay.Bill bill = new PbProject.Logic.Pay.Bill(); strFromValue = bill.MakeSMS(id, "", 14) == true ? "充值成功" : "充值失败"; } else { strFromValue = "账户余额不足"; } } #endregion } } catch (Exception) { strFromValue = "支付异常"; } if (!string.IsNullOrEmpty(url)) { Response.Redirect(url); } if (!string.IsNullOrEmpty(strFromValue)) { OnErrorNew(strFromValue, false); } Response.Write(strFromValue); }
/// <summary> /// 在线充值 /// </summary> /// <param name="id">订单id</param> /// <param name="payWay">支付方式</param> /// <param name="code">网银银行代码</param> /// <param name="price">充值金额</param> private void OnlineRepaymentOrderPay(string id, string payWay, string code, string price) { string strFromValue = ""; var url = string.Empty; try { PbProject.Logic.Pay.DataAction data = new PbProject.Logic.Pay.DataAction(); Tb_Ticket_OrderBLL ticket_Order = new Tb_Ticket_OrderBLL(); //string indexId = ticket_Order.GetIndexId();//内部流水号 string orderId = ticket_Order.GetOrderId("1");//订单编号 //string payCpyNo = mCompany.UninCode; //付款公司编号 string payId = mUser != null?mUser.id.ToString() : ""; //付款公司编号 string act = UseAct(payWay, mUser.CpyNo); //收款账号 if (!string.IsNullOrEmpty(payId) && !string.IsNullOrEmpty(act)) { //添加交易日志 //bool reuslt = new PbProject.Logic.Pay.Bill().InsertLogMoneyDetail(orderId, indexId, price, payWay, mUser, mCompany); if (payWay == "1" || payWay == "5")//支付宝 { #region 支付宝 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 string detail = act + "^" + actPrice.ToString("F2") + "^充值收款"; #endregion AliPayParam aliPayParam = new AliPayParam(); aliPayParam.Out_trade_no = orderId; //内部订单号 aliPayParam.Subject = "在线充值"; //商品名称 aliPayParam.Body = "在线充值"; //商品描述 aliPayParam.Total_fee = total.ToString(); //订单总价 aliPayParam.Royalty_parameters = detail; //分润参数 aliPayParam.Extend_param = ""; //公用业务扩展参数,支付宝用于 显示 PNR (格式:参数名1^参数值1|参数名2^参数值2|......) aliPayParam.Extra_common_param = payId; //自定义字段 aliPayParam.DefaultBank = code; //网银标示 strFromValue = new PbProject.Logic.Pay.AliPay().GetPay(aliPayParam); #endregion } else if (payWay == "2" || payWay == "6")//快钱 { #region 快钱 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 int totalInt = int.Parse((total * 100).ToString().Split('.')[0]); int paySXFInt = int.Parse((paySXF * 100).ToString().Split('.')[0]); int actPriceInt = int.Parse((actPrice * 100).ToString().Split('.')[0]); string detail = "1^" + act + "^" + actPriceInt.ToString() + "^0^充值收款"; #endregion _99BillParam billParam = new _99BillParam(); billParam.Orderid = orderId; //0.订单编号 billParam.Price = totalInt.ToString(); //1.订单金额,单位“分” billParam.Money = paySXFInt.ToString();; //2.手续费,单位“分” billParam.Pname = "在线充值"; //3.商品名称 billParam.Ext = payId; //4.自定义字段 billParam.Detail = detail; //5.分润数据集 billParam.Ptype = "1"; //6.分润类别,1 立刻分润 0 异步分润 billParam.Payid = "*****@*****.**";; //7.付款帐户 billParam.Paytype = (string.IsNullOrEmpty(code)) ? "00" : "10"; //8. 00:组合支付,10:银行卡支付 billParam.Bankcode = code; //9: 银行代码 strFromValue = new PbProject.Logic.Pay._99Bill().GetPay(billParam); #endregion } else if (payWay == "3" || payWay == "7")//汇付天下 { #region 汇付天下 #region 参数赋值 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 string detail = "Agent:" + act + ":" + actPrice; #endregion ChinaPnrParam chinaPnrParam = new ChinaPnrParam(); chinaPnrParam.Orderid = orderId; //订单号 chinaPnrParam.Price = total.ToString("f2"); //订单总价 chinaPnrParam.Merpriv = payId; //自定义字段 chinaPnrParam.Details = detail; strFromValue = new PbProject.Logic.Pay.ChinaPnr().Buy(chinaPnrParam); #endregion } else if (payWay == "4" || payWay == "8" || payWay == "40")// 财付通 { #region 财付通 #region 参数赋值 string actXSF = UseAct(payWay, mUser.CpyNo.Substring(0, 12)); //手续费收款账号 decimal total = decimal.Parse(price); //订单支付金额 decimal supperates = 0.001M; //支付费率 decimal paySXF = data.FourToFiveNum(total * supperates, 2); //支付手续费 decimal actPrice = total - paySXF; //收款账号金额 total = total * 100; //TenPayParam tenPayParam = new TenPayParam(); //tenPayParam.Bus_Args = string.Format("{0}^{1}^1|{2}^{3}^2", act, actPrice, actXSF, paySXF); ////tenPayParam.Bus_Desc = "12345^深圳-上海^1^fady^庄^13800138000";///业务描述,特定格式的字符串,格式为:PNR^航程^机票张数^机票销售商在机票平台的id^联系人姓名^联系电话 //tenPayParam.Bus_Desc = "机票充值"; //tenPayParam.Desc = "在线充值"; //tenPayParam.Orderid = orderId; //tenPayParam.Total_Tee = total.ToString("F0"); //tenPayParam.UserHostAddress = Page.Request.UserHostAddress; string queryParam = string.Format("orderid={0}&total_tee={1}&userhostaddress={2}&attach={3}&busargs={4}&busdesc={5}&banktype={6}", orderId, total.ToString("F0"), Request.UserHostAddress, mUser.id.ToString(), string.Format("{0}^{1}^1|{2}^{3}^2", act, (actPrice * 100).ToString("F0"), actXSF, (paySXF * 100).ToString("F0")), "在线充值", code);//,string.Format("{0}^{1}^{2}^{3}^{4}^{5}", mOrder.PNR, mOrder.Travel, mOrder.PassengerNumber, mUser.id.ToString(), mOrder.CreateUserName, "13800000000")); url = string.Format("http://lzh.mypb.cn/Pay/TenPay.aspx?{0}", queryParam); //strFromValue = new PbProject.Logic.Pay.TenPay().SplitPayRequest(tenPayParam); #endregion #endregion } } else { strFromValue = "收款方账号错误!"; } } catch (Exception) { strFromValue = "收款方账号异常!"; } if (!string.IsNullOrEmpty(url)) { Response.Redirect(url); } if (!string.IsNullOrEmpty(strFromValue)) { OnErrorNew(strFromValue, false); } Response.Write(strFromValue); }
/// <summary> /// 机票支付 /// </summary> /// <param name="id">订单</param> /// <param name="payWay">支付方式</param> /// <param name="code">网银银行代码</param> private void TicketOrderPay(string id, string payWay, string code) { string msgShow = ""; string url = string.Empty; try { bool result = false; string payDetails = "";//分账明细 #region 获取订单信息 //PayWay 支付方式:1支付宝、2快钱、3汇付、4财付通、5支付宝网银、6快钱网银 、7汇付网银、8财付通网银、 //9支付宝pos、10快钱pos、11汇付pos、12财付通pos、13易宝pos、14账户支付、15收银 //string tempSqlWhere = " OrderId='" + id + "'"; string tempSqlWhere = " id='" + id + "'"; List <Tb_Ticket_Order> bParametersList = new PbProject.Logic.Order.Tb_Ticket_OrderBLL().GetListBySqlWhere(tempSqlWhere); Tb_Ticket_Order mOrder = null; if (bParametersList != null && bParametersList.Count == 1) { mOrder = bParametersList[0]; #region 判断PNR状态是否取消等,取消就不能支付 if (mOrder.OrderStatusCode != 1 && mOrder.OrderStatusCode != 9) { msgShow = "订单异常,不能支付!"; } #endregion if (this.KongZhiXiTong.Contains("|101|")) { //超过 1 小时后的订单能支付 } else { #region 超过1个小时不能支付 if (mOrder.OrderStatusCode == 1) { DateTime dtTime = DateTime.Now; if (dtTime.CompareTo(mOrder.CreateTime.AddHours(1)) > 0) { // 超过1个小时不能支付 msgShow = "超过1个小时的订单不能支付,请重新生成订单进行支付!"; } } #endregion } #region 判断PNR状态是否取消等,取消就不能支付 //扩展参数 ParamEx pe = new ParamEx(); pe.UsePIDChannel = this.KongZhiXiTong != null && this.KongZhiXiTong.Contains("|48|") ? 2 : 0; SendInsManage sendins = new SendInsManage(mUser.LoginName, mCompany.UninCode, pe, this.configparam); string ErrMsg; if (mOrder.OrderSourceType == 1 && mOrder.A9 != "1") { PnrAnalysis.PnrModel PnrModel = sendins.GetPnr(mOrder.PNR, mOrder.Office, out ErrMsg); if (ErrMsg.IndexOf("已被取消") != -1) { msgShow = "此PNR(" + mOrder.PNR + ")状态为异常,请检查PNR状态后再试!"; } else if (PnrModel != null && ErrMsg == "") { if (PnrModel.PassengerNameIsCorrent) { if (KongZhiXiTong != null && KongZhiXiTong.Contains("|23|")) { if ((PnrModel._OldPnrContent.Contains("THIS PNR WAS ENTIRELY CANCELLED") && PnrModel._OldPnrContent.ToUpper().Contains(mOrder.PNR.ToUpper()))) { msgShow = "此PNR(" + mOrder.PNR + ")状态为异常,请检查PNR状态后再试!"; } else { string PnrStatus = PnrModel.PnrStatus; if (string.IsNullOrEmpty(PnrStatus)) { msgShow = "此PNR(" + mOrder.PNR + ")数据异常,请检查PNR状态后再试!"; } else { if (!PnrStatus.Contains("HK") && !PnrStatus.Contains("DK") && !PnrStatus.Contains("RR") && !PnrStatus.Contains("KK")) { msgShow = "此PNR(" + mOrder.PNR + ")状态为:" + PnrStatus + ",请检查PNR状态后再试!"; } } } } } else { msgShow = "此PNR(" + mOrder.PNR + ")中乘机人名字:" + string.Join(",", PnrModel.ErrorPassengerNameList.ToArray()) + " 不正确!"; } } } #endregion 判断PNR状态是否取消等,取消就不能支付 if (msgShow == "") { mOrder.PayWay = int.Parse(payWay); // 切换支付方式:修改订单账单明细数据 result = new PbProject.Logic.Pay.Bill().UpdateOrderAndTicketPayDetail(mOrder); if (result == true) { //获取分账明细 payDetails = new PbProject.Logic.Pay.Bill().PayDetails(payWay, mOrder.OrderId); result = string.IsNullOrEmpty(payDetails) ? false : result; } } } #endregion if (result) { #region 支付 if (payWay == "1" || payWay == "5")//支付宝 { #region 支付参数赋值 AliPayParam aliPayParam = new AliPayParam(); aliPayParam.Body = "机票订单"; aliPayParam.DefaultBank = code; aliPayParam.Extra_common_param = mUser.id.ToString(); //自定义:操作人id aliPayParam.Out_trade_no = mOrder.OrderId; aliPayParam.Royalty_parameters = payDetails; //分账明细 aliPayParam.Subject = "机票订单"; aliPayParam.Total_fee = mOrder.PayMoney.ToString("f2"); if ((!string.IsNullOrEmpty(mOrder.A9) && mOrder.A9 == "1") || string.IsNullOrEmpty(mOrder.PNR)) { //不检查编码 OnErrorNew("不检查编码,PNR:" + mOrder.PNR, false); } else { //需要检查编码 #region 判断PNR tempSqlWhere = " PNR='" + mOrder.PNR + "' and OrderStatusCode=4 and (PayWay=1 or PayWay=5)"; List <Tb_Ticket_Order> orderListNew = new PbProject.Logic.Order.Tb_Ticket_OrderBLL().GetListBySqlWhere(tempSqlWhere); if (orderListNew == null || orderListNew.Count == 0) { //先看该订单支付已经支付过 aliPayParam.Extend_param = "PNR^" + mOrder.PNR; } else { OnErrorNew("该编码已经有支付记录,PNR:" + mOrder.PNR, false); } #endregion } #endregion msgShow = new PbProject.Logic.Pay.AliPay().GetPay(aliPayParam); } else if (payWay == "2" || payWay == "6")//快钱 { PbProject.Logic.Pay.DataAction d = new PbProject.Logic.Pay.DataAction(); decimal tempMoney = d.FourToFiveNum(mOrder.PayMoney * 0.001M, 2) * 100; //手续费 #region 支付参数赋值 _99BillParam billParam = new _99BillParam(); billParam.Bankcode = code; billParam.Detail = payDetails; //分账明细 billParam.Ext = mUser.id.ToString(); //操作人id billParam.Money = tempMoney.ToString("f0"); //供应商收款 billParam.Orderid = mOrder.OrderId; //billParam.Payid = "*****@*****.**"; billParam.Payid = ""; billParam.Paytype = (string.IsNullOrEmpty(code)) ? "00" : "10"; billParam.Pname = "机票订单"; billParam.Price = (mOrder.PayMoney * 100).ToString("f0"); //供应商收款 billParam.Ptype = "1"; #endregion msgShow = new PbProject.Logic.Pay._99Bill().GetPay(billParam); } else if (payWay == "3" || payWay == "7")//汇付天下 { #region 支付参数赋值 ChinaPnrParam chinaPnrParam = new ChinaPnrParam(); chinaPnrParam.Orderid = mOrder.OrderId; //订单号 chinaPnrParam.Price = mOrder.PayMoney.ToString("f2"); //订单总价 chinaPnrParam.Merpriv = mUser.id.ToString(); //自定义字段 chinaPnrParam.Details = payDetails; //分账明细 chinaPnrParam.Pnr = mOrder.PNR; #endregion msgShow = new PbProject.Logic.Pay.ChinaPnr().Buy(chinaPnrParam); } else if (payWay == "4" || payWay == "8" || payWay == "40")// 财付通 { string queryParam = string.Format("orderid={0}&total_tee={1}&userhostaddress={2}&attach={3}&busargs={4}&busdesc={5}&banktype={6}", mOrder.OrderId, (mOrder.PayMoney * 100).ToString("F0"), Request.UserHostAddress, mUser.id.ToString(), payDetails, string.Format("{0}^{1}^{2}^{3}^{4}^{5}", mOrder.PNR, mOrder.Travel, mOrder.PassengerNumber, mUser.id.ToString(), mOrder.CreateUserName, "13800000000"), code); url = string.Format("http://lzh.mypb.cn/Pay/TenPay.aspx?{0}", queryParam); // url = string.Format("TenPay.aspx?{0}", queryParam); } #endregion } else { OnErrorNew("支付错误:" + payDetails, false); msgShow = string.IsNullOrEmpty(msgShow) ? "支付错误" : msgShow; } } catch (Exception ex) { msgShow = "支付异常"; OnErrorNew(msgShow + ex.ToString(), false); } if (!string.IsNullOrEmpty(url)) { Response.Redirect(url); } else { OnErrorNew(msgShow, false); Response.Write(msgShow); } }