public List <StoreActivityEntity> GetPlatformActivityEntity(int productId, int gradeId) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("SELECT p.ActivityId,0 StoreId,1 ActivityType ,p.PromoteType,p.StartDate,p.GiftIds, "); stringBuilder.Append(" (CASE WHEN PromoteType = " + 13 + " THEN '满' + REPLACE(CAST(p.Condition AS VARCHAR(10) ),'.00','') + '件享'+REPLACE(CAST(p.DiscountValue * 10 AS VARCHAR(10)),'.00','') + '折' "); stringBuilder.Append(" WHEN PromoteType = 14 THEN '满' + REPLACE(CAST(p.Condition AS VARCHAR(10) ),'.00','') + '件立减' + CAST(p.DiscountValue AS VARCHAR(10))+'元' "); stringBuilder.Append(" WHEN PromoteType = 4 THEN '单品买' + REPLACE(CAST(p.Condition AS VARCHAR(10) ),'.00','') + '件享' + REPLACE(CAST(p.DiscountValue*10 AS VARCHAR(10)),'.00','') + '折' END )AS ActivityName "); stringBuilder.Append(" FROM [Hishop_Promotions] p"); StringBuilder stringBuilder2 = stringBuilder; object arg = productId; PromoteType promoteType = PromoteType.FullQuantityDiscount; object arg2 = promoteType.GetHashCode(); promoteType = PromoteType.FullQuantityReduced; stringBuilder2.AppendFormat(" WHERE ( ActivityId IN (SELECT ActivityId FROM Hishop_PromotionProducts WHERE ProductId= {0}) OR PromoteType = {1} OR PromoteType = {2}) AND GETDATE() BETWEEN p.StartDate AND p.EndDate", arg, arg2, promoteType.GetHashCode()); if (gradeId > 0) { stringBuilder.Append(" AND p.ActivityId IN(SELECT ActivityId FROM Hishop_PromotionMemberGrades WHERE GradeId = " + gradeId + ")"); } DbCommand sqlStringCommand = base.database.GetSqlStringCommand(stringBuilder.ToString()); List <StoreActivityEntity> result = new List <StoreActivityEntity>(); using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand)) { result = DataHelper.ReaderToList <StoreActivityEntity>(objReader).ToList(); } return(result); }
public PromotionInfo GetCombinationReducedPromotion(int gradeId, decimal amount, int quantity, out decimal reducedAmount) { DbCommand sqlStringCommand = base.database.GetSqlStringCommand("SELECT * FROM Hishop_Promotions WHERE DateDiff(DD, StartDate, getdate()) >= 0 AND DateDiff(DD, EndDate, getdate()) <= 0 AND PromoteType in(" + 12 + ") AND ActivityId IN (SELECT ActivityId FROM Hishop_PromotionMemberGrades WHERE GradeId = @GradeId)"); base.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, gradeId); IList <PromotionInfo> list = new List <PromotionInfo>(); using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand)) { while (dataReader.Read()) { list.Add(DataMapper.PopulatePromote(dataReader)); } } PromotionInfo result = null; reducedAmount = default(decimal); foreach (PromotionInfo item in list) { PromoteType promoteType = item.PromoteType; if (promoteType == PromoteType.FullAmountReduced && amount >= item.Condition && item.DiscountValue > reducedAmount) { reducedAmount = item.DiscountValue; result = item; } } return(result); }
public static bool AddGiftItem(int giftId, int quantity, PromoteType promotype) { if (HiContext.Current.User.IsAnonymous) { return(CookieShoppingProvider.Instance().AddGiftItem(giftId, quantity)); } return(ShoppingProvider.Instance().AddGiftItem(giftId, quantity, promotype)); }
public void RemoveGiftItem(int giftId, PromoteType promotype) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Ecshop_GiftShoppingCarts WHERE UserId = @UserId AND GiftId = @GiftId AND PromoType=@PromoType"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId); this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, giftId); this.database.AddInParameter(sqlStringCommand, "PromoType", DbType.Int32, (int)promotype); this.database.ExecuteNonQuery(sqlStringCommand); }
public void UpdateGiftItemQuantity(int giftId, int quantity, PromoteType promotype) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Ecshop_GiftShoppingCarts SET Quantity = @Quantity WHERE UserId = @UserId AND GiftId = @GiftId AND PromoType=@PromoType"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId); this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, giftId); this.database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, quantity); this.database.AddInParameter(sqlStringCommand, "PromoType", DbType.Int32, (int)promotype); this.database.ExecuteNonQuery(sqlStringCommand); }
public static void RemoveGiftItem(int giftId, PromoteType promotype) { if (HiContext.Current.User.IsAnonymous) { CookieShoppingProvider.Instance().RemoveGiftItem(giftId); } else { ShoppingProvider.Instance().RemoveGiftItem(giftId, promotype); } }
public bool AddGiftItem(int giftId, int quantity, PromoteType promotype) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("IF EXISTS(SELECT GiftId FROM Ecshop_GiftShoppingCarts WHERE UserId = @UserId AND GiftId = @GiftId AND PromoType=@PromoType) UPDATE Ecshop_GiftShoppingCarts SET Quantity = Quantity + @Quantity WHERE UserId = @UserId AND GiftId = @GiftId AND PromoType=@PromoType; ELSE INSERT INTO Ecshop_GiftShoppingCarts(UserId, GiftId, Quantity, AddTime,PromoType) VALUES (@UserId, @GiftId, @Quantity, @AddTime,@PromoType)"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId); this.database.AddInParameter(sqlStringCommand, "GiftId", DbType.Int32, giftId); this.database.AddInParameter(sqlStringCommand, "Quantity", DbType.Int32, quantity); this.database.AddInParameter(sqlStringCommand, "AddTime", DbType.DateTime, DateTime.Now); this.database.AddInParameter(sqlStringCommand, "PromoType", DbType.Int32, (int)promotype); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static void RemoveGiftItem(int giftId, PromoteType promotype) { if (HiContext.Current.User.IsAnonymous) { new CookieShoppingDao().RemoveGiftItem(giftId); } else { new ShoppingCartDao().RemoveGiftItem(giftId, promotype); } }
public Promote GetPromote(PromoteType promoteType) { if (promotes == null) { return(null); } var results = promotes.FindAll(x => x.type == promoteType && !CUtils.IsAppInstalled(x.package) && CUtils.IsCacheExists(x.featureUrl)); if (results == null || results.Count == 0) { return(null); } return(CUtils.GetRandom(results.ToArray())); }
public static bool AddGiftItem(int giftId, int quantity, PromoteType promotype) { bool result; if (HiContext.Current.User.IsAnonymous) { result = CookieShoppingProvider.Instance().AddGiftItem(giftId, quantity); } else { result = ShoppingProvider.Instance().AddGiftItem(giftId, quantity, promotype); } return(result); }
public int GetGiftItemQuantity(PromoteType promotype) { int result = 0; DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT ISNULL(SUM(Quantity),0) as Quantity FROM Ecshop_GiftShoppingCarts WHERE UserId = @UserId AND PromoType=@PromoType"); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, HiContext.Current.User.UserId); this.database.AddInParameter(sqlStringCommand, "PromoType", DbType.Int32, (int)promotype); using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { result = int.Parse(dataReader["Quantity"].ToString()); } } return(result); }
public PromotionInfo GetSecondPromotion(Member member, PromoteType promoteType) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Ecshop_Promotions WHERE DateDiff(DD, StartDate, getdate()) >= 0 AND DateDiff(DD, EndDate, getdate()) <= 0 AND PromoteType = @PromoteType AND ActivityId IN (SELECT ActivityId FROM Ecshop_PromotionMemberGrades WHERE GradeId = @GradeId) ORDER BY DiscountValue DESC"); this.database.AddInParameter(sqlStringCommand, "PromoteType", DbType.Int32, (int)promoteType); this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, member.GradeId); PromotionInfo result = null; using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { result = DataMapper.PopulatePromote(dataReader); } } return(result); }
private DataGridViewModel <Dictionary <string, object> > GetDataList(bool isWholesale) { DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >(); DataTable promotions = PromoteHelper.GetPromotions(false, isWholesale, false); dataGridViewModel.rows = DataHelper.DataTableToDictionary(promotions); dataGridViewModel.total = promotions.Rows.Count; foreach (Dictionary <string, object> row in dataGridViewModel.rows) { PromoteType promoteType = (PromoteType)row["PromoteType"].ToInt(0); row.Add("PromoteTypeText", ""); row.Add("PromoteInfo", ""); switch (promoteType) { case PromoteType.FullAmountReduced: row["PromoteTypeText"] = "满额优惠金额"; row["PromoteInfo"] = string.Format("满足金额:{0} 优惠金额:{1}", row["Condition"].ToDecimal(0).F2ToString("f2"), row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; case PromoteType.FullQuantityDiscount: row["PromoteTypeText"] = "满量打折"; row["PromoteInfo"] = string.Format("满足数量:{0} 折扣值:{1}", row["Condition"].ToInt(0).F2ToString("f2"), row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; case PromoteType.FullQuantityReduced: row["PromoteTypeText"] = "满量优惠金额"; row["PromoteInfo"] = string.Format("满足数量:{0} 优惠金额:{1}", row["Condition"].ToInt(0).F2ToString("f2"), row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; case PromoteType.FullAmountSentGift: row["PromoteTypeText"] = "满额送礼品"; break; case PromoteType.FullAmountSentTimesPoint: row["PromoteTypeText"] = "满额送倍数积分"; row["PromoteInfo"] = string.Format("满足金额:{0},倍数:{1}", row["Condition"].ToDecimal(0).F2ToString("f2"), row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; case PromoteType.FullAmountSentFreight: row["PromoteTypeText"] = "满额免运费"; row["PromoteInfo"] = string.Format("满足金额:{0}", row["Condition"].ToDecimal(0).F2ToString("f2")); break; } } return(dataGridViewModel); }
public static void UpdateGiftItemQuantity(int giftId, int quantity, PromoteType promotype) { Member member = HiContext.Current.User as Member; if (quantity <= 0) { ShoppingCartProcessor.RemoveGiftItem(giftId, promotype); } if (member == null) { CookieShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity); } else { ShoppingProvider.Instance().UpdateGiftItemQuantity(giftId, quantity, promotype); } }
private DataGridViewModel <Dictionary <string, object> > GetDataList(bool isWholesale, bool isMobileExclusive) { DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >(); DataTable promotions = PromoteHelper.GetPromotions(true, isWholesale, isMobileExclusive); dataGridViewModel.rows = DataHelper.DataTableToDictionary(promotions); dataGridViewModel.total = promotions.Rows.Count; foreach (Dictionary <string, object> row in dataGridViewModel.rows) { PromoteType promoteType = (PromoteType)row["PromoteType"].ToInt(0); row.Add("PromoteTypeText", ""); row.Add("PromoteInfo", ""); switch (promoteType) { case PromoteType.QuantityDiscount: row["PromoteTypeText"] = "按批发数量打折"; row["PromoteInfo"] = string.Format("购买数量:{0} 折扣值:{1}", row["Condition"].ToInt(0).F2ToString("f2"), row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; case PromoteType.SentGift: row["PromoteTypeText"] = "买商品送礼品"; break; case PromoteType.SentProduct: { row["PromoteTypeText"] = "有买有送"; Dictionary <string, object> dictionary = row; int num = row["Condition"].ToInt(0); string arg = num.ToString(); num = row["DiscountValue"].ToInt(0); dictionary["PromoteInfo"] = $"购买数量:{arg} 赠送数量:{num.ToString()}"; break; } case PromoteType.MobileExclusive: row["PromoteTypeText"] = "手机专享价"; row["PromoteInfo"] = string.Format("移动端立减{0}元", row["DiscountValue"].ToDecimal(0).F2ToString("f2")); break; } } return(dataGridViewModel); }
string ConvertPromoteType(PromoteType promoteType) { if (promoteType == PromoteType.FullDiscount) { return("满额打折"); } if (promoteType == PromoteType.FullFree) { return("满额免费用"); } if (promoteType == PromoteType.PurchaseGift) { return("买几送几"); } if (promoteType == PromoteType.WholesaleDiscount) { return("批发打折"); } return(string.Empty); }
public static PromotionFactory Create(PromoteType promoteType) { if (promoteType == PromoteType.FullDiscount) { return(FullDiscountFactory.Instance()); } if (promoteType == PromoteType.FullFree) { return(FullFreeFactory.Instance()); } if (promoteType == PromoteType.PurchaseGift) { return(PurchaseGiftFactory.Instance()); } if (promoteType == PromoteType.WholesaleDiscount) { return(WholesaleDiscountFactory.Instance()); } return(null); }
string ConvertPromoteType(PromoteType promoteType) { if (promoteType == PromoteType.FullDiscount) { return "满额打折"; } if (promoteType == PromoteType.FullFree) { return "满额免费用"; } if (promoteType == PromoteType.PurchaseGift) { return "买几送几"; } if (promoteType == PromoteType.WholesaleDiscount) { return "批发打折"; } return string.Empty; }
public static PromotionFactory Create(PromoteType promoteType) { if (promoteType == PromoteType.FullDiscount) { return FullDiscountFactory.Instance(); } if (promoteType == PromoteType.FullFree) { return FullFreeFactory.Instance(); } if (promoteType == PromoteType.PurchaseGift) { return PurchaseGiftFactory.Instance(); } if (promoteType == PromoteType.WholesaleDiscount) { return WholesaleDiscountFactory.Instance(); } return null; }
public static string GetShortName(PromoteType promotionType) { string result = ""; switch (promotionType) { case PromoteType.Discount: case PromoteType.QuantityDiscount: result = "折"; break; case PromoteType.Amount: result = "促"; break; case PromoteType.Reduced: result = "减"; break; case PromoteType.SentGift: break; case PromoteType.SentProduct: result = "送"; break; default: switch (promotionType) { case PromoteType.FullAmountSentTimesPoint: result = "积分加倍"; break; case PromoteType.FullAmountSentFreight: result = "包邮"; break; } break; } return(result); }
public PromotionInfo GetSendPromotion(int gradeId, decimal amount, PromoteType promoteType, int storeId = 0) { string text = "SELECT * FROM Hishop_Promotions WHERE DateDiff(DD, StartDate, getdate()) >= 0 AND DateDiff(DD, EndDate, getdate()) <= 0 AND PromoteType = @PromoteType AND Condition <= @Condition AND ActivityId IN (SELECT ActivityId FROM Hishop_PromotionMemberGrades WHERE GradeId = @GradeId)"; text = ((storeId <= 0) ? (text + " AND (StoreType in (0,1) OR ActivityId IN (select ActivityId FROM Hishop_StoreActivitys sa WHERE sa.StoreId=0 AND sa.ActivityType=1))") : (text + " AND (StoreType=1 OR ActivityId IN (select ActivityId FROM Hishop_StoreActivitys sa WHERE sa.StoreId=" + storeId + " AND sa.ActivityType=1))")); text += " ORDER BY DiscountValue DESC"; DbCommand sqlStringCommand = base.database.GetSqlStringCommand(text); base.database.AddInParameter(sqlStringCommand, "PromoteType", DbType.Int32, (int)promoteType); base.database.AddInParameter(sqlStringCommand, "Condition", DbType.Currency, amount); base.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, gradeId); PromotionInfo result = null; using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { result = DataMapper.PopulatePromote(dataReader); } } return(result); }
public abstract bool AddGiftItem(int giftId, int quantity, PromoteType promotype);
public static int GetGiftItemQuantity(PromoteType promotype) { return(ShoppingProvider.Instance().GetGiftItemQuantity(promotype)); }
public abstract int GetGiftItemQuantity(PromoteType promotype);
public abstract void RemoveGiftItem(int giftId, PromoteType promotype);
public static int GetGiftItemQuantity(PromoteType promotype) { return(new ShoppingCartDao().GetGiftItemQuantity(promotype)); }
public abstract PromotionInfo GetSendPromotion(Member member, decimal amount, PromoteType promoteType);
public abstract void UpdateGiftItemQuantity(int giftId, int quantity, PromoteType promotype);