/// <summary>
 /// 获取店铺优惠活动数量
 /// </summary>
 /// <param name="sellerId">卖家Id</param>
 /// <param name="global">是否为全店活动</param>
 /// <param name="status">活动状态</param>
 /// <returns></returns>
 public int PromotionActivityCount(int sellerId, bool?global = null, bool?status = null)
 {
     return(Try(nameof(PromotionActivityCount), () =>
     {
         var cmd = SqlBuilder.Select("count(0)")
                   .From("Activity")
                   .Where("SellerId=@sellerId", new { sellerId })
                   .Where(global.HasValue, "Global=@global", new { global })
                   .Where(status.HasValue, "Status=@status", new { status })
                   .ToCommand();
         return PromotionConn.ExecuteScalar <int>(cmd);
     }));
 }
 /// <summary>
 /// 创建店铺优惠活动
 /// </summary>
 /// <param name="o">店铺优惠活动</param>
 /// <returns></returns>
 public int PromotionActivityCreate(Promotion.Activity o)
 {
     if (o.Global)
     {
         o.ItemScope = string.Empty;
     }
     if (o.LimitType == Promotion.LimitType.None)
     {
         o.LimitValue = 0;
     }
     return(Try(nameof(PromotionActivityCreate), () =>
     {
         var cmd = SqlBuilder.Insert("Activity")
                   .Column("Type", o.Type)
                   .Column("Name", o.Name)
                   .Column("Title", o.Title)
                   .Column("Global", o.Global)
                   .Column("WarmUp", o.WarmUp)
                   .Column("Infinite", o.Infinite)
                   .Column("Picture", o.Picture ?? string.Empty)
                   .Column("StartedOn", o.StartedOn)
                   .Column("StoppedOn", o.StoppedOn)
                   .Column("Platform", o.Platform)
                   .Column("MediaScope", o.MediaScope ?? string.Empty)
                   .Column("ItemScope", o.ItemScope ?? string.Empty)
                   .Column("LimitType", o.LimitType)
                   .Column("LimitValue", o.LimitValue)
                   .Column("FreightFree", o.FreightFree)
                   .Column("FreightFreeExclude", o.FreightFreeExclude ?? string.Empty)
                   .Column("ExternalUrl", o.ExternalUrl ?? string.Empty)
                   .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)
                   .ToCommand(true);
         return PromotionConn.ExecuteScalar <int>(cmd);
     }));
 }