private static List<GetItemsModel> ConvertPageItemInfo(IEnumerable<GoodsDetail> models) { var r = new List<GetItemsModel>(); if (models != null) { models.ForEach(item => { var remenModel = new GetItemsModel { Sales = (int)item.Sales, Id = (int)item.Id, Price = item.Price, MarketPrice = item.MarketPrice, SubTitle = item.ItemTitle, Picture = item.Picture, Zhekou = "1", Pictures = (item.Pictures ?? "").Split(new[] {","}, StringSplitOptions.RemoveEmptyEntries) }; if (item.MarketPrice > 0) { remenModel.Zhekou = (Math.Round(item.Price / item.MarketPrice, 1) * 10).ToString(); } ReadItemDianmingAndQuyu(remenModel, item.Partners); r.Add(remenModel); }); } return r; }
private static void ReadItemDianmingAndQuyu(GetItemsModel item, IList<int> partnerIds) { var shops = Partner.GetShop(partnerIds); if (shops == null || !shops.Any()) return; if (shops.Count > 1) { item.Quyu = string.Format("{0}店通用", shops.Count); item.Dianming = shops[0].Title; return; } var area = ""; if (shops[0].Areas != null && shops[0].Areas.Any()) { area = shops[0].Areas.Last().Value; } item.Dianming = shops[0].Title; item.Quyu = area; }