private void buildShowPrice(CommodityListCDTO commodity, List <Deploy.CommodityStockDTO> comStocks, TodayPromotion todayPromotion) { if (commodity == null) { return; } commodity.RealPrice = commodity.Price; commodity.OriPrice = commodity.MarketPrice; if (todayPromotion != null) { commodity.RealPrice = todayPromotion.DiscountPrice > 0 ? todayPromotion.DiscountPrice.Value : Math.Round(commodity.Price * todayPromotion.Intensity / 10.0m, 2); commodity.OriPrice = commodity.Price; } else { if (comStocks != null && comStocks.Any()) { var minMarkPriceStock = comStocks.Where(c => c.MarketPrice.HasValue).OrderBy(c => c.MarketPrice).FirstOrDefault(); if (minMarkPriceStock != null) { commodity.OriPrice = comStocks.Min(c => c.MarketPrice); } } } }
/// <summary> /// 获取商品列表 /// </summary> /// <param name="qryCommodityDTO"></param> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO> GetCommodityListExt(Jinher.AMP.BTP.Deploy.CustomDTO.QryCommodityDTO qryCommodityDTO) { if (qryCommodityDTO == null) { return(new List <CommodityListCDTO>()); } List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO> result; Jinher.AMP.ZPH.Deploy.CustomDTO.QryCommodityDTO query = new ZPH.Deploy.CustomDTO.QryCommodityDTO() { SetCategoryId = qryCommodityDTO.SetCategoryId, PageIndex = qryCommodityDTO.PageIndex, PageSize = qryCommodityDTO.PageSize, FieldSort = qryCommodityDTO.FieldSort, Order = qryCommodityDTO.Order, IsHasStock = qryCommodityDTO.IsHasStock, MinPrice = qryCommodityDTO.MinPrice, MaxPrice = qryCommodityDTO.MaxPrice, ChannelId = qryCommodityDTO.ChannelId, AppId = qryCommodityDTO.AppId }; try { result = new List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO>(); List <Jinher.AMP.ZPH.Deploy.CustomDTO.CommodityListCDTO> comListReuslt = Jinher.AMP.BTP.TPS.ZPHSV.Instance.GetCommodityList(query); //类转换一下 foreach (Jinher.AMP.ZPH.Deploy.CustomDTO.CommodityListCDTO comTmp in comListReuslt) { Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO comTmpBTP = new CommodityListCDTO(); comTmpBTP.Name = comTmp.Name; comTmpBTP.Price = comTmp.Price; comTmpBTP.Id = comTmp.Id; comTmpBTP.Pic = comTmp.Pic; comTmpBTP.Intensity = comTmp.Intensity; comTmpBTP.State = comTmp.State; comTmpBTP.Stock = comTmp.Stock; comTmpBTP.DiscountPrice = comTmp.DiscountPrice; comTmpBTP.LimitBuyEach = comTmp.LimitBuyEach; comTmpBTP.LimitBuyTotal = comTmp.LimitBuyTotal; comTmpBTP.SurplusLimitBuyTotal = comTmp.SurplusLimitBuyTotal; comTmpBTP.AppId = comTmp.AppId; comTmpBTP.IsActiveCrowdfunding = comTmp.IsActiveCrowdfunding; comTmpBTP.AppName = comTmp.AppName; comTmpBTP.MarketPrice = comTmp.MarketPrice; comTmpBTP.IsEnableSelfTake = comTmp.IsEnableSelfTake; result.Add(comTmpBTP); } return(result); } catch (Exception ex) { LogHelper.Error(string.Format("获取商品列表接口异常。qryCommodityDTO:{0}", JsonHelper.JsonSerializer(qryCommodityDTO)), ex); return(new List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO>()); } }