/// <summary> /// 添加满赠到购物车中 /// </summary> /// <param name="orderProductList">订单商品列表</param> /// <param name="partProductInfo">购买商品</param> /// <param name="fullSendPromotionInfo">满赠促销活动</param> /// <param name="sid">用户sessionId</param> /// <param name="uid">用户id</param> /// <param name="buyTime">购买时间</param> public static void AddFullSendToCart(ref List<OrderProductInfo> orderProductList, PartProductInfo partProductInfo, FullSendPromotionInfo fullSendPromotionInfo, string sid, int uid, DateTime buyTime) { OrderProductInfo orderProductInfo = BuildOrderProduct(partProductInfo); InitOrderProduct(orderProductInfo, 0, sid, uid, buyTime); SetFullSendOrderProduct(orderProductInfo, fullSendPromotionInfo); AddOrderProductList(new List<OrderProductInfo>() { orderProductInfo }); orderProductList.Add(orderProductInfo); }
/// <summary> /// 更新满赠促销活动 /// </summary> public static void UpdateFullSendPromotion(FullSendPromotionInfo fullSendPromotionInfo) { BrnMall.Data.Promotions.UpdateFullSendPromotion(fullSendPromotionInfo); }
/// <summary> /// 设置订单商品的满赠促销活动 /// </summary> /// <param name="orderProductInfo">订单商品</param> /// <param name="fullSendPromotionInfo">满赠促销活动</param> public static void SetFullSendPromotionOfOrderProduct(OrderProductInfo orderProductInfo, FullSendPromotionInfo fullSendPromotionInfo) { orderProductInfo.ExtCode4 = fullSendPromotionInfo.PmId; }
/// <summary> /// 设置满赠订单商品 /// </summary> /// <param name="orderProductInfo">订单商品</param> /// <param name="fullSendPromotionInfo">满赠促销活动</param> public static void SetFullSendOrderProduct(OrderProductInfo orderProductInfo, FullSendPromotionInfo fullSendPromotionInfo) { orderProductInfo.RealCount = 1; orderProductInfo.BuyCount = 1; orderProductInfo.DiscountPrice = fullSendPromotionInfo.AddMoney; orderProductInfo.Type = 4; orderProductInfo.ExtCode1 = fullSendPromotionInfo.PmId; }
/// <summary> /// 更新满赠促销活动 /// </summary> public void UpdateFullSendPromotion(FullSendPromotionInfo fullSendPromotionInfo) { DbParameter[] parms = { GenerateInParam("@storeid", SqlDbType.Int,4,fullSendPromotionInfo.StoreId), GenerateInParam("@starttime", SqlDbType.DateTime,8,fullSendPromotionInfo.StartTime), GenerateInParam("@endtime", SqlDbType.DateTime,8,fullSendPromotionInfo.EndTime), GenerateInParam("@userranklower", SqlDbType.SmallInt,2,fullSendPromotionInfo.UserRankLower), GenerateInParam("@state", SqlDbType.TinyInt,1,fullSendPromotionInfo.State), GenerateInParam("@name", SqlDbType.NVarChar,50,fullSendPromotionInfo.Name), GenerateInParam("@limitmoney", SqlDbType.Int, 4, fullSendPromotionInfo.LimitMoney), GenerateInParam("@addmoney", SqlDbType.Int, 4, fullSendPromotionInfo.AddMoney), GenerateInParam("@pmid", SqlDbType.Int,4,fullSendPromotionInfo.PmId) }; string commandText = string.Format("UPDATE [{0}fullsendpromotions] SET [storeid]=@storeid,[starttime]=@starttime,[endtime]=@endtime,[userranklower]=@userranklower,[state]=@state,[name]=@name,[limitmoney]=@limitmoney,[addmoney]=@addmoney WHERE [pmid]=@pmid", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
public ActionResult AddFullSendPromotion(FullSendPromotionModel model) { if (ModelState.IsValid) { FullSendPromotionInfo fullSendPromotionInfo = new FullSendPromotionInfo() { StoreId = WorkContext.StoreId, Name = model.PromotionName, StartTime = model.StartTime, EndTime = model.EndTime, UserRankLower = model.UserRankLower, State = model.State, LimitMoney = model.LimitMoney, AddMoney = model.AddMoney }; AdminPromotions.CreateFullSendPromotion(fullSendPromotionInfo); AddStoreAdminLog("添加满赠促销活动", "添加满赠促销活动,满赠促销活动为:" + model.PromotionName); return PromptView("满赠促销活动添加成功"); } LoadFullSendPromotion(); return View(model); }
/// <summary> /// 创建满赠促销活动 /// </summary> public void CreateFullSendPromotion(FullSendPromotionInfo fullSendPromotionInfo) { DbParameter[] parms = { GenerateInParam("@storeid", SqlDbType.Int,4,fullSendPromotionInfo.StoreId), GenerateInParam("@starttime", SqlDbType.DateTime,8,fullSendPromotionInfo.StartTime), GenerateInParam("@endtime", SqlDbType.DateTime,8,fullSendPromotionInfo.EndTime), GenerateInParam("@userranklower", SqlDbType.SmallInt,2,fullSendPromotionInfo.UserRankLower), GenerateInParam("@state", SqlDbType.TinyInt,1,fullSendPromotionInfo.State), GenerateInParam("@name", SqlDbType.NVarChar,50,fullSendPromotionInfo.Name), GenerateInParam("@limitmoney", SqlDbType.Int, 4, fullSendPromotionInfo.LimitMoney), GenerateInParam("@addmoney", SqlDbType.Int, 4, fullSendPromotionInfo.AddMoney) }; string commandText = string.Format("INSERT INTO [{0}fullsendpromotions]([storeid],[starttime],[endtime],[userranklower],[state],[name],[limitmoney],[addmoney]) VALUES(@storeid,@starttime,@endtime,@userranklower,@state,@name,@limitmoney,@addmoney)", RDBSHelper.RDBSTablePre); RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); }
/// <summary> /// 生成商品的促销信息 /// </summary> /// <param name="singlePromotionInfo">单品促销活动</param> /// <param name="buySendPromotionList">买送促销活动列表</param> /// <param name="fullSendPromotionInfo">满赠促销活动</param> /// <param name="fullCutPromotionInfo">满减促销活动</param> /// <returns></returns> public static string GeneratePromotionMsg(SinglePromotionInfo singlePromotionInfo, List<BuySendPromotionInfo> buySendPromotionList, FullSendPromotionInfo fullSendPromotionInfo, FullCutPromotionInfo fullCutPromotionInfo) { StringBuilder promotionMsg = new StringBuilder(); //单品促销 if (singlePromotionInfo != null) { //折扣类别 switch (singlePromotionInfo.DiscountType) { case 0://折扣 promotionMsg.AppendFormat("折扣:{0}折<br/>", singlePromotionInfo.DiscountValue); break; case 1://直降 promotionMsg.AppendFormat("直降:{0}元<br/>", singlePromotionInfo.DiscountValue); break; case 2://折后价 promotionMsg.AppendFormat("折后价:{0}元<br/>", singlePromotionInfo.DiscountValue); break; } //积分 if (singlePromotionInfo.PayCredits > 0) promotionMsg.AppendFormat("赠送{0}:{1}<br/>", Credits.PayCreditName, singlePromotionInfo.PayCredits); //优惠劵 if (singlePromotionInfo.CouponTypeId > 0) { CouponTypeInfo couponTypeInfo = Coupons.GetCouponTypeById(singlePromotionInfo.CouponTypeId); if (couponTypeInfo != null) promotionMsg.AppendFormat("赠送优惠劵:{0}<br/>", couponTypeInfo.Name); } } //买送促销 if (buySendPromotionList != null && buySendPromotionList.Count > 0) { promotionMsg.Append("买送促销:"); foreach (BuySendPromotionInfo buySendPromotionInfo in buySendPromotionList) promotionMsg.AppendFormat("买{0}送{1},", buySendPromotionInfo.BuyCount, buySendPromotionInfo.SendCount); promotionMsg.Remove(promotionMsg.Length - 1, 1); promotionMsg.Append("<br/>"); } //满赠促销 if (fullSendPromotionInfo != null) { promotionMsg.Append("满赠促销:"); promotionMsg.AppendFormat("满{0}元加{1}元<br/>", fullSendPromotionInfo.LimitMoney, fullSendPromotionInfo.AddMoney); } //满减促销 if (fullCutPromotionInfo != null) { promotionMsg.Append("满减促销:"); promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney1, fullCutPromotionInfo.CutMoney1); if (fullCutPromotionInfo.LimitMoney2 > 0 && fullCutPromotionInfo.CutMoney2 > 0) promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney2, fullCutPromotionInfo.CutMoney2); if (fullCutPromotionInfo.LimitMoney3 > 0 && fullCutPromotionInfo.CutMoney3 > 0) promotionMsg.AppendFormat("满{0}元减{1}元,", fullCutPromotionInfo.LimitMoney3, fullCutPromotionInfo.CutMoney3); promotionMsg.Remove(promotionMsg.Length - 1, 1); promotionMsg.Append("<br/>"); } return promotionMsg.Length > 0 ? promotionMsg.Remove(promotionMsg.Length - 5, 5).ToString() : ""; }
/// <summary> /// 从IDataReader创建FullSendPromotionInfo /// </summary> public static FullSendPromotionInfo BuildFullSendPromotionFromReader(IDataReader reader) { FullSendPromotionInfo fullSendPromotionInfo = new FullSendPromotionInfo(); fullSendPromotionInfo.PmId = TypeHelper.ObjectToInt(reader["pmid"]); fullSendPromotionInfo.StoreId = TypeHelper.ObjectToInt(reader["storeid"]); fullSendPromotionInfo.StartTime = TypeHelper.ObjectToDateTime(reader["starttime"]); fullSendPromotionInfo.EndTime = TypeHelper.ObjectToDateTime(reader["endtime"]); fullSendPromotionInfo.UserRankLower = TypeHelper.ObjectToInt(reader["userranklower"]); fullSendPromotionInfo.State = TypeHelper.ObjectToInt(reader["state"]); fullSendPromotionInfo.Name = reader["name"].ToString(); fullSendPromotionInfo.LimitMoney = TypeHelper.ObjectToInt(reader["limitmoney"]); fullSendPromotionInfo.AddMoney = TypeHelper.ObjectToInt(reader["addmoney"]); return fullSendPromotionInfo; }
/// <summary> /// 更新满赠促销活动 /// </summary> public static void UpdateFullSendPromotion(FullSendPromotionInfo fullSendPromotionInfo) { BrnMall.Core.BMAData.RDBS.UpdateFullSendPromotion(fullSendPromotionInfo); if (_promotionnosql != null) _promotionnosql.DeleteFullSendPromotion(fullSendPromotionInfo.PmId); }
/// <summary> /// 创建满赠促销活动 /// </summary> public static void CreateFullSendPromotion(FullSendPromotionInfo fullSendPromotionInfo) { BrnMall.Core.BMAData.RDBS.CreateFullSendPromotion(fullSendPromotionInfo); }