예제 #1
0
        public NotifyPage()
        {
            if (EPayments.CheckPayment(DNTRequest.GetString("notify_id")))//验证请求是否来自支付宝,或者是伪造的
            {
                //获取需要的信息
                int    orderStatus = EPayments.ConvertAlipayTradeStatus(DNTRequest.GetString("trade_status"));
                string orderCode   = DNTRequest.GetString("out_trade_no", true);
                string tradeNo     = DNTRequest.GetString("trade_no", true);

                if (string.IsNullOrEmpty(orderCode) || string.IsNullOrEmpty(tradeNo) || orderStatus <= 0)
                {
                    return;
                }

                CreditOrderInfo orderInfo = CreditOrders.GetCreditOrderInfoByOrderCode(orderCode);


                //如果订单状态为未成功交易
                if (orderInfo != null && orderInfo.OrderStatus < 2)
                {
                    float[] extcredits = new float[8];
                    extcredits[orderInfo.Credit - 1] = orderInfo.Amount;

                    if (UserCredits.UpdateUserExtCredits(orderInfo.Uid, extcredits, true) != 1)
                    {
                        orderStatus = 0;
                    }

                    CreditsLogs.AddCreditsLog(orderInfo.Uid, orderInfo.Uid, orderInfo.Credit, orderInfo.Credit, 0, orderInfo.Amount, Utils.GetDateTime(), 3);//添加积分兑换转账和充值记录

                    NoticeInfo notice = new NoticeInfo();
                    notice.Postdatetime = Utils.GetDateTime();
                    notice.Type         = NoticeType.GoodsTradeNotice;
                    notice.Poster       = "系统";
                    notice.Posterid     = 0;
                    notice.Uid          = orderInfo.Uid;
                    notice.Note         = string.Format("您购买的积分 {0} 已经成功充值,请<a href=\"usercpcreaditstransferlog.aspx\">查收</a>!(支付宝订单号:{1})", ForumUtils.ConvertCreditAndAmountToWord(orderInfo.Credit, orderInfo.Amount), tradeNo);
                    Notices.CreateNoticeInfo(notice);

                    CreditOrders.UpdateCreditOrderInfo(orderInfo.OrderId, tradeNo, orderStatus, Utils.GetDateTime());//修改积分订单记录状态
                }
                //判断当前请求是支付宝GET式(直接跳转)或者是服务器POST式(需返回success使得支付宝停止继续发送通知)
                if (DNTRequest.IsPost())
                {
                    HttpContext.Current.Response.Write("success");
                }
                else
                {
                    HttpContext.Current.Response.Redirect("../usercpcreaditstransferlog.aspx?paysuccess=true");
                }
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (!IsLogin())
            {
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                bool isPasswordError = true;

                switch (config.Passwordmode)
                {
                case 1:    //动网兼容模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                case 0:    //默认模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                default:     //第三方加密验证模式
                {
                    if (PasswordModeProvider.GetInstance() != null)
                    {
                        isPasswordError = !PasswordModeProvider.GetInstance().CheckPassword(user, DNTRequest.GetString("password"));
                    }
                    break;
                }
                }
                if (isPasswordError)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于等于0的整数");
                    return;
                }
                int fromto = Users.GetUserId(DNTRequest.GetString("fromto").Trim());
                if (fromto == -1)
                {
                    AddErrLine("指定的转帐接受人不存在");
                    return;
                }
                int extcredits = DNTRequest.GetInt("extcredits", 0);
                if (extcredits < 1 || extcredits > 8)
                {
                    AddErrLine("请正确选择要转帐的积分类型!");
                    return;
                }
                //对转帐后的积分增减进行修改设置
                string extcreditsName = Scoresets.GetScoreSet(extcredits).Name.Trim();
                if (Utils.StrIsNullOrEmpty(extcreditsName))
                {
                    AddErrLine("错误的输入!");
                    return;
                }
                if ((Users.GetUserExtCredits(userid, extcredits) - paynum) < Scoresets.GetTransferMinCredits())
                {
                    AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", extcreditsName, Scoresets.GetTransferMinCredits().ToString()));
                    return;
                }

                //计算并更新2个扩展积分的新值
                float toPayNum = (float)Math.Round(paynum * (1 - creditstax), 2);
                Users.UpdateUserExtCredits(userid, extcredits, paynum * -1);
                Users.UpdateUserExtCredits(fromto, extcredits, toPayNum);
                CreditsLogs.AddCreditsLog(userid, fromto, extcredits, extcredits, paynum, toPayNum, Utils.GetDateTime(), 2);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("积分转帐完毕, 正在返回积分兑换与转帐记录");
            }
        }
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            creditstax = Scoresets.GetCreditsTax();

            if (userid == -1)
            {
                AddErrLine("你尚未登录");

                return;
            }
            user = Discuz.Forum.Users.GetUserInfo(userid);

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (Utils.MD5(DNTRequest.GetString("password")) != password)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于等于0的整数");
                    return;
                }

                int fromto = Discuz.Forum.Users.GetUserID(DNTRequest.GetString("fromto").Trim());
                if (fromto == -1)
                {
                    AddErrLine("指定的转帐接受人不存在");
                    return;
                }

                int extcredits = DNTRequest.GetInt("extcredits", 0);
                if (extcredits < 1 || extcredits > 8)
                {
                    AddErrLine("请正确选择要转帐的金币类型!");
                    return;
                }

                //对转帐后的金币增减进行修改设置
                UserExtcreditsInfo extcreditsinfo = Scoresets.GetScoreSet(extcredits);
                if (extcreditsinfo.Name.Trim() == "")
                {
                    AddErrLine("错误的输入!");
                    return;
                }


                //UserInfo __userinfo = Discuz.Forum.Users.GetUserInfo(userid);
                if ((Discuz.Forum.Users.GetUserExtCredits(userid, extcredits) - paynum) < Scoresets.GetTransferMinCredits())
                {
                    AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", extcreditsinfo.Name, Scoresets.GetTransferMinCredits().ToString()));
                    return;
                }

                //计算并更新2个扩展金币的新值
                float topaynum = (float)Math.Round(paynum * (1 - creditstax), 2);
                Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits, paynum * -1);
                Discuz.Forum.Users.UpdateUserExtCredits(fromto, extcredits, topaynum);
                CreditsLogs.AddCreditsLog(userid, fromto, extcredits, extcredits, paynum, topaynum, Utils.GetDateTime(),
                                          2);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("金币转帐完毕, 正在返回金币兑换与转帐记录");
            }

            score             = Scoresets.GetValidScoreName();
            extcreditspaylist = Scoresets.GetScorePaySet(1);
        }
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            string jsCreditsRateArray = "";

            foreach (DataRow dr in Scoresets.GetScorePaySet(0).Rows)
            {
                jsCreditsRateArray += "creditsrate[" + dr["id"] + "] = " + dr["rate"] + ";\r\n";
            }
            jscreditsratearray = string.Format(jscreditsratearray, jsCreditsRateArray);

            if (!IsLogin())
            {
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                bool isPasswordError = true;

                switch (config.Passwordmode)
                {
                case 1:    //动网兼容模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                case 0:    //默认模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                default:     //第三方加密验证模式
                {
                    if (PasswordModeProvider.GetInstance() != null)
                    {
                        isPasswordError = !PasswordModeProvider.GetInstance().CheckPassword(user, DNTRequest.GetString("password"));
                    }
                    break;
                }
                }
                if (isPasswordError)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于0的整数");
                    return;
                }
                if (DNTRequest.GetInt("extcredits1", 0) < 1 || DNTRequest.GetInt("extcredits2", 0) < 1 || DNTRequest.GetInt("extcredits1", 0) > 8 || DNTRequest.GetInt("extcredits2", 0) > 8)
                {
                    AddErrLine("请正确选择要兑换的积分类型!");
                    return;
                }
                if (DNTRequest.GetInt("extcredits1", 0) == DNTRequest.GetInt("extcredits2", 0))
                {
                    AddErrLine("不能兑换相同类型的积分");
                    return;
                }

                //对交易后的积分增减进行修改设置
                UserExtcreditsInfo extcredits1info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits1", 0));
                UserExtcreditsInfo extcredits2info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits2", 0));
                if (Utils.StrIsNullOrEmpty(extcredits1info.Name) || Utils.StrIsNullOrEmpty(extcredits2info.Name))
                {
                    AddErrLine("错误的输入!");
                    return;
                }
                if ((Users.GetUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0)) - paynum) < Scoresets.GetExchangeMinCredits())
                {
                    AddErrLine("抱歉, 您的 \"" + extcredits1info.Name + "\" 不足." + Scoresets.GetExchangeMinCredits());
                    return;
                }

                UserInfo userInfo = Users.GetUserInfo(userid);

                float extcredit2paynum = (float)Math.Round(paynum * (extcredits1info.Rate / extcredits2info.Rate) * (1 - creditstax), 2);
                Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0), paynum * -1);
                Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits2", 0), extcredit2paynum);
                CreditsLogs.AddCreditsLog(userid, userid, DNTRequest.GetInt("extcredits1", 0), DNTRequest.GetInt("extcredits2", 0), paynum, extcredit2paynum, Utils.GetDateTime(), 1);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("积分兑换完毕, 正在返回积分兑换与转帐记录");
            }
        }
예제 #5
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            creditstax        = Scoresets.GetCreditsTax();
            extcreditspaylist = Scoresets.GetScorePaySet(0);
            score             = Scoresets.GetValidScoreName();

            jscreditsratearray = "<script type=\"text/javascript\">\r\nvar creditsrate = new Array();\r\n";
            foreach (DataRow dr in extcreditspaylist.Rows)
            {
                jscreditsratearray = jscreditsratearray + "creditsrate[" + dr["id"].ToString() + "] = " +
                                     dr["rate"].ToString() + ";\r\n";
            }
            jscreditsratearray = jscreditsratearray + "\r\n</script>";

            if (userid == -1)
            {
                AddErrLine("你尚未登录");

                return;
            }
            user = Discuz.Forum.Users.GetUserInfo(userid);
            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                if (Utils.MD5(DNTRequest.GetString("password")) != password)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于0的整数");
                    return;
                }

                int extcredits1 = DNTRequest.GetInt("extcredits1", 0);
                int extcredits2 = DNTRequest.GetInt("extcredits2", 0);
                if (extcredits1 < 1 || extcredits2 < 1 || extcredits1 > 8 || extcredits2 > 8)
                {
                    AddErrLine("请正确选择要兑换的金币类型!");
                    return;
                }
                if (extcredits1 == extcredits2)
                {
                    AddErrLine("不能兑换相同类型的金币");
                    return;
                }

                //对交易后的金币增减进行修改设置
                UserExtcreditsInfo extcredits1info = Scoresets.GetScoreSet(extcredits1);
                UserExtcreditsInfo extcredits2info = Scoresets.GetScoreSet(extcredits2);

                if ((extcredits1info.Name.Trim() == "") || (extcredits2info.Name.Trim() == ""))
                {
                    AddErrLine("错误的输入!");
                    return;
                }


                UserInfo __userinfo = Discuz.Forum.Users.GetUserInfo(userid);
                if ((Discuz.Forum.Users.GetUserExtCredits(userid, extcredits1) - paynum) < Scoresets.GetExchangeMinCredits())
                {
                    AddErrLine("抱歉, 您的 \"" + extcredits1info.Name + "\" 不足." +
                               Scoresets.GetExchangeMinCredits().ToString());
                    return;
                }

                //计算并更新2个扩展金币的新值
                extcredits1rate = extcredits1info.Rate;
                extcredits2rate = extcredits2info.Rate;
                float extcredit2paynum =
                    (float)Math.Round(paynum * (extcredits1rate / extcredits2rate) * (1 - creditstax), 2);
                Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits1, paynum * -1);
                Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits2, extcredit2paynum);
                CreditsLogs.AddCreditsLog(userid, userid, extcredits1, extcredits2, paynum, extcredit2paynum,
                                          Utils.GetDateTime(), 1);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("金币兑换完毕, 正在返回金币兑换与转帐记录");
            }
        }