/// <summary> /// 设置店铺优惠活动为不可用 /// </summary> /// <param name="id">店铺优惠活动Id</param> /// <param name="sellerId">卖家Id</param> /// <returns></returns> public bool PromotionActivityDisable(int id, int?sellerId = null) { return(Try(nameof(PromotionActivityUpdate), () => { var cmd = SqlBuilder.Update("Activity") .Column("Status=0") .Where("Id=@Id and Seller=@SellerId", new { id }) .Where(sellerId.HasValue && sellerId.Value > 0, "Seller=@SellerId", new { sellerId }) .ToCommand(); return PromotionConn.Execute(cmd) > 0; })); }
/// <summary> /// 更新店铺优惠活动 /// </summary> /// <param name="o">店铺优惠活动</param> /// <returns></returns> public bool PromotionActivityUpdate(Promotion.Activity o) { if (o.LimitType == Promotion.LimitType.None) { o.LimitValue = 0; } return(Try(nameof(PromotionActivityUpdate), () => { var cmd = SqlBuilder.Update("Activity") .Column("Name", o.Name) .Column("Title", o.Title) .Column("Global", o.Global) .Column("WarmUp", o.WarmUp) .Column("Infinite", o.Infinite) .Column("Picture", o.Picture) .Column("StartedOn", o.StartedOn) .Column("StoppedOn", o.StoppedOn) .Column("Platform", o.Platform) .Column("MediaScope", o.MediaScope) .Column("ItemScope", o.ItemScope) .Column("LimitType", o.LimitType) .Column("LimitValue", o.LimitValue) .Column("FreightFree", o.FreightFree) .Column("FreightFreeExclude", o.FreightFreeExclude) .Column("ExternalUrl", o.ExternalUrl) .Column("RuleData", o.RuleData) //.Column("SellerId", o.SellerId) //.Column("SellerName", o.SellerName) .Column("Status", o.Status) //.Column("CreatedOn", o.CreatedOn) .Column("ModifiedBy", o.ModifiedBy) .Column("ModifiedOn", o.ModifiedOn) .Where("Id=@id", new { o.Id }) .ToCommand(); return PromotionConn.Execute(cmd) > 0; })); }