public static string GetLimitedTimeDiscountName(int limitedTimeDiscountId) { string activityName = string.Empty; LimitedTimeDiscountInfo discountInfo = new LimitedTimeDiscountDao().GetDiscountInfo(limitedTimeDiscountId); if (discountInfo != null) { activityName = discountInfo.ActivityName; } return(activityName); }
public static void AddLineItem(string skuId, int quantity, int categoryid, int Templateid, int type = 0, int exchangeId = 0, int limitedTimeDiscountId = 0) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (quantity <= 0) { quantity = 1; } int num = 1; int num2 = 0; if (limitedTimeDiscountId == 0) { int productId = 0; SKUItem skuItem = new SkuDao().GetSkuItem(skuId); if (skuItem != null) { productId = skuItem.ProductId; int id = Globals.ToNum(new LimitedTimeDiscountDao().GetLimitedTimeDiscountIdByProductId(currentMember.UserId, skuId, productId)); if (id > 0) { LimitedTimeDiscountInfo discountInfo = new LimitedTimeDiscountDao().GetDiscountInfo(id); if (new MemberDao().CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, currentMember.UserId)) { int num5 = GetLimitedTimeDiscountUsedNum(id, skuId, productId, currentMember.UserId, true); if (discountInfo.LimitNumber == 0) { limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; } else if ((discountInfo.LimitNumber - num5) >= quantity) { limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; } else if ((discountInfo.LimitNumber - num5) < quantity) { num = 2; limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; num2 = quantity - (discountInfo.LimitNumber - num5); quantity = discountInfo.LimitNumber - num5; } } } } } new ShoppingCartDao().AddLineItem(currentMember, skuId, quantity, categoryid, Templateid, type, exchangeId, limitedTimeDiscountId); if (num == 2) { new ShoppingCartDao().AddLineItem(currentMember, skuId, num2, categoryid, Templateid, type, exchangeId, 0); } }
public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isCountDown, bool isSignBuy) { if (shoppingCart.LineItems.Count == 0) { return(null); } OrderInfo info = new OrderInfo { Points = shoppingCart.GetPoint(), ReducedPromotionId = shoppingCart.ReducedPromotionId, ReducedPromotionName = shoppingCart.ReducedPromotionName, ReducedPromotionAmount = shoppingCart.ReducedPromotionAmount, IsReduced = shoppingCart.IsReduced, SentTimesPointPromotionId = shoppingCart.SentTimesPointPromotionId, SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName, IsSendTimesPoint = shoppingCart.IsSendTimesPoint, TimesPoint = shoppingCart.TimesPoint, FreightFreePromotionId = shoppingCart.FreightFreePromotionId, FreightFreePromotionName = shoppingCart.FreightFreePromotionName, IsFreightFree = shoppingCart.IsFreightFree }; string str = string.Empty; if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems) { str = str + string.Format("'{0}',", info2.SkuId); } } if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo info3 in shoppingCart.LineItems) { LineItemInfo info4 = new LineItemInfo { SkuId = info3.SkuId, ProductId = info3.ProductId, SKU = info3.SKU, Quantity = info3.Quantity, ShipmentQuantity = info3.ShippQuantity, CommissionDiscount = 100 }; if (info3.LimitedTimeDiscountId > 0) { bool flag = true; LimitedTimeDiscountInfo discountInfo = new LimitedTimeDiscountDao().GetDiscountInfo(info3.LimitedTimeDiscountId); if (discountInfo == null) { flag = false; } else { info4.CommissionDiscount = discountInfo.CommissionDiscount; } if (!flag) { info3.LimitedTimeDiscountId = 0; } } info4.ItemCostPrice = new SkuDao().GetSkuItem(info3.SkuId).CostPrice; info4.ItemListPrice = info3.MemberPrice; info4.ItemAdjustedPrice = info3.AdjustedPrice; info4.ItemDescription = info3.Name; info4.ThumbnailsUrl = info3.ThumbnailUrl60; info4.ItemWeight = info3.Weight; info4.SKUContent = info3.SkuContent; info4.PromotionId = info3.PromotionId; info4.PromotionName = info3.PromotionName; info4.MainCategoryPath = info3.MainCategoryPath; info4.Type = info3.Type; info4.ExchangeId = info3.ExchangeId; info4.PointNumber = info3.PointNumber * info4.Quantity; info4.ThirdCommission = info3.ThirdCommission; info4.SecondCommission = info3.SecondCommission; info4.FirstCommission = info3.FirstCommission; info4.IsSetCommission = info3.IsSetCommission; info4.LimitedTimeDiscountId = info3.LimitedTimeDiscountId; info.LineItems.Add(info4.SkuId + info4.Type + info4.LimitedTimeDiscountId, info4); } } info.Tax = 0.00M; info.InvoiceTitle = ""; return(info); }
public ShoppingCartItemInfo GetCartItemInfo(MemberInfo member, string skuId, int quantity, int type = 0, int bargainDetialId = 0, int limitedTimeDiscountId = 0) { ShoppingCartItemInfo info = null; DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_ShoppingCart_GetItemInfo"); this.database.AddInParameter(storedProcCommand, "Quantity", DbType.Int32, quantity); this.database.AddInParameter(storedProcCommand, "UserId", DbType.Int32, (member != null) ? member.UserId : 0); this.database.AddInParameter(storedProcCommand, "SkuId", DbType.String, skuId); this.database.AddInParameter(storedProcCommand, "GradeId", DbType.Int32, (member != null) ? member.GradeId : 0); this.database.AddInParameter(storedProcCommand, "Type", DbType.Int32, type); using (IDataReader reader = this.database.ExecuteReader(storedProcCommand)) { if (!reader.Read()) { return(info); } info = new ShoppingCartItemInfo { SkuId = skuId, Quantity = quantity, MainCategoryPath = reader["MainCategoryPath"].ToString(), ProductId = (int)reader["ProductId"] }; if (DBNull.Value != reader["CubicMeter"]) { info.CubicMeter = (decimal)reader["CubicMeter"]; } if (DBNull.Value != reader["FreightWeight"]) { info.FreightWeight = (decimal)reader["FreightWeight"]; } if (reader["SKU"] != DBNull.Value) { info.SKU = (string)reader["SKU"]; } info.Name = (string)reader["ProductName"]; if (DBNull.Value != reader["Weight"]) { info.Weight = (int)reader["Weight"]; } if (DBNull.Value != reader["FreightTemplateId"]) { info.FreightTemplateId = (int)reader["FreightTemplateId"]; } else { info.FreightTemplateId = 0; } if (DBNull.Value != reader["ThirdCommission"]) { info.ThirdCommission = (decimal)reader["ThirdCommission"]; } else { info.ThirdCommission = 0M; } if (DBNull.Value != reader["SecondCommission"]) { info.SecondCommission = (decimal)reader["SecondCommission"]; } else { info.SecondCommission = 0M; } if (DBNull.Value != reader["FirstCommission"]) { info.FirstCommission = (decimal)reader["FirstCommission"]; } else { info.FirstCommission = 0M; } if (DBNull.Value != reader["IsSetCommission"]) { info.IsSetCommission = (bool)reader["IsSetCommission"]; } else { info.IsSetCommission = false; } BargainDetialInfo bargainDetialInfo = null; if (bargainDetialId > 0) { bargainDetialInfo = new BargainDao().GetBargainDetialInfo(bargainDetialId); } if ((bargainDetialId > 0) && (bargainDetialInfo != null)) { info.MemberPrice = info.AdjustedPrice = bargainDetialInfo.Price; } else { info.MemberPrice = info.AdjustedPrice = decimal.Round((decimal)reader["SalePrice"], 2); } if (limitedTimeDiscountId > 0) { LimitedTimeDiscountProductInfo info3 = new LimitedTimeDiscountDao().GetLimitedTimeDiscountProductByLimitIdAndProductIdAndUserId(limitedTimeDiscountId, info.ProductId, (member != null) ? member.UserId : 0); if (((info3 != null) && (info3.BeginTime <= DateTime.Now)) && (DateTime.Now < info3.EndTime)) { info.MemberPrice = info.AdjustedPrice = decimal.Round(info3.FinalPrice, 2); info.LimitedTimeDiscountId = limitedTimeDiscountId; } else { info.LimitedTimeDiscountId = 0; } } else { info.LimitedTimeDiscountId = 0; } if (DBNull.Value != reader["ThumbnailUrl40"]) { info.ThumbnailUrl40 = reader["ThumbnailUrl40"].ToString(); } if (DBNull.Value != reader["ThumbnailUrl60"]) { info.ThumbnailUrl60 = reader["ThumbnailUrl60"].ToString(); } if (DBNull.Value != reader["ThumbnailUrl100"]) { info.ThumbnailUrl100 = reader["ThumbnailUrl100"].ToString(); } if (DBNull.Value != reader["IsfreeShipping"]) { info.IsfreeShipping = Convert.ToBoolean(reader["IsfreeShipping"]); } string str = string.Empty; if (reader.NextResult()) { while (reader.Read()) { if (((reader["AttributeName"] != DBNull.Value) && !string.IsNullOrEmpty((string)reader["AttributeName"])) && ((reader["ValueStr"] != DBNull.Value) && !string.IsNullOrEmpty((string)reader["ValueStr"]))) { object obj2 = str; str = string.Concat(new object[] { obj2, reader["AttributeName"], ":", reader["ValueStr"], "; " }); } } } info.SkuContent = str; if (reader.NextResult()) { while (reader.Read()) { info.Type = 1; if (DBNull.Value != reader["ProductNumber"]) { info.ProductNumber = Convert.ToInt32(reader["ProductNumber"]); } if (DBNull.Value != reader["PointNumber"]) { info.PointNumber = Convert.ToInt32(reader["PointNumber"]); } if (DBNull.Value != reader["status"]) { info.Status = Convert.ToInt32(reader["status"]); } if (DBNull.Value != reader["exChangeId"]) { info.ExchangeId = Convert.ToInt32(reader["exChangeId"]); } } return(info); } info.Type = 0; } return(info); }
public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isCountDown, bool isSignBuy) { OrderInfo result; if (shoppingCart.LineItems.Count == 0) { result = null; } else { OrderInfo orderInfo = new OrderInfo(); orderInfo.Points = shoppingCart.GetPoint(); orderInfo.ReducedPromotionId = shoppingCart.ReducedPromotionId; orderInfo.ReducedPromotionName = shoppingCart.ReducedPromotionName; orderInfo.ReducedPromotionAmount = shoppingCart.ReducedPromotionAmount; orderInfo.IsReduced = shoppingCart.IsReduced; orderInfo.SentTimesPointPromotionId = shoppingCart.SentTimesPointPromotionId; orderInfo.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName; orderInfo.IsSendTimesPoint = shoppingCart.IsSendTimesPoint; orderInfo.TimesPoint = shoppingCart.TimesPoint; orderInfo.FreightFreePromotionId = shoppingCart.FreightFreePromotionId; orderInfo.FreightFreePromotionName = shoppingCart.FreightFreePromotionName; orderInfo.IsFreightFree = shoppingCart.IsFreightFree; string str = string.Empty; if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo current in shoppingCart.LineItems) { str += string.Format("'{0}',", current.SkuId); } } if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo current in shoppingCart.LineItems) { LineItemInfo lineItemInfo = new LineItemInfo(); lineItemInfo.SkuId = current.SkuId; lineItemInfo.ProductId = current.ProductId; lineItemInfo.SKU = current.SKU; lineItemInfo.Quantity = current.Quantity; lineItemInfo.ShipmentQuantity = current.ShippQuantity; lineItemInfo.CommissionDiscount = 100; if (current.LimitedTimeDiscountId > 0) { bool flag = true; LimitedTimeDiscountInfo discountInfo = new LimitedTimeDiscountDao().GetDiscountInfo(current.LimitedTimeDiscountId); if (discountInfo == null) { flag = false; } else { lineItemInfo.CommissionDiscount = discountInfo.CommissionDiscount; } if (!flag) { current.LimitedTimeDiscountId = 0; } } lineItemInfo.ItemCostPrice = new SkuDao().GetSkuItem(current.SkuId).CostPrice; lineItemInfo.ItemListPrice = current.MemberPrice; lineItemInfo.ItemAdjustedPrice = current.AdjustedPrice; lineItemInfo.ItemDescription = current.Name; lineItemInfo.ThumbnailsUrl = current.ThumbnailUrl60; lineItemInfo.ItemWeight = current.Weight; lineItemInfo.SKUContent = current.SkuContent; lineItemInfo.PromotionId = current.PromotionId; lineItemInfo.PromotionName = current.PromotionName; lineItemInfo.MainCategoryPath = current.MainCategoryPath; lineItemInfo.Type = current.Type; lineItemInfo.ExchangeId = current.ExchangeId; lineItemInfo.PointNumber = current.PointNumber * lineItemInfo.Quantity; lineItemInfo.ThirdCommission = current.ThirdCommission; lineItemInfo.SecondCommission = current.SecondCommission; lineItemInfo.FirstCommission = current.FirstCommission; lineItemInfo.IsSetCommission = current.IsSetCommission; lineItemInfo.LimitedTimeDiscountId = current.LimitedTimeDiscountId; orderInfo.LineItems.Add(lineItemInfo.SkuId + lineItemInfo.Type + lineItemInfo.LimitedTimeDiscountId, lineItemInfo); } } orderInfo.Tax = 0.00m; orderInfo.InvoiceTitle = ""; result = orderInfo; } return(result); }
static LimitedTimeDiscountHelper() { LimitedTimeDiscountHelper._act = new LimitedTimeDiscountDao(); }
public ShoppingCartItemInfo GetCartItemInfo(DateTime startSendDate, int quantityPerDay, int sendDays, MemberInfo member, string skuId, int quantity, int type = 0, int bargainDetialId = 0, int limitedTimeDiscountId = 0) { ShoppingCartItemInfo shoppingCartItemInfo = null; System.Data.Common.DbCommand storedProcCommand = this.database.GetStoredProcCommand("ss_ShoppingCart_GetItemInfo"); this.database.AddInParameter(storedProcCommand, "Quantity", System.Data.DbType.Int32, quantity); this.database.AddInParameter(storedProcCommand, "UserId", System.Data.DbType.Int32, (member != null) ? member.UserId : 0); this.database.AddInParameter(storedProcCommand, "SkuId", System.Data.DbType.String, skuId); this.database.AddInParameter(storedProcCommand, "GradeId", System.Data.DbType.Int32, (member != null) ? member.GradeId : 0); this.database.AddInParameter(storedProcCommand, "Type", System.Data.DbType.Int32, type); using (System.Data.IDataReader dataReader = this.database.ExecuteReader(storedProcCommand)) { if (dataReader.Read()) { shoppingCartItemInfo = new ShoppingCartItemInfo(); shoppingCartItemInfo.SkuId = skuId; ShoppingCartItemInfo arg_E7_0 = shoppingCartItemInfo; shoppingCartItemInfo.ShippQuantity = quantity; arg_E7_0.Quantity = quantity; shoppingCartItemInfo.MainCategoryPath = dataReader["MainCategoryPath"].ToString(); shoppingCartItemInfo.ProductId = (int)dataReader["ProductId"]; if (DBNull.Value != dataReader["CubicMeter"]) { shoppingCartItemInfo.CubicMeter = (decimal)dataReader["CubicMeter"]; } if (DBNull.Value != dataReader["FreightWeight"]) { shoppingCartItemInfo.FreightWeight = (decimal)dataReader["FreightWeight"]; } if (dataReader["SKU"] != DBNull.Value) { shoppingCartItemInfo.SKU = (string)dataReader["SKU"]; } shoppingCartItemInfo.Name = (string)dataReader["ProductName"]; if (DBNull.Value != dataReader["Weight"]) { shoppingCartItemInfo.Weight = (int)dataReader["Weight"]; } if (DBNull.Value != dataReader["FreightTemplateId"]) { shoppingCartItemInfo.FreightTemplateId = (int)dataReader["FreightTemplateId"]; } else { shoppingCartItemInfo.FreightTemplateId = 0; } if (DBNull.Value != dataReader["ThirdCommission"]) { shoppingCartItemInfo.ThirdCommission = (decimal)dataReader["ThirdCommission"]; } else { shoppingCartItemInfo.ThirdCommission = 0m; } if (DBNull.Value != dataReader["SecondCommission"]) { shoppingCartItemInfo.SecondCommission = (decimal)dataReader["SecondCommission"]; } else { shoppingCartItemInfo.SecondCommission = 0m; } if (DBNull.Value != dataReader["FirstCommission"]) { shoppingCartItemInfo.FirstCommission = (decimal)dataReader["FirstCommission"]; } else { shoppingCartItemInfo.FirstCommission = 0m; } if (DBNull.Value != dataReader["IsSetCommission"]) { shoppingCartItemInfo.IsSetCommission = (bool)dataReader["IsSetCommission"]; } else { shoppingCartItemInfo.IsSetCommission = false; } BargainDetialInfo bargainDetialInfo = null; if (bargainDetialId > 0) { bargainDetialInfo = new BargainDao().GetBargainDetialInfo(bargainDetialId); } if (bargainDetialId > 0 && bargainDetialInfo != null) { shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = bargainDetialInfo.Price); } else { shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = decimal.Round((decimal)dataReader["SalePrice"], 2)); } if (limitedTimeDiscountId > 0) { LimitedTimeDiscountProductInfo limitedTimeDiscountProductByLimitIdAndProductIdAndUserId = new LimitedTimeDiscountDao().GetLimitedTimeDiscountProductByLimitIdAndProductIdAndUserId(limitedTimeDiscountId, shoppingCartItemInfo.ProductId, (member != null) ? member.UserId : 0); if (limitedTimeDiscountProductByLimitIdAndProductIdAndUserId != null && limitedTimeDiscountProductByLimitIdAndProductIdAndUserId.BeginTime <= DateTime.Now && DateTime.Now < limitedTimeDiscountProductByLimitIdAndProductIdAndUserId.EndTime) { shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = decimal.Round(limitedTimeDiscountProductByLimitIdAndProductIdAndUserId.FinalPrice, 2)); shoppingCartItemInfo.LimitedTimeDiscountId = limitedTimeDiscountId; } else { shoppingCartItemInfo.LimitedTimeDiscountId = 0; } } else { shoppingCartItemInfo.LimitedTimeDiscountId = 0; } if (DBNull.Value != dataReader["ThumbnailUrl40"]) { shoppingCartItemInfo.ThumbnailUrl40 = dataReader["ThumbnailUrl40"].ToString(); } if (DBNull.Value != dataReader["ThumbnailUrl60"]) { shoppingCartItemInfo.ThumbnailUrl60 = dataReader["ThumbnailUrl60"].ToString(); } if (DBNull.Value != dataReader["ThumbnailUrl100"]) { shoppingCartItemInfo.ThumbnailUrl100 = dataReader["ThumbnailUrl100"].ToString(); } if (DBNull.Value != dataReader["IsfreeShipping"]) { shoppingCartItemInfo.IsfreeShipping = Convert.ToBoolean(dataReader["IsfreeShipping"]); } string text = string.Empty; if (dataReader.NextResult()) { while (dataReader.Read()) { if (dataReader["AttributeName"] != DBNull.Value && !string.IsNullOrEmpty((string)dataReader["AttributeName"]) && dataReader["ValueStr"] != DBNull.Value && !string.IsNullOrEmpty((string)dataReader["ValueStr"])) { object obj = text; text = string.Concat(new object[] { obj, dataReader["AttributeName"], ":", dataReader["ValueStr"], "; " }); } } } shoppingCartItemInfo.SkuContent = text; if (dataReader.NextResult()) { while (dataReader.Read()) { shoppingCartItemInfo.Type = 1; if (DBNull.Value != dataReader["ProductNumber"]) { shoppingCartItemInfo.ProductNumber = Convert.ToInt32(dataReader["ProductNumber"]); } if (DBNull.Value != dataReader["PointNumber"]) { shoppingCartItemInfo.PointNumber = Convert.ToInt32(dataReader["PointNumber"]); } if (DBNull.Value != dataReader["status"]) { shoppingCartItemInfo.Status = Convert.ToInt32(dataReader["status"]); } if (DBNull.Value != dataReader["exChangeId"]) { shoppingCartItemInfo.ExchangeId = Convert.ToInt32(dataReader["exChangeId"]); } } } else { shoppingCartItemInfo.Type = 0; } } } return(shoppingCartItemInfo); }