예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SortedDictionary <string, string> sPara = GetRequestGet();

        if (sPara.Count > 0)//判断是否有带返回参数
        {
            Notify aliNotify = new Notify();
            // bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]);
            bool verifyResult = true;
            if (verifyResult)//验证成功
            {
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //请在这里加上商户的业务逻辑程序代码


                //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表

                //商户订单号

                string out_trade_no = Request.QueryString["out_trade_no"];

                //支付宝交易号

                string trade_no = Request.QueryString["trade_no"];

                //交易状态
                string trade_status = Request.QueryString["trade_status"];
                string openId       = Request.QueryString["body"];
                //总额
                string total_fee = Request.QueryString["total_fee"];
                if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                {
                    //判断该笔订单是否在商户网站中已经做过处理
                    //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                    //如果有做过处理,不执行商户的业务程序
                    try
                    {
                        BaseClass.Dal.ChongzhiLog sl = new BaseClass.Dal.ChongzhiLog();
                        bool isOrderValid            = sl.CZisok(out_trade_no, openId);
                        log4netHelper.WriteDebugLog(typeof(return_url), "订单notify", "订单号:" + out_trade_no + "处理状态:" + isOrderValid);
                        LVWEIBA.DAL.order_list   oodd  = new LVWEIBA.DAL.order_list();
                        LVWEIBA.Model.order_list order = oodd.GetModel(out_trade_no);

                        var isOrder = order != null && order.user_id == openId;
                        if (isOrderValid || isOrder)
                        {
                            string  mid   = openId;
                            decimal money = decimal.Parse(total_fee) / 100;

                            LVWEIBA.Model.order_list oom = oodd.GetModel(out_trade_no);
                            //正式状态
                            oom.order_zt = "DCX";
                            oodd.Update(oom);
                            //发送短信通知用户和商户
                            var orderMx = new LVWEIBA.DAL.order_Mx().GetModel(out_trade_no);
                            var member  = new LVWEIBA.BLL.MemberInfo().GetModel(mid);
                            //发送短信通知用户和商户(判断是门票还是尾单)
                            if (orderMx.ProType != null && (orderMx.ProType.Equals("DZP") || orderMx.ProType.Equals("ZZP")))
                            {
                                var bll = new LVWEIBA.DAL.ProviderSpot();
                                LVWEIBA.Model.ProviderSpot providerSpot = bll.GetModel(int.Parse(orderMx.productNum));
                                LVWEIBA.MessageService.NotifyUsersTicket(member.Tel, providerSpot.MasterTel, orderMx);
                                providerSpot.Num = providerSpot.Num - orderMx.ProCount;
                                bll.Update(providerSpot);
                                log4netHelper.WriteDebugLog(typeof(return_url), "订单return", "修改余量: productNum is:" + orderMx.productNum + "TicketCount is:" + providerSpot.Num);
                            }
                            else
                            {
                                LVWEIBA.Model.LvULines lvModel = new LVWEIBA.DAL.LvULines().GetModel(orderMx.productNum);
                                LVWEIBA.MessageService.NotifyUsers(member.Tel, lvModel.LineMasterMoble, orderMx);
                                //修改线路余量
                                LVWEIBA.BLL.LvULines lvubLL = new LVWEIBA.BLL.LvULines();
                                if (lvModel != null)
                                {
                                    lvModel.adultTicketCount = lvModel.adultTicketCount - orderMx.adultCount;
                                    lvModel.puppyTicketCount = lvModel.puppyTicketCount - orderMx.puppyCount;
                                    lvubLL.Update(lvModel);
                                    log4netHelper.WriteDebugLog(typeof(return_url), "订单return", "修改余量: productNum is:" + orderMx.productNum);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        moneyUnFreeze(out_trade_no, openId);
                        couponUnUse(out_trade_no);
                    }

                    Response.Redirect("http://wx.lvwei8.com/index/indent_show.aspx?order_id=" + out_trade_no);
                }
                else
                {
                    Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                }
                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                Response.Write("验证失败");
            }
        }
        else
        {
            Response.Write("无返回参数");
        }
    }
예제 #2
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, Request.Form["notify_id"], Request.Form["sign"]);

            if (verifyResult)//验证成功
            {
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //请在这里加上商户的业务逻辑程序代码

                //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                //商户订单号
                openId = Request.Form["body"];
                string out_trade_no = Request.Form["out_trade_no"];

                //支付宝交易号

                string trade_no = Request.Form["trade_no"];

                //交易状态
                string trade_status = Request.Form["trade_status"];
                //总额
                string total_fee = Request.Form["total_fee"];


                if (Request.Form["trade_status"] == "TRADE_FINISHED")
                {
                    //
                }
                else if (Request.Form["trade_status"] == "TRADE_SUCCESS")
                {
                    BaseClass.Dal.ChongzhiLog sl = new BaseClass.Dal.ChongzhiLog();
                    bool isOrderValid            = sl.CZisok(out_trade_no, openId);
                    log4netHelper.WriteDebugLog(typeof(notify_url), "订单notify", "订单号:" + out_trade_no + "处理状态:" + isOrderValid);
                    if (isOrderValid)
                    {
                        string  mid   = openId;
                        decimal money = decimal.Parse(total_fee) / 100;
                        LVWEIBA.DAL.order_list   oodd = new LVWEIBA.DAL.order_list();
                        LVWEIBA.Model.order_list oom  = oodd.GetModel(out_trade_no);
                        if (oom.order_zt != "DCX")
                        {
                            //正式状态
                            oom.order_zt = "DCX";
                            oodd.Update(oom);
                            //发送短信通知用户和商户
                            var orderMx = new LVWEIBA.DAL.order_Mx().GetModel(out_trade_no);
                            var member  = new LVWEIBA.BLL.MemberInfo().GetModel(mid);
                            //发送短信通知用户和商户(判断是门票还是尾单)
                            if (orderMx.ProType != null && (orderMx.ProType.Equals("DZP") || orderMx.ProType.Equals("ZZP")))
                            {
                                var bll = new LVWEIBA.DAL.ProviderSpot();
                                LVWEIBA.Model.ProviderSpot providerSpot = bll.GetModel(int.Parse(orderMx.productNum));
                                LVWEIBA.MessageService.NotifyUsersTicket(member.Tel, providerSpot.MasterTel, orderMx);
                                providerSpot.Num = providerSpot.Num - orderMx.ProCount;
                                bll.Update(providerSpot);
                                log4netHelper.WriteDebugLog(typeof(notify_url), "订单notify", "修改余量: productNum is:" + orderMx.productNum + "TicketCount is:" + providerSpot.Num);
                            }
                            else
                            {
                                LVWEIBA.Model.LvULines lvModel = new LVWEIBA.DAL.LvULines().GetModel(orderMx.productNum);
                                LVWEIBA.MessageService.NotifyUsers(member.Tel, lvModel.LineMasterMoble, orderMx);
                                //修改线路余量
                                LVWEIBA.BLL.LvULines lvubLL = new LVWEIBA.BLL.LvULines();
                                if (lvModel != null)
                                {
                                    lvModel.adultTicketCount = lvModel.adultTicketCount - orderMx.adultCount;
                                    lvModel.puppyTicketCount = lvModel.puppyTicketCount - orderMx.puppyCount;
                                    lvubLL.Update(lvModel);
                                    log4netHelper.WriteDebugLog(typeof(notify_url), "订单notify", "修改余量: productNum is:" + orderMx.productNum);
                                }
                            }
                        }
                    }
                }
                //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
                Response.Write("success");  //请不要修改或删除
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            }
            else//验证失败
            {
                string out_trade_no = Request.Form["out_trade_no"];
                moneyUnFreeze(out_trade_no, openId);
                couponUnUse(out_trade_no);
                Response.Write("fail");
            }
        }
        else
        {
            Response.Write("无通知参数");
        }
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string   postStr = "";
        TXT_Help th      = new TXT_Help();

        if (Request.HttpMethod.ToLower() == "post")
        {
            Stream s = System.Web.HttpContext.Current.Request.InputStream;
            byte[] b = new byte[s.Length];
            s.Read(b, 0, (int)s.Length);
            postStr = Encoding.UTF8.GetString(b);

            XmlHelp xh = new XmlHelp();
            SortedDictionary <string, string> sParams = xh.GetInfoFromXml(postStr);
            try
            {
                if (sParams["return_code"].ToString() == "SUCCESS")
                {
                    BaseClass.Dal.ChongzhiLog sl = new BaseClass.Dal.ChongzhiLog();
                    bool isOrderValid            = sl.CZisok(sParams["out_trade_no"].ToString(), sParams["openid"].ToString());
                    BaseClass.Common.LoggerUtil.printLog("订单:" + sParams["out_trade_no"].ToString() + "处理状态:" + isOrderValid);
                    if (isOrderValid)
                    {
                        string  mid   = sParams["openid"].ToString();
                        decimal money = decimal.Parse(sParams["cash_fee"].ToString()) / 100;
                        LVWEIBA.DAL.order_list   oodd = new LVWEIBA.DAL.order_list();
                        LVWEIBA.Model.order_list oom  = oodd.GetModel(sParams["out_trade_no"].ToString());
                        //正式状态
                        oom.order_zt = "DCX";
                        oodd.Update(oom);
                        //发送短信通知用户和商户
                        var orderMx = new LVWEIBA.DAL.order_Mx().GetModel(sParams["out_trade_no"].ToString());
                        var member  = new LVWEIBA.BLL.MemberInfo().GetModel(mid);
                        //发送短信通知用户和商户(判断是门票还是尾单)
                        if (orderMx.ProType != null && (orderMx.ProType.Equals("DZP") || orderMx.ProType.Equals("ZZP")))
                        {
                            var bll = new LVWEIBA.DAL.ProviderSpot();
                            LVWEIBA.Model.ProviderSpot providerSpot = bll.GetModel(int.Parse(orderMx.productNum));
                            LVWEIBA.MessageService.NotifyUsersTicket(member.Tel, providerSpot.MasterTel, orderMx);
                            providerSpot.Num = providerSpot.Num - orderMx.ProCount;
                            bll.Update(providerSpot);
                            BaseClass.Common.LoggerUtil.printLog("修改余量: productNum is:" + orderMx.productNum + "TicketCount is:" + providerSpot.Num);
                        }
                        else
                        {
                            LVWEIBA.Model.LvULines lvModel = new LVWEIBA.DAL.LvULines().GetModel(orderMx.productNum);
                            LVWEIBA.MessageService.NotifyUsers(member.Tel, lvModel.LineMasterMoble, orderMx);
                            //修改线路余量
                            LVWEIBA.BLL.LvULines lvubLL = new LVWEIBA.BLL.LvULines();
                            if (lvModel != null)
                            {
                                lvModel.adultTicketCount = lvModel.adultTicketCount - orderMx.adultCount;
                                lvModel.puppyTicketCount = lvModel.puppyTicketCount - orderMx.puppyCount;
                                lvubLL.Update(lvModel);
                                BaseClass.Common.LoggerUtil.printLog("修改余量: productNum is:" + orderMx.productNum + "adultTicketCount is:" + lvModel.adultTicketCount + "puppyTicketCount is:" + lvModel.puppyTicketCount);
                            }
                        }
                        //返回成功
                        Response.Write(returnOKMessage());
                    }
                    else
                    {
                        th.ReFreshTXT(postStr, "D:\\msg\\zhifuErr\\", "错误CZ" + DateTime.Now.ToString("yyMMddHHmmssff") + ".txt");
                        Response.Write(returnFailMessage());
                    }
                }
                else
                {
                    //一系列还原操作
                    moneyUnFreeze(sParams["out_trade_no"].ToString(), sParams["openid"].ToString());
                    couponUnUse(sParams["out_trade_no"].ToString());
                    Response.Write(returnFailMessage());
                }
            }
            catch (Exception ex)
            {
                BaseClass.Common.LoggerUtil.printLog("订单" + sParams["out_trade_no"].ToString() + "处理错误," + "ex:" + ex.Message + ex.StackTrace);
                //一系列还原操作
                moneyUnFreeze(sParams["out_trade_no"].ToString(), sParams["openid"].ToString());
                couponUnUse(sParams["out_trade_no"].ToString());
                Response.Write(returnFailMessage());
            }
        }
    }