Exemple #1
0
        /// <summary>
        /// 获取超级分销商Sku价格
        /// </summary>
        /// <param name="skuId"></param>
        /// <returns></returns>
        public List <SkuPrice> GetSuperRetailTraderSkuPrice(string skuId, string customerId)
        {
            List <SkuPrice> list = new List <SkuPrice>();
            StringBuilder   sql  = new StringBuilder();

            sql.AppendFormat(@" declare @cost decimal(18,2)
            select @cost = Cost from T_SuperRetailTraderConfig where CustomerId = @CustomerId and isdelete = 0
            if (@cost = 0 or @cost is null) 
            begin select @cost = 100 end
            select a.SkuId,CONVERT(decimal(18,2),a.DistributerCostPrice / (@cost/100)) as DistributerPrice from T_SuperRetailTraderSkuMapping a where IsDelete = 0 and Skuid in ({0})", skuId);

            SqlParameter[] pars = new SqlParameter[]
            {
                new SqlParameter("@CustomerId", customerId)
            };

            using (SqlDataReader rdr = this.SQLHelper.ExecuteReader(CommandType.Text, sql.ToString(), pars))
            {
                while (rdr.Read())
                {
                    SkuPrice m = new SkuPrice();
                    if (rdr["SkuId"] != DBNull.Value)
                    {
                        m.sku_id = rdr["SkuId"].ToString();
                    }
                    if (rdr["DistributerPrice"] != DBNull.Value)
                    {
                        m.price = Convert.ToDecimal(rdr["DistributerPrice"]);
                    }
                    list.Add(m);
                }
            }
            return(list);
        }
        /// <summary>
        ///     Gets the sku price.
        ///     获取所有商品的价格
        ///     在线状态的
        /// </summary>
        public IEnumerable <SkuPrice> GetSkuPrice(long productId = 0)
        {
            var sqlWhere = string.Empty;

            if (productId > 0)
            {
                sqlWhere = $" and Shop_Product.Id={productId} ";
            }

            var sql =
                $@"SELECT   dbo.Shop_ProductSku.Id, dbo.Shop_ProductSku.ProductId, dbo.Shop_ProductSku.Price, dbo.Shop_Product.PriceStyleId, dbo.Shop_Product.MinCashRate
            FROM dbo.Shop_ProductSku INNER JOIN dbo.Shop_Product ON dbo.Shop_ProductSku.ProductId = dbo.Shop_Product.Id Where Shop_Product.ProductStatus=2 {
                        sqlWhere
                    } order by id desc ";
            var result = new List <SkuPrice>();

            using (var reader = RepositoryContext.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    var productSkuItem = new SkuPrice
                    {
                        ProductSkuId = reader["Id"].ConvertToLong(0),
                        ProductId    = reader["ProductId"].ConvertToLong(0),
                        Price        = reader["Price"].ToDecimal(),
                        PriceStyleId = reader["PriceStyleId"].ToGuid(),
                        MinCashRate  = reader["MinCashRate"].ToDecimal()
                    };
                    result.Add(productSkuItem);
                }
            }

            return(result);
        }