Ejemplo n.º 1
0
        /// <summary>
        /// 查询商品收藏
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string List(HttpContext context)
        {
            int pageIndex = !string.IsNullOrEmpty(context.Request["pageindex"]) ? int.Parse(context.Request["pageindex"]) : 1;
            int pageSize  = !string.IsNullOrEmpty(context.Request["pagesize"]) ? int.Parse(context.Request["pagesize"]) : 10;
            var type      = context.Request["type"];

            StringBuilder sbWhere = new StringBuilder();

            sbWhere.AppendFormat(" MainId='{0}'  ", currentUserInfo.UserID);

            if (!string.IsNullOrEmpty(type))
            {
                sbWhere.AppendFormat(" AND RelationType='{0}'", type);
            }
            else
            {
                sbWhere.AppendFormat(" AND RelationType='ProductCollect' ");
            }

            var           relationData = bllCommRela.GetLit <CommRelationInfo>(pageSize, pageIndex, sbWhere.ToString(), "AutoId Desc");
            int           totalCount   = bllCommRela.GetCount <CommRelationInfo>(sbWhere.ToString());
            List <object> list         = new List <object>();

            foreach (var item in relationData)
            {
                var productInfo = bllMall.GetProduct(item.RelationId);
                if (productInfo != null && productInfo.IsDelete == 0)
                {
                    var collectProductInfo = new
                    {
                        product_id    = int.Parse(productInfo.PID),
                        collect_time  = Math.Round(bllCommRela.GetTimeStamp(item.RelationTime), 0),
                        title         = productInfo.PName,
                        category_id   = productInfo.CategoryId,
                        quote_price   = productInfo.PreviousPrice,
                        price         = productInfo.Price,
                        img_url       = bllMall.GetImgUrl(productInfo.RecommendImg),
                        is_onsale     = productInfo.IsOnSale,
                        product_type  = productInfo.ArticleCategoryType,
                        province      = productInfo.Province,
                        city          = productInfo.City,
                        ex1           = productInfo.Ex1,
                        ex19          = productInfo.Ex19,
                        tags          = productInfo.Tags,
                        category_name = productInfo.CategoryName
                    };
                    list.Add(collectProductInfo);
                }
            }
            var data = new
            {
                totalcount = totalCount,
                list       = list
            };

            return(ZentCloud.Common.JSONHelper.ObjectToJson(data));
        }