public static void GetMall_ShipRateDetailByCardIDList(int ProductID, List <int> CartIDList, int OrderID, out List <Dictionary <string, object> > list, int ProvinceID = 0, int Quantity = 0, int UserID = 0) { list = new List <Dictionary <string, object> >(); var ship_rate_list = Mall_ShipRate.GetMall_ShipRates().ToArray(); if (ProductID > 0) { var data = Mall_Product.GetMall_Product(ProductID); CalculateRateByProductOutDic(ship_rate_list, out list, ProvinceID: ProvinceID, Quantity: Quantity, BusinessID: data.BusinessID); return; } if (OrderID > 0) { var orderitem_list = Mall_OrderItem.GetMall_OrderItemListByOrderID(OrderID); if (orderitem_list.Length == 0) { return; } var product_list = Mall_Product.GetMall_ProductListByIDList(orderitem_list.Select(p => p.ProductID).ToList()); int TotalQuantity = orderitem_list.Sum(p => p.Quantity); CalculateRateByProductOutDic(ship_rate_list, out list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: orderitem_list[0].BusinessID); return; } if (CartIDList.Count > 0) { var cart_list = Foresight.DataAccess.Mall_ShoppingCart.GetMall_ShoppingCartListByIDList(CartIDList, UserID); var product_list = Foresight.DataAccess.Mall_ProductDetail.GetMall_ProductDetailListByIDList(cart_list.Select(p => p.ProductID).ToList()); var variant_list = Foresight.DataAccess.Mall_Product_VariantDetail.GetMall_Product_VariantDetailListByIDList(cart_list.Select(p => p.VariantID).ToList()); var business_list = Foresight.DataAccess.Mall_Business.GetMall_BusinessListByIDList(product_list.Select(p => p.BusinessID).ToList()); decimal totalprice = 0; int totalsalepoint = 0; int TotalQuantity = 0; string totalpricedesc = string.Empty; var productlist = Mall_ShoppingCart.getshoppingcartitems(cart_list, product_list, variant_list, 0, string.Empty, out totalprice, out totalsalepoint, out TotalQuantity, out totalpricedesc); var my_list = new List <Dictionary <string, object> >(); CalculateRateByProductOutDic(ship_rate_list, out my_list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: 0); list.AddRange(my_list); foreach (var business in business_list) { totalprice = 0; totalsalepoint = 0; TotalQuantity = 0; totalpricedesc = string.Empty; productlist = Mall_ShoppingCart.getshoppingcartitems(cart_list, product_list, variant_list, business.ID, string.Empty, out totalprice, out totalsalepoint, out TotalQuantity, out totalpricedesc); my_list = new List <Dictionary <string, object> >(); CalculateRateByProductOutDic(ship_rate_list, out my_list, ProvinceID: ProvinceID, Quantity: TotalQuantity, BusinessID: business.ID); list.AddRange(my_list); } } return; }
private static void CalculateRateByProduct(Mall_Product data, out string RateTitle, out decimal RateAmount, out int RateID, out int RateType, int ProvinceID = 0, int Quantity = 0) { RateTitle = "快递 免邮"; RateAmount = 0; RateID = 0; RateType = 0; if (data == null) { return; } if (data.ShipRateID <= 0) { return; } var ship_rate = Mall_ShipRate.GetMall_ShipRate(data.ShipRateID); if (ship_rate == null) { return; } RateID = ship_rate.ID; RateType = ship_rate.RateType; var ship_rate_list = Mall_ShipRateDetail.GetMall_ShipRateDetailListByRateID(ship_rate.ID, ProvinceID: ProvinceID); if (ship_rate_list.Length > 0) { RateAmount = CalculateRateAmount(ship_rate_list[0], Quantity); if (RateAmount > 0) { RateTitle = "快递"; } } else if (ship_rate.RateType == 2) { RateTitle = ship_rate.RateTypeDesc; } else { var default_ship_rate = Mall_ShipRateDetail.GetDefaultMall_ShipRateDetailByRateID(ship_rate.ID); if (default_ship_rate != null) { RateAmount = CalculateRateAmount(default_ship_rate, Quantity); if (RateAmount > 0) { RateTitle = "快递"; } } } }
public static void GetMall_ShipRateDetailByKeywords(int ProductID, List <int> CartIDList, int OrderID, out string RateTitle, out decimal RateAmount, out int RateID, out int RateType, int ProvinceID = 0, int Quantity = 0, int UserID = 0) { RateTitle = "快递 免邮"; RateAmount = 0; RateID = 0; RateType = 0; if (ProductID > 0) { var data = Mall_Product.GetMall_Product(ProductID); CalculateRateByProduct(data, out RateTitle, out RateAmount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: Quantity); return; } if (OrderID > 0) { var orderitem_list = Mall_OrderItem.GetMall_OrderItemListByOrderID(OrderID); var product_list = Mall_Product.GetMall_ProductListByIDList(orderitem_list.Select(p => p.ProductID).ToList()); foreach (var item in orderitem_list) { var product = product_list.FirstOrDefault(p => p.ID == item.ProductID); decimal my_rate_amount = 0; string my_rate_title = string.Empty; CalculateRateByProduct(product, out my_rate_title, out my_rate_amount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: item.Quantity); RateAmount += my_rate_amount; RateTitle += my_rate_title + " "; } return; } if (CartIDList.Count > 0) { var cartitem_list = Mall_ShoppingCart.GetMall_ShoppingCartListByIDList(CartIDList, UserID); var product_list = Mall_Product.GetMall_ProductListByIDList(cartitem_list.Select(p => p.ProductID).ToList()); foreach (var item in cartitem_list) { var product = product_list.FirstOrDefault(p => p.ID == item.ProductID); decimal my_rate_amount = 0; string my_rate_title = string.Empty; CalculateRateByProduct(product, out my_rate_title, out my_rate_amount, out RateID, out RateType, ProvinceID: ProvinceID, Quantity: item.Quantity); RateAmount += my_rate_amount; RateTitle += my_rate_title + " "; } return; } }
public static List <Dictionary <string, object> > getshoppingcartitems(Mall_ShoppingCart[] list, Mall_ProductDetail[] products, Mall_Product_VariantDetail[] product_variants, int BusinessID, string context_path, out decimal totalprice, out int totalsalepoint, out int TotalQuantity, out string totalpricedesc) { totalprice = 0; TotalQuantity = 0; totalpricedesc = string.Empty; totalsalepoint = 0; List <Dictionary <string, object> > productlist = new List <Dictionary <string, object> >(); Mall_ProductDetail[] my_products = new Mall_ProductDetail[] { }; if (BusinessID > 0) { my_products = products.Where(p => p.BusinessID == BusinessID).ToArray(); } else { my_products = products.Where(p => p.IsZiYing).ToArray(); } var my_cartlist = list.Where(p => my_products.Select(q => q.ID).ToList().Contains(p.ProductID)).ToArray(); foreach (var item in my_cartlist) { var my_product = products.FirstOrDefault(p => p.ID == item.ProductID); if (my_product == null) { continue; } var my_variant = product_variants.FirstOrDefault(p => p.ID == item.VariantID); decimal price = 0; int salepoint = 0; bool isallowproductsale = false; bool isallowpointsale = false; bool isallowvipsale = false; bool isallowstaffsale = false; int type = Mall_Product.GetFinalProductOrderType(item.ProductOrderType, my_product.ProductOrderType); string pricedesc = Mall_Product.GetOrderItemPriceDesc(my_product, my_variant, item.Quantity, out price, out salepoint, out isallowproductsale, out isallowpointsale, out isallowvipsale, out isallowstaffsale, out totalpricedesc, ProductOrderType: type); string desc = string.Empty; if (!string.IsNullOrEmpty(item.VariantTitle) && !string.IsNullOrEmpty(item.VariantName)) { desc = item.VariantTitle + ": " + item.VariantName; } Dictionary <string, object> dic = new Dictionary <string, object>(); dic["id"] = item.ID; dic["productid"] = item.ProductID; dic["variantid"] = item.VariantID; dic["imageurl"] = !string.IsNullOrEmpty(my_product.CoverImage) ? context_path + my_product.CoverImage : "../image/error-img.png"; dic["title"] = my_product.ProductName; dic["desc"] = desc; dic["pricedesc"] = pricedesc; dic["price"] = price; dic["salepoint"] = salepoint; dic["quantity"] = item.Quantity; dic["checked"] = false; dic["maxquantity"] = my_product.MaxQuantity; dic["quantitylimit"] = my_product.QuantityLimit > 0 ? my_product.QuantityLimit : 0; dic["producttypeid"] = my_product.ProductTypeID; dic["ProductOrderType"] = item.ProductOrderType > 0 ? item.ProductOrderType : 16; totalprice += price * item.Quantity; totalsalepoint += salepoint * item.Quantity; TotalQuantity += item.Quantity; productlist.Add(dic); } if (totalsalepoint > 0 && totalprice > 0) { totalpricedesc = "¥" + totalprice.ToString("0.00") + " + " + totalsalepoint.ToString() + "积分"; } else if (totalprice > 0) { totalpricedesc = "¥" + totalprice.ToString("0.00"); } else if (totalsalepoint > 0) { totalpricedesc = totalsalepoint.ToString() + "积分"; } return(productlist); }
public static Mall_OrderItemDetail[] GetMall_OrderItemDetailListByOrderIDList(List <int> OrderIDList) { if (OrderIDList.Count == 0) { return(new Mall_OrderItemDetail[] { }); } List <SqlParameter> parameters = new List <SqlParameter>(); List <string> conditions = new List <string>(); conditions.Add("[OrderID] in (" + string.Join(",", OrderIDList.ToArray()) + ")"); conditions.Add("[ProductTypeID]!=10"); string Statement = @"select ID,OrderID,Quantity,Price,ProductTypeID,ProductID,VariantID from Mall_OrderItem where " + string.Join(" and ", conditions); var list = GetList <Mall_OrderItemDetail>(Statement, parameters).ToArray(); if (list.Length == 0) { return(new Mall_OrderItemDetail[] { }); } var myList1 = list.Where(p => p.ProductTypeID != 5).ToArray(); var myList2 = list.Where(p => p.ProductTypeID == 5).ToArray(); var ProductIDList = myList1.Select(p => p.ProductID).ToList(); var VariantIDList = myList1.Select(p => p.VariantID).ToList(); var HouseServiceIDList = myList2.Select(p => p.ProductID).ToList(); var HouseServiceTypeIDList = myList2.Select(p => p.VariantID).ToList(); var productList = new Mall_Product[] { }; var variantList = new Mall_Product_Variant[] { }; var houseServiceTypeList = new Wechat_HouseServiceType[] { }; if (ProductIDList.Count > 0) { productList = Mall_Product.GetMall_ProductListByIDList(ProductIDList); } if (VariantIDList.Count > 0) { variantList = Mall_Product_Variant.GetMall_Product_VariantListByIDList(VariantIDList); } if (HouseServiceTypeIDList.Count > 0) { houseServiceTypeList = Wechat_HouseServiceType.GetWechat_HouseServiceTypes().ToArray(); } foreach (var item in list) { if (item.ProductTypeID == 5) { var myType = houseServiceTypeList.FirstOrDefault(p => p.ID == item.VariantID); if (myType != null) { item.BasicPrice = myType.BasicPrice > 0 ? myType.BasicPrice : 0; continue; } } if (item.ProductTypeID != 5) { var myVariant = variantList.FirstOrDefault(p => p.ID == item.VariantID); if (myVariant != null) { item.BasicPrice = myVariant.VariantBasicPrice > 0 ? myVariant.VariantBasicPrice : 0; continue; } var myProduct = productList.FirstOrDefault(p => p.ID == item.ProductID); if (myProduct != null) { item.BasicPrice = myProduct.BasicPrice > 0 ? myProduct.BasicPrice : 0; continue; } } } return(list); }
public static string GetOrderItemPriceDesc(Mall_Product product, Mall_Product_VariantDetail product_variant, int quantity, out decimal price, out int salepoint, out bool isallowproductsale, out bool isallowpointsale, out bool isallowvipsale, out bool isallowstaffsale, out string totalpricedesc, int ProductOrderType = 0) { string pricedesc = string.Empty; price = product.OrderItemPrice; salepoint = 0; isallowproductsale = false; isallowpointsale = false; isallowvipsale = false; isallowstaffsale = false; string desc = string.Empty; totalpricedesc = string.Empty; if (product_variant != null) { desc = product_variant.FinalVariantTitle + ": " + product_variant.VariantName; if (ProductOrderType == 16) { isallowproductsale = true; price = product_variant.FinalVariantPrice; } else if (ProductOrderType == 17) { isallowpointsale = true; price = product_variant.VariantPointPrice; salepoint = product_variant.VariantPoint; } else if (ProductOrderType == 18) { isallowvipsale = true; price = product_variant.VariantVIPPrice; salepoint = product_variant.VariantVIPPoint; } else if (ProductOrderType == 25) { isallowstaffsale = true; price = product_variant.VariantStaffPrice; salepoint = product_variant.VariantStaffPoint; } else { if (product.IsAllowProductBuy) { isallowproductsale = true; price = product_variant.FinalVariantPrice; } else if (product.IsAllowPointBuy) { isallowpointsale = true; price = product_variant.VariantPointPrice; salepoint = product_variant.VariantPoint; } else if (product.IsAllowVIPBuy) { isallowvipsale = true; price = product_variant.VariantVIPPrice; salepoint = product_variant.VariantVIPPoint; } else if (product.IsAllowStaffBuy) { isallowstaffsale = true; price = product_variant.VariantStaffPrice; salepoint = product_variant.VariantStaffPoint; } } } if (price > 0 && salepoint > 0) { pricedesc = "¥" + price.ToString("0.00") + " + " + salepoint.ToString() + "积分"; totalpricedesc = "¥" + (price * quantity).ToString("0.00") + " + " + (salepoint * quantity).ToString() + "积分"; } else if (price > 0) { pricedesc = "¥" + price.ToString("0.00"); totalpricedesc = "¥" + (price * quantity).ToString("0.00"); } else if (salepoint > 0) { pricedesc = salepoint.ToString() + "积分"; totalpricedesc = (salepoint * quantity).ToString() + "积分"; } return(pricedesc); }