Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Request.QueryString["id"].ToString();
            var active = ActiveHelper.GetItem(Convert.ToInt32(Id));

            SellerId = active.SellerId.ToString();
        }
Exemplo n.º 2
0
        private void GetItem(HttpContext context)
        {
            int aid  = GetInt("newid");
            var item = ActiveHelper.GetItem(aid);

            if (item == null)
            {
                ReturnErrorMsg("不存在该活动");
                return;
            }
            var data = new
            {
                newid      = item.Id,
                title      = item.Title,
                img        = Utility.GetSizePicUrl(item.CoverImgUrl, 540, 400, context),
                summary    = item.Summary,
                descrition = item.Description,
                dateline   = item.CreateTime.GetUnixTime(),
                Views      = item.Views,
                Commentnum = item.Commentnum
            };

            item.Views++;
            ActiveHelper.Update(item);

            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Exemplo n.º 3
0
        private void GetItem()
        {
            int aid  = GetInt("id");
            var item = ActiveHelper.GetItem(aid);

            if (item == null)
            {
                ReturnErrorMsg("资讯不存在:id" + aid);
                return;
            }
            var coupon = CouponHelper.GetItem(item.CouponId);
            var data   = new
            {
                Id          = item.Id,
                SellerId    = item.SellerId,
                CouponId    = item.CouponId,
                CouponTitle = coupon.Title,
                Summary     = item.Summary,
                Title       = item.Title,
                Views       = item.Views,
                Commentnum  = item.Commentnum,
                ImgId       = item.CoverImgId,
                ImgUrl      = item.CoverImgUrl == "" ? "http://placehold.it/128x128" : item.CoverImgUrl,
                CreateTime  = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                Description = item.Description
            };
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private void UpdateData()
        {
            var id = GetInt("id");

            var active = ActiveHelper.GetItem(id);

            active.CouponId    = GetInt("ticket_id");
            active.Title       = GetString("Title");
            active.CoverImgUrl = GetString("thumbnail");
            active.Description = GetString("content");
            var text = GetString("text");

            active.Summary = text.Length > 20 ? text.Substring(0, 20) : text;
            //active.Summary = active.Description.Length > 20 ? active.Description.Substring(0, 20) : active.Description;

            ActiveHelper.Update(active);
        }
Exemplo n.º 6
0
        private void ActiveCommentList(HttpContext context)
        {
            int aid    = GetInt("newid");
            int index  = GetInt("start");
            int size   = GetInt("limit");
            var active = ActiveHelper.GetItem(aid);
            var cms    = CommentHelper.GetPagings(active.SellerId, CommentType.Avtive, aid, index * size, size);
            var users  = new List <Account>();

            if (cms.Results.Count != 0)
            {
                users = AccountHelper.GetUserList(cms.Results.Select(c => c.UserId).ToList()).ToList();
            }
            var data = new CommentsForApis();

            foreach (var cm in cms.Results)
            {
                var user = users.FirstOrDefault(u => u.Id == cm.UserId);
                if (user == null)
                {
                    throw new ArgumentNullException(string.Format("userId:{0}", cm.UserId));
                }
                var result = new ComentsForApi
                {
                    Avatar   = Utility.GetSizePicUrl(user.Avatar, 100, 100, context),
                    UserName = user.UserName,
                    Sex      = (int)user.Sex,
                    Dateline = cm.CreateTime.GetUnixTime(),
                    Message  = cm.Content
                };
                data.Comments.Add(result);
            }
            data.Commentnum = cms.TotalCount;
            JsonTransfer jt = new JsonTransfer();

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