コード例 #1
0
        public int AddMedal_U(int id, int sender)
        {
            if (CheckMedalDiff(id, sender))
            {
                return(-2);
            }                                             //不能重复颁发
            B_Guest_Bar     barbll  = new B_Guest_Bar();
            M_Guest_Bar     barmod  = barbll.SelReturnModel(id);
            M_GuestBookCate catemod = new B_GuestBookCate().SelReturnModel(barmod.CateID);
            int             medalid = 2;//吧主勋章

            //不是吧主扣除积分
            if (!catemod.IsBarOwner(sender))
            {
                if (barmod.CUser == sender)
                {
                    return(-3);
                }            //非吧主不能给自己颁发勋章
                medalid = 1; //网友勋章
                B_User     buser = new B_User();
                M_UserInfo mu    = buser.SelReturnModel(sender);
                if (mu.UserExp <= 0)
                {
                    return(-1);
                }                                  //用户积分不足
                buser.ChangeVirtualMoney(sender, new M_UserExpHis()
                {
                    score     = -1,
                    ScoreType = (int)M_UserExpHis.SType.Point,
                    detail    = string.Format("{0} {1}在版面:{2}发表勋章给:[{3}]的贴子,扣除{4}分", DateTime.Now, mu.UserName, catemod.CateName, barmod.Title, catemod.SendScore)
                });
            }
            Insert(new M_Guest_Medals()
            {
                UserID = barmod.CUser, BarID = id, MedalID = medalid, Sender = sender
            });
            return(medalid);
        }