Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            string type    = context.Request["type"];
            string cate_id = context.Request["cate_id"];
            string keyword = context.Request["keyword"];
            string sort    = context.Request["sort"];
            string rows    = context.Request["rows"];
            string page    = context.Request["page"];
            int    total   = 0;
            List <WXMallProductInfo> data = bllMall.GetProductList(keyword, null, cate_id, sort,
                                                                   page, rows, null, null, null, "IsOnSale", null, null, null, null, null, null,
                                                                   null, null, null, null, null, out total, 0, false, type);
            List <dynamic> list = new List <dynamic>();

            foreach (var item in data)
            {
                List <WXMallProductInfo> relList = new List <WXMallProductInfo>();
                if (!string.IsNullOrWhiteSpace(item.RelationProductId))
                {
                    string pIDStrings = "'" + item.RelationProductId.Replace(",", "','") + "'";
                    relList = bllMall.GetColMultListByKey <WXMallProductInfo>(int.MaxValue, 1, "PID", pIDStrings, "PID,PName,Price,Unit", true);
                }
                list.Add(new
                {
                    product_id        = item.PID,
                    category_id       = item.CategoryId,
                    category_name     = bllMall.GetArticleCategoryName(item.CategoryId),
                    title             = item.PName,
                    summary           = item.Summary,
                    access_level      = item.AccessLevel,
                    quote_price       = item.PreviousPrice,
                    price             = item.Price,
                    img               = item.RecommendImg,
                    unit              = item.Unit,
                    status            = item.IsOnSale,
                    sort              = item.Sort,
                    relation_products = from p in relList
                                        select new
                    {
                        product_id = p.PID,
                        title      = p.PName,
                        price      = p.Price,
                        unit       = p.Unit
                    }
                });
            }

            apiResp.result = new
            {
                totalcount = total,
                list       = list
            };
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            string type    = context.Request["type"];
            string cate_id = context.Request["cate_id"];
            string keyword = context.Request["keyword"];
            string sort    = context.Request["sort"];
            string rows    = context.Request["rows"];
            string page    = context.Request["page"];
            int    total   = 0;
            var    data    = bllMall.GetProductList(keyword, cate_id, null, sort,
                                                    page, rows, null, null, null, null, null, null, null, null, null, null,
                                                    null, null, null, null, null, out total, 0, false, type);

            bool isAdded = type.Contains("Added");
            ArticleCategoryTypeConfig nCategoryTypeConfig = bllArticleCategory.GetArticleCategoryTypeConfig(bllArticleCategory.WebsiteOwner, type);

            if (nCategoryTypeConfig == null)
            {
                nCategoryTypeConfig = new ArticleCategoryTypeConfig();
            }
            List <dynamic> list = new List <dynamic>();

            foreach (var item in data)
            {
                List <WXMallProductInfo> relList = new List <WXMallProductInfo>();
                if (!string.IsNullOrWhiteSpace(item.RelationProductId))
                {
                    string pIDStrings = "'" + item.RelationProductId.Replace(",", "','") + "'";
                    relList = bllMall.GetColMultListByKey <WXMallProductInfo>(int.MaxValue, 1, "PID", pIDStrings, "PID,PName,Price,Unit");
                }
                List <ProductSku> skuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0}", item.PID), "SkuId,ProductId,PropValueIdEx1,PropValueIdEx2,PropValueIdEx3,Price");
                list.Add(new
                {
                    product_id        = item.PID,
                    category_name     = bllMall.GetArticleCategoryName(item.CategoryId),
                    title             = item.PName,
                    summary           = item.Summary,
                    access_level      = item.AccessLevel,
                    count             = item.Stock,
                    price             = item.Price,
                    img               = item.RecommendImg,
                    imgs              = item.ShowImage,
                    unit              = item.Unit,
                    relation_products = from p in relList
                                        select new {
                        product_id = p.PID,
                        title      = p.PName,
                        price      = p.Price,
                        unit       = p.Unit,
                        sku_id     = bllMall.GetProductSkuId(p.PID)
                    },
                    sku_list = from p in skuList.Where(p => checkEx(isAdded, nCategoryTypeConfig.TimeSetMethod, p)).OrderBy(p => p.PropValueIdEx1)
                               select new
                    {
                        sku_id     = p.SkuId,
                        product_id = p.ProductId,
                        price      = p.Price,
                        ex1        = p.PropValueIdEx1,
                        ex2        = p.PropValueIdEx2,
                        ex3        = p.PropValueIdEx3
                    },
                    sku_id = skuList.Count == 0? 0: skuList[0].SkuId
                });
            }
            apiResp.result = new
            {
                totalcount = total,
                list       = list
            };
            apiResp.status = true;
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            string            productId   = context.Request["product_id"];
            WXMallProductInfo productInfo = bllMall.GetByKey <WXMallProductInfo>("PID", productId, true);

            if (productInfo == null)
            {
                apiResp.msg  = "数据未找到";
                apiResp.code = (int)APIErrCode.IsNotFound;
                bllMall.ContextResponse(context, apiResp);
                return;
            }

            List <WXMallProductInfo> relList = new List <WXMallProductInfo>();

            if (!string.IsNullOrWhiteSpace(productInfo.RelationProductId))
            {
                string pIDStrings = "'" + productInfo.RelationProductId.Replace(",", "','") + "'";
                relList = bllMall.GetColMultListByKey <WXMallProductInfo>(int.MaxValue, 1, "PID", pIDStrings, "PID,PName,Price,Unit", true);
            }
            if (relList.Count == 0)
            {
                productInfo.RelationProductId = "";
            }
            else
            {
                relList = relList.Distinct().ToList();
                productInfo.RelationProductId = ZentCloud.Common.MyStringHelper.ListToStr(relList.Select(p => p.PID).ToList(), "", ",");
            }
            List <ProductSku> skuList = bllMall.GetColList <ProductSku>(int.MaxValue, 1, string.Format("ProductId={0}", productInfo.PID), "SkuId,ProductId,PropValueIdEx1,PropValueIdEx2,PropValueIdEx3,Price");

            apiResp.result = new
            {
                product_id        = productInfo.PID,
                product_title     = productInfo.PName,
                category_id       = productInfo.CategoryId,
                product_summary   = productInfo.Summary,
                product_desc      = productInfo.PDescription,
                price             = productInfo.Price,
                unit              = productInfo.Unit,
                is_onsale         = productInfo.IsOnSale,
                totalcount        = productInfo.Stock,
                sort              = productInfo.Sort,
                access_Level      = productInfo.AccessLevel,
                show_imgs         = productInfo.ShowImage,
                relation_products = from p in relList
                                    select new
                {
                    product_id = p.PID,
                    title      = p.PName,
                    price      = p.Price,
                    unit       = p.Unit
                },
                sku_list = from p in skuList
                           select new
                {
                    id    = p.SkuId,
                    price = p.Price,
                    start = p.PropValueIdEx1,
                    end   = p.PropValueIdEx2,
                    week  = p.PropValueIdEx3
                }
            };
            apiResp.status = true;
            apiResp.msg    = "查询完成";
            apiResp.code   = (int)APIErrCode.IsSuccess;
            bllMall.ContextResponse(context, apiResp);
        }