Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Lebi_OnlinePay pay = B_Lebi_OnlinePay.GetModel("Code='alipaybatch'");

            if (pay == null)
            {
                Response.Write("参数错误");
                Response.End();
                return;
            }

            SortedDictionary <string, string> sPara = GetRequestPost();

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

                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码
                    string           batch_no = RequestTool.RequestSafeString("batch_no");
                    Lebi_Cash_alipay cash     = B_Lebi_Cash_alipay.GetModel("Code='" + batch_no + "'");
                    if (cash != null)
                    {
                        //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                        //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表

                        //批量付款数据中转账成功的详细信息
                        //格式为:流水号^收款方账号^收款
                        //账号姓名^付款金额^成功标识(S)^
                        //成功原因(null)^支付宝内部流水号
                        //^完成时间。
                        //每条记录以“ |”间隔
                        string success_details = RequestTool.RequestString("success_details");
                        //批量付款数据中转账失败的详细信息
                        string fail_details = RequestTool.RequestString("fail_details");

                        string[] arr = success_details.Split('|');
                        foreach (string temp in arr)
                        {
                            string[]  item  = temp.Split('^');
                            Lebi_Cash model = B_Lebi_Cash.GetModel("id=" + item[0] + "");
                            if (model != null)
                            {
                                model.Type_id_CashStatus = 402;
                                B_Lebi_Cash.Update(model);
                            }
                        }

                        cash.Time_Paid  = System.DateTime.Now;
                        cash.IsPaid     = 1;
                        cash.result_no  = fail_details;
                        cash.result_yes = success_details;
                        B_Lebi_Cash_alipay.Update(cash);

                        //判断是否在商户网站中已经做过了这次通知返回的处理
                        //如果没有做过处理,那么执行商户的业务程序
                        //如果有做过处理,那么不执行商户的业务程序
                    }
                    Response.Write("success");  //请不要修改或删除

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

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("无通知参数");
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Lebi_OnlinePay pay = B_Lebi_OnlinePay.GetModel("Code='alipaybatch'");

            if (pay == null)
            {
                Response.Write("参数错误");
                Response.End();
                return;
            }
            Shop.Bussiness.Site site = new Shop.Bussiness.Site();
            string ids = RequestTool.RequestString("ids");

            if (ids == "")
            {
                Response.Write("参数错误");
                Response.End();
                return;
            }

            List <Lebi_Cash> models = B_Lebi_Cash.GetList("id in (" + ids + ")", "");
            decimal          money  = 0;
            string           con    = "";

            foreach (Lebi_Cash model in models)
            {
                money = money + model.Money - model.Fee;
                //string t = "" + model.id + "^" + model.AccountCode + "^" + model.AccountName + "^" + (model.Money - model.Fee) + "^" + model.Remark + "";
                string t = "" + model.id + "^" + model.AccountCode + "^" + model.AccountName + "^" + (model.Money - model.Fee) + "^提现申请";
                con += t + "|";
            }
            con = con.TrimEnd('|');
            Lebi_Cash_alipay cash = new Lebi_Cash_alipay();

            cash.alipay_user     = pay.Email;
            cash.alipay_username = "";
            cash.Cash_ids        = ids;
            cash.Code            = Shop.Bussiness.Order.CreateOrderCode();
            cash.Content         = con;
            cash.count           = models.Count;
            cash.Money           = money;
            B_Lebi_Cash_alipay.Add(cash);

            //服务器异步通知页面路径
            string notify_url = "http://" + RequestTool.GetRequestDomain() + site.WebPath + "/onlinepay/alipaybatch/notify_url.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数

            //页面跳转同步通知页面路径
            string return_url = "http://" + RequestTool.GetRequestDomain() + site.WebPath + "/onlinepay/alipaybatch/return_url.aspx";
            //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/


            //需http://格式的完整路径,不允许加?id=123这类自定义参数

            //付款账号
            string email = pay.Email;
            //必填

            //付款账户名
            string account_name = pay.UserRealName;
            //必填,个人支付宝账号是真实姓名公司支付宝账号是公司名称

            //付款当天日期
            string pay_date = System.DateTime.Now.ToString("yyyyMMdd");
            //必填,格式:年[4位]月[2位]日[2位],如:20100801

            //批次号
            string batch_no = cash.Code;
            //必填,格式:当天日期[8位]+序列号[3至16位],如:201008010000001

            //付款总金额
            string batch_fee = money.ToString();
            //必填,即参数detail_data的值中所有金额的总和

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

            //付款详细数据
            string detail_data = con;
            //必填,格式:流水号1^收款方帐号1^真实姓名^付款金额1^备注说明1|流水号2^收款方帐号2^真实姓名^付款金额2^备注说明2....


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

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

            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "batch_trans_notify");
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("email", email);
            sParaTemp.Add("account_name", account_name);
            sParaTemp.Add("pay_date", pay_date);
            sParaTemp.Add("batch_no", batch_no);
            sParaTemp.Add("batch_fee", batch_fee);
            sParaTemp.Add("batch_num", batch_num);
            sParaTemp.Add("detail_data", detail_data);

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

            Response.Write(sHtmlText);
        }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Cash_alipay model)
 {
     return(D_Lebi_Cash_alipay.Instance.Add(model));
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Cash_alipay model)
 {
     D_Lebi_Cash_alipay.Instance.Update(model);
 }
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Cash_alipay SafeBindForm(Lebi_Cash_alipay model)
 {
     return(D_Lebi_Cash_alipay.Instance.SafeBindForm(model));
 }