string TAB = ScTool.ORDER; // 订单表名称 ///// <summary> ///// 判断ext中是否含有开发者帐号信息 ///// </summary> ///// <returns></returns> //private bool ContainsAuthorInfo() //{ // String orderExt = Request["ext"]; // bool ContainsAuthor = (orderExt != null && orderExt.Contains("author(" + UserAccount + ")")); // if (!ContainsAuthor) Response.Write("创建订单时需包含开发者信息" + "ext=author(" + UserAccount + ")author"); // return ContainsAuthor; //} /// <summary> /// 载入后执行参数对应的sql请求 /// </summary> public override void Load(object sender, EventArgs e) { if (UserType == 0 && (param.Equals("") || (param.Contains("ShowOrder") && !param.Contains("OrderSuccess")))) { Response.Redirect("../PayFor/UserLogin.aspx"); } Dictionary <string, string> staticPramsDic = null; // 静态参数字典 // 若存在静态参数,则使用静态参数 if (!StaticParam.Equals("")) { staticPramsDic = ScTool.ToParamsDic(StaticParam); StaticParam = ""; } //PayType = ScTool.PayTypeAli; string type = Request["PayType"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("PayType")) { type = staticPramsDic["PayType"]; } if (type != null && !type.Equals("")) { PayType = type; } if (PayType.Equals("")) { if (staticPramsDic == null) { NoteInfo(); // 从Pay.aspx Transfer过来,不显示接口说明信息 } else { Response.Write("扫码客户端类型未知,创建订单失败!<br/>请使用支付宝或微信扫码支付"); } // 显示订单信息 string showOrder = Request["ShowOrder"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("ShowOrder")) { showOrder = staticPramsDic["ShowOrder"]; } if (showOrder != null && !showOrder.Equals("")) { if (showOrder.Equals(ScTool.PayTypeAli) || showOrder.Equals(ScTool.PayTypeWechat)) { DB = new DataBase(ScTool.DBName(showOrder), ScTool.UserName, ScTool.Password); // 修改指定的订单为支付成功 string orderId = Request["OrderSuccess"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("OrderSuccess")) { orderId = staticPramsDic["OrderSuccess"]; } if (orderId != null && !orderId.Equals("")) { string result = "fail"; if (UserType == 2) { result = OrderSuccess(DB, orderId); } //else if (UserType == 1) result = OrderSuccess(DB, orderId, UserAccount); else if (UserType == 1) { result = "false no allowed!"; } Response.Write(ScTool.Pre("OrderSuccess->" + orderId + ": " + result)); } // 显示指定类型的订单信息 if (UserType == 2) { ScTool.showTable(this.Controls, DB, ScTool.ORDER); } else if (UserType == 1) { ScTool.showTable(this.Controls, DB, ScTool.ORDER, "where ext like '%" + "author(" + UserAccount + ")" + "%' "); } } } } else { //if (!ContainsAuthorInfo()) return; // 连接指定的数据库,若不存在则创建 DB = new DataBase(ScTool.DBName(PayType), ScTool.UserName, ScTool.Password); //DB.DeletTable(ScTool.ORDER); confirmOrderTab(); //统计金额总数,指定是否清空 string ParamClear = Request["MoneyAllClear"]; if (ParamClear != null) { bool clear = ParamClear.Trim().ToLower().Equals("true"); if (clear) { string result = MoneyAllClear(DB, UserAccount); Response.Write(result); } else { String SuccessValue = ParamClear.Equals("TrueFinish") ? ParamClear : ""; string MoneyCount = MoneyAll(DB, UserAccount, SuccessValue); Response.Write(MoneyCount); } return; } // 解析创建订单参数信息 string machinCode = Request["machinCode"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("machinCode")) { machinCode = staticPramsDic["machinCode"]; } if (machinCode == null) { machinCode = ""; } string soft = Request["soft"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("soft")) { soft = staticPramsDic["soft"]; } if (soft == null) { soft = ""; } string product = Request["product"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("product")) { product = staticPramsDic["product"]; } if (product == null) { product = ""; } string money = Request["money"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("money")) { money = staticPramsDic["money"]; } string ext = Request["ext"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("ext")) { ext = staticPramsDic["ext"]; } if (ext == null) { ext = ""; } string preOrderId = Request["preOrderId"]; if (staticPramsDic != null && staticPramsDic.ContainsKey("preOrderId")) { preOrderId = staticPramsDic["preOrderId"]; } if (preOrderId == null) { preOrderId = ""; } #region 一预下单号不再多次创建订单 String keyOrderId = "O_Id"; String keyLink = "O_Link"; // 若订单号不存在,或不相同则重新记录; 并清空链接地址信息 if (Session[keyOrderId] == null || !(Session[keyOrderId] as string).Equals(preOrderId)) { Session[keyOrderId] = preOrderId; Session[keyLink] = null; } if (Session[keyLink] != null && !(Session[keyLink] as string).Equals("")) { string link = (Session[keyLink] as string); Response.Redirect(link); // 直接重定向到二维码对应链接 return; } #endregion // 支付金额不可为空,根据给定的参数创建订单 if (money != null && !money.Equals("")) { string id = createOrder(machinCode, soft, product, money, ext, preOrderId); if (!id.Equals("")) { string link = Cashier.GetQrLink(DB, money, id); if (!link.Equals("")) { if (!preOrderId.Equals("")) // 设置预下单为扫码成功 { DataBase preDB = new DataBase(ScTool.DBName("pre"), ScTool.UserName, ScTool.Password); Pay.SetScanSuccess(preDB, preOrderId, PayType); } // 若若链接信息不存在,或不相同则重新记录 if (Session[keyLink] == null || !(Session[keyLink] as string).Equals(link)) { Session[keyLink] = link; } Response.Redirect(link); // 重定向到二维码对应链接 } else { deletOrder(id); Response.Write(ScTool.Alert("服务器忙或不支持该金额,请稍候再试! Order.aspx")); } } else { Response.Write("创建订单失败! Order.aspx"); } } else { Response.Write("创建订单金额为空! Order.aspx"); } //List<String> names = DB.DataBaseNames(); // 服务器中所有数据库名称 //List<String> names2 = DB.TableNames(); // 当前数据库中所有表名称 //DB.DeletDataBase("PayDataBase"); //List<String> names3 = DB.DataBaseNames(); // 服务器中所有数据库名称 } }