예제 #1
0
        /// <summary>
        /// 向支付宝账户提交充值记录
        /// </summary>
        /// <param name="id">充值编号</param>
        /// <returns></returns>
        public ContentResult PayMoney(string batchid)
        {
            try
            {
                using (var db = new EFContext())
                {
                    var syspayhistory = db.syspayhistory.FirstOrDefault(x => x.BatchId == batchid);
                    if (syspayhistory == null)
                    {
                        return(Content("订单无效无法进行支付"));
                    }
                    switch (syspayhistory.OrderMode)
                    {
                    case 1:
                        #region 在线充值
                    {
                        var model = db.selshopjinbirecharge.FirstOrDefault(x => x.BatchId == batchid);
                        if (model == null)
                        {
                            return(Content("订单无效无法进行支付"));
                        }

                        var selshop = db.selshop.FirstOrDefault(x => x.ID == model.ShopID);
                        if (selshop == null)
                        {
                            return(Content("订单用户无效无法进行支付"));
                        }

                        //数据库充值记录写入成功之后,调用支付接口开始充值

                        #region 支付参数
                        //商户订单号
                        string out_trade_no = model.BatchId;
                        //商户网站订单系统中唯一订单号,必填 在下面赋值

                        //订单名称
                        string subject = string.Format("美味云充值");
                        //必填

                        //付款金额
                        string total_fee = model.Data.ToString();
                        //必填

                        //订单描述
                        string body = string.Format("用户:{0} 于 {1} 向{2}充值{3}元,充值单号:{4},商户订单号:{5}", selshop.ShopName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "美味云", total_fee, model.ID, model.BatchId);
                        //选填

                        //超时时间
                        string it_b_pay = "24h";
                        //选填

                        //钱包token
                        string extern_token = string.Empty;


                        //选填
                        #endregion

                        #region 把参数打包
                        SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                        sParaTemp.Add("service", Config.service);
                        sParaTemp.Add("partner", Config.partner);
                        sParaTemp.Add("seller_id", Config.seller_id);
                        sParaTemp.Add("_input_charset", Config.input_charset.ToLower());
                        sParaTemp.Add("payment_type", Config.payment_type);
                        sParaTemp.Add("notify_url", Config.notify_url);
                        sParaTemp.Add("return_url", Config.return_url);
                        sParaTemp.Add("anti_phishing_key", Config.anti_phishing_key);
                        sParaTemp.Add("exter_invoke_ip", Config.exter_invoke_ip);
                        sParaTemp.Add("out_trade_no", out_trade_no);
                        sParaTemp.Add("subject", subject);
                        sParaTemp.Add("total_fee", total_fee);
                        sParaTemp.Add("body", body);
                        sParaTemp.Add("it_b_pay", it_b_pay);


                        #endregion
                        string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                        Response.Write(sHtmlText);
                    }
                        #endregion
                        break;

                    case 2:
                        #region 短信充值

                    {
                        var model = db.selshopsmschange.FirstOrDefault(x => x.BatchId == batchid);
                        if (model == null)
                        {
                            return(Content("订单无效无法进行支付"));
                        }

                        var selshop = db.selshop.FirstOrDefault(x => x.ID == model.ShopID);
                        if (selshop == null)
                        {
                            return(Content("订单用户无效无法进行支付"));
                        }

                        //数据库充值记录写入成功之后,调用支付接口开始充值

                        #region 支付参数
                        //商户订单号
                        string out_trade_no = model.BatchId;
                        //商户网站订单系统中唯一订单号,必填 在下面赋值

                        //订单名称
                        string subject = string.Format("美味云支付");
                        //必填

                        //付款金额
                        string total_fee = model.Money.ToString();
                        //必填

                        //订单描述
                        string body = string.Format("用户:{0} 于 {1} 向{2}支付{3}元,支付单号:{4},商户订单号:{5}", selshop.ShopName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "美味云", total_fee, model.ID, model.BatchId);
                        //选填

                        //超时时间
                        string it_b_pay = "24h";
                        //选填

                        //钱包token
                        string extern_token = string.Empty;


                        //选填
                        #endregion

                        #region 把参数打包
                        SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                        sParaTemp.Add("service", Config.service);
                        sParaTemp.Add("partner", Config.partner);
                        sParaTemp.Add("seller_id", Config.seller_id);
                        sParaTemp.Add("_input_charset", Config.input_charset.ToLower());
                        sParaTemp.Add("payment_type", Config.payment_type);
                        sParaTemp.Add("notify_url", Config.notify_url);
                        sParaTemp.Add("return_url", Config.return_url);
                        sParaTemp.Add("anti_phishing_key", Config.anti_phishing_key);
                        sParaTemp.Add("exter_invoke_ip", Config.exter_invoke_ip);
                        sParaTemp.Add("out_trade_no", out_trade_no);
                        sParaTemp.Add("subject", subject);
                        sParaTemp.Add("total_fee", total_fee);
                        sParaTemp.Add("body", body);
                        sParaTemp.Add("it_b_pay", it_b_pay);


                        #endregion
                        string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                        Response.Write(sHtmlText);
                    }
                        #endregion
                        break;

                    case 3:
                        #region 系统升级
                    {
                        var model = db.selshopversion.FirstOrDefault(x => x.BatchId == batchid);
                        if (model == null)
                        {
                            return(Content("订单无效无法进行支付"));
                        }

                        var selshop = db.selshop.FirstOrDefault(x => x.ID == model.ShopID);
                        if (selshop == null)
                        {
                            return(Content("订单用户无效无法进行支付"));
                        }

                        //数据库充值记录写入成功之后,调用支付接口开始充值

                        #region 支付参数
                        //商户订单号
                        string out_trade_no = model.BatchId;
                        //商户网站订单系统中唯一订单号,必填 在下面赋值

                        //订单名称
                        string subject = string.Format("美味云支付");
                        //必填

                        //付款金额
                        string total_fee = model.Money.ToString();
                        //必填

                        //订单描述
                        string body = string.Format("用户:{0} 于 {1} 向{2}支付{3}元,支付单号:{4},商户订单号:{5}", selshop.ShopName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "美味云", total_fee, model.ID, model.BatchId);
                        //选填

                        //超时时间
                        string it_b_pay = "24h";
                        //选填

                        //钱包token
                        string extern_token = string.Empty;


                        //选填
                        #endregion

                        #region 把参数打包
                        SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                        sParaTemp.Add("service", Config.service);
                        sParaTemp.Add("partner", Config.partner);
                        sParaTemp.Add("seller_id", Config.seller_id);
                        sParaTemp.Add("_input_charset", Config.input_charset.ToLower());
                        sParaTemp.Add("payment_type", Config.payment_type);
                        sParaTemp.Add("notify_url", Config.notify_url);
                        sParaTemp.Add("return_url", Config.return_url);
                        sParaTemp.Add("anti_phishing_key", Config.anti_phishing_key);
                        sParaTemp.Add("exter_invoke_ip", Config.exter_invoke_ip);
                        sParaTemp.Add("out_trade_no", out_trade_no);
                        sParaTemp.Add("subject", subject);
                        sParaTemp.Add("total_fee", total_fee);
                        sParaTemp.Add("body", body);
                        sParaTemp.Add("it_b_pay", it_b_pay);


                        #endregion
                        string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                        Response.Write(sHtmlText);
                    }
                        #endregion
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception Exc)
            {
                return(Content(Exc.ToString()));
            }
            return(Content(ConstantHelper.Success));
        }
예제 #2
0
    protected void BtnAlipay_Click(object sender, EventArgs e)
    {
        ////////////////////////////////////////////请求参数////////////////////////////////////////////

        //服务器异步通知页面路径
        string notify_url = "http://商户网关地址/cae_charge_agent-CSHARP-UTF-8/notify_url.aspx";
        //需http://格式的完整路径,不允许加?id=123这类自定义参数

        //商户订单号
        string out_order_no = WIDout_order_no.Text.Trim();
        //商户网站唯一订单号(商户自定义)

        //金额
        string amount = WIDamount.Text.Trim();
        //代扣订单金额

        //支付宝标题
        string subject = WIDsubject.Text.Trim();
        //订单名称摘要

        //转出支付宝账号
        string trans_account_out = WIDtrans_account_out.Text.Trim();
        //转出的支付宝人民币资金账号(user_id+0156)【该字段还可传递支付宝登录账户(邮箱或手机号)】

        //转入支付宝账号
        string trans_account_in = WIDtrans_account_in.Text.Trim();
        //转入的支付宝人民币资金账号(user_id+0156)【该字段还可传递支付宝登录账户(邮箱或手机号)】

        //代扣模式
        string charge_type = WIDcharge_type.Text.Trim();
        //机票代扣时走的是交易模式(固定值为:trade)

        //代理业务编号
        string type_code = WIDtype_code.Text.Trim();
        //唯一标识商户和支付宝签署的某项业务码(机票CAE代扣的type_code为pid+1000310004)


        ////////////////////////////////////////////////////////////////////////////////////////////////

        //把请求参数打包成数组
        SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

        sParaTemp.Add("partner", Config.Partner);
        sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
        sParaTemp.Add("service", "cae_charge_agent");
        sParaTemp.Add("notify_url", notify_url);
        sParaTemp.Add("out_order_no", out_order_no);
        sParaTemp.Add("amount", amount);
        sParaTemp.Add("subject", subject);
        sParaTemp.Add("trans_account_out", trans_account_out);
        sParaTemp.Add("trans_account_in", trans_account_in);
        sParaTemp.Add("charge_type", charge_type);
        sParaTemp.Add("type_code", type_code);

        //建立请求
        string sHtmlText = Submit.BuildRequest(sParaTemp);

        //请在这里加上商户的业务逻辑程序代码

        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——

        XmlDocument xmlDoc = new XmlDocument();

        try
        {
            xmlDoc.LoadXml(sHtmlText);
            string strXmlResponse = xmlDoc.SelectSingleNode("/alipay").InnerText;
            Response.Write(strXmlResponse);
        }
        catch (Exception exp)
        {
            Response.Write(sHtmlText);
        }

        //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
    }
예제 #3
0
        /// <summary>
        /// 支付
        /// </summary>
        public ActionResult Pay()
        {
            //订单id列表
            string oidList = WebHelper.GetQueryString("oidList");

            decimal          allSurplusMoney = 0M;
            List <OrderInfo> orderList       = new List <OrderInfo>();

            foreach (string oid in StringHelper.SplitString(oidList))
            {
                //订单信息
                OrderInfo orderInfo = Orders.GetOrderByOid(TypeHelper.StringToInt(oid));
                if (orderInfo != null && orderInfo.OrderState == (int)OrderState.WaitPaying && orderInfo.PayMode == 1)
                {
                    orderList.Add(orderInfo);
                }
                else
                {
                    return(Redirect("/mob"));
                }
                allSurplusMoney += orderInfo.SurplusMoney;
            }

            if (orderList.Count < 1 || allSurplusMoney == 0M)
            {
                return(Redirect("/mob"));
            }

            //支付类型
            string payment_type = "1";

            //服务器异步通知页面路径,需http://格式的完整路径,不能加?id=123这类自定义参数
            string notify_url = string.Format("http://{0}/mob/alipay/notify", BMAConfig.MallConfig.SiteUrl);
            //页面跳转同步通知页面路径,需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
            string return_url = string.Format("http://{0}/mob/alipay/return", BMAConfig.MallConfig.SiteUrl);

            //商户订单号
            string out_trade_no = oidList + Randoms.CreateRandomValue(10, false);
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = BMAConfig.MallConfig.SiteTitle + "购物";
            //必填

            //付款金额
            string total_fee = allSurplusMoney.ToString();
            //必填

            //商品展示地址
            string show_url = string.Format("http://{0}/images/alipay.jgp", BMAConfig.MallConfig.SiteUrl);
            //必填,需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html

            //订单描述
            string body = "";
            //选填

            //超时时间
            string it_b_pay = "";
            //选填

            //钱包token
            string extern_token = "";
            //选填


            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("seller_id", Config.Seller_id);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "alipay.wap.create.direct.pay.by.user");
            sParaTemp.Add("payment_type", payment_type);
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("return_url", return_url);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", subject);
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("show_url", show_url);
            sParaTemp.Add("body", body);
            sParaTemp.Add("it_b_pay", it_b_pay);
            sParaTemp.Add("extern_token", extern_token);

            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");

            return(Content(sHtmlText));
        }
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[OrderF2F]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            OrderF2F OrderF2F = new OrderF2F();

            OrderF2F = JsonToObject.ConvertJsonToModel(OrderF2F, json);

            UserTrack UserTrack = new UserTrack();

            UserTrack = JsonToObject.ConvertJsonToModel(UserTrack, json);

            #region 获取并处理用户信息
            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == OrderF2F.Token);
            if (baseUsers == null)//用户令牌不存在
            {
                DataObj.OutError("2004");
                return;
            }
            if (baseUsers.State != 1)//用户被锁定
            {
                DataObj.OutError("2003");
                return;
            }
            if (baseUsers.CardStae != 2)//未实名认证
            {
                //DataObj.OutError("2006");
                //return;
            }
            if (baseUsers.MiBao != 1)//未设置支付密码
            {
                //DataObj.OutError("2008");
                //return;
            }
            string NeekName = baseUsers.NeekName;
            if (NeekName.IsNullOrEmpty())
            {
                NeekName = baseUsers.TrueName;
            }
            if (NeekName.IsNullOrEmpty())
            {
                NeekName = "货款";
            }
            #endregion

            if (OrderF2F.Action == "Create")
            {
                int    PayWay  = OrderF2F.PayWay;
                string Tag     = "";
                byte   PayType = 0;
                string PayName = "";

                if (OrderF2F.OType == 7)
                {//支付宝
                    Tag     = "AliPay";
                    PayName = "条码付-";
                }
                if (OrderF2F.OType == 8)
                {//微信
                    Tag     = "WeiXin";
                    PayName = "刷卡付-";
                }
                if (PayWay.IsNullOrEmpty())
                {
                    if (Tag == "AliPay")
                    {
                        PayWay = 5;//兼容老版本
                    }
                    if (Tag == "WeiXin")
                    {
                        PayWay = 6;//兼容老版本
                    }
                }
                PayConfig PayConfig = Entity.PayConfig.FirstOrDefault(n => n.Id == PayWay && n.State == 1);
                //获取系统支付配置
                if (PayConfig == null)
                {
                    DataObj.OutError("1000");
                    return;
                }
                if (PayConfig.GroupType != Tag)
                {
                    DataObj.OutError("1000");
                    return;
                }
                PayName += PayConfig.Name;

                int InType = 0;
                if (!OrderF2F.InType.IsNullOrEmpty())
                {
                    InType = 1;
                }

                SysControl SysControl = new SysControl();

                #region 版本比较 升级之后比较长时间后可以考滤删除版本判断代码
                bool IsNew     = true;
                var  vSysAgent = this.Entity.SysAgent.FirstOrDefault(o => o.Id == baseUsers.Agent);
                if (vSysAgent == null)
                {
                    DataObj.OutError("1000");
                    return;
                }
                IsNew = BizExt.NewOrOldVersion(vSysAgent, Equipment, this.Entity);
                #endregion
                if (IsNew)//新版
                {
                    if (InType == 1)
                    {
                        SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay && n.LagEntryDay > 0);
                    }
                    else
                    {
                        SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay && n.LagEntryDay == 0);
                    }
                }
                else
                {
                    //旧版
                    SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag && n.PayWay == PayWay);
                    if (SysControl.LagEntryDay > 0)
                    {
                        InType = 1;
                    }
                    else
                    {
                        InType = 0;
                    }
                }
                //获取系统支付配置
                if (SysControl == null)
                {
                    DataObj.OutError("1005");
                    return;
                }
                if (InType == 1 && (SysControl.LagEntryDay.IsNullOrEmpty() || SysControl.LagEntryNum.IsNullOrEmpty()))
                {
                    DataObj.Msg = "请升级到最新版再发起Tn到帐交易!";
                    DataObj.OutError("1005");
                    return;
                }
                SysControl syscontrol = SysControl.ChkState();
                if (syscontrol.State != 1)
                {
                    DataObj.OutError("1005");
                    return;
                }

                #region 创建订单
                //处理交易地点
                if (OrderF2F.X.IsNullOrEmpty() || OrderF2F.Y.IsNullOrEmpty())
                {
                    DataObj.OutError("1000");
                    return;
                }
                //开始处理参数 PayId扣款码,OType通道,7支付宝,8微信
                if (OrderF2F.Amoney.IsNullOrEmpty() || OrderF2F.PayId.IsNullOrEmpty() || OrderF2F.OType.IsNullOrEmpty())
                {
                    DataObj.OutError("1000");
                    return;
                }

                OrderF2F.Amoney = OrderF2F.Amoney.FormatMoney();

                //获取用户支付配置
                UserPay UserPay = Entity.UserPay.FirstOrDefault(n => n.UId == baseUsers.Id && n.PId == PayWay);
                if (UserPay == null)
                {
                    DataObj.OutError("1000");
                    return;
                }
                //获取分支机构信息
                SysAgent SysAgent = new SysAgent();
                if (!baseUsers.Agent.IsNullOrEmpty())
                {
                    SysAgent = Entity.SysAgent.FirstOrNew(n => n.Id == baseUsers.Agent);
                }

                OrderF2F.PayWay = PayWay;
                //获取系统配置
                SysSet SysSet = Entity.SysSet.FirstOrDefault();
                if (InType == 1)
                {//客户端传来T+N但是系统没开启时无效
                    if (SysSet.LagEntry == 0)
                    {
                        InType = 0;
                    }
                }
                if (InType == 1)
                {
                    //手续费
                    OrderF2F.Poundage = 0;
                    //商户费率
                    OrderF2F.UserRate = 0;
                    //T+n时,代理佣金为 交易金额*费率
                    decimal AgentPayGet = OrderF2F.Amoney * SysSet.AgentGet;
                    OrderF2F.AgentPayGet = (Double)AgentPayGet;
                    //佣金舍位
                    OrderF2F.AgentPayGet = OrderF2F.AgentPayGet.Floor();
                }
                else
                {
                    //手续费
                    OrderF2F.Poundage = OrderF2F.Amoney * (decimal)UserPay.Cost;
                    //手续费取进
                    OrderF2F.Poundage = OrderF2F.Poundage.Ceiling();
                    //商户费率
                    OrderF2F.UserRate = UserPay.Cost;
                    //分支机构佣金设置为0,待分润计算后再写入
                    OrderF2F.AgentPayGet = 0;
                }

                OrderF2F.UId = baseUsers.Id;
                //到帐金额=支付金额-手续费
                OrderF2F.PayMoney = OrderF2F.Amoney - OrderF2F.Poundage;
                //第三方支付通道率
                OrderF2F.SysRate = (double)PayConfig.Cost;

                //这里是利润计算==========
                //利润=总金额-到帐-支付手续费
                decimal GetAll = OrderF2F.Amoney - OrderF2F.PayMoney - OrderF2F.Amoney * (decimal)OrderF2F.SysRate;
                //利润舍位
                GetAll = GetAll.Floor();
                //总利润
                OrderF2F.AIdPayGet = (double)GetAll;

                OrderF2F.Agent      = SysAgent.Id;//分支机构Id
                OrderF2F.AId        = baseUsers.AId;
                OrderF2F.FId        = 0;
                OrderF2F.OrderState = 1;
                OrderF2F.PayState   = 0;
                OrderF2F.AgentState = 0;
                OrderF2F.AddTime    = DateTime.Now;

                //写入前,判断交易金额限制
                if (OrderF2F.Amoney < syscontrol.SNum || OrderF2F.Amoney > syscontrol.ENum)
                {
                    DataObj.OutError("1006");
                    return;
                }
                //写入订单总表
                Orders Orders = new Orders();
                Orders.UId   = OrderF2F.UId;
                Orders.TName = NeekName;

                Orders.PayType = PayType;
                Orders.PayName = PayName;

                Orders.RUId     = 0;
                Orders.RName    = string.Empty;
                Orders.TType    = OrderF2F.OType;
                Orders.TState   = 1;
                Orders.Amoney   = OrderF2F.Amoney;
                Orders.Poundage = OrderF2F.Poundage;
                Orders.AddTime  = DateTime.Now;
                Orders.PayState = 0;
                Orders.PayWay   = PayConfig.Id;

                Orders.Agent      = OrderF2F.Agent;
                Orders.AgentState = 0;
                Orders.AId        = OrderF2F.AId;
                Orders.FId        = 0;
                Orders.ComeWay    = 1;

                string OrderAddress = OrderF2F.OrderAddress;
                if (OrderAddress.IsNullOrEmpty())
                {
                    OrderAddress = Utils.GetAddressByGPS(OrderF2F.X, OrderF2F.Y);
                }
                Orders.OrderAddress = OrderAddress;
                Orders.X            = OrderF2F.X;
                Orders.Y            = OrderF2F.Y;

                if (InType == 1)
                {
                    if (IsNew)//新版
                    {
                        Orders.LagEntryDay = SysControl.LagEntryDay;
                        Orders.LagEntryNum = SysControl.LagEntryNum;
                    }
                    else
                    {
                        Orders.LagEntryDay = SysSet.LagEntryDay;
                        Orders.LagEntryNum = SysSet.LagEntryNum;
                    }
                }
                else
                {
                    Orders.LagEntryDay = 0;
                    Orders.LagEntryNum = 0;
                }

                Entity.Orders.AddObject(Orders);
                Entity.SaveChanges();
                Entity.Refresh(RefreshMode.StoreWins, Orders);

                OrderF2F.OId = Orders.TNum;
                Entity.OrderF2F.AddObject(OrderF2F);
                Entity.SaveChanges();

                //=======================================
                UserTrack.ENo        = DataObj.ENo;
                UserTrack.OPType     = Orders.PayName;
                UserTrack.UserName   = Orders.TNum;
                UserTrack.GPSAddress = Orders.OrderAddress;
                UserTrack.GPSX       = Orders.X;
                UserTrack.GPSY       = Orders.Y;
                if (!OrderF2F.IP.IsNullOrEmpty())
                {
                    UserTrack.IP = OrderF2F.IP;
                }
                Orders.SeavGPSLog(UserTrack, Entity);
                //=======================================

                #endregion

                if (PayConfig.DllName == "AliPay")
                {
                    #region 支付宝调用支付
                    string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' });    //接口信息 商户号,密钥,支付宝号
                    if (PayConfigArr.Length != 3)
                    {
                        DataObj.OutError("9999");
                        return;
                    }
                    if (AlipayVer == "1.0")
                    {
                        #region 1.0老接口
                        Submit Submit = new Submit();
                        Submit.pid = PayConfigArr[0];
                        Submit.key = PayConfigArr[1];
                        //卖家支付宝帐户
                        string seller_email = PayConfigArr[2];

                        //订单业务类型
                        string product_code = "BARCODE_PAY_OFFLINE";
                        //SOUNDWAVE_PAY_OFFLINE:声波支付,FINGERPRINT_FAST_PAY:指纹支付,BARCODE_PAY_OFFLINE:条码支付

                        string dynamic_id_type = "qrcode";    //动态ID类型 soundwave:声波,qrcode:二维码,barcode:条码


                        ////////////////////////////////////////////////////////////////////////////////////////////////

                        //把请求参数打包成数组
                        SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                        sParaTemp.Add("partner", Submit.pid);
                        sParaTemp.Add("_input_charset", "utf-8");
                        sParaTemp.Add("service", "alipay.acquire.createandpay");
                        sParaTemp.Add("seller_email", seller_email);
                        sParaTemp.Add("out_trade_no", OrderF2F.OId);
                        sParaTemp.Add("subject", Orders.TName + ":" + OrderF2F.OId);
                        sParaTemp.Add("total_fee", OrderF2F.Amoney.ToString("F2"));
                        sParaTemp.Add("product_code", product_code);
                        sParaTemp.Add("dynamic_id_type", dynamic_id_type);
                        sParaTemp.Add("dynamic_id", OrderF2F.PayId);

                        sParaTemp.Add("notify_url", NoticePath + "/PayCenter/AliPay/Notice.html");
                        //建立请求
                        string sHtmlText = Submit.BuildRequest(sParaTemp);
                        //Utils.WriteLog(sHtmlText);
                        try
                        {
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(sHtmlText);
                            string is_success = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText;
                            if (is_success == "T")
                            {
                                string trade_no    = xmlDoc.SelectSingleNode("/alipay/response/alipay/trade_no").InnerText;
                                string result_code = xmlDoc.SelectSingleNode("/alipay/response/alipay/result_code").InnerText;
                                if (result_code == "ORDER_SUCCESS_PAY_SUCCESS")
                                {    //成功
                                    OrderF2F.Trade_no = trade_no;
                                    Entity.SaveChanges();
                                    Orders = Orders.PaySuccess(Entity);
                                }
                                else if (result_code == "ORDER_SUCCESS_PAY_INPROCESS")    //返回支付处理中,需要进行轮询
                                {
                                    //此处立马返回
                                    OrderF2F.Trade_no = trade_no;
                                    Entity.SaveChanges();
                                }
                                else
                                {
                                    AliPayApi Api = new AliPayApi();
                                    Api.AlipayCancel(Orders.TNum, Submit.pid, Submit.key);    //交易异常,取消交易

                                    Orders.TState       = 0;
                                    OrderF2F.OrderState = 0;
                                    Entity.SaveChanges();
                                }
                            }
                            else
                            {
                                Orders.TState       = 0;
                                OrderF2F.OrderState = 0;
                                Entity.SaveChanges();
                            }
                        }
                        catch (Exception Ex)
                        {
                            //Utils.WriteLog(Ex.ToString());
                            Orders.TState       = 0;
                            OrderF2F.OrderState = 0;
                            Entity.SaveChanges();
                        }
                        #endregion
                    }
                    if (AlipayVer == "2.0")
                    {
                        #region 2.0新接口

                        ALF2FPAY ALF2FPAY = new ALF2FPAY();
                        ALF2FPAY.pid   = PayConfigArr[0];
                        ALF2FPAY.appId = PayConfigArr[2];
                        IAopClient    client = new DefaultAopClient(ALF2FPAY.serverUrl, ALF2FPAY.appId, ALF2FPAY.merchant_private_key, "json", ALF2FPAY.version, ALF2FPAY.sign_type, ALF2FPAY.alipay_public_key, ALF2FPAY.charset);
                        StringBuilder sb     = new StringBuilder();
                        sb.Append("{\"out_trade_no\":\"" + OrderF2F.OId + "\",");
                        sb.Append("\"scene\":\"bar_code\",");
                        sb.Append("\"auth_code\":\"" + OrderF2F.PayId + "\",");
                        sb.Append("\"total_amount\":\"" + OrderF2F.Amoney.ToMoney() + "\",");
                        sb.Append("\"subject\":\"" + Orders.TName + ":" + OrderF2F.OId + "\",");
                        string expire_time = System.DateTime.Now.AddMinutes(30).ToString("yyyy-MM-dd HH:mm:ss");
                        sb.Append("\"time_expire\":\"" + expire_time + "\"}");
                        AlipayTradePayRequest payRequst = new AlipayTradePayRequest();
                        payRequst.BizContent = sb.ToString();
                        Dictionary <string, string> paramsDict  = (Dictionary <string, string>)payRequst.GetParameters();
                        AlipayTradePayResponse      payResponse = client.Execute(payRequst);
                        if (payResponse != null)
                        {
                            payResponse.SaveLog(Entity);    //保存记录

                            switch (payResponse.Code)
                            {
                            case "10000":        //成功
                                OrderF2F.Trade_no = payResponse.TradeNo;
                                Entity.SaveChanges();
                                Orders = Orders.PaySuccess(Entity);
                                break;

                            case "10003":        //返回支付处理中,需要进行轮询
                                OrderF2F.Trade_no = payResponse.TradeNo;
                                Entity.SaveChanges();
                                break;

                            case "20000":        //交易异常,取消交易

                                string      CancelStr = "{\"out_trade_no\":\"" + Orders.TNum + "\"}";
                                ALF2FPAYObj ObjCancel = new ALF2FPAYObj();
                                ObjCancel.BizCode = CancelStr;
                                ObjCancel.Client  = client;
                                AliPayApi Api = new AliPayApi();
                                Api.AlipayCancel(ObjCancel);

                                Orders.TState       = 0;
                                OrderF2F.OrderState = 0;
                                Entity.SaveChanges();

                                break;

                            case "40004":        //返回失败
                                Orders.TState       = 0;
                                OrderF2F.OrderState = 0;
                                Entity.SaveChanges();
                                break;
                            }
                        }
                        #endregion
                    }
                    #endregion
                }

                if (PayConfig.DllName == "WeiXin")
                {
                    #region 微信调用支付
                    //初始化支付配置
                    WxPayConfig WxPayConfig  = new WxPayConfig();
                    string[]    PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 appid,mchid,key,appsecret
                    if (PayConfigArr.Length != 4 && PayConfigArr.Length != 5)
                    {
                        DataObj.OutError("9999");
                        return;
                    }
                    string ServerIp     = ConfigurationManager.AppSettings["ServerIp"].ToString();
                    string Wx_Cert_Path = ConfigurationManager.AppSettings["Wx_Cert_Path"].ToString();
                    string Wx_Cert_PWD  = ConfigurationManager.AppSettings["Wx_Cert_PWD"].ToString();
                    WxPayConfig.IP        = ServerIp;
                    WxPayConfig.APPID     = PayConfigArr[0];
                    WxPayConfig.MCHID     = PayConfigArr[1];
                    WxPayConfig.KEY       = PayConfigArr[2];
                    WxPayConfig.APPSECRET = PayConfigArr[3];
                    if (PayConfigArr.Length == 5)
                    {
                        WxPayConfig.SubMCHID = PayConfigArr[4];
                    }
                    WxPayConfig.SSLCERT_PATH     = Wx_Cert_Path;
                    WxPayConfig.SSLCERT_PASSWORD = Wx_Cert_PWD;
                    //支付配置结束

                    WxPayData data = new WxPayData();
                    data.SetValue("auth_code", OrderF2F.PayId);               //授权码
                    data.SetValue("body", Orders.TName + ":" + OrderF2F.OId); //商品描述

                    string total_fee = (OrderF2F.Amoney * 100).ToString("F0");

                    data.SetValue("total_fee", total_fee);                       //总金额
                    data.SetValue("out_trade_no", OrderF2F.OId);                 //产生随机的商户订单号

                    WxPayData result = WxPayApi.Micropay(data, WxPayConfig, 10); //提交被扫支付,接收返回结果
                    result.SaveLog(Entity);

                    if (!result.IsSet("return_code") || result.GetValue("return_code").ToString() == "FAIL")
                    {    //支付失败
                        Orders.TState       = 0;
                        OrderF2F.OrderState = 0;
                        Entity.SaveChanges();
                    }
                    else
                    {
                        if (!result.CheckSign(WxPayConfig.KEY))
                        {    //签名失败,取消订单
                            Orders.TState       = 0;
                            OrderF2F.OrderState = 0;
                            Entity.SaveChanges();
                        }
                        else
                        {
                            if (result.GetValue("return_code").ToString() == "SUCCESS" && result.GetValue("result_code").ToString() == "SUCCESS")
                            {    //直接支付成功
                                OrderF2F.Trade_no = result.GetValue("transaction_id").ToString();
                                Entity.SaveChanges();
                                Orders = Orders.PaySuccess(Entity);
                            }
                            else
                            {
                                if (result.GetValue("err_code").ToString() != "USERPAYING" && result.GetValue("err_code").ToString() != "SYSTEMERROR")
                                {    //业务明确失败
                                    Orders.TState       = 0;
                                    OrderF2F.OrderState = 0;
                                    Entity.SaveChanges();
                                }
                                else
                                {     //需要查单
                                }
                            }
                        }
                    }
                    #endregion
                }

                #region 提交好付
                if (PayConfig.DllName == "HFAliPay" || PayConfig.DllName == "HFWeiXin")
                {
                    string NoticeUrl = "";
                    string Action    = "";
                    if (PayConfig.DllName == "HFAliPay")
                    {
                        NoticeUrl = NoticePath + "/PayCenter/HFAliPay/Notice.html";
                        Action    = "AliCode";
                    }
                    if (PayConfig.DllName == "HFWeiXin")
                    {
                        NoticeUrl = NoticePath + "/PayCenter/HFWeiXin/Notice.html";
                        Action    = "WxCode";
                    }
                    string[] PayConfigArr = PayConfig.QueryArray.Split(',');
                    if (PayConfigArr.Length != 3)
                    {
                        DataObj.OutError("1000");
                        return;
                    }
                    //提交结算中心
                    string merId    = PayConfigArr[0]; //商户号
                    string merKey   = PayConfigArr[1]; //商户密钥
                    string JsPayWay = PayConfigArr[2]; //绑定通道

                    string  orderId    = Orders.TNum;  //商户流水号
                    decimal money      = Orders.Amoney * 100;
                    long    intmoney   = Int64.Parse(money.ToString("F0"));
                    string  OrderMoney = intmoney.ToString();//金额,以分为单

                    string PostJson = "{\"action\":\"" + Action + "\",\"txnamt\":\"" + OrderMoney + "\",\"merid\":\"" + merId + "\",\"payway\":\"" + JsPayWay + "\",\"orderid\":\"" + orderId + "\",\"backurl\":\"" + NoticeUrl + "\",\"code\":\"" + OrderF2F.PayId + "\"}";

                    string DataBase64 = LokFuEncode.Base64Encode(PostJson, "utf-8");
                    string Sign       = (DataBase64 + merKey).GetMD5();

                    DataBase64 = HttpUtility.UrlEncode(DataBase64);
                    string PostData = string.Format("req={0}&sign={1}", DataBase64, Sign);

                    string HF_Url = "https://api.zhifujiekou.com/api/mpgateway";

                    string Ret = Utils.PostRequest(HF_Url, PostData, "utf-8");

                    JObject JS = new JObject();
                    try
                    {
                        JS = (JObject)JsonConvert.DeserializeObject(Ret);
                    }
                    catch (Exception Ex)
                    {
                        Log.Write("[Order_HF]:", "【Ret】" + Ret, Ex);
                    }
                    if (JS == null)
                    {
                        DataObj.OutError("1000");
                        return;
                    }
                    string resp = JS["resp"].ToString();
                    Ret = LokFuEncode.Base64Decode(resp, "utf-8");
                    try
                    {
                        JS = (JObject)JsonConvert.DeserializeObject(Ret);
                    }
                    catch (Exception Ex)
                    {
                        Log.Write("[Order_HF]:", "【Ret2】" + Ret, Ex);
                    }
                    if (JS == null)
                    {
                        DataObj.OutError("1000");
                        return;
                    }
                    string respcode = JS["respcode"].ToString();
                    if (respcode != "00")
                    {
                        string respmsg = JS["respmsg"].ToString();
                        DataObj.OutError("1000");
                        Utils.WriteLog("[Order_HF_Err]:【" + respcode + "】" + respmsg, "orderface");
                        return;
                    }
                }
                #endregion

                DataObj.Data = Orders.OutJson();
                DataObj.Code = "0000";
                DataObj.OutString();
            }
            if (OrderF2F.Action == "GET")//获取订交易信息
            {
                //开始处理参数
                if (OrderF2F.OId.IsNullOrEmpty())
                {
                    DataObj.OutError("1000");
                    return;
                }
                Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == OrderF2F.OId && n.UId == baseUsers.Id);
                if (Orders == null)
                {
                    DataObj.OutError("1000");
                    return;
                }
                OrderF2F  Orderf2f  = Entity.OrderF2F.FirstOrDefault(n => n.OId == OrderF2F.OId && n.UId == baseUsers.Id);
                PayConfig PayConfig = Entity.PayConfig.FirstOrNew(n => n.Id == Orders.PayWay);
                if (Orders.TState == 1 && Orders.PayState == 0)
                {
                    if (PayConfig.DllName == "AliPay")
                    {
                        #region 支付宝处理
                        string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' });    //接口信息 商户号,密钥,APPId
                        if (PayConfigArr.Length != 3)
                        {
                            DataObj.OutError("9999");
                            return;
                        }
                        if (AlipayVer == "1.0")
                        {
                            #region 1.0老接口
                            string pid        = PayConfigArr[0];
                            string key        = PayConfigArr[1];
                            int    queryTimes = 10; //查询次数计数器
                            int    Run        = 0;
                            while (queryTimes > 0 && Run != 1)
                            {
                                AliPayApi Api        = new AliPayApi();
                                int       succResult = Api.AliPayQuery(Orderf2f.OId, pid, key);
                                //如果需要继续查询,则等待2s后继续
                                if (succResult == 2)
                                {
                                    //Thread.Sleep(5000);
                                    //continue;
                                    Run = 1;    //跳出循环,20160420
                                }
                                //查询成功,返回订单查询接口返回的数据
                                else if (succResult == 1)
                                {
                                    Orders = Orders.PaySuccess(Entity);
                                    Run    = 1;
                                }
                                //订单交易失败
                                else
                                {
                                    Orders.TState       = 0;
                                    Orderf2f.OrderState = 0;
                                    Entity.SaveChanges();
                                }
                                queryTimes--;
                            }
                            #endregion
                        }
                        if (AlipayVer == "2.0")
                        {
                            #region 2.0新接口
                            ALF2FPAY ALF2FPAY = new ALF2FPAY();
                            ALF2FPAY.pid   = PayConfigArr[0];
                            ALF2FPAY.appId = PayConfigArr[2];

                            IAopClient client = new DefaultAopClient(ALF2FPAY.serverUrl, ALF2FPAY.appId, ALF2FPAY.merchant_private_key, "json", ALF2FPAY.version, ALF2FPAY.sign_type, ALF2FPAY.alipay_public_key, ALF2FPAY.charset);

                            string      QueryStr = "{\"out_trade_no\":\"" + Orders.TNum + "\"}";
                            ALF2FPAYObj ObjQuery = new ALF2FPAYObj();
                            ObjQuery.BizCode = QueryStr;
                            ObjQuery.Client  = client;
                            ObjQuery.Entity  = Entity;
                            AliPayApi Api = new AliPayApi();
                            AlipayTradeQueryResponse queryResponse = Api.LoopAlipayQuery(ObjQuery);
                            if (queryResponse != null)
                            {
                                if (queryResponse.Code == "10000")
                                {
                                    if (queryResponse.TradeStatus == "TRADE_FINISHED" || queryResponse.TradeStatus == "TRADE_SUCCESS")
                                    {
                                        Orders = Orders.PaySuccess(Entity);
                                    }
                                }
                            }
                            #endregion
                        }

                        #endregion
                    }
                    if (PayConfig.DllName == "WeiXin")
                    {
                        #region 微信处理
                        //初始化支付配置
                        WxPayConfig WxPayConfig  = new WxPayConfig();
                        string[]    PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 appid,mchid,key,appsecret
                        if (PayConfigArr.Length != 4 && PayConfigArr.Length != 5)
                        {
                            DataObj.OutError("9999");
                            return;
                        }
                        string ServerIp     = ConfigurationManager.AppSettings["ServerIp"].ToString();
                        string Wx_Cert_Path = ConfigurationManager.AppSettings["Wx_Cert_Path"].ToString();
                        string Wx_Cert_PWD  = ConfigurationManager.AppSettings["Wx_Cert_PWD"].ToString();
                        WxPayConfig.IP        = ServerIp;
                        WxPayConfig.APPID     = PayConfigArr[0];
                        WxPayConfig.MCHID     = PayConfigArr[1];
                        WxPayConfig.KEY       = PayConfigArr[2];
                        WxPayConfig.APPSECRET = PayConfigArr[3];
                        if (PayConfigArr.Length == 5)
                        {
                            WxPayConfig.SubMCHID = PayConfigArr[4];
                        }
                        WxPayConfig.SSLCERT_PATH     = Wx_Cert_Path;
                        WxPayConfig.SSLCERT_PASSWORD = Wx_Cert_PWD;
                        //支付配置结束
                        int queryTimes = 10;    //查询次数计数器
                        int Run        = 0;
                        while (queryTimes > 0 && Run != 1)
                        {
                            int       succResult  = 0;//查询结果
                            MicroPay  MicroPay    = new MicroPay();
                            WxPayData queryResult = MicroPay.WXQuery(Orderf2f.OId, WxPayConfig, Entity, out succResult);
                            //如果需要继续查询,则等待2s后继续
                            if (succResult == 2)
                            {
                                //Thread.Sleep(5000);
                                //continue;
                                Run = 1;    //跳出循环,20160420
                            }
                            //查询成功,返回订单查询接口返回的数据
                            else if (succResult == 1)
                            {
                                Orderf2f.Trade_no = queryResult.GetValue("transaction_id").ToString();
                                int ret = Entity.SaveChanges();
                                Orders = Orders.PaySuccess(Entity);
                                Run    = 1;
                            }
                            //订单交易失败
                            else
                            {
                                Orders.TState       = 0;
                                Orderf2f.OrderState = 0;
                                Entity.SaveChanges();
                            }
                            queryTimes--;
                        }
                        #endregion
                    }
                    if (PayConfig.DllName == "HFAliPay" || PayConfig.DllName == "HFWeiXin")
                    {
                        #region 好付处理
                        string[] QueryArr = PayConfig.QueryArray.Split(',');
                        if (QueryArr.Length == 3)
                        {
                            //提交结算中心
                            string merId      = QueryArr[0]; //商户号
                            string merKey     = QueryArr[1]; //商户密钥
                            string orderId    = Orders.TNum; //商户流水号
                            string PostJson   = "{\"merid\":\"" + merId + "\",\"orderid\":\"" + orderId + "\"}";
                            string DataBase64 = LokFuEncode.Base64Encode(PostJson, "utf-8");
                            string Sign       = (DataBase64 + merKey).GetMD5();
                            DataBase64 = HttpUtility.UrlEncode(DataBase64);
                            string PostData = string.Format("req={0}&sign={1}", DataBase64, Sign);
                            string HF_Url   = "https://api.zhifujiekou.com/api/query";
                            string Ret      = Utils.PostRequest(HF_Url, PostData, "utf-8");

                            JObject JS = new JObject();
                            try
                            {
                                JS = (JObject)JsonConvert.DeserializeObject(Ret);
                            }
                            catch (Exception Ex)
                            {
                                Log.Write("[Order_HFQuery]:", "【Ret】" + Ret, Ex);
                            }
                            if (JS == null)
                            {
                                DataObj.OutError("1000");
                                return;
                            }
                            string resp = JS["resp"].ToString();
                            Ret = LokFuEncode.Base64Decode(resp, "utf-8");
                            try
                            {
                                JS = (JObject)JsonConvert.DeserializeObject(Ret);
                            }
                            catch (Exception Ex)
                            {
                                Log.Write("[Order_HFQuery]:", "【Ret2】" + Ret, Ex);
                            }
                            if (JS == null)
                            {
                                DataObj.OutError("1000");
                                return;
                            }
                            string respcode = JS["respcode"].ToString();
                            if (respcode != "00")
                            {
                                string respmsg = JS["respmsg"].ToString();
                                DataObj.OutError("1000");
                                Utils.WriteLog("[Order_HFQuery_Err]:【" + respcode + "】" + respmsg, "orderface");
                                return;
                            }
                            string resultcode = JS["resultcode"].ToString();
                            if (resultcode == "0000" || resultcode == "1002" || resultcode == "1004")
                            {
                                string txnamt    = JS["txnamt"].ToString();
                                int    factmoney = int.Parse(txnamt);
                                if (((int)(Orders.Amoney * 100)) == factmoney)
                                {
                                    Orders = Orders.PaySuccess(Entity);
                                }
                            }
                        }
                        #endregion
                    }
                }
                DataObj.Data = Orders.OutJson();
                DataObj.Code = "0000";
                DataObj.OutString();
            }
            if (OrderF2F.Action == "Cancel")//取消交易
            {
                //开始处理参数
                if (OrderF2F.OId.IsNullOrEmpty())
                {
                    DataObj.OutError("1000");
                    return;
                }
                Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == OrderF2F.OId && n.UId == baseUsers.Id);
                if (Orders == null)
                {
                    DataObj.OutError("1000");
                    return;
                }
                OrderF2F Orderf2f = Entity.OrderF2F.FirstOrDefault(n => n.OId == OrderF2F.OId && n.UId == baseUsers.Id);
                if (Orders.TState == 1 && Orders.PayState == 0)
                {
                    PayConfig PayConfig = Entity.PayConfig.FirstOrNew(n => n.Id == Orders.PayWay);
                    if (PayConfig.DllName == "AliPay")
                    {
                        #region 支付宝处理
                        string[] PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' });    //接口信息 商户号,密钥,支付宝号
                        if (PayConfigArr.Length != 3)
                        {
                            DataObj.OutError("9999");
                            return;
                        }
                        if (AlipayVer == "1.0")
                        {
                            #region 1.0老接口
                            string    pid = PayConfigArr[0];
                            string    key = PayConfigArr[1];
                            AliPayApi Api = new AliPayApi();
                            Api.AlipayCancel(Orders.TNum, pid, key);
                            #endregion
                        }
                        if (AlipayVer == "2.0")
                        {
                            #region 2.0新接口
                            ALF2FPAY ALF2FPAY = new ALF2FPAY();
                            ALF2FPAY.pid   = PayConfigArr[0];
                            ALF2FPAY.appId = PayConfigArr[2];
                            IAopClient  client    = new DefaultAopClient(ALF2FPAY.serverUrl, ALF2FPAY.appId, ALF2FPAY.merchant_private_key, "json", ALF2FPAY.version, ALF2FPAY.sign_type, ALF2FPAY.alipay_public_key, ALF2FPAY.charset);
                            string      CancelStr = "{\"out_trade_no\":\"" + Orders.TNum + "\"}";
                            ALF2FPAYObj ObjCancel = new ALF2FPAYObj();
                            ObjCancel.BizCode = CancelStr;
                            ObjCancel.Client  = client;
                            ObjCancel.Entity  = Entity;
                            AliPayApi Api = new AliPayApi();
                            Api.AlipayCancel(ObjCancel);
                            #endregion
                        }
                        #endregion
                    }
                    if (PayConfig.DllName == "WeiXin")
                    {
                        #region 微信处理
                        //初始化支付配置
                        WxPayConfig WxPayConfig  = new WxPayConfig();
                        string[]    PayConfigArr = PayConfig.QueryArray.Split(new char[] { ',' }); //接口信息 appid,mchid,key,appsecret
                        if (PayConfigArr.Length != 4 && PayConfigArr.Length != 5)
                        {
                            DataObj.OutError("9999");
                            return;
                        }
                        string ServerIp     = ConfigurationManager.AppSettings["ServerIp"].ToString();
                        string Wx_Cert_Path = ConfigurationManager.AppSettings["Wx_Cert_Path"].ToString();
                        string Wx_Cert_PWD  = ConfigurationManager.AppSettings["Wx_Cert_PWD"].ToString();
                        WxPayConfig.IP        = ServerIp;
                        WxPayConfig.APPID     = PayConfigArr[0];
                        WxPayConfig.MCHID     = PayConfigArr[1];
                        WxPayConfig.KEY       = PayConfigArr[2];
                        WxPayConfig.APPSECRET = PayConfigArr[3];
                        if (PayConfigArr.Length == 5)
                        {
                            WxPayConfig.SubMCHID = PayConfigArr[4];
                        }
                        WxPayConfig.SSLCERT_PATH     = Wx_Cert_Path;
                        WxPayConfig.SSLCERT_PASSWORD = Wx_Cert_PWD;
                        //支付配置结束
                        MicroPay MicroPay = new MicroPay();
                        MicroPay.WXCancel(OrderF2F.OId, WxPayConfig, Entity);    //取消订单,重试10次
                        #endregion
                    }
                    if (PayConfig.DllName == "HFAliPay" || PayConfig.DllName == "HFWeiXin")
                    {
                        #region 好付处理
                        string[] QueryArr = PayConfig.QueryArray.Split(',');
                        if (QueryArr.Length == 3)
                        {
                            //提交结算中心
                            string merId      = QueryArr[0]; //商户号
                            string merKey     = QueryArr[1]; //商户密钥
                            string orderId    = Orders.TNum; //商户流水号
                            string PostJson   = "{\"merid\":\"" + merId + "\",\"orderid\":\"" + orderId + "\"}";
                            string DataBase64 = LokFuEncode.Base64Encode(PostJson, "utf-8");
                            string Sign       = (DataBase64 + merKey).GetMD5();
                            DataBase64 = HttpUtility.UrlEncode(DataBase64);
                            string PostData = string.Format("req={0}&sign={1}", DataBase64, Sign);
                            string HF_Url   = "https://api.zhifujiekou.com/api/cancel";
                            string Ret      = Utils.PostRequest(HF_Url, PostData, "utf-8");

                            JObject JS = new JObject();
                            try
                            {
                                JS = (JObject)JsonConvert.DeserializeObject(Ret);
                            }
                            catch (Exception Ex)
                            {
                                Log.Write("[Order_HFCancel]:", "【Ret】" + Ret, Ex);
                            }
                            if (JS == null)
                            {
                                DataObj.OutError("1000");
                                return;
                            }
                            string resp = JS["resp"].ToString();
                            Ret = LokFuEncode.Base64Decode(resp, "utf-8");
                            try
                            {
                                JS = (JObject)JsonConvert.DeserializeObject(Ret);
                            }
                            catch (Exception Ex)
                            {
                                Log.Write("[Order_HFCancel]:", "【Ret2】" + Ret, Ex);
                            }
                            if (JS == null)
                            {
                                DataObj.OutError("1000");
                                return;
                            }
                            string respcode = JS["respcode"].ToString();
                            if (respcode != "00")
                            {
                                string respmsg = JS["respmsg"].ToString();
                                DataObj.OutError("1000");
                                Utils.WriteLog("[Order_HFQuery_Err]:【" + respcode + "】" + respmsg, "orderface");
                                return;
                            }
                        }
                        #endregion
                    }
                    Orders.TState       = 0;
                    Orderf2f.OrderState = 0;
                    Entity.SaveChanges();
                }
                DataObj.Data = Orders.OutJson();
                DataObj.Code = "0000";
                DataObj.OutString();
            }
        }
예제 #5
0
        public override void ProcessMessage()
        {
            #region
            //本地下载
            if (InObject.XIAZAILX == "1")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("分院代码不能为空");
                }
                OutObject = new ZHIFUBAOJSMXXZ_OUT();
                //每页固定查询50条
                int star = 1 + (int.Parse(InObject.PAGENO) - 1) * 50;
                int end  = 50 + (int.Parse(InObject.PAGENO) - 1) * 50;
                //分页数据
                var Listxx = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00016, InObject.RIQI, end, star, InObject.BASEINFO.FENYUANDM));
                //数据总量
                var TotalTb = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00017, InObject.RIQI, InObject.BASEINFO.FENYUANDM));
                OutObject.PAGENO   = InObject.PAGENO;
                OutObject.PAGESIZE = "50";
                ///判断是否还有数据没下载
                if (TotalTb.Rows.Count <= (int.Parse(InObject.PAGENO) - 1) * 3 + Listxx.Rows.Count)
                {
                    OutObject.HASNEXTPAGE = "F";
                }
                else
                {
                    OutObject.HASNEXTPAGE = "T";
                }
                if (Listxx.Rows.Count > 0)
                {
                    foreach (DataRow dr in Listxx.Rows)
                    {
                        ZHIFUBAOMX zfbdzmx = new ZHIFUBAOMX();
                        zfbdzmx.MERCHANTOUTORDERNO = dr["IOUTTRADENO"].ToString();
                        zfbdzmx.TOTALFEE           = dr["ITOTALFEE"].ToString();
                        if (dr["JIESUANZT"].ToString() == "1")
                        {
                            zfbdzmx.TRANSCODEMSG = "收费";
                        }
                        else if (dr["JIESUANZT"].ToString() == "3")
                        {
                            zfbdzmx.TRANSCODEMSG = "退费";
                        }
                        zfbdzmx.TRANSDATE = dr["QINGQIUSJ"].ToString();
                        zfbdzmx.CZYDM     = dr["CAOZUOYDM"].ToString();
                        zfbdzmx.CZYXM     = dr["CAOZUOYXM"].ToString();

                        zfbdzmx.TRADENO = dr["TRADENO"].ToString();
                        OutObject.ZHIFUBAOXZMX.Add(zfbdzmx);
                    }
                }
            }
            #endregion
            #region  载支付宝
            //下载支付宝
            else if (InObject.XIAZAILX == "2")
            {
                if (string.IsNullOrEmpty(InObject.BASEINFO.FENYUANDM))
                {
                    throw new Exception("分院代码不能为空");
                }
                DataTable dt = DBVisitor.ExecuteTable(SqlLoad.GetFormat(SQ.HIS00006, InObject.BASEINFO.FENYUANDM));
                if (dt.Rows.Count <= 0)
                {
                    throw new Exception("查询不到医院代码为【" + InObject.BASEINFO.FENYUANDM + "】的医院信息");
                }
                //先删除这一天的下载记录
                DBVisitor.ExecuteBool(SqlLoad.GetFormat(SQ.HIS00020, InObject.RIQI));
                //页号
                string page_no = InObject.PAGENO;
                //必填,必须是正整数
                //账务查询开始时间
                string gmt_start_time = DateTime.Parse(InObject.RIQI).ToString("yyyy-MM-dd 00:00:00");// WIDgmt_start_time.Text.Trim();
                //格式为:yyyy-MM-ddHH:mm:ss
                //账务查询结束时间
                string gmt_end_time = DateTime.Parse(InObject.RIQI).ToString("yyyy-MM-dd 23:59:59");;
                //格式为:yyyy-MM-ddHH:mm:ss

                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", dt.Rows[0]["PARTNER"].ToString());// Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "account.page.query");
                sParaTemp.Add("page_no", page_no);
                sParaTemp.Add("gmt_start_time", gmt_start_time);
                sParaTemp.Add("gmt_end_time", gmt_end_time);
                sParaTemp.Add("key", dt.Rows[0]["KEY"].ToString());
                //sParaTemp.Add("iw_account_log_id", InObject.IWACCOUNTLOGID);
                //sParaTemp.Add("trade_no", InObject.TRADENO);
                //sParaTemp.Add("merchant_out_order_no", InObject.MERCHANTOUTORDERNO);
                //sParaTemp.Add("deposit_bank_no", InObject.DEPOSITBANKNO);
                //sParaTemp.Add("page_size", InObject.PAGESIZE);

                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp);

                //请在这里加上商户的业务逻辑程序代码

                #region 支付宝错误码字典
                Dictionary <string, string> ErrDic = new Dictionary <string, string>();
                ErrDic.Add("REQUIRED_DATE", "起始和结束时间不能为空");
                ErrDic.Add("ILLEGAL_DATE_FORMAT", "起始和结束时间格式不正确");
                ErrDic.Add("ILLEGAL_DATE_TOO_LONG", "起始和结束时间间隔超过最大间隔");
                ErrDic.Add("START_DATE_AFTER_NOW", "起始时间大于当前时间");
                ErrDic.Add("START_DATE_AFTER_END_DATE", "起始时间大于结束时间");
                ErrDic.Add("ILLEGAL_PAGE_NO", "当前页码必须为数据且必须大于0");
                ErrDic.Add("START_DATE_OUT_OF_RANGE", "查询时间超出范围");
                ErrDic.Add("ILLEGAL_PAGE_SIZE", "分页大小必须为数字且大于0");
                ErrDic.Add("ILLEGAL_ACCOUNT_LOG_ID", "账务流水必须为数字且大于0");
                ErrDic.Add("TOO_MANY_QUERY", "当前查询量太多");
                ErrDic.Add("ACCOUNT_NOT_EXIST", "要查询的用户不存在");
                ErrDic.Add("ACCESS_ACCOUNT_DENIED", "无权查询该账户的账务明细");
                ErrDic.Add("SYSTEM_BUSY", "系统繁忙");
                ErrDic.Add("ILLEGAL_SIGN", "签名不正确");
                ErrDic.Add("ILLEGAL_ARGUMENT", "参数不正确");
                ErrDic.Add("ILLEGAL_SERVICE", "非法服务名称");
                ErrDic.Add("ILLEGAL_USER", "用户ID不正确");
                ErrDic.Add("ILLEGAL_PARTNER", "合作伙伴信息不正确");
                ErrDic.Add("ILLEGAL_EXTERFACE", "接口配置不正确");
                ErrDic.Add("ILLEGAL_PARTNER_EXTERFACE", "合作伙伴接口信息不正确");
                ErrDic.Add("ILLEGAL_SECURITY_PROFILE", "未找到匹配的密钥配置");
                ErrDic.Add("ILLEGAL_SIGN_TYPE", "签名类型不正确");
                ErrDic.Add("ILLEGAL_CHARSET", "字符集不合法");
                ErrDic.Add("ILLEGAL_CLIENT_IP", "客户端IP地址无权访问服务");
                ErrDic.Add("HAS_NO_PRIVILEGE", "未开通此接口权限");
                ErrDic.Add("USER_DATA_MIGRATE_ERROR", "用户的数据未迁移或者迁移状态未完成");
                //系统错误 ,联系支付宝技术支持处理
                ErrDic.Add("SYSTEM_ERROR", "支付宝系统错误");
                ErrDic.Add("SESSION_TIMEOUT", "session超时");
                ErrDic.Add("ILLEGAL_TARGET_SERVICE", "错误的target_service");
                ErrDic.Add("ILLEGAL_ACCESS_SWITCH_SYSTEM", "partner不允许访问该类型的系统");
                ErrDic.Add("ILLEGAL_SWITCH_SYSTEM", "切换系统异常");
                ErrDic.Add("ILLEGAL_ENCODING", "不支持该编码类型");
                ErrDic.Add("EXTERFACE_IS_CLOSED", "接口已关闭");
                #endregion

                #region 分析结算出差
                OutObject = new ZHIFUBAOJSMXXZ_OUT();
                XmlDocument xmlDoc = new XmlDocument();

                try
                {
                    xmlDoc.LoadXml(sHtmlText);
                    XmlNodeList nodeList = xmlDoc.SelectSingleNode("alipay").ChildNodes;
                    foreach (XmlNode xn in nodeList)
                    {
                        //判断是否异常,如果返回异常 则抛出
                        if (xn.Name == "is_success" && xn.InnerText == "F")
                        {
                            foreach (XmlNode xnerr in nodeList)
                            {
                                if (xnerr.Name == "error")
                                {
                                    foreach (var errmsg in ErrDic)
                                    {
                                        if (errmsg.Key == xnerr.InnerText.ToUpper())
                                        {
                                            throw new Exception(errmsg.Key + "|" + errmsg.Value);
                                        }
                                    }
                                }
                            }
                        }


                        if (xn.Name == "response")
                        {
                            XmlElement  xe      = (XmlElement)xn;
                            XmlNodeList subList = xe.ChildNodes;
                            foreach (XmlNode xmlNode in subList)
                            {
                                if (xmlNode.Name == "account_page_query_result")
                                {
                                    XmlElement  xemx      = (XmlElement)xmlNode;
                                    XmlNodeList submxList = xemx.ChildNodes;
                                    string      text      = "";
                                    foreach (XmlNode mxnode in submxList)
                                    {
                                        if (mxnode.Name == "has_next_page")
                                        {
                                            OutObject.HASNEXTPAGE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "page_no")
                                        {
                                            OutObject.PAGENO = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "page_size")
                                        {
                                            OutObject.PAGESIZE = mxnode.InnerText;
                                        }
                                        if (mxnode.Name == "account_log_list")
                                        {
                                            XmlElement  mx     = (XmlElement)mxnode;
                                            XmlNodeList mxList = mx.ChildNodes;
                                            foreach (XmlNode nodemx in mxList)
                                            {
                                                XmlElement  mx1     = (XmlElement)nodemx;
                                                XmlNodeList mxList1 = mx1.ChildNodes;
                                                ZHIFUBAOMX  zfbdzmx = new ZHIFUBAOMX();

                                                //明细列表赋值
                                                foreach (XmlNode nodemx1 in mxList1)
                                                {
                                                    //BALANCE	余额
                                                    if (nodemx1.Name == "balance")
                                                    {
                                                        zfbdzmx.BALANCE = nodemx1.InnerText;
                                                    }
                                                    //INCOME	收入金额
                                                    if (nodemx1.Name == "income")
                                                    {
                                                        if (double.Parse(nodemx1.InnerText) != 0)
                                                        {
                                                            // zfbdzmx.INCOME = nodemx1.InnerText;
                                                            zfbdzmx.TOTALFEE = nodemx1.InnerText;
                                                        }
                                                    }
                                                    //OUTCOME	支出金额
                                                    if (nodemx1.Name == "outcome")
                                                    {
                                                        // zfbdzmx.OUTCOME = nodemx1.InnerText;
                                                        if (double.Parse(nodemx1.InnerText) != 0)
                                                        {
                                                            // zfbdzmx.INCOME = nodemx1.InnerText;
                                                            zfbdzmx.TOTALFEE = "-" + nodemx1.InnerText;
                                                        }
                                                    }
                                                    ////BANKACCOUNTNAME	银行帐号名称
                                                    //if (nodemx1.Name == "bank_account_name")
                                                    //    zfbdzmx.BANKACCOUNTNAME = nodemx1.InnerText;
                                                    ////BANKACCOUNTNO	银行帐号
                                                    //if (nodemx1.Name == "bank_account_no")
                                                    //    zfbdzmx.BANKACCOUNTNO = nodemx1.InnerText;
                                                    ////BANKNAME	银行名称
                                                    //if (nodemx1.Name == "bank_name")
                                                    //    zfbdzmx.BANKNAME = nodemx1.InnerText;
                                                    // //BUYERACCOUNT	买家支付宝人民币资金账户
                                                    if (nodemx1.Name == "buyer_account")
                                                    {
                                                        zfbdzmx.BUYERACCOUNT = nodemx1.InnerText;
                                                    }
                                                    ////CURRENCY	货币代码
                                                    //if (nodemx1.Name == "currency")
                                                    //    zfbdzmx.CURRENCY = nodemx1.InnerText;
                                                    ////GOODSTITLE	商品名称
                                                    //if (nodemx1.Name == "goods_title")
                                                    //    zfbdzmx.GOODSTITLE = nodemx1.InnerText;
                                                    ////IWACCOUNTLOGID	财务序列号
                                                    //if (nodemx1.Name == "iw_account_log_id")
                                                    //    zfbdzmx.IWACCOUNTLOGID = nodemx1.InnerText;
                                                    ////MEMO	备注
                                                    //if (nodemx1.Name == "memo")
                                                    //    zfbdzmx.MEMO = nodemx1.InnerText;
                                                    //MERCHANTOUTORDERNO	商户订单号
                                                    if (nodemx1.Name == "merchant_out_order_no")
                                                    {
                                                        zfbdzmx.MERCHANTOUTORDERNO = nodemx1.InnerText;
                                                    }
                                                    ////OUTHERACCOUNTEMAIL	财务对方邮箱
                                                    //if (nodemx1.Name == "other_account_email")
                                                    //    zfbdzmx.OTHERACCOUNTFULLNAME = nodemx1.InnerText;
                                                    ////OTHERACCOUNTFULLNAME	财务对方名称
                                                    //if (nodemx1.Name == "other_account_fullname")
                                                    //    zfbdzmx.OTHERACCOUNTFULLNAME = nodemx1.InnerText;
                                                    ////OTHERUSERID	财务对方支付宝用户号
                                                    //if (nodemx1.Name == "other_user_id")
                                                    //    zfbdzmx.OTHERUSERID = nodemx1.InnerText;
                                                    //PARTNERID	合作者身份ID
                                                    if (nodemx1.Name == "partner_id")
                                                    {
                                                        zfbdzmx.PARTNERID = nodemx1.InnerText;
                                                    }
                                                    ////SELLERACCOUNT 卖家支付宝人民币资金账户
                                                    //if (nodemx1.Name == "seller_account")
                                                    //    zfbdzmx.SELLERACCOUNT = nodemx1.InnerText;
                                                    //SELLERFULLNAME	卖家姓名
                                                    if (nodemx1.Name == "seller_fullname")
                                                    {
                                                        zfbdzmx.SELLERFULLNAME = nodemx1.InnerText;
                                                    }
                                                    ////SERVICFEE	交易服务费
                                                    //if (nodemx1.Name == "service_fee")
                                                    //    zfbdzmx.SERVICFEE = nodemx1.InnerText;
                                                    ////SERVICEFEERATIO	交易服务费率
                                                    //if (nodemx1.Name == "service_fee_ratio")
                                                    //    zfbdzmx.SERVICEFEERATIO = nodemx1.InnerText;
                                                    //TOTALFEE	交易总金额
                                                    //if (nodemx1.Name == "total_fee")
                                                    //    zfbdzmx.TOTALFEE = nodemx1.InnerText;
                                                    //TRADENO	支付宝交易号
                                                    if (nodemx1.Name == "trade_no")
                                                    {
                                                        zfbdzmx.TRADENO = nodemx1.InnerText;
                                                    }
                                                    ////TRANSACCOUNT	财务本方支付宝人民币资金账户
                                                    //if (nodemx1.Name == "trans_account")
                                                    //    zfbdzmx.TRANSACCOUNT = nodemx1.InnerText;
                                                    //TRANSCODEMSG	业务类型
                                                    if (nodemx1.Name == "trans_code_msg")
                                                    {
                                                        zfbdzmx.TRANSCODEMSG = nodemx1.InnerText;
                                                    }
                                                    //TRANSDATE	交易时间
                                                    if (nodemx1.Name == "trans_date")
                                                    {
                                                        zfbdzmx.TRANSDATE = nodemx1.InnerText;
                                                    }
                                                    ////TRANSOUTERORDERNO	订单号
                                                    //if (nodemx1.Name == "trans_out_order_no")
                                                    //    zfbdzmx.TRANSOUTERORDERNO = nodemx1.InnerText;
                                                    ////DEPOSITBANKNO	网银充值流水号
                                                    //if (nodemx1.Name == "deposit_bank_no")
                                                    //    zfbdzmx.DEPOSITBANKNO = nodemx1.InnerText;
                                                    ////TRADEREFUNDAMOUNT	累积退款金额
                                                    //if (nodemx1.Name == "trade_refund_amount")
                                                    //    zfbdzmx.TRADEREFUNDAMOUNT = nodemx1.InnerText;
                                                }
                                                if (string.IsNullOrEmpty(zfbdzmx.TOTALFEE))
                                                {
                                                    zfbdzmx.TOTALFEE = "0";
                                                }
                                                if (double.Parse(zfbdzmx.TOTALFEE) < 0)
                                                {
                                                    zfbdzmx.MERCHANTOUTORDERNO = "T" + zfbdzmx.MERCHANTOUTORDERNO;
                                                }
                                                //   OutObject.ZHIFUBAOMX.Add(zfbdzmx);
                                                string sfzh = "";
                                                if (string.IsNullOrEmpty(zfbdzmx.BUYERACCOUNT) && zfbdzmx.BUYERACCOUNT.Length > 4)
                                                {
                                                    DataTable dtqyxx = DBVisitor.ExecuteTable(string.Format("select * from gy_bangdinggx where BINRENSB='{0}'", zfbdzmx.BUYERACCOUNT.Substring(0, zfbdzmx.BUYERACCOUNT.Length - 4)));
                                                    if (dtqyxx.Rows.Count > 0)
                                                    {
                                                        sfzh = dtqyxx.Rows[0]["SHENFENZH"].ToString();
                                                    }
                                                }
                                                DBVisitor.ExecuteNonQuery(SqlLoad.GetFormat(SQ.HIS00018,
                                                                                            zfbdzmx.MERCHANTOUTORDERNO,  //IOUTTRADENO	VARCHAR2(50)	N			商户订单号
                                                                                            zfbdzmx.TOTALFEE,            //ITOTALFEE	VARCHAR2(100)	N			总金额
                                                                                            "",                          //JIESUANZT	NUMBER(4)	Y			状态  0支付  1退费
                                                                                            zfbdzmx.TRANSDATE,           //JIESUANSJ	DATE	Y			结算时间
                                                                                            zfbdzmx.BUYERACCOUNT,        //IBUYERID	VARCHAR2(50)	Y			买家支付宝用户号
                                                                                            sfzh,                        //IBUYEREMAIL	VARCHAR2(50)	Y			买家支付宝帐号
                                                                                            "",                          //IAGREENNO	VARCHAR2(50)	Y			协议号
                                                                                            zfbdzmx.TRADENO,             //TRADENO	VARCHAR2(50)	Y			支付宝交易号
                                                                                            InObject.BASEINFO.FENYUANDM, //FENYUANDM	VARCHAR2(50)	Y			分院代码
                                                                                            ""                           //SHOUKUANZH	VARCHAR2(50)	Y			收款帐号
                                                                                            ));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception(exp.Message.ToString());
                }
                #endregion
                #endregion
            }
            else
            {
                throw new Exception("下载类型不正确");
            }
        }
예제 #6
0
        protected void BtnAlipay_Click(object sender, EventArgs e)
        {
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //支付类型
            string payment_type = "1";
            //必填,不能修改
            //服务器异步通知页面路径
            string notify_url = "http://商户网关地址/create_direct_pay_by_user-CSHARP-UTF-8/notify_url.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = "http://商户网关地址/create_direct_pay_by_user-CSHARP-UTF-8/return_url.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

            //商户订单号
            string out_trade_no = WIDout_trade_no.Text.Trim();
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = WIDsubject.Text.Trim();
            //必填

            //付款金额
            string total_fee = WIDtotal_fee.Text.Trim();
            //必填

            //订单描述

            string body = WIDbody.Text.Trim();
            //默认支付方式
            string paymethod = "bankPay";
            //必填
            //默认网银
            string defaultbank = WIDdefaultbank.Text.Trim();
            //必填,银行简码请参考接口技术文档

            //商品展示地址
            string show_url = WIDshow_url.Text.Trim();
            //需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html

            //防钓鱼时间戳
            string anti_phishing_key = "";
            //若要使用请调用类文件submit中的query_timestamp函数

            //客户端的IP地址
            string exter_invoke_ip = "";
            //非局域网的外网IP地址,如:221.0.0.1


            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("seller_email", Config.Seller_email);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "create_direct_pay_by_user");
            sParaTemp.Add("payment_type", payment_type);
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("return_url", return_url);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", subject);
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("body", body);
            sParaTemp.Add("paymethod", paymethod);
            sParaTemp.Add("defaultbank", defaultbank);
            sParaTemp.Add("show_url", show_url);
            sParaTemp.Add("anti_phishing_key", anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);

            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");

            Response.Write(sHtmlText);
        }
        private void PayAlipay()
        {
            try
            {
                ////////////////////////////////////////////请求参数////////////////////////////////////////////
                //支付类型
                string payment_type = "1";
                //必填,不能修改
                //服务器异步通知页面路径
                string notify_url = ConfigurationManager.AppSettings["notify_url"].ToString();
                //需http://格式的完整路径,不能加?id=123这类自定义参数

                //页面跳转同步通知页面路径
                string return_url = ConfigurationManager.AppSettings["call_back_url"].ToString();
                //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

                //商户订单号
                string out_trade_no = Request.QueryString["out_trade_no"].ToString();
                //商户网站订单系统中唯一订单号,必填

                //订单名称
                string subject = Request.QueryString["subject"].ToString();
                //必填

                //付款金额
                string total_fee = Request.QueryString["total_fee"];
                //必填

                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组

                string tmp = Config.Partner;
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("seller_id", Config.Seller_id);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "alipay.wap.create.direct.pay.by.user");
                sParaTemp.Add("payment_type", payment_type);
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("return_url", return_url);
                sParaTemp.Add("out_trade_no", out_trade_no);
                sParaTemp.Add("subject", subject);
                sParaTemp.Add("total_fee", total_fee);
                logger.Info("partner:" + Config.Partner);
                logger.Info("seller_id:" + Config.Seller_id);
                logger.Info("_input_charset:" + Config.Input_charset.ToLower());
                logger.Info("payment_type:" + payment_type);
                logger.Info("notify_url:" + notify_url);
                logger.Info("return_url:" + return_url);
                logger.Info("out_trade_no:" + out_trade_no);
                logger.Info("subject:" + subject);
                logger.Info("total_fee:" + total_fee);
                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                Response.Write(sHtmlText);
            }
            catch (Exception ex)
            {
                logger.Error("Default页面异常:" + ex);
            }
        }
예제 #8
0
        /// <summary>
        ///     发起一个支付宝的请求(包括授权接口和交易接口)
        /// </summary>
        /// <param name="tradeno">订单号</param>
        /// <param name="totalfee">付款金额</param>
        /// <param name="merchanturl"></param>
        /// <param name="notifyurl">异步回调地址</param>
        /// <param name="callbackurl">同步回调地址</param>
        /// <param name="cussubject">订单名称</param>
        public void AlipayRequest(string tradeno, string totalfee,
                                  string notifyurl, string callbackurl, string merchanturl,
                                  string cussubject)
        {
            //支付宝网关地址
            var GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?";

            ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token////////////////////////////////////////////

            var format = "xml";
            var v      = "2.0";
            //请求号
            var req_id = DateTime.Now.ToString("yyyyMMddHHmmss");

            //req_data详细信息
            var notify_url = notifyurl;
            //需http://格式的完整路径,不允许加?id=123这类自定义参数
            var call_back_url = callbackurl;
            //需http://格式的完整路径,不允许加?id=123这类自定义参数
            var merchant_url = merchanturl;
            //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数
            //商户订单号
            var out_trade_no = tradeno;
            var subject      = cussubject;
            //付款金额
            var total_fee = totalfee;
            //请求业务参数详细
            var req_dataToken = "<direct_trade_create_req><notify_url>" + notify_url + "</notify_url><call_back_url>" +
                                call_back_url + "</call_back_url><seller_account_name>" + Config.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>";
            //把请求参数打包成数组
            var 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);

            //建立请求
            var sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken);
            //URLDECODE返回的信息
            var code = Encoding.GetEncoding(Config.Input_charset);

            sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code);

            //解析远程模拟提交后返回的信息
            var dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken);

            //获取token
            if (!dicHtmlTextToken.ContainsKey("request_token"))
            {
                Response.Write("获取request_token失败" + JsonConvert.SerializeObject(dicHtmlTextToken));
                return;
            }
            var request_token = dicHtmlTextToken["request_token"];

            LogHelper.CreateLog(string.Format("获取request_token:{0}", request_token), tradeno);
            #region 根据授权码token调用交易接口alipay.wap.auth.authAndExecute

            //业务详细
            var req_data = "<auth_and_execute_req><request_token>" + request_token +
                           "</request_token></auth_and_execute_req>";
            //必填

            //把请求参数打包成数组
            var 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);

            //建立请求
            var sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认");
            LogHelper.CreateLog(string.Format("成功获取支付页面"), tradeno);
            Response.Write(sHtmlText);

            #endregion 根据授权码token调用交易接口alipay.wap.auth.authAndExecute
        }
예제 #9
0
        public void Index()
        {
            ErrorMessage errorMessage = ErrorMessage.失败;

            string url = StringHelper.GetHost();

            if (string.IsNullOrEmpty(url))
            {
                errorMessage = ErrorMessage.订单初始化失败;
                return;
            }

            int    payType  = 0;
            string orderId  = "";
            int    money    = 0;
            int    userType = 0;

            if (PayContext.VerifyPayOrderInfo(1, out errorMessage, out payType, out orderId, out money, out userType))
            {
                //支付宝网关地址
                string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?";

                #region

                //返回格式, 必填,不需要修改
                string format = "xml";

                //返回格式, 必填,不需要修改
                string v = "2.0";

                //请求号, 必填,须保证每次请求都是唯一
                string req_id = DateTime.Now.ToString("yyyyMMddHHmmss");

                //req_data详细信息

                //服务器异步通知页面路径 ,需http://格式的完整路径,不允许加?id=123这类自定义参数
                string notify_url = string.Format("http://{0}/alipay/notify", url);

                //页面跳转同步通知页面路径, 需http://格式的完整路径,不允许加?id=123这类自定义参数
                string call_back_url = string.Format("http://{0}/alipay/result", url);

                //操作中断返回地址, 用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数
                string merchant_url = string.Format("http://{0}/order/recharge", url);

                //卖家支付宝帐户
                string seller_email = Config.SellerEmail;

                //商户网站订单系统中唯一订单号,必填

                //订单名称 必填
                string subject = GetName(money);

                //付款金额(单位:元) 必填
                string total_fee = GetFee(money);

                //请求业务参数详细 必填
                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>" + orderId + "</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"];

                #endregion

                //业务详细 必填
                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);

                //建立请求
                string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认");
                Response.Write(sHtmlText);
            }
        }
예제 #10
0
        /// <summary>
        /// 支付宝 支付
        /// </summary>
        void ZhiFuBao(int intDingDanId)
        {
            Entity.DingDan info = DAL.DingDan.DingDanEntityGet(intDingDanId);

            if (info != null)
            {
                #region 支付宝即时到账参数

                //合作方身份id
                string partner = "2088801581813827";

                //支付类型
                string payment_type = "1";
                //必填,不能修改
                //服务器异步通知页面路径
                string notify_url = "http://gaokao.gelunjiaoyu.com/gaokaocard/NotifyUrl.aspx";
                //需http://格式的完整路径,不能加?id=123这类自定义参数

                //页面跳转同步通知页面路径
                string return_url = "http://gaokao.gelunjiaoyu.com/gaokaocard/ReturnUrl.aspx";
                //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

                //卖家支付宝帐户
                string seller_email = "*****@*****.**";
                string seller_id    = "2088801581813827";
                //必填

                //商户订单号
                string out_trade_no = info.DingDanHao;
                //商户网站订单系统中唯一订单号,必填

                int Count = info.Count;

                //订单名称
                string subject = info.Subject;
                //必填

                //付款金额
                string total_fee = string.Format("{0:N2}", info.DingDanJinE.ToString());
                //必填

                //订单描述
                string body = info.Body;



                //商品展示地址
                string show_url = "http://gaokao.gelunjiaoyu.com/gaokaocard/ShowUrl.aspx";
                //需以http://开头的完整路径,例如:/gaokao/myorder.html

                //防钓鱼时间戳
                string anti_phishing_key = "";
                //若要使用请调用类文件submit中的query_timestamp函数

                //客户端的IP地址
                string exter_invoke_ip = Request.UserHostAddress;
                //非局域网的外网IP地址,如:221.0.0.1



                //代签名字符串
                string preStr = "_input_charset=utf-8" +
                                "&body=" + body +
                                "&exter_invoke_ip=" + exter_invoke_ip +
                                "&notify_url=" + notify_url +
                                "&out_trade_no=" + out_trade_no +
                                "&partner=" + partner +
                                "&payment_type=" + payment_type +
                                "&return_url=" + return_url +
                                "&seller_email=" + seller_email +
                                "&service=" + "create_direct_pay_by_user" +
                                "&show_url=" + show_url +
                                "&subject=" + subject +
                                "&total_fee=" + total_fee;

                #endregion

                #region 调用支付宝接口,发送请求

                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                //sParaTemp.Add("anti_phishing_key", anti_phishing_key);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("body", body);
                sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("out_trade_no", out_trade_no);
                sParaTemp.Add("partner", partner);
                sParaTemp.Add("payment_type", payment_type);
                sParaTemp.Add("return_url", return_url);
                sParaTemp.Add("seller_email", seller_email);
                sParaTemp.Add("service", "create_direct_pay_by_user");
                //sParaTemp.Add("seller_id", seller_id);
                sParaTemp.Add("show_url", show_url);
                sParaTemp.Add("subject", subject);
                sParaTemp.Add("total_fee", total_fee);
                //sParaTemp.Add("sign", AlipayMD5.Sign(preStr, "tozq0prk7lau6ue1khoq5kg1ek17qvmd", Config.Input_charset.ToLower()));
                //sParaTemp.Add("sign_type", Config.Sign_type);

                Config.Key = "tozq0prk7lau6ue1khoq5kg1ek17qvmd";

                //建立请求
                string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");

                Response.Write(sHtmlText);

                #endregion
            }
            else
            {
                Basic.MsgHelper.AlertBackMsg("服务器正忙...");
            }
        }
예제 #11
0
        public ActionResult PayPages(FormCollection collection)
        {
            OrderNumber          = collection["WIDout_trade_no"];
            OrderName            = collection["WIDsubject"];
            OrderMoney           = collection["WIDtotal_fee"];
            OrderDescribe        = collection["WIDbody"];
            ProductExhibitionUrl = collection["WIDshow_url"];

            ////////////////////////////////////////////请求参数////////////////////////////////////////////
            //支付类型
            string payment_type = "1";
            //必填,不能修改
            //服务器异步通知页面路径
            string notify_url = "http://demo.jinhusns.com/Alipay/notify_url";
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = "http://demo.jinhusns.com/Alipay/return_url";
            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

            //商户订单号
            string out_trade_no = OrderNumber.Trim();
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = OrderName.Trim();
            //必填

            //付款金额
            string total_fee = OrderMoney.Trim();
            //必填

            //订单描述

            string body = OrderDescribe.Trim();
            //商品展示地址
            string show_url = ProductExhibitionUrl.Trim();
            //需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html

            //防钓鱼时间戳
            string anti_phishing_key = "";
            //若要使用请调用类文件submit中的query_timestamp函数

            //客户端的IP地址
            string exter_invoke_ip = "";
            //非局域网的外网IP地址,如:221.0.0.1


            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Configs.Partner);
            sParaTemp.Add("seller_email", Configs.Seller_email);
            sParaTemp.Add("_input_charset", Configs.Input_charset.ToLower());
            sParaTemp.Add("service", "create_direct_pay_by_user");
            sParaTemp.Add("payment_type", payment_type);
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("return_url", return_url);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", subject);
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("body", body);
            sParaTemp.Add("show_url", show_url);
            sParaTemp.Add("anti_phishing_key", anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);

            //建立请求
            string     sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
            HtmlString url       = new HtmlString(sHtmlText);

            ViewBag.url = url;
            //Response.Write(sHtmlText);


            return(View("PayPage"));
        }
예제 #12
0
        protected void BtnAlipay_Click()
        {
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //支付类型
            string payment_type = "1";
            //必填,不能修改
            //服务器异步通知页面路径
            string notify_url = "http://www.ssqian.com/Order/PayNotifyForAlipay.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = "http://www.ssqian.com/Order/PayReturnForAlipay.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/

            //卖家支付宝帐户
            string seller_email = Com.Alipay.Config.Account;
            //必填

            //商户订单号
            string out_trade_no = m_order.OrderID;
            //商户网站订单系统中唯一订单号,必填

            //订单名称
            string subject = "命理咨询服务费";
            //必填

            //付款金额
            string total_fee = m_order.PayAmount.ToString("0.00");
            //必填

            //订单描述

            string body = "";
            //商品展示地址
            string show_url = AppCmn.AppConfig.HomeUrl();
            //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html

            //防钓鱼时间戳
            string anti_phishing_key = "";
            //若要使用请调用类文件submit中的query_timestamp函数

            //客户端的IP地址
            string exter_invoke_ip = Request.UserHostAddress;
            //非局域网的外网IP地址,如:221.0.0.1


            ////////////////////////////////////////////////////////////////////////////////////////////////

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "create_direct_pay_by_user");
            sParaTemp.Add("payment_type", payment_type);
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("return_url", return_url);
            sParaTemp.Add("seller_email", seller_email);
            sParaTemp.Add("out_trade_no", out_trade_no);
            sParaTemp.Add("subject", subject);
            sParaTemp.Add("total_fee", total_fee);
            sParaTemp.Add("body", body);
            sParaTemp.Add("show_url", show_url);
            sParaTemp.Add("anti_phishing_key", anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", exter_invoke_ip);

            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");

            Response.Write(sHtmlText);
        }
예제 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int     orderid               = Request["orderid"].ConvertTo <int>(0);
            decimal quit_fee              = Request["quit_fee"].ConvertTo <decimal>(0);
            int     rentserverid          = Request["rentserverid"].ConvertTo <int>(0);
            int     b2b_eticket_Depositid = Request["b2b_eticket_Depositid"].ConvertTo <int>(0);

            int rentserver_refundlogid = 0;

            if (orderid == 0 || quit_fee == 0)
            {
                lblresult.InnerText = "参数传递错误";
                return;
            }

            B2b_order oldorder = new B2bOrderData().GetOrderById(orderid);

            if (oldorder != null)
            {
                if (rentserverid > 0)
                { //退押金
                    B2b_Rentserver_RefundLog refundlog = new B2b_Rentserver_RefundLogData().GetServerRefundlog(orderid, rentserverid, b2b_eticket_Depositid, 2);
                    if (refundlog == null)
                    {
                        lblresult.InnerText = "押金状态需要是 退押金处理中 才可退款";
                        return;
                    }
                    rentserver_refundlogid = refundlog.id;
                }
                else
                {
                    //退订单
                    if (oldorder.Order_state == 17 || oldorder.Order_state == 18)
                    {
                    }
                    else
                    {
                        lblresult.InnerText = "订单状态有误:" + EnumUtils.GetName((OrderStatus)oldorder.Order_state);;
                        return;
                    }
                }
            }
            else
            {
                lblresult.InnerText = "订单获取出错";
                return;
            }

            //得到订单的支付信息
            B2b_pay mpay = new B2bPayData().GetSUCCESSPayById(orderid);

            if (mpay == null)
            {
                lblresult.InnerText = "支付信息获取不到";
                return;
            }
            if (mpay.Trade_status != "TRADE_SUCCESS")
            {
                string r = "订单支付没有成功,不可退款";
                //Response.Write(r);
                lblresult.InnerText = r;
                return;
            }
            #region 支付宝退款
            B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(mpay.comid);
            if (model == null)
            {
                string data2 = "支付宝设置信息不存在";
                //Response.Write(data2);
                lblresult.InnerText = data2;

                return;
            }
            lock (lockobj)
            {
                ////////////////////////////////////////////请求参数////////////////////////////////////////////
                int    nowbatch_num   = 0;  //退款笔数
                string nowdetail_data = ""; //退款详细数据


                nowbatch_num   = 1;
                nowdetail_data = mpay.Trade_no + "^" + quit_fee.ToString("F2") + "^" + "协商退款";//原付款支付宝交易号^退款总金额^退款理由

                //服务器异步通知页面路径
                string notify_url = "http://shop.etown.cn/ui/vasui/alipay/refund_notify_url.aspx";
                //需http://格式的完整路径,不允许加?id=123这类自定义参数

                //卖家支付宝帐户
                string seller_email = Config.Seller_email.ToString().Trim();
                //必填

                //退款当天日期
                string refund_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //必填,格式:年[4位]-月[2位]-日[2位] 小时[2位 24小时制]:分[2位]:秒[2位],如:2007-10-01 13:13:13

                //批次号
                string batch_no = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                //必填,格式:当天日期[8位]+序列号[3至24位],如:201008010000001

                //退款笔数
                string batch_num = nowbatch_num.ToString();
                //必填,参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的数量999个)

                //退款详细数据
                string detail_data = nowdetail_data;
                //必填,具体格式请参见接口技术文档


                ////////////////////////////////////////////////////////////////////////////////////////////////

                //把请求参数打包成数组
                SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
                sParaTemp.Add("partner", Config.Partner);
                sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
                sParaTemp.Add("service", "refund_fastpay_by_platform_pwd");
                sParaTemp.Add("notify_url", notify_url);
                sParaTemp.Add("seller_email", seller_email);
                sParaTemp.Add("refund_date", refund_date);
                sParaTemp.Add("batch_no", batch_no);
                sParaTemp.Add("batch_num", batch_num);
                sParaTemp.Add("detail_data", detail_data);

                B2b_pay_alipayrefundlog nowlog = new B2b_pay_alipayrefundlog
                {
                    id                     = 0,
                    orderid                = orderid,
                    service                = "refund_fastpay_by_platform_pwd",
                    partner                = Config.Partner,
                    notify_url             = notify_url,
                    seller_email           = Config.Seller_email,
                    seller_user_id         = Config.Partner,
                    refund_date            = DateTime.Parse(refund_date),
                    batch_no               = batch_no,
                    batch_num              = int.Parse(batch_num),
                    detail_data            = detail_data,
                    notify_time            = DateTime.Parse("1970-01-01"),
                    notify_type            = "",
                    notify_id              = "",
                    success_num            = 0,
                    result_details         = "",
                    error_code             = "",
                    error_desc             = "",
                    refund_fee             = quit_fee,
                    rentserver_refundlogid = rentserver_refundlogid
                };
                int ee = new B2b_pay_alipayrefundlogData().Editalipayrefundlog(nowlog);
                if (ee > 0)
                {
                    //建立请求
                    string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认");
                    Response.Write(sHtmlText);
                    //lblresult.InnerText = sHtmlText;
                    return;
                }
                else
                {
                    //Response.Write("{\"type\":\"100\",\"msg\":\"退款操作完成(款项需手动退款).\"}");
                    lblresult.InnerText = "意外错误";
                    return;
                }
            }
            #endregion
        }