Exemple #1
0
        public ActionResult GetProductList2()
        {
            string ids = DoRequest.Request("ids");
            List <ShortProductInfo> list = new List <ShortProductInfo>();
            var res = GetShortProductsByProductIds.Do(ids);

            if (res != null && res.Body != null && res.Body.product_list != null)
            {
                list = res.Body.product_list;
            }
            foreach (ShortProductInfo item in list)
            {
                DateTime _sDate = DateTime.Parse(item.promotion_bdate);
                DateTime _eDate = DateTime.Parse(item.promotion_edate);
                if (_sDate <= DateTime.Now && DateTime.Now <= _eDate)
                {
                    item.sale_price = item.promotion_price;//促销价
                }
            }

            List <TypeList> tList = GetTypeListAll.Do(-1).Body.type_list;

            foreach (ShortProductInfo item in list)
            {
                string   path    = item.product_type_path;
                string[] _tem    = path.Split(',');
                int      _xCount = 0;
                for (int x = 0; x < _tem.Length; x++)
                {
                    if (string.IsNullOrEmpty(_tem[x].Trim()))
                    {
                        continue;
                    }
                    int _v = Utils.StrToInt(_tem[x].Trim());
                    foreach (TypeList em in tList)
                    {
                        if (em.product_type_id == _v)
                        {
                            if (_xCount > 0)
                            {
                                item.type_name += (" &gt;&gt; ");
                            }
                            item.type_name += (em.type_name);
                            _xCount++;
                        }
                    }
                }
            }

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult GetProductTypeInfo()
        {
            int parentId = DoRequest.GetFormInt("parentId");
            int itemId   = DoRequest.GetFormInt("itemId");

            List <TypeList> tList = new List <TypeList>();
            var             res   = GetTypeListAll.Do(-1);

            if (res != null && res.Body != null && res.Body.type_list != null)
            {
                tList = res.Body.type_list;
            }

            TypeList pInfo = new TypeList();
            TypeList tInfo = new TypeList();

            List <TypeList> temList = tList.FindAll(
                delegate(TypeList item)
            {
                return(item.product_type_id == parentId);
            });

            if (temList.Count > 0)
            {
                pInfo = temList[0];
            }
            //子分类
            temList = tList.FindAll(
                delegate(TypeList item)
            {
                return(item.product_type_id == itemId);
            });
            if (temList.Count > 0)
            {
                tInfo = temList[0];
            }

            #region 设置排序
            if (tInfo.product_type_id < 1)
            {
                temList = tList.FindAll(
                    delegate(TypeList item)
                {
                    return(item.parent_type_id == parentId);
                });
                int sort = 0;
                foreach (TypeList em in temList)
                {
                    if (em.sort_no > sort)
                    {
                        sort = em.sort_no;
                    }
                }
                sort++;
                tInfo.sort_no = sort;
            }
            #endregion

            #region 分类名路径
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string[] arr = null;
            sb.Append("根");
            if (pInfo.product_type_path != null)
            {
                arr = pInfo.product_type_path.Split(',');
                foreach (string s in arr)
                {
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    int             val  = Utils.StrToInt(s.Trim());
                    List <TypeList> list = tList.FindAll(
                        delegate(TypeList item)
                    {
                        return(item.product_type_id == val);
                    });
                    if (list.Count > 0)
                    {
                        sb.Append(" >> " + list[0].type_name);
                    }
                }
            }
            #endregion

            return(Json(new { parent = pInfo, type = tInfo, parentName = sb.ToString() }, JsonRequestBehavior.AllowGet));
        }