示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Tolog("进入支付回调");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                xmlDoc.Save(string.Format("C:\\WXPay\\PayRechargeNotify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));//写入日志

                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }
                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value); //全部参数排序
                PayConfig payConfig = bllPay.GetPayConfig();
                if (!bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))              //验证签名
                {
                    Tolog("验证签名出错");
                    Response.Write(failXml);
                    return;
                }
                OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"]);
                if (orderPay == null)
                {
                    Tolog("订单未找到");
                    Response.Write(failXml);
                    return;
                }
                if (orderPay.Status.Equals(1))
                {
                    Tolog("已支付");
                    Response.Write(successXml);
                    return;
                }
                //更新订单状态
                if (parametersAll["return_code"].Equals("SUCCESS") && parametersAll["result_code"].Equals("SUCCESS"))//交易成功
                {
                    string msg = "";
                    orderPay.Trade_No = parametersAll["transaction_id"];
                    if (!bll.PayRechargeTransfers(orderPay, parametersAll["openid"], parametersAll["transaction_id"], out msg))
                    {
                        Tolog(msg);
                        Response.Write(failXml);
                        return;
                    }
                    Response.Write(successXml);
                    return;
                }
                Tolog("返回信息有误");
                Response.Write(failXml);
            }
            catch (Exception ex)
            {
                Tolog("出错了:" + ex.Message);
                Response.Write(failXml);
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                try
                {
                    xmlDoc.Save(string.Format("C:\\WXPay\\Notify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                }
                catch (Exception)
                {
                }
                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }

                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value);//全部参数排序

                BllOrder bllOrder = new BllOrder();
                BLLJIMP.Model.OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"], "", bllOrder.WebsiteOwner);

                BllPay    bllPay    = new BllPay();
                PayConfig payConfig = bllPay.GetPayConfig();
                if (bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))//验证签名
                {
                    if (orderPay == null)
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }

                    if (orderPay.Status == 1)
                    {
                        Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                        return;
                    }
                    orderPay.Status = 1;
                    if (bllOrder.Update(orderPay))
                    {
                        BLLUser bllUser = new BLLUser();
                        if (orderPay.Type == "1")
                        {
                            int score = 0;
                            int.TryParse(orderPay.Ex1, out score);
                            BLLKeyValueData bllKeyValueData  = new BLLKeyValueData();
                            string          ScoreDispalyName = bllKeyValueData.GetDataVaule("ScoreDispalyName", "1", bllKeyValueData.WebsiteOwner);

                            string msg = "消费" + orderPay.Total_Fee + "元,充值" + score + ScoreDispalyName;
                            if (bllUser.AddUserScoreDetail(orderPay.UserId, EnumStringHelper.ToString(ScoreDefineType.Recharge), bllUser.WebsiteOwner, score, msg))
                            {
                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                            //BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                            //bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);
                        }
                        else if (orderPay.Type == "2")
                        {
                            string invoiceMsg;
                            if (orderPay.Ex1 == "1")
                            {
                                invoiceMsg = "带发票,";
                            }
                            else
                            {
                                invoiceMsg = "无发票,";
                            }

                            string msg = "充值VIP," + invoiceMsg + "消费" + orderPay.Total_Fee.ToString() + "元";


                            BLLKeyValueData bllKeyValueData = new BLLKeyValueData();
                            string          VIPDatelong     = bllKeyValueData.GetDataVaule("VIPDatelong", "1", bllKeyValueData.WebsiteOwner);
                            if (string.IsNullOrWhiteSpace(VIPDatelong))
                            {
                                VIPDatelong = "12";
                            }
                            int datelong = Convert.ToInt32(VIPDatelong);

                            BLLUserExpand bllUserExpand = new BLLUserExpand();
                            UserExpand    userVip       = bllUserExpand.GetUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId);
                            string        userVipEndDate;
                            if (userVip == null || DateTime.Parse(userVip.DataValue) < DateTime.Now)
                            {
                                userVipEndDate = DateTime.Now.AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                userVipEndDate = DateTime.Parse(userVip.DataValue).AddMonths(datelong).ToString("yyyy-MM-dd");
                            }
                            bllUserExpand.UpdateUserExpand(BLLJIMP.Enums.UserExpandType.UserIsVip, orderPay.UserId, userVipEndDate);

                            //更新用户字段
                            UserScoreDetailsInfo scoreModel = new UserScoreDetailsInfo();
                            scoreModel.AddNote   = msg;
                            scoreModel.AddTime   = DateTime.Now;
                            scoreModel.Score     = 0;
                            scoreModel.UserID    = orderPay.UserId;
                            scoreModel.ScoreType = "RechargeVIP";
                            UserInfo currUser = bllUser.GetUserInfo(orderPay.UserId);
                            scoreModel.TotalScore   = currUser.TotalScore;
                            scoreModel.WebSiteOwner = currUser.WebsiteOwner;
                            if (bllUser.Add(scoreModel))
                            {
                                BLLSystemNotice bllSystemNotice = new BLLSystemNotice();
                                bllSystemNotice.SendNotice(BLLSystemNotice.NoticeType.SystemMessage, null, null, orderPay.UserId, msg);

                                Response.Write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
                            }
                            else
                            {
                                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                            }
                        }

                        return;
                    }
                    else
                    {
                        Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
                        return;
                    }
                }
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
            catch (Exception)
            {
                Response.Write("<xml><return_code><![CDATA[FAIL]]></return_code></xml>");
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Tolog("进入支付回调");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                //xmlDoc.Load(@"D:\PayRegisterNotify20170613203329981.xml");
                xmlDoc.Save(string.Format("C:\\WXPay\\PayRegisterNotify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));//写入日志

                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }
                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value); //全部参数排序
                PayConfig payConfig = bllPay.GetPayConfig();
                if (!bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))              //验证签名
                {
                    Tolog("验证签名出错");
                    Response.Write(failXml);
                    return;
                }
                OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"]);
                if (orderPay == null)
                {
                    Tolog("订单未找到");
                    Response.Write(failXml);
                    return;
                }
                if (orderPay.Status.Equals(1))
                {
                    Tolog("已支付");
                    Response.Write(successXml);
                    return;
                }
                BLLJIMP.Model.API.User.PayRegisterUser requestUser = JsonConvert.DeserializeObject <BLLJIMP.Model.API.User.PayRegisterUser>(orderPay.Ex1);
                UserLevelConfig levelConfig = bll.QueryUserLevel(orderPay.WebsiteOwner, "DistributionOnLine", requestUser.level.ToString());
                if (levelConfig == null)
                {
                    Tolog("会员等级未找到");
                    Response.Write(failXml);
                    return;
                }
                //更新订单状态
                if (parametersAll["return_code"].Equals("SUCCESS") && parametersAll["result_code"].Equals("SUCCESS"))//交易成功
                {
                    UserInfo regUser = bllUser.GetUserInfoByPhone(requestUser.phone, orderPay.WebsiteOwner);
                    if (regUser != null && regUser.MemberLevel >= 10)
                    {
                        Tolog("该手机已注册会员");
                        Response.Write(failXml);
                        return;
                    }
                    if (regUser != null && regUser.MemberLevel > requestUser.level)
                    {
                        Tolog("该会员有更高级别");
                        Response.Write(failXml);
                        return;
                    }
                    if (regUser != null)
                    {
                        regUser.UserType          = 2;
                        regUser.TrueName          = requestUser.truename;
                        regUser.DistributionOwner = requestUser.spreadid;
                        regUser.MemberLevel       = requestUser.level;
                        regUser.MemberStartTime   = DateTime.Now;
                        regUser.MemberApplyTime   = orderPay.InsertDate;
                        regUser.RegIP             = requestUser.regIP;
                        regUser.Password          = requestUser.password;
                        regUser.MemberApplyStatus = 9;
                        regUser.IdentityCard      = requestUser.idcard;
                        regUser.Province          = requestUser.province;
                        regUser.City         = requestUser.city;
                        regUser.District     = requestUser.district;
                        regUser.Town         = requestUser.town;
                        regUser.ProvinceCode = requestUser.provinceCode;
                        regUser.CityCode     = requestUser.cityCode;
                        regUser.DistrictCode = requestUser.districtCode;
                        regUser.TownCode     = requestUser.townCode;
                        regUser.RegUserID    = null;
                        regUser.RegisterWay  = "线上";
                        regUser.IsDisable    = 0;
                        regUser.RegUserID    = null;
                    }
                    else
                    {
                        regUser                   = new UserInfo();
                        regUser.UserID            = requestUser.userid;
                        regUser.UserType          = 2;
                        regUser.TrueName          = requestUser.truename;
                        regUser.WebsiteOwner      = orderPay.WebsiteOwner;
                        regUser.DistributionOwner = requestUser.spreadid;
                        regUser.Phone             = requestUser.phone;
                        regUser.MemberLevel       = requestUser.level;
                        regUser.MemberStartTime   = DateTime.Now;
                        regUser.MemberApplyTime   = orderPay.InsertDate;
                        regUser.Regtime           = DateTime.Now;
                        regUser.LastLoginDate     = DateTime.Parse("1970-01-01");
                        regUser.RegIP             = requestUser.regIP;
                        regUser.Password          = requestUser.password;
                        regUser.MemberApplyStatus = 9;
                        regUser.IdentityCard      = requestUser.idcard;
                        regUser.Province          = requestUser.province;
                        regUser.City              = requestUser.city;
                        regUser.District          = requestUser.district;
                        regUser.Town              = requestUser.town;
                        regUser.ProvinceCode      = requestUser.provinceCode;
                        regUser.CityCode          = requestUser.cityCode;
                        regUser.DistrictCode      = requestUser.districtCode;
                        regUser.TownCode          = requestUser.townCode;
                        regUser.RegisterWay       = "线上";
                        regUser.IsDisable         = 0;
                        regUser.RegUserID         = null;
                    }
                    string msg = "";
                    orderPay.Trade_No = parametersAll["transaction_id"];
                    //线上注册分佣
                    if (!bll.PayRegisterTransfers(regUser, orderPay, parametersAll["openid"], parametersAll["transaction_id"], levelConfig, out msg))
                    {
                        Tolog(msg);
                        Response.Write(failXml);
                        return;
                    }
                    //发送优惠券
                    if (!string.IsNullOrEmpty(levelConfig.CouponId))
                    {
                        BLLCardCoupon bllCardCoupon = new BLLCardCoupon();
                        bllCardCoupon.SendCardCouponsByCurrUserInfo(regUser, levelConfig.CouponId);
                    }

                    Response.Write(successXml);
                    return;
                }
                Tolog("返回信息有误");
                Response.Write(failXml);
            }
            catch (Exception ex)
            {
                Tolog("出错了:" + ex.ToString());
                Response.Write(failXml);
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Tolog("进入支付回调");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                xmlDoc.Save(string.Format("C:\\WXPay\\NotifyActivity{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));//写入日志

                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }
                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value); //全部参数排序
                PayConfig payConfig = bllPay.GetPayConfig();
                if (!bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))              //验证签名
                {
                    Tolog("验证签名出错");
                    Response.Write(failXml);
                    return;
                }
                var orderInfo = bllMeifan.GetActivityDataByOrderId(parametersAll["out_trade_no"]);
                if (orderInfo == null)
                {
                    // Tolog("订单未找到");
                    Response.Write(failXml);
                    return;
                }
                if (orderInfo.PaymentStatus == 1)
                {
                    // Tolog("已支付");
                    Response.Write(successXml);
                    return;
                }
                //更新订单状态
                if (parametersAll["return_code"].Equals("SUCCESS") && parametersAll["result_code"].Equals("SUCCESS"))//交易成功
                {
                    //orderInfo.PaymentStatus = 1;
                    if (bllOrder.Update(orderInfo, string.Format(" PaymentStatus=1"), string.Format(" OrderId='{0}'", orderInfo.OrderId)) > 0)
                    {
                        Response.Write(successXml);
                        return;
                    }
                    else
                    {
                        Response.Write(failXml);
                        return;
                    }
                }

                Response.Write(failXml);
            }
            catch (Exception ex)
            {
                Tolog("出错了:" + ex.ToString());
                Response.Write(failXml);
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //Tolog("进入支付回调");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Request.InputStream);
                xmlDoc.Save(string.Format("C:\\WXPay\\PayUpgradeNotify{0}.xml", DateTime.Now.ToString("yyyyMMddHHmmssfff")));//写入日志

                //全部参数
                Dictionary <string, string> parametersAll = new Dictionary <string, string>();
                foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes)
                {
                    string key   = item.Name;
                    string value = item.InnerText;
                    if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value)))
                    {
                        parametersAll.Add(key, value);
                    }
                }
                parametersAll = (from entry in parametersAll
                                 orderby entry.Key ascending
                                 select entry).ToDictionary(pair => pair.Key, pair => pair.Value); //全部参数排序
                PayConfig payConfig = bllPay.GetPayConfig();
                if (!bllPay.VerifySignatureWx(parametersAll, payConfig.WXPartnerKey))              //验证签名
                {
                    Tolog("验证签名出错");
                    Response.Write(failXml);
                    return;
                }
                OrderPay orderPay = bllOrder.GetOrderPay(parametersAll["out_trade_no"]);
                if (orderPay == null)
                {
                    Tolog("订单未找到");
                    Response.Write(failXml);
                    return;
                }
                if (orderPay.Status.Equals(1))
                {
                    Tolog("已支付");
                    Response.Write(successXml);
                    return;
                }
                BLLJIMP.Model.API.User.PayUpgrade payUpgrade = JsonConvert.DeserializeObject <BLLJIMP.Model.API.User.PayUpgrade>(orderPay.Ex1);
                //更新订单状态
                if (parametersAll["return_code"].Equals("SUCCESS") && parametersAll["result_code"].Equals("SUCCESS"))//交易成功
                {
                    string msg = "";
                    orderPay.Trade_No = parametersAll["transaction_id"];
                    UserLevelConfig levelConfig = bll.QueryUserLevel(orderPay.WebsiteOwner, "DistributionOnLine", payUpgrade.toLevel.ToString());
                    UserInfo        payUser     = bllUser.GetUserInfo(orderPay.UserId, orderPay.WebsiteOwner);
                    if (!string.IsNullOrEmpty(levelConfig.CouponId))
                    {
                        BLLCardCoupon bllCardCoupon = new BLLCardCoupon();
                        bllCardCoupon.SendCardCouponsByCurrUserInfo(payUser, levelConfig.CouponId);
                    }
                    //支付升级分佣
                    if (!bll.PayUpgradeTransfers(orderPay, payUpgrade, parametersAll["openid"], parametersAll["transaction_id"], out msg))
                    {
                        Tolog(msg);
                        Response.Write(failXml);
                        return;
                    }

                    Response.Write(successXml);
                    return;
                }
                Tolog("返回信息有误");
                Response.Write(failXml);
            }
            catch (Exception ex)
            {
                Tolog("出错了:" + ex.Message);
                Response.Write(failXml);
            }
        }