/// <summary> /// 获取菜品总价和总押金 /// </summary> /// <param name="listFoods"></param> /// <returns></returns> public Price_Deposit GetFoodPriceAndDeposit(List <foodId_Amount> listFoods) { Price_Deposit result = new Price_Deposit(); var ids = listFoods.Select(p => p.foodId).ToArray(); var idsStr = string.Join(",", ids); var list = CacheHelper.GetByCondition <FoodInfo>("FoodInfo", " id in (" + idsStr + ")"); var r = new decimal(); foreach (var item in listFoods) { var price = list.Where(p => p.id == item.foodId).Select(p => p.foodPrice).First(); r += item.amount * (decimal)price; } result.price = r; var sum = new decimal(0); foreach (var item in listFoods) { var food = list.Where(p => p.id == item.foodId).First(); var amount = item.amount; var deposit = (decimal)food.deposit; sum += amount * deposit; } result.deposit = sum; return(result); }
public Price_Deposit GetFoodPriceAndDepositByAFA(List <AreaId_foodId_amount> listafa, int areaId) { Price_Deposit result = new Price_Deposit(); listafa = listafa.Where(p => p.areaId == areaId).ToList(); if (listafa.Count < 1) { result.price = 0; result.deposit = 0; } else { var listFoods = new List <foodId_Amount>(); foreach (var item in listafa) { foodId_Amount fa = new foodId_Amount(); fa.foodId = item.foodId; fa.amount = item.amount; listFoods.Add(fa); } result = GetFoodPriceAndDeposit(listFoods); } return(result); }