Exemplo n.º 1
0
        /// <summary>
        /// 购买主题
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="tid">主题id</param>
        /// <param name="posterid">发帖者用户id</param>
        /// <param name="price">价格</param>
        /// <param name="netamount"></param>
        /// <returns></returns>
        public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount)
        {
            int tmpprice = price;

            if (price > Scoresets.GetMaxIncPerTopic())
            {
                tmpprice = Scoresets.GetMaxIncPerTopic();
            }

            ShortUserInfo userInfo = Discuz.Data.Users.GetShortUserInfo(uid);

            if (userInfo == null)
            {
                return(-2);
            }

            if (GetUserExtCredits(userInfo, Scoresets.GetTopicAttachCreditsTrans()) < price)
            {
                return(-1);
            }

            Discuz.Data.Users.BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetTopicAttachCreditsTrans());
            UserCredits.UpdateUserCredits(uid);
            UserCredits.UpdateUserCredits(posterid);
            return(Discuz.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount));
        }
Exemplo n.º 2
0
        public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount)
        {
            if (price > Scoresets.GetMaxIncPerTopic())
            {
                Scoresets.GetMaxIncPerTopic();
            }

            var user = User.FindByID(uid);

            if (user == null)
            {
                return(-2);
            }

            if (PaymentLogs.GetUserExtCredits(user, Scoresets.GetTopicAttachCreditsTrans()) < (float)price)
            {
                return(-1);
            }

            Discuz.Data.Users.BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetTopicAttachCreditsTrans());
            CreditsFacade.UpdateUserCredits(uid);
            CreditsFacade.UpdateUserCredits(posterid);
            return(Discuz.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 购买主题
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="tid">主题id</param>
        /// <param name="posterid">发帖者用户id</param>
        /// <param name="price">价格</param>
        /// <param name="netamount"></param>
        /// <returns></returns>
        public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount)
        {
            int tmpprice = price;

            if (price > Scoresets.GetMaxIncPerTopic())
            {
                tmpprice = Scoresets.GetMaxIncPerTopic();
            }



            IDataReader reader = Users.GetShortUserInfoToReader(uid);

            if (reader == null)
            {
                return(-2);
            }

            if (!reader.Read())
            {
                reader.Close();
                return(-2);
            }

            if (Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) < price)
            {
                reader.Close();
                return(-1);
            }
            reader.Close();

            DatabaseProvider.GetInstance().BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetCreditsTrans());
            UserCredits.UpdateUserCredits(uid);
            UserCredits.UpdateUserCredits(posterid);
            return(DatabaseProvider.GetInstance().AddPaymentLog(uid, tid, posterid, price, netamount));
        }