/// <summary> /// 获取商品数据 通过分类CD /// </summary> /// <param name="categoryCD"></param> /// <returns></returns> public BaseResponseModel <GoodsDataOutput> GetGoodsByCategoryCD(string categoryCD) { string errMsg = string.Empty; GoodsDataOutput result = null; try { result = goodsService.GetGoodsByCategoryCD(categoryCD); } catch (VerificationException ex) { errMsg = ex.Message; } catch (Exception ex) { errMsg = ex.Message; } return(ResponsePack.Responsing(result, errMsg)); }
/// <summary> /// 商品组装方法 /// </summary> /// <param name="goodsIDs"></param> /// <returns></returns> public GoodsDataOutput GenerateGoods(IEnumerable <int> goodsIDs, bool ifDetail = false) { //基础信息 var goodsData = GetGoodsDataByGoodsIDs(goodsIDs); //商品图片 var goodsPicture = GetGoodsPictures(goodsData.Select(i => i.goodsID), !ifDetail); //组装 var goodsDto = from goods in goodsData join picture in goodsPicture on goods.goodsID equals picture.goodsId select new GoodsCell() { goodsID = goods.goodsID, aPrice = goods.aPrice, price = goods.price, classID = goods.classID, goodsCD = goods.goodsCD, goodsName = goods.goodsName, text1 = goods.text1, text2 = goods.text2, goodsPictrures = new List <GoodsPictrure>() { new GoodsPictrure() { file = picture.file, key = picture.file } } }; GoodsDataOutput output = new GoodsDataOutput() { goods = goodsDto.ToList(), goodsCount = goodsDto.Count() }; return(output); }