コード例 #1
0
ファイル: CouponHandler.cs プロジェクト: longer310/code201406
        private void CouponComment()
        {
            int     cid    = GetInt("couponid");
            int     uid    = GetInt("uid");
            string  msg    = GetString("message");
            var     coupon = CouponHelper.GetItem(cid);
            Comment c      = new Comment();

            c.SellerId = coupon.SellerId;
            c.TypeId   = coupon.Id;
            c.UserId   = uid;
            c.Content  = msg;
            c.Type     = CommentType.Coupons;
            //冗余两个字段
            c.Img   = coupon.ImgUrl;
            c.Title = coupon.Title;

            try
            {
                CommentHelper.Create(c);
                coupon.Commentnum += 1;
                CouponHelper.Update(coupon);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            var          user = AccountHelper.GetUser(uid);
            ExtcreditLog log  = new ExtcreditLog();

            if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentCoupon, cid, uid))
            {
                //积分获得
                log.UserId   = uid;
                log.SellerId = user.SellerId;
                log.SourceId = cid;
                var setting = SystemHelper.GetMerchantExtend(user.SellerId);

                log.Extcredit  = setting != null ? setting.CommentIntegral : 0;
                log.Type       = ExtcreditSourceType.CommentCoupon;
                log.CreateTime = DateTime.Now;

                ExtcreditLogHelper.AddExtcreditLog(log);

                user.Integral += log.Extcredit;
                AccountHelper.SaveAccount(user);
            }

            //ReturnCorrectMsg("评论成功");
            JsonTransfer jt = new JsonTransfer();

            jt.Add("data", new IntegralData(log.Extcredit));
            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
コード例 #2
0
        private void ActiveComment(HttpContext context)
        {
            int     aid    = GetInt("newid");
            int     uid    = GetInt("uid");
            var     user   = AccountHelper.GetUser(uid);
            string  msg    = GetString("message");
            var     active = ActiveHelper.GetItem(aid);
            Comment c      = new Comment();

            c.SellerId = active.SellerId;
            c.TypeId   = active.Id;
            c.UserId   = uid;
            c.Content  = msg;
            c.Type     = CommentType.Avtive;
            //冗余两个字段
            c.Img   = active.CoverImgUrl;
            c.Title = active.Title;

            try
            {
                CommentHelper.Create(c);
                active.Commentnum += 1;
                ActiveHelper.Update(active);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            ExtcreditLog log            = new ExtcreditLog();
            var          merchantExtend = SystemHelper.GetMerchantExtend(user.SellerId);

            if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentActive, aid, uid))
            {
                //积分获得
                log.UserId     = uid;
                log.SellerId   = user.SellerId;
                log.SourceId   = aid;
                log.Extcredit  = merchantExtend != null ? merchantExtend.CommentIntegral : 0;
                log.Type       = ExtcreditSourceType.CommentActive;
                log.CreateTime = DateTime.Now;

                ExtcreditLogHelper.AddExtcreditLog(log);

                user.Integral += log.Extcredit;
                AccountHelper.SaveAccount(user);
            }

            //ReturnCorrectMsg("评论成功");
            JsonTransfer jt = new JsonTransfer();

            jt.Add("data", new IntegralData(log.Extcredit));
            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
コード例 #3
0
        /// <summary>
        /// 图片评论
        /// </summary>
        /// <returns></returns>
        public void ImgComment()
        {
            int            userId = GetInt("uid");
            int            imgId  = GetInt("pid");
            string         msg    = GetString("message");
            var            user   = AccountHelper.GetUser(userId);
            SourceMaterial sm     = SourceMaterialHelper.GetItem(imgId);
            Comment        c      = new Comment();

            c.SellerId = sm.SellerId;
            c.TypeId   = sm.Id;
            c.UserId   = userId;
            c.Content  = msg;
            c.Type     = CommentType.Img;
            //冗余两个字段
            c.Img   = sm.Url;
            c.Title = sm.Title;
            try
            {
                CommentHelper.Create(c);
                sm.Commentnum += 1;
                SourceMaterialHelper.Update(sm);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            ExtcreditLog log = new ExtcreditLog();

            if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentImg, imgId, userId))
            {
                //积分获得
                log.UserId   = userId;
                log.SellerId = user.SellerId;
                log.SourceId = imgId;
                var setting = SystemHelper.GetMerchantExtend(user.SellerId);
                log.Extcredit  = setting != null ? setting.CommentIntegral : 0;
                log.Type       = ExtcreditSourceType.CommentImg;
                log.CreateTime = DateTime.Now;

                ExtcreditLogHelper.AddExtcreditLog(log);

                user.Integral += log.Extcredit;
                AccountHelper.SaveAccount(user);
            }

            //ReturnCorrectMsg("评论成功");
            JsonTransfer jt = new JsonTransfer();

            jt.Add("data", new IntegralData(log.Extcredit));
            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }