示例#1
0
        public void BuyInviteCode()
        {
            if (invitecodecount >= invitationconfiginfo.InviteCodeMaxCountToBuy)
            {
                AddErrLine("您所拥有的邀请码数量超过了系统上限,无法再购买");
                return;
            }

            string[] strExtCredits = Utils.SplitString(invitationconfiginfo.InviteCodePrice, ",");
            float[]  extCredits    = new float[8];
            for (int i = 0; i < 8; i++)
            {
                extCredits[i] = Utils.StrToFloat(strExtCredits[i], 0) * -1;
            }

            if (UserCredits.UpdateUserExtCredits(userid, extCredits, false) > 0)
            {
                CreateInviteCode();
            }
            else
            {
                string addExtCreditsTip = "";
                if (EPayments.IsOpenEPayments())
                {
                    addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>";
                }
                AddErrLine("积分不足,无法购买邀请码" + addExtCreditsTip);
                return;
            }
        }
示例#2
0
        /// <summary>
        /// 发帖成功
        /// </summary>
        /// <param name="values">版块积分设置</param>
        /// <param name="topicinfo">主题信息</param>
        /// <param name="topicid">主题ID</param>
        private void PostTopicSucceed(float[] values, TopicInfo topicinfo, int topicid)
        {
            if (values != null) ///使用版块内积分
            {
                UserCredits.UpdateUserExtCredits(userid, values, false);
                if (userid != -1)
                    UserCredits.WriteUpdateUserExtCreditsCookies(values);
            }
            else ///使用默认积分
            {
                UserCredits.UpdateUserCreditsByPostTopic(userid);
                if (userid != -1)
                    UserCredits.WriteUpdateUserExtCreditsCookies(Scoresets.GetUserExtCredits(CreditsOperationType.PostTopic));
            }

            //当使用伪aspx
            if (config.Aspxrewrite == 1)
                SetUrl(topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0));
            else
                SetUrl((topicinfo.Special == 4 ? ShowDebateAspxRewrite(topicid) : ShowTopicAspxRewrite(topicid, 0)) + "&forumpage=" + forumpageid);

            ForumUtils.WriteCookie("postmessage", "");
            ForumUtils.WriteCookie("clearUserdata", "forum");
            SetLastPostedForumCookie();

            SetMetaRefresh();
            MsgForward("posttopic_succeed");
            AddMsgLine("发表主题成功, 返回该主题<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, forumpageid) + "\">点击这里返回 " + forum.Name + "</a>)<br />");

            //通知应用有新主题
            Sync.NewTopic(topicid.ToString(), topicinfo.Title, topicinfo.Poster, topicinfo.Posterid.ToString(), topicinfo.Fid.ToString(), "");
        }
示例#3
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");
            }
        }
示例#4
0
 /// <summary>
 /// 更新用户积分
 /// </summary>
 /// <param name="values">版块积分设置</param>
 private void UpdateUserCredits(float[] values)
 {
     if (values != null)
     {
         UserCredits.UpdateUserExtCredits(userid, values, false);//使用版块内积分
         if (userid != -1)
         {
             UserCredits.WriteUpdateUserExtCreditsCookies(values);
         }
     }
     else
     {
         UserCredits.UpdateUserCreditsByPosts(userid);//使用默认积分
         if (userid != -1)
         {
             UserCredits.WriteUpdateUserExtCreditsCookies(Scoresets.GetUserExtCredits(CreditsOperationType.PostReply));
         }
     }
 }
示例#5
0
        public string SetExtCredits()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }

                if (Discuz.Forum.Users.GetShortUserInfo(Uid).Adminid != 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            if (!this.CheckRequiredParams("uids,additional_values"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            if (!Utils.IsNumericArray(GetParam("additional_values").ToString().Split(',')) || !Utils.IsNumericArray(GetParam("uids").ToString().Split(',')))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            string[] values = GetParam("additional_values").ToString().Split(',');
            if (values.Length != 8)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            List <float> list = new List <float>();

            for (int i = 0; i < values.Length; i++)
            {
                list.Add(Utils.StrToFloat(values[i], 0));
            }

            foreach (string uId in GetParam("uids").ToString().Split(','))
            {
                int id = TypeConverter.StrToInt(uId);
                if (id == 0)
                {
                    continue;
                }
                UserCredits.UpdateUserExtCredits(id, list.ToArray(), true);
                UserCredits.UpdateUserCredits(id);

                //向第三方应用同步积分
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != 0.0)
                    {
                        Sync.UpdateCredits(TypeConverter.StrToInt(uId), i + 1, list[i].ToString(), ApiKey);
                    }
                }
            }

            int successful = 1;

            if (Format == FormatType.JSON)
            {
                return(successful == 1 ? "true" : "false");
            }

            SetExtCreditsResponse secr = new SetExtCreditsResponse();

            secr.Successfull = successful;

            return(SerializationHelper.Serialize(secr));
        }