Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string str  = "";
            string str2 = base.Request.QueryString["vaid"];

            if (!string.IsNullOrEmpty(str2))
            {
                List <string> values = OneyuanTaoHelp.GetParticipantPids(str2, true, false, "alipay");
                if (values.Count == 0)
                {
                    base.Response.Write("没有适合支付宝退款的活动参与记录!");
                    return;
                }
                str = string.Join(",", values);
            }
            if (str == "")
            {
                str = base.Request.QueryString["pids"];
            }
            if (string.IsNullOrEmpty(str))
            {
                base.Response.Write("非正常访问!");
            }
            else
            {
                IList <OneyuanTaoParticipantInfo> refundParticipantList = OneyuanTaoHelp.GetRefundParticipantList(str.Replace(" ", "").Replace(" ", "").Trim().Split(new char[] { ',' }));
                if (refundParticipantList == null)
                {
                    base.Response.Write("获取夺宝信息失败,可能信息已删除!");
                }
                else
                {
                    List <alipayReturnInfo> refundList     = new List <alipayReturnInfo>();
                    SiteSettings            masterSettings = SettingsManager.GetMasterSettings(false);
                    foreach (OneyuanTaoParticipantInfo info in refundParticipantList)
                    {
                        if (((info.IsPay && !info.IsRefund) && (!info.IsWin && !string.IsNullOrEmpty(info.PayNum))) && (!string.IsNullOrEmpty(info.PayWay) && !(info.PayWay == "weixin")))
                        {
                            alipayReturnInfo item = new alipayReturnInfo
                            {
                                alipaynum = info.PayNum,
                                refundNum = info.TotalPrice,
                                Remark    = masterSettings.SiteName + "退款,对应活动编码:" + info.ActivityId
                            };
                            refundList.Add(item);
                        }
                    }
                    if (refundList.Count == 0)
                    {
                        base.Response.Write("当前选择的退款记录不符号退款条件,为非支付宝付款记录!");
                    }
                    else
                    {
                        string s = RefundHelper.AlipayRefundRequest(string.Format("http://{0}/Admin/OutPay/OneyuanAlipayRefundNotify.aspx", base.Request.Url.Host), refundList);
                        base.Response.Write(s);
                        base.Response.End();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text  = "";
            string text2 = base.Request.QueryString["vaid"];

            if (!string.IsNullOrEmpty(text2))
            {
                System.Collections.Generic.List <string> participantPids = OneyuanTaoHelp.GetParticipantPids(text2, true, false, "alipay");
                if (participantPids.Count == 0)
                {
                    base.Response.Write("没有适合支付宝退款的活动参与记录!");
                    return;
                }
                text = string.Join(",", participantPids);
            }
            if (text == "")
            {
                text = base.Request.QueryString["pids"];
            }
            if (string.IsNullOrEmpty(text))
            {
                base.Response.Write("非正常访问!");
                return;
            }
            text = text.Replace("\u3000", "").Replace(" ", "").Trim();
            string[] pIds = text.Split(new char[]
            {
                ','
            });
            System.Collections.Generic.IList <OneyuanTaoParticipantInfo> refundParticipantList = OneyuanTaoHelp.GetRefundParticipantList(pIds);
            if (refundParticipantList == null)
            {
                base.Response.Write("获取夺宝信息失败,可能信息已删除!");
                return;
            }
            System.Collections.Generic.List <alipayReturnInfo> list = new System.Collections.Generic.List <alipayReturnInfo>();
            foreach (OneyuanTaoParticipantInfo current in refundParticipantList)
            {
                if (current.IsPay && !current.IsRefund && !current.IsWin && !string.IsNullOrEmpty(current.PayNum) && !string.IsNullOrEmpty(current.PayWay) && !(current.PayWay == "weixin"))
                {
                    alipayReturnInfo item = new alipayReturnInfo
                    {
                        alipaynum = current.PayNum,
                        refundNum = current.TotalPrice,
                        Remark    = "一元夺宝退款,对应活动编码:" + current.ActivityId
                    };
                    list.Add(item);
                }
            }
            if (list.Count == 0)
            {
                base.Response.Write("当前选择的退款记录不符号退款条件,为非支付宝付款记录!");
                return;
            }
            string notify_url = string.Format("http://{0}/Admin/OutPay/OneyuanAlipayRefundNotify.aspx", base.Request.Url.Host);
            string s          = RefundHelper.AlipayRefundRequest(notify_url, list);

            base.Response.Write(s);
            base.Response.End();
        }
Ejemplo n.º 3
0
        private string BatchWxRefund(string Pids)
        {
            List <string> source = new List <string>();
            string        str    = "";

            if (string.IsNullOrEmpty(Pids))
            {
                str = "{\"state\":false,\"msg\":\"参数错误!\"}";
            }
            else
            {
                string message = "";
                IList <OneyuanTaoParticipantInfo> refundParticipantList = OneyuanTaoHelp.GetRefundParticipantList(Pids.Replace(" ", "").Replace(" ", "").Split(new char[] { ',' }));
                int num = 0;
                foreach (OneyuanTaoParticipantInfo info in refundParticipantList)
                {
                    try
                    {
                        if (((info != null) && info.IsPay) && (info.PayWay == "weixin"))
                        {
                            source.Add(info.ActivityId);
                            if (!info.IsRefund)
                            {
                                string str3 = info.out_refund_no;
                                if (string.IsNullOrEmpty(str3))
                                {
                                    str3 = RefundHelper.GenerateRefundOrderId();
                                    OneyuanTaoHelp.Setout_refund_no(info.Pid, str3);
                                }
                                string wxRefundNum = "";
                                string str5        = RefundHelper.SendWxRefundRequest(info.Pid, info.TotalPrice, info.TotalPrice, str3, out wxRefundNum);
                                if (str5 == "")
                                {
                                    info.Remark    = "退款成功";
                                    info.RefundNum = wxRefundNum;
                                    OneyuanTaoHelp.SetRefundinfo(info);
                                    num++;
                                    continue;
                                }
                                info.Remark = "退款失败:" + str5.Replace("OK", "");
                                OneyuanTaoHelp.SetRefundinfoErr(info);
                                if (((!str5.Contains("金额不足") && !str5.Contains("mch_id")) && (!str5.Contains("mch_id") && !str5.ToLower().Contains("appid"))) && ((!str5.Contains("密码") && !str5.Contains("证书")) && (!str5.Contains("签名") && !str5.ToLower().Contains("mchid"))))
                                {
                                    continue;
                                }
                                message = str5;
                                break;
                            }
                            num++;
                        }
                    }
                    catch (Exception exception)
                    {
                        message = exception.Message;
                        Globals.Debuglog("微信退款异常信息:" + exception.Message, "_wxrefund.txt");
                    }
                }
                if (num == 0)
                {
                    if (message == "")
                    {
                        str = "{\"state\":false,\"msg\":\"微信批量退款失败!\"}";
                    }
                    else
                    {
                        message = message.Replace(",", ",").Replace("\"", " ").Replace("'", " ").Replace(":", " ");
                        str     = "{\"state\":false,\"msg\":\"退款中断->" + message + "\"}";
                    }
                }
                else
                {
                    string[] strArray2 = new string[] { "{\"state\":true,\"msg\":\"成功退款", num.ToString(), "笔,失败", (refundParticipantList.Count - num).ToString(), "笔\"}" };
                    str = string.Concat(strArray2);
                }
            }
            OneyuanTaoHelp.SetIsAllRefund(source.Distinct <string>().ToList <string>());
            return(str);
        }
Ejemplo n.º 4
0
        private string BatchWxRefund(string Pids)
        {
            System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
            string result;

            if (!string.IsNullOrEmpty(Pids))
            {
                string   text = "";
                string[] pIds = Pids.Replace(" ", "").Replace("\u3000", "").Split(new char[]
                {
                    ','
                });
                System.Collections.Generic.IList <OneyuanTaoParticipantInfo> refundParticipantList = OneyuanTaoHelp.GetRefundParticipantList(pIds);
                int num = 0;
                foreach (OneyuanTaoParticipantInfo current in refundParticipantList)
                {
                    try
                    {
                        if (current != null && current.IsPay && current.PayWay == "weixin")
                        {
                            list.Add(current.ActivityId);
                            if (!current.IsRefund)
                            {
                                string text2 = current.out_refund_no;
                                if (string.IsNullOrEmpty(text2))
                                {
                                    text2 = RefundHelper.GenerateRefundOrderId();
                                    OneyuanTaoHelp.Setout_refund_no(current.Pid, text2);
                                }
                                string refundNum = "";
                                string text3     = RefundHelper.SendWxRefundRequest(current.Pid, current.TotalPrice, current.TotalPrice, text2, out refundNum);
                                if (text3 == "")
                                {
                                    current.Remark    = "退款成功";
                                    current.RefundNum = refundNum;
                                    OneyuanTaoHelp.SetRefundinfo(current);
                                    num++;
                                }
                                else
                                {
                                    current.Remark = "退款失败:" + text3.Replace("OK", "");
                                    OneyuanTaoHelp.SetRefundinfoErr(current);
                                    if (text3.Contains("金额不足") || text3.Contains("mch_id") || text3.Contains("mch_id") || text3.ToLower().Contains("appid") || text3.Contains("密码") || text3.Contains("证书") || text3.Contains("签名") || text3.ToLower().Contains("mchid"))
                                    {
                                        text = text3;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                num++;
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        text = ex.Message;
                        Globals.Debuglog("微信退款异常信息:" + ex.Message, "_wxrefund.txt");
                    }
                }
                if (num == 0)
                {
                    if (text == "")
                    {
                        result = "{\"state\":false,\"msg\":\"微信批量退款失败!\"}";
                    }
                    else
                    {
                        text   = text.Replace(",", ",").Replace("\"", " ").Replace("'", " ").Replace(":", " ");
                        result = "{\"state\":false,\"msg\":\"退款中断->" + text + "\"}";
                    }
                }
                else
                {
                    result = string.Concat(new string[]
                    {
                        "{\"state\":true,\"msg\":\"成功退款",
                        num.ToString(),
                        "笔,失败",
                        (refundParticipantList.Count - num).ToString(),
                        "笔\"}"
                    });
                }
            }
            else
            {
                result = "{\"state\":false,\"msg\":\"参数错误!\"}";
            }
            list = list.Distinct <string>().ToList <string>();
            OneyuanTaoHelp.SetIsAllRefund(list);
            return(result);
        }