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 = "快递"; } } } }