コード例 #1
0
        public IList <Prod.Sku> ProdSkuList(int itemId)
        {
            var cmd = SqlBuilder
                      .Select("*").From("sku")
                      .Where("ItemId=@ItemId", new { itemId })
                      .ToCommand();

            return(StoreConn.Query <Prod.Sku>(cmd).ToList());
        }
コード例 #2
0
        /*
         * /// <summary>
         * /// 创建店铺优惠活动规则
         * /// </summary>
         * /// <param name="o">店铺优惠活动规则</param>
         * /// <returns></returns>
         * public bool PromotionDefaultRuleCreate(Promotion.Default.Rule o)
         * {
         *  try
         *  {
         *      var cmd = SqlBuilder
         *          .Insert("[Default.Rule]")
         *          .Column("ParentId", o.ParentId)
         *          .Column("Upon", o.Upon)
         *          .Column("Value", o.Value)
         *          .Column("SendGift", o.SendGift)
         *          .Column("GiftJson", o.GiftData)
         *          .Column("SendCoupon", o.SendCoupon)
         *          .Column("CouponJson", o.CouponData)
         *          .Column("SellerId", o.SellerId)
         *          .Column("Status", o.Status)
         *          .Column("CreatedBy", o.CreatedBy)
         *          .Column("CreatedOn", o.CreatedOn)
         *          .ToCommand();
         *      return PromotionConn.Execute(cmd) > 0;
         *  }
         *  catch (Exception e)
         *  {
         *      OnException(e);
         *  }
         *  return false;
         * }
         *
         * /// <summary>
         * /// 更新店铺优惠活动规则
         * /// </summary>
         * /// <param name="o">店铺优惠活动规则</param>
         * /// <returns></returns>
         * public bool PromotionDefaultRuleUpdate(Promotion.Default.Rule o)
         * {
         *  try
         *  {
         *      var cmd = SqlBuilder
         *          .Update("[Default.Rule]")
         *          .Column("Upon", o.Upon)
         *          .Column("Value", o.Value)
         *          .Column("SendGift", o.SendGift)
         *          .Column("GiftJson", o.GiftData)
         *          .Column("SendCoupon", o.SendCoupon)
         *          .Column("CouponJson", o.CouponData)
         *          .Column("Status", o.Status)
         *          .Where("Id=@Id", new { o.Id })
         *          .ToCommand();
         *      return PromotionConn.Execute(cmd) > 0;
         *  }
         *  catch (Exception e)
         *  {
         *      OnException(e);
         *  }
         *  return false;
         * }
         *
         * /// <summary>
         * /// 获取店铺优惠活动规则
         * /// </summary>
         * /// <param name="id">店铺优惠活动规则Id</param>
         * /// <param name="sellerId">卖家Id</param>
         * /// <returns></returns>
         * public Promotion.Default.Rule PromotionDefaultRuleGet(int id, int? sellerId = null)
         * {
         *  try
         *  {
         *      var cmd = SqlBuilder
         *          .Select("*")
         *          .From("[Default.Rule]")
         *          .Where("Id=@Id", new { id })
         *          .Where(sellerId.HasValue, "SellerId=@sellerId", new { sellerId })
         *          .ToCommand();
         *      return PromotionConn.Query<Promotion.Default.Rule>(cmd).FirstOrDefault();
         *  }
         *  catch (Exception e)
         *  {
         *      OnException(e);
         *  }
         *  return null;
         * }
         *
         * /// <summary>
         * /// 设置店铺优惠活动规则为不可用
         * /// </summary>
         * /// <param name="id">店铺优惠活动规则Id</param>
         * /// <param name="sellerId">卖家Id</param>
         * /// <returns></returns>
         * public bool PromotionDefaultRuleDisable(int id, int? sellerId = null)
         * {
         *  var sql = "update [Default.Rule] set [Status]=0 where Id=@Id";
         *  if (sellerId.HasValue)
         *  {
         *      sql = "update [Default.Rule] set [Status]=0 where Id=@Id and Seller=@SellerId";
         *  }
         *  var cmd = SqlBuilder.Raw(sql).Append(sellerId.HasValue, "", new { sellerId }).ToCommand();
         *  try
         *  {
         *      return PromotionConn.Execute(cmd) > 0;
         *  }
         *  catch (Exception e)
         *  {
         *      OnException(e);
         *  }
         *  return false;
         * }
         */

        #endregion

        /// <summary>
        /// 获取搭配组合套餐
        /// </summary>
        /// <param name="id">搭配组合套餐Id</param>
        /// <param name="includeItems">是否包含套餐附属商品信息</param>
        /// <returns></returns>
        public Promotion.Package PromotionPackageGet(int id, bool includeItems = false)
        {
            if (includeItems)
            {
                const string sql = @"select * from Package where Id=@id;select * from PackageItem where ParentId=@id";
                var          cmd = SqlBuilder.Raw(sql, new { id }).ToCommand();
                return
                    (StoreConn.Query <Promotion.Package, Promotion.Package.Item, int>(cmd, o => o.Id,
                                                                                      o => o.ParentId, (a, b) =>
                {
                    a.Items = b.ToList();
                }).FirstOrDefault());
            }
            else
            {
                var cmd = SqlBuilder.Select("*")
                          .From("Package")
                          .Where("Id=@id", new { id })
                          .ToCommand();

                return(PromotionConn.Query <Promotion.Package>(cmd).FirstOrDefault());
            }
        }