Пример #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));
        }
Пример #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));
        }
Пример #3
0
 /// <summary>
 /// 获取主题附件交易积分字段名称
 /// </summary>
 /// <returns></returns>
 public static string GetTopicAttachCreditsTransName()
 {
     return(Scoresets.GetValidScoreName()[Scoresets.GetTopicAttachCreditsTrans()]);
 }