/// <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) { topicinfo.Special = 3; Topics.UpdateSpecial(topicinfo);//更新标志位为已结帖状态 //开始给分和记录 int winerId = 0, isbest = 0, postid = 0, bonus = 0; string winnerName = string.Empty; for (int i = 0; i < winerIdArray.Length; i++) { winerId = winerIdArray[i]; bonus = Utils.StrToInt(costBonusArray[i], 0); winnerName = winnerNameArray[i]; postid = postIdArray[i]; if (winerId > 0 && bonus > 0) { Users.UpdateUserExtCredits(winerId, Scoresets.GetCreditsTrans(), bonus); } if (Utils.InArray(postid.ToString(), valuableAnswerArray)) { isbest = 1; } if (postid == bestAnswer) { isbest = 2; } AddLog(topicinfo.Tid, topicinfo.Posterid, winerId, winnerName, postid, bonus, isbest); } }
/// <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)); }
/// <summary> /// 添加悬赏日志 /// </summary> /// <param name="tid">主题Id</param> /// <param name="authorid">悬赏者Id</param> /// <param name="winerid">获奖者Id</param> /// <param name="winnerName">获奖者用户名</param> /// <param name="postid">帖子Id</param> /// <param name="bonus">奖励积分</param> /// <param name="isbest">是否是最佳答案,0=不是,1=是较好的答案,2=最佳答案</param> public static void AddLog(int tid, int authorid, int winerid, string winnerName, int postid, int bonus, int isbest) { DatabaseProvider.GetInstance().AddBonusLog(tid, authorid, winerid, winnerName, postid, bonus, Scoresets.GetCreditsTrans(), isbest); }