Exemplo n.º 1
0
        /// <summary>
        /// 结束悬赏并给分
        /// </summary>
        /// <param name="topicinfo">主题信息</param>
        /// <param name="userid">当前执行此操作的用户Id</param>
        /// <param name="postIdArray">帖子Id数组</param>
        /// <param name="winerIdArray">获奖者Id数组</param>
        /// <param name="winnerNameArray">获奖者的用户名数组</param>
        /// <param name="costBonusArray">奖励积分数组</param>
        /// <param name="valuableAnswerArray">有价值答案的pid数组</param>
        /// <param name="bestAnswer">最佳答案的pid</param>
        public static void CloseBonus(TopicInfo topicinfo, int userid, int[] postIdArray, int[] winerIdArray, string[] winnerNameArray, string[] costBonusArray, string[] valuableAnswerArray, int bestAnswer)
        {
            int isbest = 0, bonus = 0;

            topicinfo.Special = 3;         //标示为悬赏主题
            Topics.UpdateTopic(topicinfo); //更新标志位为已结帖状态

            //开始给分和记录
            for (int i = 0; i < winerIdArray.Length; i++)
            {
                bonus = TypeConverter.StrToInt(costBonusArray[i]);
                if (winerIdArray[i] > 0 && bonus > 0)
                {
                    Users.UpdateUserExtCredits(winerIdArray[i], Scoresets.GetBonusCreditsTrans(), bonus);
                }

                if (Utils.InArray(postIdArray[i].ToString(), valuableAnswerArray))
                {
                    isbest = 1;
                }

                if (postIdArray[i] == bestAnswer)
                {
                    isbest = 2;
                }

                Discuz.Data.Bonus.AddLog(topicinfo.Tid, topicinfo.Posterid, winerIdArray[i], winnerNameArray[i], postIdArray[i], bonus, Scoresets.GetBonusCreditsTrans(), isbest);
            }
        }