Esempio n. 1
0
        public ActionResult GetProductInfo2()
        {
            int productid            = DoRequest.GetFormInt("productid");
            ShortProductInfo product = new ShortProductInfo();
            var res = GetShortProductsByProductIds.Do(productid.ToString());

            if (res != null && res.Body != null && res.Body.product_list != null)
            {
                product = res.Body.product_list[0];
            }
            return(Json(product, JsonRequestBehavior.AllowGet));
            //return Json(new {productname=product.product_name, seotitle=product.seo_title, seotext=product.seo_text,seokey=product.seo_key }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
        public ActionResult SeachProduct()
        {
            int pagesize  = DoRequest.RequestInt("size", 10);
            int pageindex = DoRequest.RequestInt("page", 1);

            if (pagesize > 100)
            {
                pagesize = 100;
            }
            if (pageindex < 1)
            {
                pageindex = 1;
            }
            int sType    = DoRequest.RequestInt("stype");
            int isonsale = DoRequest.RequestInt("isonsale", 1);

            string q    = DoRequest.HtmlEncode(DoRequest.Request("q").Trim());
            string sKey = "";

            #region 处理查询关键词中的空格
            string[] qList = q.Split(' ');
            for (int i = 0; i < qList.Length; i++)
            {
                if (string.IsNullOrEmpty(qList[i].Trim()))
                {
                    continue;
                }
                if (i > 0)
                {
                    sKey += " ";
                }
                sKey += qList[i];
            }
            q = sKey;
            #endregion
            if (sKey.Length > 50)
            {
                sKey = Utils.CutString(sKey, 0, 50);
            }

            int dataCount = 0;
            int pageCount = 0;
            List <ProductsInfo> _table = new List <ProductsInfo>();
            var res = QueryProductInfo.Do(pagesize, pageindex
                                          , 0
                                          , -1
                                          , -1
                                          , sType
                                          , -1
                                          , -1
                                          , isonsale
                                          , 1
                                          , sKey
                                          , "modifytime"
                                          , "desc"
                                          , ref dataCount
                                          , ref pageCount);
            if (res != null && res.Body != null && res.Body.product_list != null)
            {
                _table = res.Body.product_list;
            }

            List <ShortProductInfo> list = new List <ShortProductInfo>();
            // System.Text.StringBuilder ids = new System.Text.StringBuilder();
            //ids.Append("0");
            foreach (ProductsInfo item in _table)
            {
                #region
                ShortProductInfo Info = new ShortProductInfo();
                Info.product_id        = item.product_id;
                Info.product_code      = item.product_code;
                Info.product_name      = item.product_name;
                Info.product_type_path = item.product_type_path;
                Info.product_type_id   = item.product_type_id;

                Info.market_price = item.market_price;
                Info.sale_price   = item.sale_price;
                Info.mobile_price = item.mobile_price;

                decimal  _promotion_price = item.promotion_price;
                DateTime _sDate           = DateTime.Parse(item.promotion_bdate);
                DateTime _eDate           = DateTime.Parse(item.promotion_edate);
                if (_sDate <= DateTime.Now && DateTime.Now <= _eDate)
                {
                    Info.sale_price = _promotion_price;//促销价
                }
                Info.product_brand = item.product_brand;
                Info.stock_num     = item.stock_num;

                Info.sales_promotion = item.sales_promotion;
                Info.product_spec    = item.product_spec;

                Info.shop_id   = item.shop_id;
                Info.img_src   = item.img_src;
                Info.sku_count = item.sku_count;
                #endregion
                list.Add(Info);
            }

            return(Json(new
            {
                dataCount = dataCount
                ,
                pageCount = pageCount
                ,
                size = pagesize
                ,
                index = pageindex
                ,
                data = list
            }
                        , JsonRequestBehavior.AllowGet));
        }