Example #1
0
        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;
            }
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Example #2
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();
        }
Example #3
0
        private void NegateShelf()
        {
            var ids = Utility.GetListint(GetString("ids"));

            foreach (var id in ids)
            {
                var item = CouponHelper.GetItem(id);
                item.Enabled = item.Enabled == 1 ? -1 : 1;
                CouponHelper.Update(item);
            }
        }
Example #4
0
        private void GetItem()
        {
            int cid         = GetInt("id");
            var item        = CouponHelper.GetItem(cid);
            var goodsTitles = new List <object>();
            var delGoodsIds = new List <int>();

            foreach (var id in item.GoodsIds)
            {
                var good = GoodsHelper.GetGoods(id);
                if (good == null)
                {
                    delGoodsIds.Add(id);
                }
                else
                {
                    goodsTitles.Add(new { id = id, title = good.Title });
                }
            }
            if (delGoodsIds.Count > 0)
            {
                foreach (var id in delGoodsIds)
                {
                    item.GoodsIds.Remove(id);
                }
                CouponHelper.Update(item);
            }
            var data = new
            {
                couponid      = item.Id,
                title         = item.Title,
                img           = item.ImgUrl,
                extcredit     = item.Extcredit,
                fullmoney     = item.FullMoney,
                discountmoney = item.DiscountMoney,
                goodstitles   = goodsTitles,
                expiry        = item.Expiry.ToString("yyyy-MM-dd"),
                description   = item.Description
            };
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Example #5
0
        private void Couponcommentlist()
        {
            int cid    = GetInt("couponid");
            int index  = GetInt("start");
            int size   = GetInt("limit");
            var coupon = CouponHelper.GetItem(cid);
            var cms    = CommentHelper.GetPagings(coupon.SellerId, CommentType.Coupons, cid, index, size);
            var data   = new CommentsForApis();

            data.Commentnum = cms.TotalCount;
            if (cms.TotalCount == 0)
            {
                JsonTransfer jt = new JsonTransfer();
                jt.AddSuccessParam();
                jt.Add("data", data);
                Response.Write(DesEncrypt(jt).ToLower());
                Response.End();
            }
            else
            {
                var users = AccountHelper.GetUserList(cms.Results.Select(c => c.UserId).ToList());
                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   = user.Avatar,
                        UserName = user.UserName,
                        Sex      = (int)user.Sex,
                        Dateline = cm.CreateTime.GetUnixTime(),
                        Message  = cm.Content
                    };
                    data.Comments.Add(result);
                }

                JsonTransfer jt = new JsonTransfer();
                jt.AddSuccessParam();
                jt.Add("data", data);
                Response.Write(DesEncrypt(jt).ToLower());
                Response.End();
            }
        }
Example #6
0
        private void Update()
        {
            int id   = GetInt("id");
            var item = CouponHelper.GetItem(id);

            item.Title = GetString("title");
            var expiry = GetString("expire_date");

            item.Expiry        = expiry != "-1" ? GetTime("expire_date") : DateTime.Now.AddDays(1);
            item.ImgUrl        = GetString("thumbnail");
            item.Extcredit     = GetInt("score");
            item.FullMoney     = GetInt("total");
            item.DiscountMoney = GetInt("discount");
            item.Enabled       = 1;
            item.GoodsIds      = Utility.GetListint(GetString("goods_selected"));
            item.Description   = GetString("content");
            var text = GetString("text");

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

            CouponHelper.CreateCoupon(item);
        }