Пример #1
0
        //public B2b_pay_alipayrefundlog GetLastestrefundsuclog(int orderid)
        //{
        //      using(var helper=new SqlHelper())
        //      {
        //           B2b_pay_alipayrefundlog r=new InternalB2b_pay_alipayrefundlog(helper).GetLastestrefundsuclog(orderid);
        //           return r;
        //      }
        //}

        public int Editalipayrefundlog(B2b_pay_alipayrefundlog nowlog)
        {
            using (var helper = new SqlHelper())
            {
                int r = new InternalB2b_pay_alipayrefundlog(helper).Editalipayrefundlog(nowlog);
                return(r);
            }
        }
        internal B2b_pay_alipayrefundlog Getrefundlogbybatch_no(string batch_no)
        {
            string sql = @"SELECT   [id]
                                          ,[orderid]
                                          ,[service]
                                          ,[partner]
                                          ,[notify_url]
                                          ,[seller_email]
                                          ,[seller_user_id]
                                          ,[refund_date]
                                          ,[batch_no]
                                          ,[batch_num]
                                          ,[detail_data]
                                          ,[notify_time]
                                          ,[notify_type]
                                          ,[notify_id]
                                          ,[success_num]
                                          ,[result_details]
                                          ,[error_code]
                                          ,[error_desc]
                                          ,refund_fee 
                                          ,rentserver_refundlogid
                                      FROM  [b2b_pay_alipayrefundlog] where batch_no=@batch_no";
            var    cmd = sqlHelper.PrepareTextSqlCommand(sql);

            cmd.AddParam("@batch_no", batch_no);
            using (var reader = cmd.ExecuteReader())
            {
                B2b_pay_alipayrefundlog m = null;
                if (reader.Read())
                {
                    m = new B2b_pay_alipayrefundlog
                    {
                        id                     = reader.GetValue <int>("id"),
                        orderid                = reader.GetValue <int>("orderid"),
                        service                = reader.GetValue <string>("service"),
                        partner                = reader.GetValue <string>("partner"),
                        notify_url             = reader.GetValue <string>("notify_url"),
                        seller_email           = reader.GetValue <string>("seller_email"),
                        seller_user_id         = reader.GetValue <string>("seller_user_id"),
                        refund_date            = reader.GetValue <DateTime>("refund_date"),
                        batch_no               = reader.GetValue <string>("batch_no"),
                        batch_num              = reader.GetValue <int>("batch_num"),
                        detail_data            = reader.GetValue <string>("detail_data"),
                        notify_time            = reader.GetValue <DateTime>("notify_time"),
                        notify_type            = reader.GetValue <string>("notify_type"),
                        notify_id              = reader.GetValue <string>("notify_id"),
                        success_num            = reader.GetValue <int>("success_num"),
                        result_details         = reader.GetValue <string>("result_details"),
                        error_code             = reader.GetValue <string>("error_code"),
                        error_desc             = reader.GetValue <string>("error_desc"),
                        refund_fee             = reader.GetValue <decimal>("refund_fee"),
                        rentserver_refundlogid = reader.GetValue <int>("rentserver_refundlogid"),
                    };
                }
                return(m);
            }
        }
Пример #3
0
        protected void BtnAlipay_Click(object sender, EventArgs e)
        {
            int     orderid  = Orderid.Text.Trim().ConvertTo <int>(0);
            decimal quit_fee = Quitfee.Text.Trim().ConvertTo <decimal>(0);


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

            if (mpay.Trade_status != "TRADE_SUCCESS")
            {
                string r = "{\"type\":1,\"msg\":\"订单支付没有成功,不可退款\"}";
                //Response.Write(r);
                lblresult.InnerText = r;
                return;
            }
            #region 支付宝退款
            B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(mpay.comid);
            if (model == null)
            {
                string data2 = "{\"type\":1,\"msg\":\"支付宝设置信息不存在!\"}";
                //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
                };
                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 = "{\"type\":\"100\",\"msg\":\"退款操作完成(款项需手动退款).\"}";
                    return;
                }
            }
            #endregion
        }
//        internal B2b_pay_alipayrefundlog GetLastestrefundsuclog(int orderid)
//        {
//            string sql = @"SELECT top 1 [id]
//                              ,[orderid]
//                              ,[service]
//                              ,[partner]
//                              ,[notify_url]
//                              ,[seller_email]
//                              ,[seller_user_id]
//                              ,[refund_date]
//                              ,[batch_no]
//                              ,[batch_num]
//                              ,[detail_data]
//                              ,[notify_time]
//                              ,[notify_type]
//                              ,[notify_id]
//                              ,[success_num]
//                              ,[result_details]
//                              ,[error_code]
//                              ,[error_desc]
//                          FROM  [b2b_pay_alipayrefundlog] where orderid=@orderid and error_code='SUCCESS' order by id desc";
//            var cmd = sqlHelper.PrepareTextSqlCommand(sql);
//            cmd.AddParam("@orderid", orderid);
//            using (var reader = cmd.ExecuteReader())
//            {
//                B2b_pay_alipayrefundlog m = null;
//                if (reader.Read())
//                {
//                    m = new B2b_pay_alipayrefundlog
//                    {
//                        id = reader.GetValue<int>("id"),
//                        orderid = reader.GetValue<int>("orderid"),
//                        service = reader.GetValue<string>("service"),
//                        partner = reader.GetValue<string>("partner"),
//                        notify_url = reader.GetValue<string>("notify_url"),
//                        seller_email = reader.GetValue<string>("seller_email"),
//                        seller_user_id = reader.GetValue<string>("seller_user_id"),
//                        refund_date = reader.GetValue<DateTime>("refund_date"),
//                        batch_no = reader.GetValue<string>("batch_no"),
//                        batch_num = reader.GetValue<int>("batch_num"),
//                        detail_data = reader.GetValue<string>("detail_data"),
//                        notify_time = reader.GetValue<DateTime>("notify_time"),
//                        notify_type = reader.GetValue<string>("notify_type"),
//                        notify_id = reader.GetValue<string>("notify_id"),
//                        success_num = reader.GetValue<int>("success_num"),
//                        result_details = reader.GetValue<string>("result_details"),
//                        error_code = reader.GetValue<string>("error_code"),
//                        error_desc = reader.GetValue<string>("error_desc"),

//                    };
//                }
//                return m;
//            }

//        }

        internal int Editalipayrefundlog(B2b_pay_alipayrefundlog nowlog)
        {
            if (nowlog.id == 0)
            {
                string sql = @"INSERT INTO  [b2b_pay_alipayrefundlog]
                                   ([orderid]
                                   ,[service]
                                   ,[partner]
                                   ,[notify_url]
                                   ,[seller_email]
                                   ,[seller_user_id]
                                   ,[refund_date]
                                   ,[batch_no]
                                   ,[batch_num]
                                   ,[detail_data]
                                   ,[notify_time]
                                   ,[notify_type]
                                   ,[notify_id]
                                   ,[success_num]
                                   ,[result_details]
                                   ,[error_code]
                                   ,[error_desc]
                                   ,refund_fee,rentserver_refundlogid)
                             VALUES
                                   (@orderid
                                   ,@service
                                   ,@partner
                                   ,@notify_url
                                   ,@seller_email
                                   ,@seller_user_id
                                   ,@refund_date
                                   ,@batch_no
                                   ,@batch_num
                                   ,@detail_data
                                   ,@notify_time
                                   ,@notify_type
                                   ,@notify_id
                                   ,@success_num
                                   ,@result_details
                                   ,@error_code
                                   ,@error_desc
                                   ,@refund_fee,@rentserver_refundlogid);select @@identity;";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@orderid", nowlog.orderid);
                cmd.AddParam("@service", nowlog.service);
                cmd.AddParam("@partner", nowlog.partner);
                cmd.AddParam("@notify_url", nowlog.notify_url);
                cmd.AddParam("@seller_email", nowlog.seller_email);
                cmd.AddParam("@seller_user_id", nowlog.seller_user_id);
                cmd.AddParam("@refund_date", nowlog.refund_date);
                cmd.AddParam("@batch_no", nowlog.batch_no);
                cmd.AddParam("@batch_num", nowlog.batch_num);
                cmd.AddParam("@detail_data", nowlog.detail_data);
                cmd.AddParam("@notify_time", nowlog.notify_time);
                cmd.AddParam("@notify_type", nowlog.notify_type);
                cmd.AddParam("@notify_id", nowlog.notify_id);
                cmd.AddParam("@success_num", nowlog.success_num);
                cmd.AddParam("@result_details", nowlog.result_details);
                cmd.AddParam("@error_code", nowlog.error_code);
                cmd.AddParam("@error_desc", nowlog.error_desc);
                cmd.AddParam("@refund_fee", nowlog.refund_fee);
                cmd.AddParam("@rentserver_refundlogid", nowlog.rentserver_refundlogid);

                object o = cmd.ExecuteScalar();
                return(int.Parse(o.ToString()));
            }
            else
            {
                string sql = @"UPDATE  [b2b_pay_alipayrefundlog]
                                   SET [orderid] = @orderid
                                      ,[service] = @service
                                      ,[partner] = @partner
                                      ,[notify_url] = @notify_url
                                      ,[seller_email] = @seller_email
                                      ,[seller_user_id] = @seller_user_id
                                      ,[refund_date] = @refund_date
                                      ,[batch_no] = @batch_no
                                      ,[batch_num] = @batch_num
                                      ,[detail_data] = @detail_data
                                      ,[notify_time] = @notify_time
                                      ,[notify_type] = @notify_type
                                      ,[notify_id] = @notify_id
                                      ,[success_num] = @success_num
                                      ,[result_details] = @result_details
                                      ,[error_code] = @error_code
                                      ,[error_desc] = @error_desc
                                      ,refund_fee=@refund_fee,
                                      rentserver_refundlogid=@rentserver_refundlogid
                                 WHERE id=@id";
                var    cmd = sqlHelper.PrepareTextSqlCommand(sql);
                cmd.AddParam("@id", nowlog.id);
                cmd.AddParam("@orderid", nowlog.orderid);
                cmd.AddParam("@service", nowlog.service);
                cmd.AddParam("@partner", nowlog.partner);
                cmd.AddParam("@notify_url", nowlog.notify_url);
                cmd.AddParam("@seller_email", nowlog.seller_email);
                cmd.AddParam("@seller_user_id", nowlog.seller_user_id);
                cmd.AddParam("@refund_date", nowlog.refund_date);
                cmd.AddParam("@batch_no", nowlog.batch_no);
                cmd.AddParam("@batch_num", nowlog.batch_num);
                cmd.AddParam("@detail_data", nowlog.detail_data);
                cmd.AddParam("@notify_time", nowlog.notify_time);
                cmd.AddParam("@notify_type", nowlog.notify_type);
                cmd.AddParam("@notify_id", nowlog.notify_id);
                cmd.AddParam("@success_num", nowlog.success_num);
                cmd.AddParam("@result_details", nowlog.result_details);
                cmd.AddParam("@error_code", nowlog.error_code);
                cmd.AddParam("@error_desc", nowlog.error_desc);
                cmd.AddParam("@refund_fee", nowlog.refund_fee);
                cmd.AddParam("@rentserver_refundlogid", nowlog.rentserver_refundlogid);

                cmd.ExecuteNonQuery();
                return(nowlog.id);
            }
        }