protected void Page_Load(object sender, EventArgs e) { orderid = Request["id"].ConvertTo <int>(0); bank = Request["bank"].ConvertTo <int>(0); if (orderid != 0) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); if (modelb2border != null) { comid = modelb2border.Comid; //if (bo == false) //{ // if (comid == 101) // { // Response.Redirect("http://vctrip.etown.cn/"); // } // Response.Redirect("http://shop" + comid + ".etown.cn"); //} } } }
/// <summary> /// 得到支付来源 /// </summary> /// <param name="order"></param> /// <returns></returns> public string GetPaycomByorder(B2b_order order) { using (var helper = new SqlHelper()) { string pay_com = new InternalB2bPay(helper).Getpaycombyorder(order); return(pay_com); } }
/// <summary> /// 得到支付总金额 /// </summary> /// <param name="m"></param> /// <returns></returns> public decimal GetPaytotalfee(B2b_order m) { using (var helper = new SqlHelper()) { decimal r = new InternalB2bPay(helper).GetPaytotalfee(m); return(r); } }
protected void Page_Load(object sender, EventArgs e) { comid = Request["comid"].ConvertTo <int>(0); agentid = Request["agentid"].ConvertTo <int>(0); orderid = Request["orderid"].ConvertTo <int>(0); md5info = Request["md5info"].ConvertTo <string>(""); string Returnmd5 = EncryptionHelper.ToMD5(orderid.ToString() + comid.ToString() + agentid.ToString() + "lixh1210", "UTF-8"); if (Returnmd5 == md5info)//验证MD5 { B2bOrderData orderdate = new B2bOrderData(); B2b_order ordermodel = orderdate.GetOrderById(orderid); if (ordermodel != null) { B2bComProData prodata = new B2bComProData(); B2b_com_pro promodel = prodata.GetProById(ordermodel.Pro_id.ToString()); if (promodel != null) { if (ordermodel.Agentid == agentid && ordermodel.Comid == comid && ordermodel.Warrant_type == 2) { ExcelRender.RenderToExcel( ExcelSqlHelper.ExecuteDataTable(CommandType.Text, "select e_proname [产品名称],pno [票号],pnum [数量] from b2b_eticket where oid=" + orderid), Context, promodel.Pro_name + ordermodel.U_subdate.Date.ToString("yyyyMMdd") + "-" + ordermodel.Id.ToString() + ".xls"); } else { err = "订单参数错误"; } } else { err = "产品错误"; } } else { err = "订单错误"; } } else { err = "验证错误"; } }
internal string Getpaycombyorder(B2b_order order) { string sql = "select pay_com from b2b_pay where oid=" + order.Id + " and trade_status='TRADE_SUCCESS'"; if (order.Shopcartid > 0) { sql = "select pay_com from b2b_pay where oid in (select id from b2b_order where shopcartid =" + order.Shopcartid + ") and trade_status='TRADE_SUCCESS'"; } var cmd = sqlHelper.PrepareTextSqlCommand(sql); using (var reader = cmd.ExecuteReader()) { string paycom = ""; if (reader.Read()) { paycom = reader.GetValue <string>("pay_com"); } return(paycom); } }
internal decimal GetPaytotalfee(B2b_order m) { string sql = "SELECT [total_fee] FROM [b2b_pay] where oid=" + m.Id + " and [trade_status]='TRADE_SUCCESS'"; if (m.Shopcartid > 0)//购物车订单,则需要查询购物车订单的支付金额 { sql = "SELECT [total_fee] FROM [b2b_pay] where oid in (select id from b2b_order where shopcartid=" + m.Shopcartid + ") and [trade_status]='TRADE_SUCCESS'"; } var cmd = sqlHelper.PrepareTextSqlCommand(sql); using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { return(reader.GetValue <decimal>("total_fee")); } return(0); } }
public string pricedetail = ""; //价格详情(暂时只有用来描述旅游) protected void Page_Load(object sender, EventArgs e) { //RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); if (Request.QueryString["code"] != null) { #region 获取用户openid code = Request.QueryString["code"]; string url = string.Format( "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appId, appsecret, code); string returnStr = HttpUtil.Send("", url); var obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); url = string.Format( "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", appId, obj.refresh_token); returnStr = HttpUtil.Send("", url); obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); WriteFile(Server.MapPath("") + "\\Log.txt", obj.access_token); WriteFile(Server.MapPath("") + "\\Log.txt", obj.openid); //url = string.Format( // "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", // obj.access_token, obj.openid); //returnStr = HttpUtil.Send("", url); //WriteFile(Server.MapPath("") + "\\Log.txt", returnStr); #endregion /////////////////////////////////////////////////////////////////////////////////////////////// orderid = Request["orderid"].ConvertTo <int>(0); if (orderid != 0) { //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); if (modelb2border != null && modelcompro != null) { #region 务类型订单金额 servertype = modelcompro.Server_type; //如果服务类型是“酒店客房”,则根据酒店扩展订单表中房态信息,获取支付金额 if (modelcompro.Server_type == 9) { B2b_order_hotel hotelorder = new B2b_order_hotelData().GetHotelOrderByOrderId(orderid); if (hotelorder != null) { string fangtai = hotelorder.Fangtai; DateTime start_data = hotelorder.Start_date; DateTime end_data = hotelorder.End_date; int bookdaynum = hotelorder.Bookdaynum; decimal everyroomprice = 0; string[] ftstr = fangtai.Split(','); for (int i = 0; i < ftstr.Length; i++) { if (ftstr[i].ConvertTo <decimal>(0) > 0) { everyroomprice += ftstr[i].ConvertTo <decimal>(0); } } price = everyroomprice.ToString(); p_totalprice1 = (modelb2border.U_num * everyroomprice - modelb2border.Integral1 - modelb2border.Imprest1); } else { } } else if (servertype == 2 || servertype == 8)//当地游;跟团游 { string outdate = modelb2border.U_traveldate.ToString("yyyy-MM-dd"); //读取団期价格,根据实际选择的団期报价 B2b_com_LineGroupDate linemode = new B2b_com_LineGroupDateData().GetLineDayGroupDate(DateTime.Parse(outdate), modelcompro.Id); if (linemode != null) { price = linemode.Menprice.ToString(); decimal childreduce = modelcompro.Childreduce; decimal childprice = decimal.Parse(price) - childreduce; if (childprice < 0) { childprice = 0; } pricedetail = modelb2border.U_num + "成人," + modelb2border.Child_u_num + "儿童(成人" + price + "元/人,儿童" + childprice + "元/人)"; p_totalprice1 = (modelb2border.U_num * (linemode.Menprice) + (modelb2border.Child_u_num) * childprice - modelb2border.Integral1 - modelb2border.Imprest1); } } else //票务 { p_totalprice1 = (modelb2border.U_num * modelcompro.Advise_price - modelb2border.Integral1 - modelb2border.Imprest1); price = modelcompro.Advise_price.ToString(); //modelb2border.Pay_price.ToString(); if (price == "0.00" || price == "0") { price = ""; } else { price = CommonFunc.OperTwoDecimal(price); } } #endregion proname = modelcompro.Pro_name; u_name = modelb2border.U_name.Substring(0, 1) + "**"; u_mobile = modelb2border.U_phone.Substring(0, 4) + "****" + modelb2border.U_phone.Substring(modelb2border.U_phone.Length - 3, 3); travel_date = modelb2border.U_traveldate.ToString(); buy_num = modelb2border.U_num; u_youxiaoqi = modelcompro.Pro_start.ToString() + " - " + modelcompro.Pro_end.ToString(); p_totalprice = CommonFunc.OperTwoDecimal(p_totalprice1.ToString()); wxp_totalprice = (p_totalprice1 * 100).ToString("F0"); price = modelb2border.Pay_price.ToString(); price = CommonFunc.OperTwoDecimal(price); comid = modelcompro.Com_id; if (comid != 0) { comName = B2bCompanyData.GetCompany(comid).Com_name; if (bo == false) { Response.Redirect("http://shop" + comid + ".etown.cn"); } } if ((int)modelb2border.Order_state != (int)OrderStatus.WaitPay) { order_status = EnumUtils.GetName((OrderStatus)modelb2border.Order_state); return; } var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } //写入支付数据库,先判定是否有此订单支付 B2bPayData datapay = new B2bPayData(); B2b_pay modelb2pay = datapay.GetPayByoId(orderid); #region 微信支付 //根据产品判断商家是否含有自己的微信支付:a.含有的话支付到商家;b.没有的话支付到平台的微信公众号账户中 B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(modelcompro.Com_id); if (model != null) { //商家微信支付的所有参数都存在 if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { appId = model.Wx_appid; appsecret = model.Wx_appkey; appkey = model.Wx_paysignkey; mchid = model.Wx_partnerid; } else { return; } } else { return; } //创建支付应答对象 var packageReqHandler = new RequestHandler(Context); //初始化 packageReqHandler.init(); timeStamp = TenpayUtil.getTimestamp(); nonceStr = TenpayUtil.getNoncestr(); //设置package订单参数 string productname = modelcompro.Pro_name.Replace("\"", "").Replace("“", "").Replace("'", "").Replace("‘", "").Replace(";", "").Replace(";", ""); packageReqHandler.setParameter("body", productname); //商品信息 127字符 packageReqHandler.setParameter("appid", appId); packageReqHandler.setParameter("mch_id", mchid); packageReqHandler.setParameter("nonce_str", nonceStr.ToLower()); packageReqHandler.setParameter("notify_url", "http://shop" + modelcompro.Com_id + ".etown.cn/wxpay/backpaynotice.aspx"); packageReqHandler.setParameter("openid", obj.openid); packageReqHandler.setParameter("out_trade_no", orderid.ToString()); //商家订单号 packageReqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress); //用户的公网ip,不是商户服务器IP packageReqHandler.setParameter("total_fee", wxp_totalprice); //商品金额,以分为单位(money * 100).ToString() packageReqHandler.setParameter("trade_type", "JSAPI"); //获取package包 sign = packageReqHandler.CreateMd5Sign("key", appkey); WriteFile(Server.MapPath("") + "\\Log.txt", sign); packageReqHandler.setParameter("sign", sign); string data = packageReqHandler.parseXML(); WriteFile(Server.MapPath("") + "\\Log.txt", data); string prepayXml = HttpUtil.Send(data, "https://api.mch.weixin.qq.com/pay/unifiedorder"); WriteFile(Server.MapPath("") + "\\Log.txt", prepayXml); //获取预支付ID var xdoc = new XmlDocument(); xdoc.LoadXml(prepayXml); XmlNode xn = xdoc.SelectSingleNode("xml"); XmlNodeList xnl = xn.ChildNodes; if (xnl.Count > 7) { prepayId = xnl[7].InnerText; package = string.Format("prepay_id={0}", prepayId); WriteFile(Server.MapPath("") + "\\Log.txt", package); } //设置支付参数 var paySignReqHandler = new RequestHandler(Context); paySignReqHandler.setParameter("appId", appId); paySignReqHandler.setParameter("timeStamp", timeStamp); paySignReqHandler.setParameter("nonceStr", nonceStr); paySignReqHandler.setParameter("package", package); paySignReqHandler.setParameter("signType", "MD5"); paySign = paySignReqHandler.CreateMd5Sign("key", appkey); WriteFile(Server.MapPath("") + "\\Log.txt", paySign); #endregion //订单提交支付信息 if (modelb2pay == null) { B2b_pay eticket = new B2b_pay() { Id = 0, Oid = orderid, Pay_com = "wx", Pay_name = modelb2border.U_name, Pay_phone = modelb2border.U_phone, Total_fee = p_totalprice1, Trade_no = "", Trade_status = "trade_pendpay", Uip = "" }; int payid = datapay.InsertOrUpdate(eticket); } else { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status != "TRADE_SUCCESS") { //防止金额有所改动 modelb2pay.Pay_com = "wx"; modelb2pay.Total_fee = p_totalprice1; datapay.InsertOrUpdate(modelb2pay); } } } } } }
protected void Page_Load(object sender, EventArgs e) { ////-1 需要替换为测试分销商id //agentinfo = new AgentCompanyData().GetAgentCompany(-1); //拉取产品 //string prochangetxt = "{" + // "\"partnerId\":2312," + // "\"body\": {" + // "\"method\":\"multi\"," + // "\"currentPage\":1," + // "\"pageSize\": 20" + // "}" + // "}"; //创建订单 //string prochangetxt = "{" + // "\"partnerId\":2312," + // "\"body\": {" + // "\"contactPerson\": {" + // "\"name\":\"李星海\"," + // "\"mobile\":\"13488761102\"" + // "}," + // "\"visitors\": [{" + // "\"name\":\"李星海\"," + // "\"mobile\":\"13488761102\"" + // "}]," + // "\"partnerOrderId\":\"90000013\"," + // "\"partnerDealId\":\"50000001\"," + // "\"wlDealId\":\"5bed3fcc73c37c31f8d8909c\"," + // "\"buyPrice\":0.01," + // "\"unitPrice\":1 ," + // "\"totalPrice\":2 ," + // "\"quantity\":2 ," + // "\"travelDate\": \"2018-12-07\"" + // "}" + // "}"; //string prochangetxt = "{\"contacts\":{\"idNum\":\"441400198002244166\",\"idType\":\"ID_CARD\",\"mobile\":\"13764517990\",\"name\":\"测试下单\"},\"num\":\"1\",\"password\":\"a6b50913\",\"serialNo\":\"2018122592819013\",\"settlePrice\":\"0.01\",\"sign\":\"3fe30eee43a6f04d62be36dc69d7a28b\",\"supplierGoodsId\":\"12811\",\"timestamp\":\"20181225135505\",\"travellerList\":[{\"idNum\":\"441400198002244166\",\"idType\":\"ID_CARD\",\"mobile\":\"13764517990\",\"name\":\"测试下单\"}],\"uid\":\"lvmama8527\",\"visitTime\":\"20181226000000\"}"; //TextBox1.Text = prochangetxt; //支付通知 // string prochangetxt = "{" + // "\"partnerId\":2312," + // "\"body\": {" + // "\"partnerOrderId\":\"90000013\"," + // "\"wlOrderId\":\"15441535059641023\"" + // "}" + // "}"; //var t= wlOrderPayRequest_data(); //退款 //string prochangetxt = "{" + // "\"partnerId\":2312," + // "\"body\": {" + // "\"wlOrderId\":\"15441535059641023\"," + // "\"wlDealId\":\"5bed3fcc73c37c31f8d8909c\"," + // "\"partnerRefundId\":\"" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "\"," +//退款流水号 // "\"partnerOrderId\":\"90000012\"," + // "\"partnerDealId\":\"50000001\"," + // "\"voucherList\":[\"15441535059641023\"]," + // "\"refundQuantity\":2," + // "\"unitPrice\":0.01," + // "\"refundPrice\":0.02," + // "\"refundFee\":0.00," + // "\"refundTime\":\"" + DateTime.Now.ToString("yyyy-MM-dd- HH:mm:ss") + "\"" + // "}" + // "}"; //TextBox1.Text = prochangetxt; ////核销 string prochangetxt = "{" + "\"partnerId\":2312," + "\"body\": {" + "\"wlOrderId\":\"15464225396069730\"," + "\"usedQuantity\":1," + "\"quantity\":1," + "\"refundedQuantity\":0," + "}" + "}"; TextBox1.Text = prochangetxt; //string consumetext = "{" + // "\"code\": 200," + // "\"describe\": \"消费通知\"," + // "\"partnerId\":" + agentinfo.mt_partnerId + "," + // "\"body\": {" + // "\"bookOrderId\": \"美团订单号\"," + // "\"partnerOrderId\": \"易城订单号\"," + // "\"orderStatus\": 0," + // "\"orderQuantity\": 0," + // "\"usedQuantity\": 0," + // "\"refundQuantity\": 0," + // "\"isConsumed\": false," +//凭证码是否消费 // "\"voucher\": \"string\"" +//订单凭证码 // "}" + // "}"; //string url = "http://test.wlski.net/wl.trip.order.create"; //var indexOf = url.IndexOf("/", 10, StringComparison.Ordinal); ////string stringToSign = "POST" + " " + url.Substring(indexOf).Replace("rhone-doc", "rhone").Replace("/", "") + "\n" + request.Headers.Get("Date"); //////正式环境需要替换为下面内容 ////string stringToSign = "POST" + " " + url.Substring(indexOf) + "\n" + request.Headers.Get("Date"); //string usekey = "E60C5FA69F937CF81F1A67F738BF5508"; //string stringToSign = "POST wl.trip.order.get \nWed, 06 May 2015 10:34:20 GMT"; //string sign = WlGetProInfoDealRequestData.GetSign(stringToSign, usekey); B2b_order order = new B2b_order() { ignoredabatime = 0, M_b2b_order_hotel = null, Id = 0, Pro_id = 12809, Speciid = 0, Order_type = 1, U_name = "李星海", U_id = 0, U_phone = "13488761102", U_idcard = "", U_num = 1, U_subdate = DateTime.Now, Payid = 0, Pay_price = 1, Cost = 1, Profit = 0, Order_state = (int)OrderStatus.WaitPay, // Pay_state = (int)PayStatus.NotPay, //支付模块未做出来前先设置为已支付 Send_state = (int)SendCodeStatus.NotSend, Ticketcode = 0, //电子码未创建,支付后产生码赋值 Rebate = 0, // 利润返佣金额暂时定为0 Ordercome = "", //订购来源 暂时定为空 U_traveldate = DateTime.Now, Dealer = "自动", Comid = 112, Pno = "", Openid = "", Ticketinfo = "", Integral1 = 0, //积分 Imprest1 = 0, //预付款 Agentid = 0, //分销ID Warrantid = 0, //授权ID Warrant_type = 1, //支付类型分销 1出票扣款 2验码扣款 Buyuid = 0, Tocomid = 0, pickuppoint = "", dropoffpoint = "", Order_remark = "", Deliverytype = 0, Province = "", City = "", Address = "", Code = "", channelcoachid = 0, //baoxiannames = baoxiannames, //baoxianpinyinnames = baoxianpinyinnames, //baoxianidcards = baoxianidcards, //autosuccess = autosuccess, //submanagename = submanagename, //yuyuepno = yuyuepno, //travelnames = travelnames, //travelphones = travelphones, //serverid = sid, //payserverpno = payserverpno, travelidcards = "", travelnations = "", travelremarks = "" }; int orderid = 0; //var data = OrderJsonData.InsertOrUpdate(order, out orderid); //var PayReturnSendEticket = new PayReturnSendEticketData(); //var s = PayReturnSendEticket.chulidingdan(298283, 1); //string consumetext = sign; TextBox2.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { Request.ValidateInput(); int orderid = Request["out_trade_no"].ConvertTo <int>(0); //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); ////////////////////////////////////////////请求参数//////////////////////////////////////////// //必填参数// //请与贵网站订单系统中的唯一订单号匹配 string out_trade_no = orderid.ToString(); //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。 string subject = ""; if (modelb2border.Order_type == 2) { subject = "预付款充值"; } else { subject = modelcompro.Pro_name; } //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里 string body = "pay"; //订单总金额,显示在支付宝收银台里的“应付总额”里 string total_fee = String.Format("{0:N2}", (modelb2border.U_num * modelb2border.Pay_price + modelb2border.Express) - modelb2border.Integral1 - modelb2border.Imprest1); // if (modelb2border.Shopcartid > 0) //如果是购物车产品重新计算费用 { total_fee = String.Format("{0:N2}", dataorder.GetCartOrderMoneyById(orderid)); } total_fee = total_fee.Replace(",", ""); //扩展功能参数——默认支付方式// //默认支付方式,代码见“即时到帐接口”技术文档 string paymethod = Request["paymethod"]; //默认网银代号,代号列表见“即时到帐接口”技术文档“附录”→“银行列表” string defaultbank = Request["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 = ""; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 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^分润备注二"; //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 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); sParaTemp.Add("default_login", "Y"); //写入支付数据库,先判定是否有此订单支付 //根据订单id得到订单信息 B2bPayData datapay = new B2bPayData(); B2b_pay modelb2pay = datapay.GetPayByoId(orderid); if (modelb2pay == null) { B2b_pay eticket = new B2b_pay() { Id = 0, Oid = orderid, Pay_com = "alipay", Pay_name = modelb2border.U_name, Pay_phone = modelb2border.U_phone, Total_fee = decimal.Parse(total_fee), Trade_no = "", Trade_status = "trade_pendpay", Uip = "", comid = 106 }; int payid = datapay.InsertOrUpdate(eticket); } else { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status != "TRADE_SUCCESS") { //防止金额有所改动 modelb2pay.comid = 106; modelb2pay.Pay_com = "alipay"; modelb2pay.Total_fee = decimal.Parse(total_fee); datapay.InsertOrUpdate(modelb2pay); } else { } } //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_direct_pay_by_user(sParaTemp); Response.Write(sHtmlText); }
protected void Page_Load(object sender, EventArgs e) { //返回订单号 orderid = Request["orderid"].ConvertTo <int>(0); agentorderid = Request["agentorderid"].ConvertTo <int>(0); act = Request["act"].ConvertTo <string>(""); if (orderid != 0) { //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); //如果订单“未付款”现实支付及订单信息 if ((int)modelb2border.Order_state == (int)OrderStatus.WaitPay) { u_name = modelb2border.U_name.Substring(0, 1) + "**"; u_mobile = modelb2border.U_phone.Substring(0, 4) + "****" + modelb2border.U_phone.Substring(modelb2border.U_phone.Length - 3, 3); ; travel_date = modelb2border.U_traveldate.ToString(); buy_num = modelb2border.U_num; p_totalprice = (int)(modelb2border.U_num * modelb2border.Pay_price); ordertype = modelb2border.Order_type; if (ordertype == 2) { proname = "预付款充值"; u_youxiaoqi = ""; } else { proname = modelcompro.Pro_name; u_youxiaoqi = modelcompro.Pro_start.ToString() + " - " + modelcompro.Pro_end.ToString(); } } comid_temp = Request["comid"].ConvertTo <int>(0); B2b_company companyinfo = B2bCompanyData.GetAllComMsg(comid_temp); if (companyinfo != null) { company = companyinfo.Com_name; } if (Session["Agentid"] != null) { //账户信息 Agentid = Int32.Parse(Session["Agentid"].ToString()); Account = Session["Account"].ToString(); Agent_company agenginfo = AgentCompanyData.GetAgentWarrant(Agentid, comid_temp); if (agenginfo != null) { yufukuan = "您预付款:" + agenginfo.Imprest + " 元"; Warrant_type = agenginfo.Warrant_type; } } } }
protected void Page_Load(object sender, EventArgs e) { string sp_billno = Request["order_no"]; string product_name = Request["product_name"]; string order_price = Request["order_price"];; string remarkexplain = Request["remarkexplain"]; string bank_type_value = Request["bank_type_value"].ConvertTo <string>("DEFAULT"); double money = 0; if (null == Request["order_price"]) { Response.Write("支付金额错误!"); Response.End(); return; } try { money = Convert.ToDouble(order_price); } catch { Response.Write("支付金额格式错误!"); Response.End(); return; } if (null == sp_billno) { ////生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一 //sp_billno = DateTime.Now.ToString("HHmmss") + TenpayUtil.BuildRandomStr(4); Response.Write("订单编号错误!"); Response.End(); return; } else { sp_billno = Request["order_no"].ToString(); } //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(sp_billno.ConvertTo <int>(0)); if (modelb2border == null) { Response.Write("订单信息获取错误!"); Response.End(); return; } //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); if (modelcompro == null) { Response.Write("产品信息错误!"); Response.End(); return; } if (modelb2border != null && modelcompro != null) { //写入支付数据库,先判定是否有此订单支付 //根据订单id得到订单信息 B2bPayData datapay = new B2bPayData(); B2b_pay modelb2pay = datapay.GetPayByoId(sp_billno.ConvertTo <int>(0)); if (modelb2pay != null) { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status == "TRADE_SUCCESS") { Response.Write("订单已经支付过!"); Response.End(); return; } } #region 获得财付通支付参数 tenpay_id,tenpay_key //根据产品判断商家是否含有自己的财付通支付: //a.含有的话支付到商家; //b.没有的话支付到平台财付通账户(易城账户,公司id=106) string tenpay_id = ""; string tenpay_key = ""; B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(modelcompro.Com_id); if (model != null) { //商家财付通支付的所有参数都存在 if (model.Tenpay_id != "" && model.Tenpay_key != "") { tenpay_id = model.Tenpay_id; tenpay_key = model.Tenpay_key; } else { model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(106); if (model == null) { Response.Write("商户财付通信息设置不完全!"); Response.End(); return; } else { //商家财付通支付的所有参数都存在 if (model.Tenpay_id != "" && model.Tenpay_key != "") { tenpay_id = model.Tenpay_id; tenpay_key = model.Tenpay_key; } else { Response.Write("商户财付通信息设置不完全!!"); Response.End(); return; } } } } else { model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(106); if (model == null) { Response.Write("商户财付通信息设置不完全!"); Response.End(); return; } else { //商家财付通支付的所有参数都存在 if (model.Tenpay_id != "" && model.Tenpay_key != "") { tenpay_id = model.Tenpay_id; tenpay_key = model.Tenpay_key; } else { Response.Write("商户财付通信息设置不完全!!"); Response.End(); return; } } } #endregion if (modelb2pay == null) { B2b_pay eticket = new B2b_pay() { Id = 0, Oid = sp_billno.ConvertTo <int>(0), Pay_com = "mtenpay", Pay_name = modelb2border.U_name, Pay_phone = modelb2border.U_phone, Total_fee = (decimal)modelb2border.Pay_price * modelb2border.U_num + modelb2border.Express - modelb2border.Integral1 - modelb2border.Imprest1, Trade_no = "", Trade_status = "trade_pendpay", Uip = "", comid = model.Com_id }; int payid = datapay.InsertOrUpdate(eticket); } else { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status != "TRADE_SUCCESS") { //防止金额有所改动 modelb2pay.comid = model.Com_id; modelb2pay.Pay_com = "mtenpay"; modelb2pay.Total_fee = (decimal)modelb2border.Pay_price * modelb2border.U_num + modelb2border.Express - modelb2border.Integral1 - modelb2border.Imprest1; datapay.InsertOrUpdate(modelb2pay); } else { Response.Write("订单已经支付过!"); Response.End(); return; } } //创建RequestHandler实例 RequestHandler reqHandler = new RequestHandler(Context); //初始化 reqHandler.init(); //设置密钥 reqHandler.setKey(tenpay_key); reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); //----------------------------- //设置支付参数 //----------------------------- reqHandler.setParameter("partner", tenpay_id); //商户号 reqHandler.setParameter("out_trade_no", sp_billno); //商家订单号 reqHandler.setParameter("total_fee", (money * 100).ToString()); //商品金额,以分为单位 reqHandler.setParameter("return_url", "http://shop" + modelcompro.Com_id.ToString() + ".etown.cn/tenpay/payReturnUrl.aspx"); //交易完成后跳转的URL reqHandler.setParameter("notify_url", "http://shop" + modelcompro.Com_id.ToString() + ".etown.cn/tenpay/payNotifyUrl.aspx"); //接收财付通通知的URL reqHandler.setParameter("body", remarkexplain); //商品描述 reqHandler.setParameter("bank_type", bank_type_value); //银行类型(中介担保时此参数无效) reqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress); //用户的公网ip,不是商户服务器IP reqHandler.setParameter("fee_type", "1"); //币种,1人民币 reqHandler.setParameter("subject", product_name); //商品名称(中介交易时必填) //系统可选参数 reqHandler.setParameter("sign_type", "MD5"); reqHandler.setParameter("service_version", "1.0"); reqHandler.setParameter("input_charset", "UTF-8"); reqHandler.setParameter("sign_key_index", "1"); //业务可选参数 reqHandler.setParameter("attach", ""); //附加数据,原样返回 reqHandler.setParameter("product_fee", "0"); //商品费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("transport_fee", "0"); //物流费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //订单生成时间,格式为yyyymmddhhmmss reqHandler.setParameter("time_expire", ""); //订单失效时间,格式为yyyymmddhhmmss reqHandler.setParameter("buyer_id", ""); //买方财付通账号 reqHandler.setParameter("goods_tag", ""); //商品标记 reqHandler.setParameter("trade_mode", "1"); //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择) reqHandler.setParameter("transport_desc", ""); //物流说明 reqHandler.setParameter("trans_type", "1"); //交易类型,1实物交易,2虚拟交易 reqHandler.setParameter("agentid", ""); //平台ID reqHandler.setParameter("agent_type", ""); //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式 reqHandler.setParameter("seller_id", ""); //卖家商户号,为空则等同于partner //获取请求带参数的url string requestUrl = reqHandler.getRequestURL(); //获取debug信息,建议把请求和debug信息写入日志,方便定位问题 string debuginfo = reqHandler.getDebugInfo(); //Response.Write("<br/>requestUrl:" + requestUrl + "<br/>"); //Response.Write("<br/>debuginfo:" + debuginfo + "<br/>"); //Get的实现方式 string a_link = "<a target=\"_blank\" href=\"" + requestUrl + "\">" + "财付通支付" + "</a>"; //Response.Write(a_link); Response.Redirect(requestUrl); //post实现方式 /* Response.Write("<form method=\"post\" action=\"" + reqHandler.getGateUrl() + "\" >\n"); * Hashtable ht = reqHandler.getAllParameters(); * foreach (DictionaryEntry de in ht) * { * Response.Write("<input type=\"hidden\" name=\"" + de.Key + "\" value=\"" + de.Value + "\" >\n"); * } * Response.Write("<input type=\"submit\" value=\"财付通支付\" >\n</form>\n");*/ } }
protected void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); //返回订单号 orderid = Request["orderid"].ConvertTo <int>(0); agentorderid = Request["agentorderid"].ConvertTo <int>(0); if (orderid != 0) { //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); if (modelb2border != null) { if (!bo) { Response.Redirect("/ui/vasui/pay.aspx?orderid=" + orderid + "&comid=" + modelb2border.Comid); } } //取消超时订单 B2b_com_pro pro_cannelorder = new B2b_com_pro(); pro_cannelorder.Server_type = 0; int rs_cannelorder = new B2bComProData().CancelOvertimeOrder(pro_cannelorder); orderstatus = EnumUtils.GetName((OrderStatus)modelb2border.Order_state); order_state = modelb2border.Order_state; paystatus = modelb2border.Pay_state;//1未支付;2已支付 order_type = modelb2border.Order_type; subtime = modelb2border.U_subdate.ToString("yyyy/MM/dd hh:mm:ss"); comid = modelb2border.Comid; #region 正常订单 if (modelb2border.Order_type == 1) { //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString(), modelb2border.Speciid); ////如果订单“未付款”显示支付及订单信息 //if ((int)modelb2border.Order_state == (int)OrderStatus.WaitPay) //{ if (modelb2border.U_name != "") { u_name = modelb2border.U_name.Substring(0, 1) + "**"; } else { u_name = "**"; } if (modelb2border.U_phone != "") { u_mobile = modelb2border.U_phone.Substring(0, 4) + "****" + modelb2border.U_phone.Substring(modelb2border.U_phone.Length - 3, 3); } else { u_mobile = "****"; } travel_date = modelb2border.U_traveldate.ToString(); buy_num = modelb2border.U_num; if (modelcompro != null) { u_youxiaoqi = modelcompro.Pro_start.ToString() + " - " + modelcompro.Pro_end.ToString(); travel_proid = modelcompro.Travelproductid; comid = modelcompro.Com_id; proname = modelcompro.Pro_name; servertype = modelcompro.Server_type; Ispanicbuy = modelcompro.Ispanicbuy; } #region 如果服务类型是“酒店客房”,则根据酒店扩展订单表中房态信息,获取支付金额 if (modelcompro.Server_type == 9) { B2b_order_hotel hotelorder = new B2b_order_hotelData().GetHotelOrderByOrderId(orderid); if (hotelorder != null) { string fangtai = hotelorder.Fangtai; DateTime start_data = hotelorder.Start_date; DateTime end_data = hotelorder.End_date; int bookdaynum = hotelorder.Bookdaynum; decimal everyroomprice = 0; string[] ftstr = fangtai.Split(','); for (int i = 0; i < ftstr.Length; i++) { if (ftstr[i].ConvertTo <decimal>(0) > 0) { everyroomprice += ftstr[i].ConvertTo <decimal>(0); } } price = everyroomprice.ToString(); p_totalprice = (modelb2border.U_num * everyroomprice - modelb2border.Integral1 - modelb2border.Imprest1); } } #endregion #region 当地游;跟团游;旅游大巴,获取支付金额 else if (servertype == 2 || servertype == 8) //当地游;跟团游;旅游大巴 { string outdate = modelb2border.U_traveldate.ToString("yyyy-MM-dd"); //读取団期价格,根据实际选择的団期报价 B2b_com_LineGroupDate linemode = new B2b_com_LineGroupDateData().GetLineDayGroupDate(DateTime.Parse(outdate), modelcompro.Id); if (linemode != null)//当地游;跟团游 { price = linemode.Menprice.ToString(); if (servertype == 2 || servertype == 8) { decimal childreduce = modelcompro.Childreduce; decimal childprice = decimal.Parse(price) - childreduce; if (childprice < 0) { childprice = 0; } pricedetail = modelb2border.U_num + "成人," + modelb2border.Child_u_num + "儿童(成人" + price + "元/人,儿童" + childprice + "元/人)"; p_totalprice = (modelb2border.U_num * (linemode.Menprice) + (modelb2border.Child_u_num) * childprice - modelb2border.Integral1 - modelb2border.Imprest1); } else //旅游大巴:没有儿童减免 { pricedetail = modelb2border.U_num + "人(" + price + "元/人)"; p_totalprice = (modelb2border.U_num * (linemode.Menprice) - modelb2border.Integral1 - modelb2border.Imprest1); } } } else if (servertype == 10) { pricedetail = modelb2border.U_num + "人(" + modelb2border.Pay_price.ToString("0.00") + "元/人)"; p_totalprice = (modelb2border.U_num * (modelb2border.Pay_price) - modelb2border.Integral1 - modelb2border.Imprest1); } #endregion #region 票务、实物,获取支付金额 else //票务 { p_totalprice = (modelb2border.U_num * modelb2border.Pay_price - modelb2border.Integral1 - modelb2border.Imprest1); price = modelb2border.Pay_price.ToString(); //modelb2border.Pay_price.ToString(); if (price == "0.00" || price == "0") { price = ""; } else { price = CommonFunc.OperTwoDecimal(price); } } #endregion //} #region 获得服务电话 var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } if (modelcompro != null) { //查询项目电话,如果有项目电话调取项目电话 var projectdata = new B2b_com_projectData(); var projectmodel = projectdata.GetProject(modelcompro.Projectid, comid); if (projectmodel != null) { if (projectmodel.Mobile != "") { phone = projectmodel.Mobile; } } } #endregion } #endregion #region 充值订单 if (modelb2border.Order_type == 2) { if (modelb2border.serverid != "") { proname = "购买服务与押金"; } else if (modelb2border.payorder == 1) { proname = "快速支付"; } else { proname = "预付款充值"; } //ordertype=2 充值订单会传递过来值 if (comid == 0) { comid = Request["comid"].ConvertTo <int>(0); } p_totalprice = (modelb2border.U_num * modelb2border.Pay_price); //获得商户电话 var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } } #endregion p_totalpricedesc = CommonFunc.OperTwoDecimal(p_totalprice.ToString()); #region 统一获得商户名称 和 微信支付链接 if (comid != 0) { wxpaylinkurl = WeiXinJsonData.GetFollowOpenLinkUrlAboutPay(comid, "http://shop" + comid + ".etown.cn/wxpay/payment_" + orderid + "_1.aspx"); comName = B2bCompanyData.GetCompany(comid).Com_name; } #endregion } }
public string nativePayImgurl = "/Images/defaultThumb.png"; //微信原生支付二维码 protected void Page_Load(object sender, EventArgs e) { //返回订单号 orderid = Request["orderid"].ConvertTo <int>(0); #region 正常订单支付操作 if (orderid != 0) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); if (bo) { Response.Redirect("/h5/pay.aspx?orderid=" + orderid); } //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); cart = modelb2border.Shopcartid;//不等于0则为购物车订单 //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString(), modelb2border.Speciid); if (modelcompro != null) { Server_type = modelcompro.Server_type; comid = modelcompro.Com_id; //绿野 不显示头部 if (modelcompro.Com_id == 2553) { viewtop = 0; } string urljson = WeiXinJsonData.getNativePayQrcode(orderid, comid, "oid"); try { XmlDocument retdoc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + urljson + "}"); XmlElement retroot = retdoc.DocumentElement; string type = retroot.SelectSingleNode("type").InnerText; string msg = retroot.SelectSingleNode("msg").InnerText; nativePayImgurl = "/ui/pmui/eticket/showtcode.aspx?pno=" + msg; } catch { } } else { //产品错误 } //如果订单“未付款”现实支付及订单信息 if ((int)modelb2border.Order_state == (int)OrderStatus.WaitPay) { u_name = modelb2border.U_name.Substring(0, 1) + "**"; u_mobile = modelb2border.U_phone.Substring(0, 4) + "****" + modelb2border.U_phone.Substring(modelb2border.U_phone.Length - 3, 3); ; travel_date = modelb2border.U_traveldate.ToString(); buy_num = modelb2border.U_num; p_totalprice = CommonFunc.OperTwoDecimal((modelb2border.U_num * modelb2border.Pay_price + modelb2border.Express - modelb2border.Integral1 - modelb2border.Imprest1).ToString()); if (modelb2border.Child_u_num > 0)//如果是旅游包含儿童的 { p_totalprice = (Decimal.Parse(p_totalprice) + modelb2border.Child_u_num * (modelb2border.Pay_price - modelcompro.Childreduce)).ToString(); } ordertype = modelb2border.Order_type; if (ordertype == 2) { proname = "预付款充值"; u_youxiaoqi = ""; } else { proname = modelcompro.Pro_name; if (modelcompro.Server_type == 10) {//服务类型是:旅游大巴 u_youxiaoqi = modelb2border.U_traveldate.ToString("yyyy-MM-dd"); } else { u_youxiaoqi = modelcompro.Pro_start.ToString() + " - " + modelcompro.Pro_end.ToString(); } } //如果是购物车订单再次处理 if (cart > 0) { proname = dataorder.GetCartOrderProById(orderid); p_totalprice = dataorder.GetCartOrderMoneyById(orderid).ToString("0.00"); buy_num = 1; } tenpay_url = string.Format("/tenpay/payRequest.aspx?order_no={0}&product_name={1}&order_price={2}&remarkexplain={3}", orderid, Server.UrlEncode(proname), Server.UrlEncode(p_totalprice), Server.UrlEncode(proname)); if (Server_type == 9) { //订房查询入住 及离店日期 var hoteldata = new B2b_order_hotelData(); var hotelmodel = hoteldata.GetHotelOrderByOrderId(orderid); if (hotelmodel != null) { stardate = hotelmodel.Start_date.ToString("yyyy-MM-dd"); enddate = hotelmodel.End_date.ToString("yyyy-MM-dd"); } } } } #endregion }
// 订单退票 public string Getorderrefund(Lvmama_reqlog mlog, Agent_company agentinfo) { var response = new backRefund(); response.uid = agentinfo.Lvmama_uid; try { int organization = agentinfo.Id; #region 把分销商发送过来的请求记入数据库日志表2 agent_requestlog Agent_requestlog reqlog = new Agent_requestlog() { Id = 0, Organization = organization, Encode_requeststr = "", Decode_requeststr = _requestParam, Request_time = DateTime.Now, Encode_returnstr = "", Decode_returnstr = "", Return_time = DateTime.Parse("1970-01-01 00:00:00"), Errmsg = "", Request_type = "discard_code", Req_seq = "", Ordernum = "", Is_dealsuc = 0, Is_second_receivereq = 0, Request_ip = CommonFunc.GetRealIP() }; int reqlogid = new Agent_requestlogData().Editagent_reqlog(reqlog); reqlog.Id = reqlogid; #endregion var data = JsonConvert.DeserializeObject <discard_codemodel>(_requestParam); if (data.uid == "") { response.uid = agentinfo.Lvmama_uid; response.status = "2"; response.msg = "数据解析失败"; return(EditLvmamalog_Order(response, mlog, reqlog)); } else { string uid = data.uid; string password = data.password; string sign = data.sign; string timestamp = data.timestamp; string extId = data.extId; Lvmama_reqlog LvmamaOrderCrateSucLog = new lvmama_reqlogData().GetLvmama_OrderpayreqlogBySelforderid(int.Parse(extId), "0"); if (LvmamaOrderCrateSucLog == null) { response.status = "4"; response.msg = "未查找到相对应订单"; return(EditLvmamalog_Order(response, mlog, null)); } string lvmamaorderid = LvmamaOrderCrateSucLog.mtorderid; data.lvmmamaorderid = lvmamaorderid; B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(int.Parse(extId)); if (modelb2border == null) { response.status = "4"; response.msg = "未查找到相对应订单"; return(EditLvmamalog_Order(response, mlog, null)); } int num = modelb2border.U_num; data.num = num; //日志表2 判断是否是二次发送相同的请求 int is_secondreq = new Agent_requestlogData().Is_secondreq(organization.ToString(), lvmamaorderid, reqlog.Request_type); #region 把发送的请求类型,请求流水号,订单号,是否是二次发送相同的请求录入数据库 日志表2 reqlog.Req_seq = lvmamaorderid; reqlog.Ordernum = extId; reqlog.Is_second_receivereq = is_secondreq; new Agent_requestlogData().Editagent_reqlog(reqlog); #endregion #region 编辑日志表1 mlog.mtorderid = lvmamaorderid; mlog.ordernum = extId; mlog.issecond_req = is_secondreq; new lvmama_reqlogData().EditReqlog(mlog); #endregion //因为是作废,重复的也可以操作,但返回不一定正确 if (is_secondreq == 1) { return(Cancel_order(reqlog, data, organization.ToString(), mlog)); } else { return(Cancel_order(reqlog, data, organization.ToString(), mlog)); } } } catch (Exception ex) { response.status = "2"; response.msg = "异常错误"; return(EditLvmamalog_Order(response, mlog, null)); } }
protected void Page_Load(object sender, EventArgs e) { //RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); if (Request.QueryString["code"] != null) { orderid = Request["orderid"].ConvertTo <int>(0); Returnmd5 = EncryptionHelper.ToMD5(orderid.ToString() + "lixh1210", "UTF-8"); if (orderid != 0) { //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); orderstatus = EnumUtils.GetName((OrderStatus)modelb2border.Order_state); paystatus = modelb2border.Pay_state;//1未支付;2已支付 order_type = modelb2border.Order_type; //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString(), modelb2border.Speciid, modelb2border.channelcoachid); if (modelcompro != null) { servertype = modelcompro.Server_type; } cart = modelb2border.Shopcartid;//购物车 #region 正常订单 if (modelb2border.Order_type == 1) { if (modelcompro != null) { #region 务类型订单金额 p_totalprice1 = new B2bOrderData().GetOrderTotalPrice(modelcompro, modelb2border, out price, out pricedetail); if (p_totalprice1 == 0 || price == "0") { Response.Write("<script>alert('订单金额不可为0');</script>"); Response.End(); return; } #endregion proname = modelcompro.Pro_name; u_name = modelb2border.U_name.Substring(0, 1) + "**"; u_mobile = modelb2border.U_phone.Substring(0, 4) + "****" + modelb2border.U_phone.Substring(modelb2border.U_phone.Length - 3, 3); travel_date = modelb2border.U_traveldate.ToString(); buy_num = modelb2border.U_num; u_youxiaoqi = modelcompro.Pro_start.ToString() + " - " + modelcompro.Pro_end.ToString(); p_totalprice = CommonFunc.OperTwoDecimal(p_totalprice1.ToString()); wxp_totalprice = (p_totalprice1 * 100).ToString("F0"); price = modelb2border.Pay_price.ToString(); price = CommonFunc.OperTwoDecimal(price); comid = modelcompro.Com_id; var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } } } #endregion #region 充值订单 if (modelb2border.Order_type == 2) { //ordertype=2 充值订单会传递过来值 comid = modelb2border.Comid; p_totalprice1 = modelb2border.U_num * modelb2border.Pay_price; p_totalprice = CommonFunc.OperTwoDecimal(p_totalprice1.ToString()); wxp_totalprice = (p_totalprice1 * 100).ToString("F0"); //获得商户电话 var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } } #endregion #region 统一获得商户名称 和 微信支付链接 if (comid != 0) { comName = B2bCompanyData.GetCompany(comid).Com_name; } #endregion #region 写入支付数据库,先判定是否有此订单支付 B2bPayData datapay = new B2bPayData(); B2b_pay modelb2pay = datapay.GetPayByoId(orderid); if (modelb2pay != null) { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status == "TRADE_SUCCESS") { Response.Write("订单已经支付过!"); Response.End(); return; } } #endregion #region 微信支付 //根据产品判断商家是否含有自己的微信支付:a.含有的话支付到商家;b.没有的话支付到平台的微信公众号账户中 B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(comid); if (model != null) { //商家微信支付的所有参数都存在 if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { appId = model.Wx_appid; appsecret = model.Wx_appkey; appkey = model.Wx_paysignkey; mchid = model.Wx_partnerid; } else { model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(106); if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { appId = model.Wx_appid; appsecret = model.Wx_appkey; appkey = model.Wx_paysignkey; mchid = model.Wx_partnerid; } } } else { model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(106); if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { appId = model.Wx_appid; appsecret = model.Wx_appkey; appkey = model.Wx_paysignkey; mchid = model.Wx_partnerid; } } #region 获取用户openid code = Request.QueryString["code"]; string url = string.Format( "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appId, appsecret, code); string returnStr = HttpUtil.Send("", url); var obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); if (obj.openid == null) { //WriteFile(Server.MapPath("") + "\\Log.txt", "code:" + code + "\r\n------------------------------\r\n returnStr:" + returnStr); url = string.Format( "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", appId, obj.refresh_token); returnStr = HttpUtil.Send("", url); obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); } //WriteFile(Server.MapPath("") + "\\Log.txt", "access_token:" + obj.access_token + "\r\n" + "--openid:" + obj.openid); //url = string.Format( // "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", // obj.access_token, obj.openid); //returnStr = HttpUtil.Send("", url); //WriteFile(Server.MapPath("") + "\\Log.txt", returnStr); #endregion //创建支付应答对象 var packageReqHandler = new RequestHandler(Context); //初始化 packageReqHandler.init(); timeStamp = TenpayUtil.getTimestamp(); nonceStr = TenpayUtil.getNoncestr(); //设置package订单参数 string productname = ""; if (modelb2border.Order_type == 1) { productname = modelcompro.Pro_name.Replace("\"", "").Replace("“", "").Replace("'", "").Replace("‘", "").Replace(";", "").Replace(";", ""); if (productname.Length > 50) { productname = productname.Substring(0, 50); } } if (modelb2border.Order_type == 2) { productname = "预付款充值"; } packageReqHandler.setParameter("body", productname); //商品信息 127字符 packageReqHandler.setParameter("appid", appId); packageReqHandler.setParameter("mch_id", mchid); packageReqHandler.setParameter("nonce_str", nonceStr.ToLower()); packageReqHandler.setParameter("notify_url", "http://shop" + comid + ".etown.cn/wxpay/backpaynotice.aspx"); packageReqHandler.setParameter("openid", obj.openid); packageReqHandler.setParameter("out_trade_no", orderid.ToString()); //商家订单号 packageReqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress); //用户的公网ip,不是商户服务器IP packageReqHandler.setParameter("total_fee", wxp_totalprice); //商品金额,以分为单位(money * 100).ToString() packageReqHandler.setParameter("trade_type", "JSAPI"); //获取package包 sign = packageReqHandler.CreateMd5Sign("key", appkey); //WriteFile(Server.MapPath("") + "\\Log.txt", sign); packageReqHandler.setParameter("sign", sign); string data = packageReqHandler.parseXML(); //WriteFile(Server.MapPath("") + "\\Log.txt", "package包签名:" + sign + "-----\r\n向统一支付接口发送的xml:" + data); string prepayXml = HttpUtil.Send(data, "https://api.mch.weixin.qq.com/pay/unifiedorder"); //WriteFile(Server.MapPath("") + "\\Log.txt", "统一支付接口返回xml:" + prepayXml); //获取预支付ID var xdoc = new XmlDocument(); xdoc.LoadXml(prepayXml); XmlNode xn = xdoc.SelectSingleNode("xml"); XmlNodeList xnl = xn.ChildNodes; if (xnl.Count > 7) { prepayId = xnl[7].InnerText; package = string.Format("prepay_id={0}", prepayId); //WriteFile(Server.MapPath("") + "\\Log.txt", "预支付id:" + package); } //设置支付参数 var paySignReqHandler = new RequestHandler(Context); paySignReqHandler.setParameter("appId", appId); paySignReqHandler.setParameter("timeStamp", timeStamp); paySignReqHandler.setParameter("nonceStr", nonceStr); paySignReqHandler.setParameter("package", package); paySignReqHandler.setParameter("signType", "MD5"); paySign = paySignReqHandler.CreateMd5Sign("key", appkey); //WriteFile(Server.MapPath("") + "\\Log.txt", "支付签名" + paySign); #endregion #region 订单提交支付信息 if (modelb2pay == null) { B2b_pay eticket = new B2b_pay() { Id = 0, Oid = orderid, Pay_com = "wx", Pay_name = modelb2border.U_name, Pay_phone = modelb2border.U_phone, Total_fee = p_totalprice1, Trade_no = "", Trade_status = "trade_pendpay", Uip = "", comid = model.Com_id }; int payid = datapay.InsertOrUpdate(eticket); } else { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status != "TRADE_SUCCESS") { //防止金额有所改动 modelb2pay.comid = model.Com_id; modelb2pay.Pay_com = "wx"; modelb2pay.Total_fee = p_totalprice1; datapay.InsertOrUpdate(modelb2pay); } } #endregion } } }
public int viewtop = 1; //头部及左侧相关显示控制 protected void Page_Load(object sender, EventArgs e) { Request.ValidateInput(); if (Session["AccountId"] != null) { AccountId = Session["AccountId"].ToString(); AccountName = Session["AccountName"].ToString(); AccountCard = Session["AccountCard"].ToString(); Today = DateTime.Now.ToString("yyyy-MM-dd"); } comid = Request["comid"].ConvertTo <int>(0); proid = Request["proid"].ConvertTo <string>(""); orderid = Request["orderid"].ConvertTo <int>(0); ordertype = Request["ordertype"].ConvertTo <string>("1"); RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); if (orderid != 0) { B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); if (modelb2border != null) { proid = modelb2border.Pro_id.ToString(); } } if (proid != "") { B2b_com_pro pro = new B2bComProData().GetProById(proid); if (pro != null) { //如果是 云顶旅游大巴的 不显示头部 if (pro.Projectid == 2179) { viewtop = 0; Scenic_name = pro.Pro_name; Com_name = pro.Pro_name; } //绿野 不显示头部 if (pro.Com_id == 2553) { viewtop = 0; } } } //根据域名读取商户ID,如果没有绑定域名直接跳转后台 B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl); if (companyinfo != null) { comid = companyinfo.Com_id; } else { //判定是否为自助域名规则安 shop1.etown.cn if (Domain_def.Domain_yanzheng(RequestUrl)) { comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl)); } } //判断商户ID(域名未绑定) if (comid != 0) { B2b_company com = B2bCompanyData.GetAllComMsg(comid); B2b_company_saleset comsetinfo = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (com != null) { if (Com_name == "") { Com_name = com.Com_name; } if (Scenic_name == "") { Scenic_name = com.Scenic_name; } Scenic_intro = com.B2bcompanyinfo.Scenic_intro; if (comsetinfo != null) { Logourl = comsetinfo.Logo; if (Logourl != "") { FileUploadModel url = new FileUploadData().GetFileById(int.Parse(Logourl)); if (url != null) { Logourl = "<img src=\"" + fileUrl + url.Relativepath + "\" alt=\"" + Scenic_name + "\" height=\"24\" />"; } } Service_Phone = comsetinfo.Service_Phone; if (Service_Phone != "") { Service_Phone = "客服电话:" + Service_Phone; } Copyright = comsetinfo.Copyright; } } } else { //如果没有商户ID(域名未绑定) 则跳转管理登陆页面。 // Response.Redirect("/Manage/index1.html"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["AccountId"] != null) { AccountId = Session["AccountId"].ToString(); AccountName = Session["AccountName"].ToString(); AccountCard = Session["AccountCard"].ToString(); Today = DateTime.Now.ToString("yyyy-MM-dd"); } comid = Request["comid"].ConvertTo <int>(0); proid = Request["proid"].ConvertTo <string>(""); orderid = Request["orderid"].ConvertTo <int>(0); ordertype = Request["ordertype"].ConvertTo <string>("1"); RequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); if (Request.QueryString["out_trade_no"] != null) { orderid = Request.QueryString["out_trade_no"].ConvertTo <int>(0); //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); proid = modelb2border.Pro_id.ToString(); } //读产品信息 if (proid != "") { //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(proid); if (modelcompro != null) { proname = modelcompro.Pro_name; comid = modelcompro.Com_id; } } //针对支付同步返回页,暂时无法绑定域名 if (Request.QueryString["out_trade_no"] == null) { //根据域名读取商户ID,如果没有绑定域名直接跳转后台 B2b_company_info companyinfo = B2bCompanyData.GetComId(RequestUrl); if (companyinfo != null) { comid = companyinfo.Com_id; } else { //判定是否为自助域名规则安 shop1.etown.cn if (Domain_def.Domain_yanzheng(RequestUrl)) { comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl)); } else { if (RequestUrl == "shop.etown.cn" || RequestUrl == "test.etown.cn" || RequestUrl == "admin.etown.cn" || RequestUrl == "admin.vctrip.com") { Response.Redirect("/Manage/index1.html"); } else { Response.Redirect("/admin/"); } } } } //判断商户ID(域名未绑定) if (comid != 0) { B2b_company com = B2bCompanyData.GetAllComMsg(comid); B2b_company_saleset comsetinfo = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (com != null) { Com_name = com.Com_name; Scenic_name = com.Scenic_name; Scenic_intro = com.B2bcompanyinfo.Scenic_intro; if (comsetinfo != null) { if (comsetinfo.Logo != "") { FileUploadModel comlogo = new FileUploadData().GetFileById(int.Parse(comsetinfo.Logo)); if (comlogo != null) { Logourl = "<img src=\"" + fileUrl + comlogo.Relativepath + "\" alt=\"" + Scenic_name + "\" height=\"80\" id=\"imglogo\" />"; } } else { Logourl = ""; } Service_Phone = comsetinfo.Service_Phone; if (Service_Phone != "") { Service_Phone = "客服电话:" + Service_Phone; } Copyright = comsetinfo.Copyright; } } } else { //如果没有商户ID(域名未绑定) 则跳转管理登陆页面。 Response.Redirect("/Manage/index1.html"); } }
protected void Page_Load(object sender, EventArgs e) { int orderid = Request["out_trade_no"].ConvertTo <int>(0); //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); if (modelb2border != null) { //支付宝网关地址 string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?"; ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token//////////////////////////////////////////// //返回格式 string format = "xml"; //必填,不需要修改 //返回格式 string v = "2.0"; //必填,不需要修改 //请求号 string req_id = DateTime.Now.ToString("yyyyMMddHHmmss"); //必填,须保证每次请求都是唯一 //req_data详细信息 //服务器异步通知页面路径 //string notify_url = ""; string notify_url = "http://" + RequestUrl + "/h5/pay_by/notify_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 //string call_back_url = "http://127.0.0.1:64704/WS_WAP_PAYWAP-CSHARP-UTF-8/call_back_url.aspx"; string call_back_url = "http://" + RequestUrl + "/h5/pay_by/call_back_url.aspx"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 //string merchant_url = "http://v.etown.cn"; string merchant_url = "http://" + RequestUrl + "/h5/Orderlist.aspx"; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 string seller_email = "*****@*****.**"; //必填 //商户订单号 string out_trade_no = modelb2border.Id.ToString(); //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = ""; if (modelb2border.Order_type == 1) { subject = modelcompro.Pro_name; } if (modelb2border.Order_type == 2) { if (modelb2border.serverid == "") { subject = "预付款充值"; } else { subject = "购买服务于押金"; } } //必填 //付款金额 string total_fee = (modelb2border.Pay_price * modelb2border.U_num + modelb2border.Express - modelb2border.Integral1 - modelb2border.Imprest1).ToString(); //必填 if (modelb2border.Child_u_num > 0)//如果是旅游包含儿童的 { total_fee = (Decimal.Parse(total_fee) + modelb2border.Child_u_num * (modelb2border.Pay_price - modelcompro.Childreduce)).ToString(); } //如果是购物车订单重新写金额 if (modelb2border.Shopcartid != 0) { total_fee = dataorder.GetCartOrderMoneyById(orderid).ToString("0.00");; } //请求业务参数详细 string req_dataToken = "<direct_trade_create_req><notify_url>" + notify_url + "</notify_url><call_back_url>" + call_back_url + "</call_back_url><seller_account_name>" + seller_email + "</seller_account_name><out_trade_no>" + out_trade_no + "</out_trade_no><subject>" + subject + "</subject><total_fee>" + total_fee + "</total_fee><merchant_url>" + merchant_url + "</merchant_url></direct_trade_create_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTempToken = new Dictionary <string, string>(); sParaTempToken.Add("partner", Config.Partner); sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower()); sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper()); sParaTempToken.Add("service", "alipay.wap.trade.create.direct"); sParaTempToken.Add("format", format); sParaTempToken.Add("v", v); sParaTempToken.Add("req_id", req_id); sParaTempToken.Add("req_data", req_dataToken); //建立请求 string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken); //URLDECODE返回的信息 Encoding code = Encoding.GetEncoding(Config.Input_charset); sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code); //解析远程模拟提交后返回的信息 Dictionary <string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken); //获取token string request_token = dicHtmlTextToken["request_token"]; ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute//////////////////////////////////////////// //业务详细 string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>"; //必填 //把请求参数打包成数组 Dictionary <string, string> sParaTemp = new Dictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("sec_id", Config.Sign_type.ToUpper()); sParaTemp.Add("service", "alipay.wap.auth.authAndExecute"); sParaTemp.Add("format", format); sParaTemp.Add("v", v); sParaTemp.Add("req_data", req_data); //写入支付数据库,先判定是否有此订单支付 //根据订单id得到订单信息 B2bPayData datapay = new B2bPayData(); B2b_pay modelb2pay = datapay.GetPayByoId(orderid); if (modelb2pay == null) { B2b_pay eticket = new B2b_pay() { Id = 0, Oid = orderid, Pay_com = "malipay", Pay_name = modelb2border.U_name, Pay_phone = modelb2border.U_phone, Total_fee = decimal.Parse(total_fee), Trade_no = "", Trade_status = "trade_pendpay", Uip = "", comid = 106 }; int payid = datapay.InsertOrUpdate(eticket); } else { //对已完成支付的,再次提交支付,跳转到订单也或显示此订单已支付 if (modelb2pay.Trade_status != "TRADE_SUCCESS") { //防止金额有所改动 modelb2pay.comid = 106; modelb2pay.Pay_com = "malipay"; modelb2pay.Total_fee = decimal.Parse(total_fee); datapay.InsertOrUpdate(modelb2pay); } } //建立请求 string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); Response.Write(sHtmlText); } }
protected void Page_Load(object sender, EventArgs e) { int order_no = Int32.Parse(Request.QueryString["out_trade_no"]); //获取订单号 //返回订单号 int orderid = order_no; if (orderid != 0) { //根据订单id得到订单信息 B2bOrderData dataorder = new B2bOrderData(); B2b_order modelb2border = dataorder.GetOrderById(orderid); //根据产品id得到产品信息 B2bComProData datapro = new B2bComProData(); B2b_com_pro modelcompro = datapro.GetProById(modelb2border.Pro_id.ToString()); //生成电子码 int u_num = modelb2border.U_num; int comid = modelcompro.Com_id; RandomCodeData datarandomcode = new RandomCodeData(); RandomCode modelrandomcode = datarandomcode.GetRandomCode();//得到未用随机码对象 //设置取出的电子码状态为1(已使用) modelrandomcode.State = 1; int randomcodeid = datarandomcode.InsertOrUpdate(modelrandomcode); string eticketcode = "9" + comid.ToString() + modelrandomcode.Code.ToString(); string sendstr = ""; //录入电子票列表 B2bEticketData eticketdata = new B2bEticketData(); B2b_eticket eticket = new B2b_eticket() { Id = 0, Com_id = comid, Pro_id = modelcompro.Id, Agent_id = 0,//直销 Pno = eticketcode, E_type = (int)EticketCodeType.ShuZiMa, Pnum = modelb2border.U_num, Use_pnum = modelb2border.U_num, E_proname = modelcompro.Pro_name, E_face_price = modelcompro.Face_price, E_sale_price = modelcompro.Advise_price, E_cost_price = modelcompro.Agentsettle_price, V_state = (int)EticketCodeStatus.NotValidate, Send_state = (int)EticketCodeSendStatus.NotSend, Subdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) }; int eticketid = eticketdata.InsertOrUpdate(eticket); if (eticketid > 0) { //生成电子码短信,稍后可单独写类或写到数据库中 diveticketcode.InnerText = "电子码生成成功:" + eticketcode; sendstr = "感谢您订购" + modelcompro.Pro_name + modelb2border.U_num + "张" + ",电子码:" + eticketcode + " 有效期至:" + modelcompro.Pro_end.ToString("yyyy-MM-dd"); } else { diveticketcode.InnerText = "电子码生成ERROR"; } } }
private string signkey = "146491#%##^11"; //签名秘钥,由慧择指定 //承保 public string Hzins_OrderApply(B2b_com_pro modelcompro, B2b_order modelb2border) { string transNo = modelb2border.Id.ToString(); //(以后需要修改为渠道商订单号)交易流水号,每次请求不能相同 string caseCode = modelcompro.Service_proid; //(以后需要更改为正式产品)方案代码,每一款保险公司产品的方案代码都不相同,由慧择分配 //签名,预签名数据:密钥+渠道商身份标识+交易流水号+方案代码 string sign = EncryptionHelper.ToMD5(signkey + partnerId + transNo + caseCode, "UTF-8"); sign = sign.ToLower(); //根据订单号 得到慧择网 承保信息 Api_hzins_OrderApplyReq_Application mapplication = new Api_hzins_OrderApplyReq_ApplicationData().GetOrderApplyReq_Application(modelb2border.Id); if (mapplication == null) { TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail1"); return("fail"); } Api_hzins_OrderApplyReq_applicantInfo mapplicationinfo = new Api_hzins_OrderApplyReq_applicantInfoData().GetOrderApplyReq_applicantInfo(modelb2border.Id); if (mapplicationinfo == null) { TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail2"); return("fail"); } List <Api_hzins_OrderApplyReq_insurantInfo> listinsurantInfo = new Api_hzins_OrderApplyReq_insurantInfoData().GetOrderApplyReq_insurantInfo(modelb2border.Id); if (listinsurantInfo == null) { TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail3"); return("fail"); } else { if (listinsurantInfo.Count == 0) { TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "fail4"); return("fail"); } } string s = "{" + "\"partnerId\":" + partnerId + "," + "\"transNo\":\"" + transNo + "\"," + "\"caseCode\":\"" + caseCode + "\"," + "\"sign\":\"" + sign + "\"," + "\"applicationData\":{" + "\"applicationDate\":\"" + mapplication.applicationDate + "\"," + "\"startDate\":\"" + mapplication.startDate + "\"," + "\"endDate\":\"" + mapplication.endDate + "\"" + "}," + "\"applicantInfo\":{" + "\"cName\":\"" + mapplicationinfo.cName + "\"," + "\"eName\":\"" + mapplicationinfo.eName + "\"," + "\"cardType\":\"" + mapplicationinfo.cardType + "\"," + "\"cardCode\":\"" + mapplicationinfo.cardCode + "\"," + "\"sex\":" + mapplicationinfo.sex + "," + "\"birthday\":\"" + mapplicationinfo.birthday + "\"," + "\"mobile\":\"" + mapplicationinfo.mobile + "\"," + "\"email\":\"" + mapplicationinfo.email + "\"," + "\"jobInfo\":null" + "}," + "\"insurantInfos\":["; string insurantInfosstr = ""; foreach (Api_hzins_OrderApplyReq_insurantInfo minsinfo in listinsurantInfo) { if (minsinfo != null) { insurantInfosstr += "{" + "\"insurantId\":" + minsinfo.insurantId + "," + "\"cName\":\"" + minsinfo.cName + "\"," + "\"eName\":\"" + minsinfo.eName + "\"," + "\"sex\":" + minsinfo.sex + "," + "\"cardType\":" + minsinfo.cardType + "," + "\"cardCode\":\"" + minsinfo.cardCode + "\"," + "\"birthday\":\"" + minsinfo.birthday + "\"," + "\"relationId\":" + minsinfo.relationId + "," + "\"count\":" + minsinfo.count + "," + "\"singlePrice\":" + minsinfo.singlePrice + "," + "\"fltNo\":null," + "\"fltDate\":null," + "\"city\":\"null\"," + "\"tripPurposeId\":" + minsinfo.tripPurposeId + "," + "\"destination\":null," + "\"visaCity\":null," + "\"jobInfo\":null," + "\"mobile\":null" + "},"; } } insurantInfosstr = insurantInfosstr.Substring(0, insurantInfosstr.Length - 1); s += insurantInfosstr + "]," + "\"extendInfo\":{" + "\"userId\":null," + "\"email\":null," + "\"userName\":null," + "\"phone\":null" + "}" + "}"; string str = new GetUrlData().HttpPostJson("http://channel.hzins.com/api/orderApply", s.Trim()); //录入和慧择网交互日志 ApiLog mapilog = new ApiLog { Id = 0, request_type = "orderApply", Serviceid = 2, Str = s.Trim(), Subdate = DateTime.Now, ReturnStr = str, ReturnSubdate = DateTime.Now, Errmsg = "", }; int ins = new ApiLogData().EditLog(mapilog); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\BaoxianLog.txt", "发送信息:" + s.Trim() + "<br>" + "返回信息:" + str); return(str); }