Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string tittle = Request["tittle"];
            string price  = Request["price"];
            string link   = Request["link"];

            if (tittle == null)
            {
                tittle = "(自定义名称)";
            }
            if (price == null)
            {
                price = "0.01";
            }
            if (link == null)
            {
                link = "";
            }

            if (link.Equals(""))
            {
                string msg = "参数link不应为空!";
                msg += "\r\n示例:" + Request.Url + "?" + "tittle=" + "测试资源xxx" + "&price=" + "0.02" + "&link=" + "http://ww.baidu.com";

                Response.Write(ScTool.Alert(msg));
                return;
            }

            LabelTittle.Text = tittle;
            LabelPrice.Text  = "待支付金额:" + price + "元";

            BtnDiv.InnerHtml = "<a href=\"" + link + "\"><img src=\"../tools/HB_pic/btn_pay.png\"></a>";
        }
Exemplo n.º 2
0
        /// <summary>
        /// 对红包码、收款码信息进行校验
        /// </summary>
        /// <param name="QrUrl">收款码</param>
        /// <param name="HbUrl">红包码</param>
        private bool ChekQrTrue(ref string QrUrl, ref string HbUrl)
        {
            bool QrError = QrUrl.ToLower().StartsWith("https://qr.alipay.com/c1");
            bool HbError = HbUrl.ToLower().StartsWith("https://qr.alipay.com/ts") || HbUrl.ToLower().StartsWith("https://qr.alipay.com/fk");

            // 若红包码、收款码传反了,则自动交换纠正
            if (QrError && HbError)
            {
                string tmp = QrUrl;
                QrUrl = HbUrl;
                HbUrl = tmp;
            }
            else if (QrError)
            {
                string msg = "您是不是错传了两个红包码?请上传一个收款码";
                Label_tip.Text = msg;
                ScTool.Alert(msg);

                return(false);
            }
            else if (HbError)
            {
                string msg = "您是不是错传了两个收款码?请上传一个红包码";
                Label_tip.Text = msg;
                ScTool.Alert(msg);

                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 上传图像,解析二维码信息
        /// </summary>
        /// <param name="uploader">通过FileUpload上传二维码图像</param>
        /// <param name="textQr">解析二维码图像上传至此处</param>
        /// <param name="subDir">Uploads子目录</param>
        /// <returns>返回二维码图像名称,用于显示</returns>
        protected string Upload_Pic(FileUpload uploader, TextBox textQr, string subDir)
        {
            // 设置文件保存目录
            string appPath = Request.PhysicalApplicationPath + @"Uploads\" + subDir + "\\";

            if (!System.IO.Directory.Exists(appPath))
            {
                System.IO.Directory.CreateDirectory(appPath);
            }

            if (uploader.HasFile)
            {
                String fileName = uploader.FileName;
                string savePath = appPath + Server.HtmlEncode(uploader.FileName);    // 生成保存路径

                uploader.SaveAs(savePath);                                           // 保存文件

                Bitmap pic = null;
                // 解析二维码信息
                try
                {
                    pic = (Bitmap)Bitmap.FromFile(savePath);

                    textQr.Text = QrTool_HB.ToCode(pic);     // 解析二维码信息
                    if (textQr.Text.Equals(""))
                    {
                        textQr.Text = "Error:请重新上传有效的二维码图像";
                    }
                    else if (!textQr.Text.ToLower().StartsWith("http://") && !textQr.Text.ToLower().StartsWith("https://"))
                    {
                        textQr.Text = "Error:" + textQr.Text;
                        ScTool.Alert("您上传的二维码未能识别,可能是图像不够清晰,请重新上传!");
                    }
                    else
                    {
                        textQr.Enabled = false;              // 获取到二维码,则不允许修改
                    }
                    pic.Dispose();
                    pic = null;
                }
                catch (Exception ex)
                {
                    textQr.Text = "";
                    pic.Dispose();
                    pic = null;
                }

                //UploadStatusLabel.Text = "Your file was saved as ->" + savePath;
                return(fileName);
            }
            else
            {
                //UploadStatusLabel.Text = "You did not specify a file to upload.";
                return("");
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // 获取订单号
            string payType    = "";
            string preOrderId = "";

            if (Request["a"] != null && !Request["a"].Equals(""))
            {
                payType    = "Ali";
                preOrderId = Request["a"];
            }

            if (Request["w"] != null && !Request["w"].Equals(""))
            {
                payType    = "Wechat";
                preOrderId = Request["w"];
            }

            if (preOrderId == null || preOrderId.Equals(""))
            {
                return;
            }


            DataBase DB = new DataBase(ScTool.DBName("pre"), ScTool.UserName, ScTool.Password);

            Dictionary <string, string> row = DB.SelectValue(ScTool.ORDER, preOrderId, "ID").RowDic();

            if (row.Count > 0 && row.ContainsKey("param"))
            {
                string oparam    = row["param"];
                string isSuccess = row["isSuccess"].ToLower();

                if (isSuccess.Equals("true"))
                {
                    Response.Write(ScTool.Alert("订单" + preOrderId + "已支付成功!"));
                }
                else
                {
                    // 获取客户端类型
                    //string agent = Request.Params.Get("HTTP_USER_AGENT");
                    //string payType = ScTool.payType(agent);

                    // 创建订单时,指定类型
                    if (payType.Equals(""))
                    {
                        string payTypeParam = Request["PayType"];
                        if (payTypeParam != null && (payTypeParam.Equals("Ali") || payTypeParam.Equals("Wechat")))
                        {
                            payType = payTypeParam;
                        }
                    }

                    //param = HttpUtility.UrlDecode(param);
                    //Response.Redirect("Order.aspx?" + "PayType=" + payType + "&" + param);

                    Order.StaticParam = "PayType=" + payType + "&" + oparam + "&preOrderId=" + preOrderId;
                    //Server.Transfer("Order.aspx");
                    Server.Transfer("../Pages/Order.aspx");
                }
            }
            else
            {
                Response.Write(ScTool.Alert("订单" + preOrderId + "不存在!请重新下单"));
            }

            //{
            //    String param = "TYPE=CreateOrder&preOrderId=" + p + "&PayType=Ali";
            //    Server.Transfer("../pages/pay.aspx?" + param);
            //}

            //p = Request["w"];
            //if (p != null && !p.Equals(""))
            //{
            //    String param = "TYPE=CreateOrder&preOrderId=" + p + "&PayType=Wechat";
            //    Server.Transfer("../pages/pay.aspx?" + param);
            //}
        }
Exemplo n.º 5
0
        string Tittle    = "";  // 商户名称

        //Boolean testMode = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ScTool.RecordUserAgent(Request);                      // 记录客户端信息
            }
            //FileUpload_HB.Style.Add("display", "none");   // 隐藏控件
            Body1.Style.Add("display", "none");   // 隐藏body
            //BtnDiv.Style.Add("display", "none");   // 隐藏按钮
            BtnDiv.Style.Add("display", "none");  // 隐藏按钮

            //Request.Params[HTTP_HOST]:60.205.185.168:8001
            //Request.Url:http://60.205.185.168:8001/Pages/request.aspx
            //string ServerUrl = "http://" + Request.Params["HTTP_HOST"];

            QrUrl  = Request["QrUrl"];  // 当前打开
            HbUrl  = Request["HbUrl"];  // 跳转至
            Tittle = Request["Tittle"]; //

            if (QrUrl == null)
            {
                QrUrl = "";
            }
            //if (testMode)
            //{
            //    if (QrUrl == null) QrUrl = "https://www.baidu.com";
            //    if (HbUrl == null) HbUrl = "https://fanyi.baidu.com"; // 默认红包码
            //}
            //else
            //{
            //if (QrUrl == null) QrUrl = "https://qr.alipay.com/tsx031041ajtuiviwd978b6";
            if (HbUrl == null)
            {
                HbUrl = "https://qr.alipay.com/c1x01990gbhjvuvwaxwkqa3";                // 默认红包码
            }
            //}

            if (Tittle == null)
            {
                Tittle = "商户名称(未设置)";
            }
            if (QrUrl.StartsWith("ShowInfo_"))
            {
                QrUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/" + "PageHB/ShowInfo.aspx?p=" + QrUrl.Substring("ShowInfo_".Length);
            }


            if (QrUrl.Equals(""))
            {
                string msg = "参数QrUrl不应为空!";
                msg += "\r\n示例:" + Request.Url + "?" + "QrUrl=" + "http://www.baidu.com" + "&HbUrl=" + "" + "&Tittle=" + "第8号当铺";

                Response.Write(ScTool.Alert(msg));
                return;
            }

            LabelTittle.Text = Tittle;

            string key  = "HbPay2";
            string date = DateTime.Now.ToString("yyyyMMdd");        // 每天可领取一次,首次跳转


            if (Session.Timeout != 60 * 24)
            {
                Session.Timeout = 60 * 24;                               // 设置Session有效时间为24小时
            }
            string value = "";

            if (Session[key] == null || !(Session[key] as string).StartsWith(date))  // 若key不存在,或非今天的则生成新的值
            {
                value        = date + "_0";
                Session[key] = value;
            }

            if ((Session[key] as string).Equals(date + "_0"))       // 打开收款码
            {
                Session[key] = date + "_1";
                //if (testMode)
                //{
                //    BtnDiv.InnerHtml = "<a id=\"BtnName1\"  target=\"_blank\" " + " onclick=\"reloadPage()\" " + " href=\"" + QrUrl + "\" " + "><img src=\"../tools/HB_pic/btn.png\"></a>";
                //}
                //else
                //{
                //BtnDiv.InnerHtml = "<a id=\"BtnName1\" " + " onclick=\"reloadPage()\" " + " href=\"" + "alipayqr://platformapi/startapp?saId=10000007&qrcode=" + QrUrl + "\" " + "><img src=\"../tools/HB_pic/btn.png\"></a>";
                BtnDiv.InnerHtml = "<a id=\"BtnName1\" " + " onclick=\"reloadPage()\" " + " href=\"" + "alipayqr://platformapi/startapp?saId=10000007&qrcode=" + QrUrl + "\" " + "> </a>";
                //}
            }
            else if ((Session[key] as string).Equals(date + "_1"))  // 重定向至红包码
            {
                // 红包首次访问计数
                if (Request["ID"] != null)
                {
                    string InfoUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/HbInfo.aspx";
                    string commond = InfoUrl + "?" + "TYPE=CountAdd&ID=" + Request["ID"];
                    ScTool.getWebData(commond);
                }

                Session[key] = date + "_2";
                Response.Redirect(HbUrl);

                // 若要回到红包页面
                //BtnDiv.InnerHtml = "<a id=\"BtnName1\" href=\"" + HbUrl + "\"><img src=\"../tools/HB_pic/btn.png\"></a>";
            }
            else
            //if ((Session[key] as string).Equals(date + "_2"))
            {
                //Response.Redirect(QrUrl);
                Session[key] = date + "_3";
                //Response.Redirect("alipayqr://platformapi/startapp?saId=10000007&qrcode=" + QrUrl);
                Response.Redirect(QrUrl);
                //BtnDiv.InnerHtml = "<a id=\"BtnName1\" " + " href=\"" + QrUrl + "\"><img src=\"../tools/HB_pic/btn.png\"></a>"; //直接链接收款码,返回会关闭页面
                //BtnDiv.InnerHtml = "<a id=\"BtnName1\" " + " href=\"" + "alipayqr://platformapi/startapp?saId=10000007&qrcode=" + QrUrl + "\"><img src=\"../tools/HB_pic/btn.png\"></a>";
            }
            //else if ((Session[key] as string).Equals(date + "_3"))
            //{
            //    Session[key] = date + "_2";
            //    BtnDiv.InnerHtml = "<a id=\"BtnName3\" " + " href=\"" + "alipayqr://platformapi/startapp?saId=10000007&qrcode=" + QrUrl + "\"><img src=\"../tools/HB_pic/btn.png\"></a>";
            //}

            //String Re = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/Redirect.aspx";
            //String Hb = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/HB.aspx";
            //String mackUrl = Re + "?p=" + Hb;
            //LinkDiv.InnerHtml = "<a href=\"" + mackUrl + "\"><asp:Label Text=\"制作我的红包收款码\" ForeColor=\"White\"></asp:Label></a>";
        }
Exemplo n.º 6
0
        /// <summary>
        /// 载入后执行参数对应的sql请求
        /// </summary>
        public override void Load(object sender, EventArgs e)
        {
            if (UserType == 0 && param.Equals(""))
            {
                Response.Redirect("../PayFor/UserLogin.aspx");
            }

            DB = new DataBase(ScTool.DBName("pre"), ScTool.UserName, ScTool.Password);

            if (Page.IsPostBack)
            {
                //Timer1.Enabled = true;
                return;
            }

            body1.Visible = false;

            TYPE = Request["TYPE"];
            if (TYPE == null)
            {
                TYPE = "";
            }

            if (param.Contains("TYPE"))
            {
                int index = param.IndexOf("TYPE");
                int start = param.IndexOf("&", index + 4);
                param = param.Substring(start + 1);
            }

            //DB.DeletTable(ScTool.ORDER);
            confirmOrderTab();

            //DB = new DataBase("master", ScTool.UserName, ScTool.Password);
            //DB.DeletDataBase(ScTool.DBName("pre"));
            //DB.DeletDataBase(ScTool.DBName(ScTool.PayTypeAli));
            //DB.DeletDataBase(ScTool.DBName(ScTool.PayTypeWechat));

            if (TYPE.Equals("PreOrder"))            // 生成新的pre订单
            {
                //if (!ContainsAuthorInfo()) return;
                this.Controls.Clear();

                string id = createOrder(param);
                Response.Write(ScTool.Reslut(id));
                return;
            }
            else if (TYPE.Equals("ShowPreOrder"))   // 显示预备下单订单号,对应的二维码待支付页面
            {
                string preOrderId = Request["preOrderId"];

                LabelPreOrderId.Text    = "当前订单号:" + preOrderId;
                LabelPreOrderPrice.Text = getNeedPayMoney(preOrderId);

                if (preOrderId != null && !preOrderId.Equals(""))
                {
                    string data = url + "?" + "TYPE=" + "CreateOrder" + "&" + "preOrderId=" + preOrderId;
                    showQR(data);
                }
                else
                {
                    Response.Write("支付失败!Pay.aspx创建订单失败");
                }
            }
            else if (TYPE.Equals("OrderResult"))    // 查询指定订单支付结果http://60.205.185.168:8002/pages/pay.aspx?TYPE=OrderResult&machinCode=J78Z-A906-E9ST-RING
            {
                this.Controls.Clear();

                string order_param = Request["P"];
                if (order_param == null || order_param.Equals(""))
                {
                    string result = OrderResult(Request["preOrderId"]); // 通过订单号查询支付结果
                    Response.Write(ScTool.Reslut(result));
                }
                else
                {
                    string result = OrderResult_param(order_param);     // 通过订单参数查询支付结果
                    Response.Write(ScTool.Reslut(result));
                }
                return;
            }
            else if (TYPE.Equals("OrderResultX"))
            {
                this.Controls.Clear();

                if (Request["preOrderId"] != null)
                {
                    string result = OrderResult(Request["preOrderId"], false); // 通过订单号查询支付结果
                    Response.Write(ScTool.Reslut(result));
                }
                else
                {
                    string machinCode = Request["machinCode"];
                    string soft       = Request["soft"];

                    string result = OnlineCode.Check(DB, OnlineCode.TAB, machinCode, soft);     // 查询指定的机器码对应订单是否已支付
                    Response.Write(ScTool.Reslut(result));
                }
                return;
            }
            else if (TYPE.Equals("CreateOrder"))    // 使用预下单信息,创建正式订单
            {
                string preOrderId = Request["preOrderId"];
                if (preOrderId != null && !preOrderId.Equals(""))
                {
                    Dictionary <string, string> row = DB.SelectValue(ScTool.ORDER, preOrderId, "ID").RowDic();
                    if (row.Count > 0 && row.ContainsKey("param"))
                    {
                        string oparam    = row["param"];
                        string isSuccess = row["isSuccess"].ToLower();

                        if (isSuccess.Equals("true"))
                        {
                            Response.Write(ScTool.Alert("订单" + preOrderId + "已支付成功!"));
                        }
                        else
                        {
                            // 获取客户端类型
                            string agent   = Request.Params.Get("HTTP_USER_AGENT");
                            string payType = ScTool.payType(agent);

                            // 创建订单时,指定类型
                            if (payType.Equals(""))
                            {
                                string payTypeParam = Request["PayType"];
                                if (payTypeParam != null && (payTypeParam.Equals("Ali") || payTypeParam.Equals("Wechat")))
                                {
                                    payType = payTypeParam;
                                }
                            }

                            //param = HttpUtility.UrlDecode(param);
                            //Response.Redirect("Order.aspx?" + "PayType=" + payType + "&" + param);

                            Order.StaticParam = "PayType=" + payType + "&" + oparam + "&preOrderId=" + preOrderId;
                            Server.Transfer("Order.aspx");
                        }
                    }
                    else
                    {
                        Response.Write(ScTool.Alert("订单" + preOrderId + "不存在!请重新下单"));
                    }
                }
            }
            else
            {
                if (!param.Equals(""))
                {
                    //if (!ContainsAuthorInfo()) return;

                    //param = HttpUtility.UrlEncode(param);
                    string preOrderId = createOrder(param);
                    LabelPreOrderId.Text = "当前订单号:" + preOrderId;

                    string needMoney = Request["money"];
                    if (needMoney != null)
                    {
                        LabelPreOrderPrice.Text = "待支付金额:" + needMoney + " 元";
                    }

                    if (!preOrderId.Equals(""))
                    {
                        string data = url + "?" + "TYPE=" + "CreateOrder" + "&" + "preOrderId=" + preOrderId;
                        //Response.Redirect("QRTool.aspx?" + data);

                        //QRTool.StaticParam = data;
                        //Server.Transfer("QRTool.aspx");

                        showQR(data);
                    }
                    else
                    {
                        Response.Write("支付失败!Pay.aspx创建订单失败");
                    }
                }
                else
                {
                    if (UserType == 2)
                    {
                        ScTool.showTable(this.Controls, DB, ScTool.ORDER);
                    }
                    else if (UserType == 1)
                    {
                        ScTool.showTable(this.Controls, DB, ScTool.ORDER, "where param like '%" + "author(" + UserAccount + ")" + "%' ");
                    }
                    NoteInfo();
                }
            }
        }
Exemplo n.º 7
0
        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();    // 服务器中所有数据库名称
            }
        }
Exemplo n.º 8
0
        string Tittle    = "";  // 商户名称

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ScTool.RecordUserAgent(Request);                      // 记录客户端信息
            }
            //Request.Params[HTTP_HOST]:60.205.185.168:8001
            //Request.Url:http://60.205.185.168:8001/Pages/request.aspx
            //string ServerUrl = "http://" + Request.Params["HTTP_HOST"];

            QrUrl  = Request["QrUrl"];  // 当前打开
            HbUrl  = Request["HbUrl"];  // 跳转至
            Tittle = Request["Tittle"]; //

            if (QrUrl == null)
            {
                QrUrl = "";
            }
            if (HbUrl == null)
            {
                HbUrl = "https://qr.alipay.com/c1x01990gbhjvuvwaxwkqa3";                // 默认红包码
            }
            if (Tittle == null)
            {
                Tittle = "商户名称(未设置)";
            }
            if (QrUrl.StartsWith("ShowInfo_"))
            {
                QrUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/" + "PageHB/ShowInfo.aspx?p=" + QrUrl.Substring("ShowInfo_".Length);
            }


            if (QrUrl.Equals(""))
            {
                string msg = "参数QrUrl不应为空!";
                msg += "\r\n示例:" + Request.Url + "?" + "QrUrl=" + "http://www.baidu.com" + "&HbUrl=" + "" + "&Tittle=" + "第8号当铺";

                Response.Write(ScTool.Alert(msg));
                return;
            }

            LabelTittle.Text = Tittle;

            string key  = "HbPay";
            string date = DateTime.Now.ToString("yyyyMMdd");        // 每天可领取一次,首次跳转

            if (Session.Timeout != 60 * 24)
            {
                Session.Timeout = 60 * 24;                          // 设置Session有效时间为24小时
            }
            string value = "";

            if (Session[key] == null || !(Session[key] as string).StartsWith(date))  // 若key不存在,或非今天的则生成新的值
            {
                value        = date;
                Session[key] = date;
            }
            else
            {
                value = Session[key] as string;                             // 获取之前的session值
                if (!value.Contains("noFrist"))
                {
                    value = value + "noFrist";                              // 记录为非首次访问
                }
                Session[key] = value;
            }
            //Label1.Text = value;

            if (value.Contains("noFrist"))  // 非首次访问,直接跳转收款
            {
                //NewLinkDiv.InnerHtml = "<a href =\"https://qr.alipay.com/tsx031041ajtuiviwd978b6\" >支付宝收款</a>";
                Response.Redirect(QrUrl);
            }
            else
            {                               // 首次访问,跳转领取红包
                //NewLinkDiv.InnerHtml = "<a href =\"https://qr.alipay.com/c1x01990gbhjvuvwaxwkqa3\" >支付宝领红包</a>";

                //string content = "<img id=\"img1\" src=\"" + ServerUrl + "/tools/HB_pic/bg.jpg\" />";
                //content += "<a href=\"" + HbUrl + "\"><img id=\"img2\" src=\"" + ServerUrl + "/tools/HB_pic/btn.png\" alt=\"点击领取红包\" /></a>";
                //BtnDiv.InnerHtml = content;

                HbUrl            = "GetHB.aspx" + "?p=" + HbUrl; //获取红包码url
                BtnDiv.InnerHtml = "<a href=\"" + HbUrl + "\"><img src=\"../tools/HB_pic/btn.png\"></a>";

                // 红包首次访问计数
                if (Request["ID"] != null)
                {
                    string InfoUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/HbInfo.aspx";
                    string commond = InfoUrl + "?" + "TYPE=CountAdd&ID=" + Request["ID"];
                    ScTool.getWebData(commond);
                }
            }

            //// 制作我的红包码
            //string CreateHbUrl = "http://" + Request.Params.Get("HTTP_HOST") + "/PageHB/HB.aspx";
            //LinkA.HRef = CreateHbUrl;
        }