/// <summary> /// 是否有该商品 /// </summary> /// <param name="goodsMenu"></param> /// <returns></returns> internal bool HasGoods(OneGoodsMenu goodsMenu) { var filter = Builders<GoodsModel>.Filter; var filterSum = filter.Eq(x => x.GoodsClass, GoodsClass.OneGoods) & filter.Eq(x => x.PrintType.GoodsTypeID, goodsMenu.SelectedPrintTypeID) & filter.Eq(x => x.PaperType.GoodsTypeID, goodsMenu.SelectedPaperTypeID) & filter.Eq(x => x.SizeType.GoodsTypeID, goodsMenu.SelectedSizeTypeID); return collection.Find(filterSum).FirstOrDefault() != null; }
/// <summary> /// 添加单张商品菜单 /// </summary> /// <param name="goodsMenu"></param> internal void PushOneGoodsMenu(OneGoodsMenu goodsMenu) { var collection = mongo.GetMongoCollection<GoodsType>(); var printType = collection.Find(x => x.GoodsTypeID.Equals(goodsMenu.SelectedPrintTypeID)).FirstOrDefault(); var paperType = collection.Find(x => x.GoodsTypeID.Equals(goodsMenu.SelectedPaperTypeID)).FirstOrDefault(); var sizeType = collection.Find(x => x.GoodsTypeID.Equals(goodsMenu.SelectedSizeTypeID)).FirstOrDefault(); var goodsImages = mongo.GetMongoCollection<GoodsPic>().Find(x => x.GoodsClass == GoodsClass.OneGoods).FirstOrDefault(); this.collection.InsertOne(new GoodsModel() { GoodsPrice = goodsMenu.GoodsPrice, GoodsOldPrice = goodsMenu.GoodsOldPrice, Images = goodsImages, PaperType = paperType, PrintType = printType, PicsNum = 1, SizeType = sizeType, GoodsClass = GoodsClass.OneGoods }); }
/// <summary> /// 获取单张商品套餐与价格,价格为零时代表套餐未选择 /// </summary> /// <param name="selectedPrintTypeID">当前选中的冲印类型ID</param> /// <param name="selectedPaperTypeID">当前选中的纸张ID</param> /// <param name="selectedSizeTypeID">当前选中的尺寸ID</param> /// <returns></returns> public string GetGoodsOne(string selectedPrintTypeID, string selectedPaperTypeID, string selectedSizeTypeID) { try { OneGoodsMenu goodsMenu = thisData.GetGoodsMenu( string.IsNullOrEmpty(selectedPrintTypeID) ? ObjectId.Empty : new ObjectId(selectedPrintTypeID), string.IsNullOrEmpty(selectedPaperTypeID) ? ObjectId.Empty : new ObjectId(selectedPaperTypeID), string.IsNullOrEmpty(selectedSizeTypeID) ? ObjectId.Empty : new ObjectId(selectedSizeTypeID)); return(new BaseResponseModel <OneGoodsMenu>() { StatusCode = Tools.ActionParams.code_ok, JsonData = goodsMenu }.ToJson()); } catch (Exception ex) { Console.WriteLine(ex.Message); return(JsonResponseModel.ErrorJson); throw; } }
internal OneGoodsMenu GetGoodsMenu(ObjectId printTypeID, ObjectId paperTypeID, ObjectId sizeTypeID) { var goodsTypeCollection = mongo.GetMongoCollection <GoodsType>(); var goodsTypeList = goodsTypeCollection.Find(Builders <GoodsType> .Filter.Empty).ToList(); var printTypes = goodsTypeList.FindAll(x => x.TypeClass == TypeClass.Print); var paperTypes = goodsTypeList.FindAll(x => x.TypeClass == TypeClass.Paper); var sizeTypes = goodsTypeList.FindAll(x => x.TypeClass == TypeClass.Size); GoodsType selectedPrintType = goodsTypeList.Find(x => x.GoodsTypeID.Equals(printTypeID)); GoodsType selectedPaperType = goodsTypeList.Find(x => x.GoodsTypeID.Equals(paperTypeID)); GoodsType selectedSizeType = goodsTypeList.Find(x => x.GoodsTypeID.Equals(sizeTypeID)); GoodsModel goods = null; if (printTypeID.Equals(ObjectId.Empty) && paperTypeID.Equals(ObjectId.Empty) && sizeTypeID.Equals(ObjectId.Empty)) { //GetDefaultSelect(printTypes, paperTypes, sizeTypes, out selectedPaperType, out selectedPrintType, out selectedSizeType); GetNoSelectOneGoods(printTypes, paperTypes, sizeTypes); } else if (printTypeID.Equals(ObjectId.Empty) && paperTypeID.Equals(ObjectId.Empty)) { ///sizeTypeID不为空情况 /// GetOnlySizeType(printTypes, paperTypes, sizeTypes, selectedSizeType); } else if (paperTypeID.Equals(ObjectId.Empty) && sizeTypeID.Equals(ObjectId.Empty)) { GetOnlyPrintType(printTypes, paperTypes, sizeTypes, selectedPrintType); } else if (printTypeID.Equals(ObjectId.Empty) && sizeTypeID.Equals(ObjectId.Empty)) { GetOnlyPaperType(printTypes, paperTypes, sizeTypes, selectedPaperType); } else if (printTypeID.Equals(ObjectId.Empty)) { GetNoPrintType(printTypes, paperTypes, sizeTypes, selectedPaperType, selectedSizeType); } else if (paperTypeID.Equals(ObjectId.Empty)) { GetNoPaperType(printTypes, paperTypes, sizeTypes, selectedPrintType, selectedSizeType); } else if (sizeTypeID.Equals(ObjectId.Empty)) { GetNoSizeType(printTypes, paperTypes, sizeTypes, selectedPaperType, selectedPrintType); } else { goods = collection.Find(x => x.PrintType.GoodsTypeID.Equals(selectedPrintType.GoodsTypeID) && x.PaperType.GoodsTypeID.Equals(selectedPaperType.GoodsTypeID) && x.SizeType.GoodsTypeID.Equals(selectedSizeType.GoodsTypeID)).FirstOrDefault(); GetCurrentSelect(printTypes, paperTypes, sizeTypes, selectedPaperType, selectedPrintType, selectedSizeType); } //GetCurrentSelect(printTypes, paperTypes, sizeTypes, selectedPaperType, selectedPrintType, selectedSizeType); OneGoodsMenu goodsMenu = new OneGoodsMenu() { GoodsID = goods != null ? goods.GoodsID : ObjectId.Empty, PaperTypes = paperTypes, PrintTypes = printTypes, SizeTypes = sizeTypes, SelectedPaperTypeID = selectedPaperType != null ? selectedPaperType.GoodsTypeID : ObjectId.Empty, SelectedPrintTypeID = selectedPrintType != null ? selectedPrintType.GoodsTypeID : ObjectId.Empty, SelectedSizeTypeID = selectedSizeType != null ? selectedSizeType.GoodsTypeID : ObjectId.Empty, GoodsPrice = goods != null ? goods.GoodsPrice : 0, GoodsOldPrice = goods != null ? goods.GoodsOldPrice : 0, GoodsSpread = goods != null ? goods.GoodsOldPrice - goods.GoodsPrice : 0 }; return(goodsMenu); }