コード例 #1
0
        public List <IndexFloor> FillIntegralGoods(DataTable table)
        {
            ///获取网站ip
            string            web_url = BaseConfiguration.SercerIp;
            List <IndexFloor> list    = new List <IndexFloor>();
            var query = from p in table.AsEnumerable()
                        group p by new { t1 = p.Field <int>("id"), t2 = p.Field <string>("floottype"), t3 = p.Field <string>("TypeName"), t4 = p.Field <string>("entId") } into floors
                select new { Id = floors.Key.t1, FlootType = floors.Key.t2, TypeName = floors.Key.t3, entId = floors.Key.t4 };

            foreach (var floor in query)
            {
                IndexFloor indexFloor = new IndexFloor()
                {
                    Entid     = floor.entId.ToString(),
                    FloorId   = floor.Id.ToString(),
                    TypeName  = floor.TypeName.ToString(),
                    FloorType = floor.FlootType.ToString().Trim()
                };
                DataTable      data     = table.Clone();
                DataRow[]      dataRows = table.Select("floottype='" + floor.FlootType.ToString() + "'");
                List <ImgInfo> imgInfos = new List <ImgInfo>();
                foreach (DataRow item in dataRows)
                {
                    ImgInfo imgInfo = new ImgInfo()
                    {
                        Entid       = item["entId"].ToString(),
                        SubTitle    = item["goodsname"].ToString(),
                        ArticleId   = item["goodsid"].ToString(),
                        Price       = item["price"].ToString(),
                        Integral    = item["integral"].ToString(),
                        DrugSpec    = item["drug_spec"].ToString(),
                        Quantity    = item["quantity"].ToString(),
                        PackageUnit = item["package_unit"].ToString()
                    };
                    if (item["img_url"].ToString() != "")
                    {
                        if (item["img_url"].ToString().Contains("http://"))
                        {
                            imgInfo.ImgUrl = item["img_url"].ToString();
                        }
                        else
                        {
                            imgInfo.ImgUrl = web_url + item["img_url"].ToString();
                        }
                    }
                    else
                    {
                        imgInfo.ImgUrl = "";
                    }
                    imgInfos.Add(imgInfo);
                }
                indexFloor.FloorDetail = imgInfos;
                list.Add(indexFloor);
            }
            return(list);
        }
コード例 #2
0
        /// <summary>
        /// 专区数据整理
        /// </summary>
        /// <param name="table">专区数据</param>
        /// <returns></returns>
        private List <IndexFloor> PrefectureFillFloor(DataTable table, string entId)
        {
            ///获取网站ip
            string            web_url = BaseConfiguration.SercerIp;
            List <IndexFloor> list    = new List <IndexFloor>();

            foreach (DataRow dr in table.Rows)
            {
                IndexFloor lc = new IndexFloor
                {
                    Entid           = dr["entid"].ToString().Trim(),
                    FloorId         = dr["FloorId"].ToString().Trim(),
                    FloorTitle      = dr["FloorTitle"].ToString().Trim(),
                    Link_Url        = dr["Floor_Link"].ToString().Trim(),
                    TypeName        = dr["TypeName"].ToString().Trim(),
                    Sort            = dr["sort"].ToString().Trim(),
                    Type            = dr["imgTypeS"].ToString().Trim(),
                    AndroidLinkType = int.Parse(dr["androidlinktype"].ToString()),
                    AndroidLinkUrl  = dr["androidlinkurl"].ToString().Trim()
                };
                if (dr["Floor_Img"].ToString().Trim() != "")
                {
                    lc.Floor_Img = web_url + dr["Floor_Img"].ToString().Trim();
                }
                else
                {
                    lc.Floor_Img = "";
                }
                lc.FloorDetail = new List <ImgInfo>();
                list.Add(lc);
            }
            if (table.Rows.Count < 4)
            {
                var placehold = XmlOperation.ReadXml("Base", "PrefecturePicture");
                for (int i = 0; i < 4 - table.Rows.Count; i++)
                {
                    IndexFloor lc = new IndexFloor
                    {
                        Entid           = entId,
                        FloorId         = "",
                        FloorTitle      = "专区推荐",
                        Link_Url        = "",
                        TypeName        = "",
                        Type            = "",
                        AndroidLinkType = 0,
                        AndroidLinkUrl  = "",
                        Floor_Img       = placehold
                    };
                    lc.FloorDetail = new List <ImgInfo>();
                    list.Add(lc);
                }
            }
            return(list);
        }
コード例 #3
0
        /// <summary>
        /// 楼层数据整理
        /// </summary>
        /// <param name="t1"></param>
        /// <param name="t2"></param>
        /// <param name="entId"></param>
        /// <param name="landing"></param>
        /// <param name="staleDated"></param>
        /// <param name="jgjb"></param>
        /// <returns></returns>
        private List <IndexFloor> FillFloor(DataTable t1, DataTable t2, string entId, bool landing, bool staleDated, string jgjb, string userId)
        {
            ///获取网站ip
            string            web_url = BaseConfiguration.SercerIp;
            List <IndexFloor> list    = new List <IndexFloor>();

            foreach (DataRow dr in t1.Rows)
            {
                IndexFloor lc = new IndexFloor
                {
                    Entid           = dr["entid"].ToString().Trim(),
                    FloorId         = dr["FloorId"].ToString().Trim(),
                    FloorTitle      = dr["FloorTitle"].ToString().Trim(),
                    Link_Url        = dr["Floor_Link"].ToString().Trim(),
                    TypeName        = dr["TypeName"].ToString().Trim(),
                    Type            = dr["imgTypeS"].ToString().Trim(),
                    AndroidLinkType = int.Parse(dr["androidlinktype"].ToString()),
                    AndroidLinkUrl  = dr["androidlinkurl"].ToString().Trim()
                };
                if (dr["Floor_Img"].ToString().Trim() != "")
                {
                    lc.Floor_Img = web_url + dr["Floor_Img"].ToString().Trim();
                }
                else
                {
                    lc.Floor_Img = "";
                }
                List <ImgInfo> imgList = new List <ImgInfo>();
                if (t2.Rows.Count > 0)
                {
                    DataRow[] imgDr = t2.Select("EntId='" + entId + "' and FloorId='" + lc.FloorId + "'", "sort_Id asc");
                    //楼层详细数据
                    foreach (DataRow drI in imgDr)
                    {
                        ImgInfo img = new ImgInfo
                        {
                            Entid           = drI["entid"].ToString().Trim(),
                            Title           = drI["FloorTitle"].ToString().Trim(),
                            ArticleId       = drI["Article_Id"].ToString().Trim(),
                            SortId          = int.Parse(drI["sort_Id"].ToString().Trim()),
                            IsBrand         = drI["Is_Brand"].ToString().Trim(),
                            BrandCode       = drI["BrandCode"].ToString().Trim(),
                            LinkUrl         = drI["link_url"].ToString().Trim(),
                            AndroidLinkType = int.Parse(dr["androidlinktype"].ToString()),
                            AndroidLinkUrl  = drI["androidlinkurl"].ToString().Trim()
                        };
                        if (drI["img_url"].ToString().Trim() != "")
                        {
                            img.ImgUrl = web_url + drI["img_url"].ToString().Trim();
                        }
                        else
                        {
                            img.ImgUrl = "";
                        }
                        if (drI["left_pic"].ToString().Trim() != "")
                        {
                            img.LeftPic = web_url + drI["left_pic"].ToString().Trim();
                        }
                        if (drI["brand_img_url"].ToString().Trim() != "")
                        {
                            img.BrandImgUrl = web_url + drI["brand_img_url"].ToString().Trim();
                        }
                        else
                        {
                            img.BrandImgUrl = "";
                        }
                        img.SubTitle    = drI["sub_title"].ToString().Trim();
                        img.DrugSpec    = drI["drug_spec"].ToString().Trim();
                        img.DrugFactory = drI["drug_factory"].ToString().Trim();
                        if (landing && !staleDated)
                        {
                            img.Price = BasisConfig.ObjToDecimal(drI["price"].ToString(), BaseConfiguration.PricePlace, 0.00M).ToString();
                        }
                        else
                        {
                            img.Price = "会员可见";
                        }
                        img.Cxbs = drI["cxbs"].ToString().Trim();
                        img.Fabh = drI["fabh"].ToString().Trim();
                        imgList.Add(img);
                    }
                    //LogQueue.Write(LogType.Debug, "FillFloor", $"Type:{lc.Type},len:{imgDr.Length}");
                    //品牌推荐  最少12 不足补位
                    if (lc.Type == "Brand" && imgDr.Length < 12)
                    {
                        imgList = BrandParatope(imgList, entId, web_url, landing, staleDated, 12 - imgDr.Length, userId);
                    }
                    else if (lc.Type == "Weekly" && imgDr.Length < 4)
                    {
                        imgList = GoodsParatope(imgList, entId, web_url, landing, staleDated, 4 - imgDr.Length, jgjb, lc.FloorTitle, userId);
                    }
                    else if ((lc.Type == "Family" || lc.Type == "Product" || lc.Type == "InSeason" || lc.Type == "Health") && imgDr.Length < 7)
                    {
                        imgList = GoodsParatope(imgList, entId, web_url, landing, staleDated, 7 - imgDr.Length, jgjb, lc.FloorTitle, userId);
                    }
                }
                lc.FloorDetail = imgList;
                list.Add(lc);
            }

            return(list);
        }