protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig             = new BLL.siteconfig().loadConfig();
            SortedDictionary <string, string> sPara = GetRequestGet();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify    = new Notify();
                bool   verifyResult = aliNotify.Verify(sPara, PLRequest.GetString("notify_id"), PLRequest.GetString("sign"));

                if (verifyResult)//验证成功
                {
                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
                    string trade_no     = PLRequest.GetString("trade_no");          //支付宝交易号
                    string order_no     = PLRequest.GetString("out_trade_no");      //获取订单号
                    string trade_status = PLRequest.GetString("trade_status");      //交易状态

                    if (trade_status == "WAIT_SELLER_SEND_GOODS" || trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        //成功状态
                        Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no));
                        return;
                    }
                }
            }
            //失败状态
            Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error"));
            return;
        }
        private void UpLoadFile(HttpContext context)
        {
            Model.siteconfig siteConfig   = new BLL.siteconfig().loadConfig();
            string           _delfile     = PLRequest.GetString("DelFilePath");
            HttpPostedFile   _upfile      = context.Request.Files["Filedata"];
            bool             _iswater     = false; //默认不打水印
            bool             _isthumbnail = false; //默认不生成缩略图

            if (PLRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (PLRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (_upfile == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater);

            //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除
            if (!string.IsNullOrEmpty(_delfile) && _delfile.IndexOf("../") == -1 &&
                _delfile.ToLower().StartsWith(siteConfig.webpath.ToLower() + siteConfig.filepath.ToLower()))
            {
                Utils.DeleteUpFile(_delfile);
            }
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            Config           xmlConfig  = new Config(); //读取配置

            v_oid       = PLRequest.GetString("v_oid").ToUpper();
            v_pstatus   = PLRequest.GetString("v_pstatus");
            v_pstring   = PLRequest.GetString("v_pstring");
            v_pmode     = PLRequest.GetString("v_pmode");
            v_md5str    = PLRequest.GetString("v_md5str");
            v_amount    = PLRequest.GetString("v_amount");
            v_moneytype = PLRequest.GetString("v_moneytype");
            remark1     = PLRequest.GetString("remark1");
            remark2     = PLRequest.GetString("remark2");

            // 拼凑加密串
            string signtext = v_oid + v_pstatus + v_amount + v_moneytype + xmlConfig.Key;

            signtext = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signtext, "md5").ToUpper();
            if (signtext == v_md5str)
            {
                if (v_pstatus.Equals("20"))
                {
                    //成功状态
                    Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + v_oid));
                    return;
                }
            }

            //失败状态
            Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error"));
            return;
        }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     mobiles = PLRequest.GetString("mobiles");
     if (!Page.IsPostBack)
     {
         ChkAdminLevel("user_sms", PLEnums.ActionEnum.View.ToString()); //检查权限
         ShowInfo(mobiles);
         TreeBind("is_lock=0");                                         //绑定类别
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sPara = GetRequestPost();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify    = new Notify();
                bool   verifyResult = aliNotify.Verify(sPara, PLRequest.GetString("notify_id"), PLRequest.GetString("sign"));

                if (verifyResult)                                                        //验证成功
                {
                    string trade_no     = PLRequest.GetString("trade_no");               //支付宝交易号
                    string order_no     = PLRequest.GetString("out_trade_no").ToUpper(); //获取订单号
                    string total_fee    = PLRequest.GetString("total_fee");              //获取总金额
                    string trade_status = PLRequest.GetString("trade_status");           //交易状态

                    if (Config.Type == "1")                                              //即时到帐接口处理方法
                    {
                        if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                        {
                            if (order_no.StartsWith("R")) //充值订单
                            {
                                BLL.user_recharge   bll   = new BLL.user_recharge();
                                Model.user_recharge model = bll.GetModel(order_no);
                                if (model == null)
                                {
                                    Response.Write("该订单号不存在");
                                    return;
                                }
                                if (model.status == 1) //已成功
                                {
                                    Response.Write("success");
                                    return;
                                }
                                if (model.amount != decimal.Parse(total_fee))
                                {
                                    Response.Write("订单金额和支付金额不相符");
                                    return;
                                }
                                bool result = bll.Confirm(order_no);
                                if (!result)
                                {
                                    Response.Write("修改订单状态失败");
                                    return;
                                }
                            }
                            else if (order_no.StartsWith("B")) //商品订单
                            {
                                BLL.orders   bll   = new BLL.orders();
                                Model.orders model = bll.GetModel(order_no);
                                if (model == null)
                                {
                                    Response.Write("该订单号不存在");
                                    return;
                                }
                                if (model.payment_status == 2) //已付款
                                {
                                    Response.Write("success");
                                    return;
                                }
                                if (model.order_amount != decimal.Parse(total_fee))
                                {
                                    Response.Write("订单金额和支付金额不相符");
                                    return;
                                }
                                bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                                if (!result)
                                {
                                    Response.Write("修改订单状态失败");
                                    return;
                                }
                                //扣除积分
                                if (model.point < 0)
                                {
                                    new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false);
                                }
                            }
                        }
                    }
                    else //担保交易接口处理方法
                    {
                        if (trade_status == "WAIT_SELLER_SEND_GOODS") //付款成功
                        {
                            if (order_no.StartsWith("R")) //充值订单
                            {
                                BLL.user_recharge   bll   = new BLL.user_recharge();
                                Model.user_recharge model = bll.GetModel(order_no);
                                if (model == null)
                                {
                                    Response.Write("该订单号不存在");
                                    return;
                                }
                                if (model.status == 1) //已成功
                                {
                                    Response.Write("success");
                                    return;
                                }
                                if (model.amount != decimal.Parse(total_fee))
                                {
                                    Response.Write("订单金额和支付金额不相符");
                                    return;
                                }
                                bool result = bll.Confirm(order_no);
                                if (!result)
                                {
                                    Response.Write("修改订单状态失败");
                                    return;
                                }
                                //自动发货
                                result = new Service().Send_goods_confirm_by_platform(trade_no, "EXPRESS", "", "DIRECT");
                                if (!result)
                                {
                                    Response.Write("自动发货失败");
                                    return;
                                }
                            }
                            else if (order_no.StartsWith("B")) //商品订单
                            {
                                BLL.orders   bll   = new BLL.orders();
                                Model.orders model = bll.GetModel(order_no);
                                if (model == null)
                                {
                                    Response.Write("该订单号不存在");
                                    return;
                                }
                                if (model.payment_status == 2) //已付款
                                {
                                    Response.Write("success");
                                    return;
                                }
                                if (model.order_amount != decimal.Parse(total_fee))
                                {
                                    Response.Write("订单金额和支付金额不相符");
                                    return;
                                }
                                bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                                if (!result)
                                {
                                    Response.Write("修改订单状态失败");
                                    return;
                                }
                                //扣除积分
                                if (model.point < 0)
                                {
                                    new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false);
                                }
                            }
                        }
                        else if (trade_status == "TRADE_FINISHED") //确认收货交易完成
                        {
                            if (order_no.StartsWith("B"))          //商品订单
                            {
                                BLL.orders   bll   = new BLL.orders();
                                Model.orders model = bll.GetModel(order_no);
                                if (model == null)
                                {
                                    Response.Write("该订单号不存在");
                                    return;
                                }
                                if (model.status > 2) //订单状态已经完成结束
                                {
                                    Response.Write("success");
                                    return;
                                }
                                if (model.order_amount != decimal.Parse(total_fee))
                                {
                                    Response.Write("订单金额和支付金额不相符");
                                    return;
                                }
                                bool result = bll.UpdateField(order_no, "status=3,complete_time='" + DateTime.Now + "'");
                                if (!result)
                                {
                                    Response.Write("修改订单状态失败");
                                    return;
                                }
                                //给会员增加积分检查升级
                                if (model.user_id > 0 && model.point > 0)
                                {
                                    new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true);
                                }
                            }
                        }
                    }

                    Response.Write("success");  //请不要修改或删除
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
        protected string remark2;     //备注1

        protected void Page_Load(object sender, EventArgs e)
        {
            //读取站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            Config           xmlConfig  = new Config(); //读取配置

            v_oid       = PLRequest.GetString("v_oid").ToUpper();
            v_pstatus   = PLRequest.GetString("v_pstatus");
            v_pstring   = PLRequest.GetString("v_pstring");
            v_pmode     = PLRequest.GetString("v_pmode");
            v_md5str    = PLRequest.GetString("v_md5str");
            v_amount    = PLRequest.GetString("v_amount");
            v_moneytype = PLRequest.GetString("v_moneytype");
            remark1     = PLRequest.GetString("remark1");
            remark2     = PLRequest.GetString("remark2");

            // 拼凑加密串
            string signtext = v_oid + v_pstatus + v_amount + v_moneytype + xmlConfig.Key;

            signtext = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signtext, "md5").ToUpper();

            if (signtext == v_md5str && v_pstatus.Equals("20"))
            {
                //成功状态
                if (v_oid.StartsWith("R")) //充值订单
                {
                    BLL.user_recharge   bll   = new BLL.user_recharge();
                    Model.user_recharge model = bll.GetModel(v_oid);
                    if (model == null)
                    {
                        Response.Write("error");
                        return;
                    }
                    if (model.status == 1) //已成功
                    {
                        Response.Write("ok");
                        return;
                    }
                    if (model.amount != decimal.Parse(v_amount))
                    {
                        Response.Write("error");
                        return;
                    }
                    bool result = bll.Confirm(v_oid);
                    if (!result)
                    {
                        Response.Write("error");
                        return;
                    }
                }
                else if (v_oid.StartsWith("B")) //商品订单
                {
                    BLL.orders   bll   = new BLL.orders();
                    Model.orders model = bll.GetModel(v_oid);
                    if (model == null)
                    {
                        Response.Write("error");
                        return;
                    }
                    if (model.payment_status == 2) //已付款
                    {
                        Response.Write("ok");
                        return;
                    }
                    if (model.order_amount != decimal.Parse(v_amount))
                    {
                        Response.Write("error");
                        return;
                    }
                    bool result = bll.UpdateField(v_oid, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                    if (!result)
                    {
                        Response.Write("error");
                        return;
                    }

                    //扣除积分
                    if (model.point < 0)
                    {
                        new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false);
                    }
                }

                //成功状态
                Response.Write("ok");
                return;
            }

            //失败状态
            Response.Write("error");
            return;
        }
Example #7
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action   = PLRequest.GetString("action");
            order_no = PLRequest.GetString("order_no");
            if (order_no.Split(',').Length > 1)
            {
                //如果多订单支付
                HttpContext.Current.Response.Redirect(linkurl("userorder", "list"));
                return;
            }
            if (order_no.ToUpper().StartsWith("R")) //充值订单
            {
                order_type = PLEnums.AmountTypeEnum.Recharge.ToString().ToLower();
            }
            else if (order_no.ToUpper().StartsWith("B")) //商品订单
            {
                order_type = PLEnums.AmountTypeEnum.BuyGoods.ToString().ToLower();
            }

            switch (action)
            {
            case "confirm":
                if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_no))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,URL传输参数有误!")));
                    return;
                }
                //是否需要支持匿名购物
                userModel = new Web.UI.BasePage().GetUserInfo();     //取得用户登录信息
                if (orderConfig.anonymous == 0 || order_no.ToUpper().StartsWith("R"))
                {
                    if (userModel == null)
                    {
                        //用户未登录
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=login"));
                        return;
                    }
                }
                else if (userModel == null)
                {
                    userModel = new Model.users();
                }
                //检查订单的类型(充值或购物)
                if (order_no.ToUpper().StartsWith("R"))     //充值订单
                {
                    rechargeModel = new BLL.user_recharge().GetModel(order_no);
                    if (rechargeModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                    //检查订单号是否已支付
                    if (rechargeModel.status == 1)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + rechargeModel.recharge_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new BLL.payment().GetModel(rechargeModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                        return;
                    }
                    //检查是否线上支付
                    if (payModel.type == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,账户充值不允许线下支付!")));
                        return;
                    }
                    order_amount = rechargeModel.amount;     //订单金额
                }
                else if (order_no.ToUpper().StartsWith("B")) //商品订单
                {
                    //检查订单是否存在
                    orderModel = new BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                    //检查是否已支付过
                    if (orderModel.payment_status == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new BLL.payment().GetModel(orderModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                        return;
                    }
                    //检查是否线下付款
                    if (orderModel.payment_status == 0)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    //检查是否积分换购,直接跳转成功页面
                    if (orderModel.order_amount == 0)
                    {
                        //修改订单状态
                        bool result = new BLL.orders().UpdateField(orderModel.order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=error"));
                            return;
                        }
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    order_amount = orderModel.order_amount;     //订单金额
                }
                else
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!")));
                    return;
                }
                break;

            case "succeed":
                //检查订单的类型(充值或购物)
                if (order_no.ToUpper().StartsWith("R"))     //充值订单
                {
                    rechargeModel = new BLL.user_recharge().GetModel(order_no);
                    if (rechargeModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                }
                else if (order_no.ToUpper().StartsWith("B"))     //商品订单
                {
                    orderModel = new BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                }
                else
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!")));
                    return;
                }
                break;
            }
        }