예제 #1
0
 public ProductInfo GetProduct(MemberInfo member, int productId)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Products WHERE ProductId =@ProductId;SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice, " + builder.ToString() + " FROM Hishop_SKUs s WHERE ProductId = @ProductId");
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     ProductInfo info = null;
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulateProduct(reader);
         }
         if (!reader.NextResult())
         {
             return info;
         }
         while (reader.Read())
         {
             info.Skus.Add((string) reader["SkuId"], DataMapper.PopulateSKU(reader));
         }
     }
     return info;
 }
예제 #2
0
 public DataTable GetBrandProducts(MemberInfo member, int? brandId, int pageNumber, int maxNum, out int total)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.Append("ProductId,ProductName,ProductCode,ShowSaleCounts AS SaleCounts,ShortDescription,ShowSaleCounts,");
     builder.Append(" ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310,MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     StringBuilder builder2 = new StringBuilder();
     builder2.Append(" SaleStatus=1");
     if (brandId.HasValue)
     {
         builder2.AppendFormat(" AND BrandId = {0}", brandId);
     }
     DbQueryResult result = DataHelper.PagingByRownumber(pageNumber, maxNum, "DisplaySequence", SortAction.Desc, true, "vw_Hishop_BrowseProductList s", "ProductId", builder2.ToString(), builder.ToString());
     DataTable data = (DataTable) result.Data;
     total = result.TotalRecords;
     return data;
 }
예제 #3
0
 public static bool CreateMemberGrade(MemberGradeInfo memberGrade)
 {
     if (null == memberGrade)
     {
         return false;
     }
     Globals.EntityCoding(memberGrade, true);
     bool flag = new MemberGradeDao().CreateMemberGrade(memberGrade);
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.AddMemberGrade, string.Format(CultureInfo.InvariantCulture, "添加了名为 “{0}” 的会员等级", new object[] { memberGrade.Name }));
     }
     return flag;
 }
예제 #4
0
 public SKUItem GetProductAndSku(MemberInfo currentMember, int productId, string options)
 {
     if (string.IsNullOrEmpty(options))
     {
         return null;
     }
     string[] strArray = options.Split(new char[] { ',' });
     if ((strArray == null) || (strArray.Length <= 0))
     {
         return null;
     }
     StringBuilder builder = new StringBuilder();
     if (currentMember != null)
     {
         int discount = new MemberGradeDao().GetMemberGrade(currentMember.GradeId).Discount;
         builder.Append("SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice,");
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) = 1", currentMember.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = s.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", currentMember.GradeId, discount);
         builder.Append(" FROM Hishop_SKUs s WHERE ProductId = @ProductId");
     }
     else
     {
         builder.Append("SELECT SkuId, ProductId, SKU,Weight, Stock, CostPrice, SalePrice FROM Hishop_SKUs WHERE ProductId = @ProductId");
     }
     foreach (string str in strArray)
     {
         string[] strArray2 = str.Split(new char[] { ':' });
         builder.AppendFormat(" AND SkuId IN (SELECT SkuId FROM Hishop_SKUItems WHERE AttributeId = {0} AND ValueId = {1}) ", strArray2[0], strArray2[1]);
     }
     SKUItem item = null;
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             item = DataMapper.PopulateSKU(reader);
         }
     }
     return item;
 }
예제 #5
0
        public DataTable GetFavorites(MemberInfo member)
        {
            int           discount = 100;
            StringBuilder builder  = new StringBuilder();

            builder.Append("SELECT a.*, b.ProductName, b.ThumbnailUrl60, b.MarketPrice,b.ShortDescription,");
            if (member != null)
            {
                discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
                builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = b.SkuId AND GradeId = {0}) = 1", member.GradeId);
                builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = b.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
            }
            else
            {
                builder.Append("SalePrice");
            }
            builder.AppendFormat(" FROM Hishop_Favorite a left join vw_Hishop_BrowseProductList b on a.ProductId = b.ProductId WHERE a.UserId={0} ORDER BY a.FavoriteId DESC", member.UserId);
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                return(DataHelper.ConverDataReaderToDataTable(reader));
            }
        }
예제 #6
0
 public DbQueryResult GetHomeProducts(MemberInfo member, ProductQuery query, bool isdistributor)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     int currentDistributorId = Globals.GetCurrentDistributorId();
     builder.Append("ProductId, ProductCode,ShortDescription,ProductName,ShowSaleCounts, ThumbnailUrl60,ThumbnailUrl40,ThumbnailUrl100,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310, MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice, ", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice,");
     }
     builder.Append("SaleCounts, Stock");
     StringBuilder builder2 = new StringBuilder(" SaleStatus =" + 1);
     if (isdistributor && (currentDistributorId > 0))
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId);
     }
     return DataHelper.PagingByRownumber(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_Hishop_BrowseProductList p", "ProductId", builder2.ToString(), builder.ToString());
 }
예제 #7
0
 public DataTable GetProducts(MemberInfo member, int? topicId, int? categoryId, int distributorId, string keyWord, int pageNumber, int maxNum, out int toal, string sort, bool isAsc = false)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.AppendFormat("ProductId,ProductName,ProductCode,ShowSaleCounts AS SaleCounts,ShortDescription,", maxNum);
     builder.Append(" ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310,MarketPrice,VistiCounts,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice");
     }
     StringBuilder builder2 = new StringBuilder();
     builder2.Append(" SaleStatus=1");
     if (topicId.HasValue)
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT RelatedProductId FROM Vshop_RelatedTopicProducts WHERE TopicId = {0})", topicId.Value);
     }
     if (categoryId.HasValue)
     {
         CategoryInfo category = new CategoryDao().GetCategory(categoryId.Value);
         if (category != null)
         {
             builder2.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path);
         }
     }
     if (!string.IsNullOrEmpty(keyWord))
     {
         builder2.AppendFormat(" AND (ProductName LIKE '%{0}%' OR ProductCode LIKE '%{0}%')", keyWord);
     }
     if (distributorId > 0)
     {
         builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId);
     }
     if (string.IsNullOrWhiteSpace(sort))
     {
         sort = "ProductId";
     }
     DbQueryResult result = DataHelper.PagingByRownumber(pageNumber, maxNum, sort, isAsc ? SortAction.Asc : SortAction.Desc, true, "vw_Hishop_BrowseProductList", "ProductId", builder2.ToString(), builder.ToString());
     DataTable data = (DataTable) result.Data;
     toal = result.TotalRecords;
     return data;
 }
예제 #8
0
 public DataTable GetTopicProducts(MemberInfo member, int topicid, int maxNum)
 {
     int discount = 100;
     StringBuilder builder = new StringBuilder();
     builder.Append("select top " + maxNum);
     builder.Append(" p.ProductId, ProductCode, ProductName,ShortDescription,ShowSaleCounts,ThumbnailUrl40,ThumbnailUrl100,ThumbnailUrl160,MarketPrice,");
     if (member != null)
     {
         discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount;
         builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) = 1", member.GradeId);
         builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice, ", member.GradeId, discount);
     }
     else
     {
         builder.Append("SalePrice,");
     }
     builder.Append("SaleCounts, Stock,t.DisplaySequence from vw_Hishop_BrowseProductList p inner join  Vshop_RelatedTopicProducts t on p.productid=t.RelatedProductId where t.topicid=" + topicid);
     builder.AppendFormat(" and SaleStatus = {0}", 1);
     builder.Append(" order by t.DisplaySequence asc");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     return this.database.ExecuteDataSet(sqlStringCommand).Tables[0];
 }
예제 #9
0
 public static bool DeleteMemberGrade(int gradeId)
 {
     ManagerHelper.CheckPrivilege(Privilege.DeleteMemberGrade);
     bool flag = new MemberGradeDao().DeleteMemberGrade(gradeId);
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.DeleteMemberGrade, string.Format(CultureInfo.InvariantCulture, "删除了编号为 “{0}” 的会员等级", new object[] { gradeId }));
     }
     return flag;
 }
예제 #10
0
 public static bool UserPayOrder(OrderInfo order)
 {
     OrderDao dao = new OrderDao();
     order.OrderStatus = OrderStatus.BuyerAlreadyPaid;
     order.PayDate = new DateTime?(DateTime.Now);
     bool flag = dao.UpdateOrder(order, null);
     if (flag)
     {
         dao.UpdatePayOrderStock(order.OrderId);
         foreach (LineItemInfo info in order.LineItems.Values)
         {
             ProductDao dao2 = new ProductDao();
             ProductInfo productDetails = dao2.GetProductDetails(info.ProductId);
             productDetails.SaleCounts += info.Quantity;
             productDetails.ShowSaleCounts += info.Quantity;
             dao2.UpdateProduct(productDetails, null);
         }
         MemberInfo member = GetMember(order.UserId);
         if (member == null)
         {
             return flag;
         }
         MemberDao dao3 = new MemberDao();
         PointDetailInfo point = new PointDetailInfo {
             OrderId = order.OrderId,
             UserId = member.UserId,
             TradeDate = DateTime.Now,
             TradeType = PointTradeType.Bounty,
             Increased = new int?(order.Points),
             Points = order.Points + member.Points
         };
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         PointDetailDao dao4 = new PointDetailDao();
         dao4.AddPointDetail(point);
         member.Expenditure += order.GetTotal();
         member.OrderNumber++;
         dao3.Update(member);
         Messenger.OrderPayment(member, order.OrderId, order.GetTotal());
         int historyPoint = dao4.GetHistoryPoint(member.UserId);
         List<MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List<MemberGradeInfo>;
         foreach (MemberGradeInfo info5 in from item in memberGrades
             orderby item.Points descending
             select item)
         {
             if (member.GradeId == info5.GradeId)
             {
                 return flag;
             }
             if (info5.Points <= historyPoint)
             {
                 member.GradeId = info5.GradeId;
                 dao3.Update(member);
                 return flag;
             }
         }
     }
     return flag;
 }
예제 #11
0
 private static void UpdateUserAccount(OrderInfo order)
 {
     MemberInfo member = new MemberDao().GetMember(order.UserId);
     if (member != null)
     {
         MemberDao dao = new MemberDao();
         PointDetailInfo point = new PointDetailInfo {
             OrderId = order.OrderId,
             UserId = member.UserId,
             TradeDate = DateTime.Now,
             TradeType = PointTradeType.Bounty,
             Increased = new int?(order.Points),
             Points = order.Points + member.Points
         };
         if ((point.Points > 0x7fffffff) || (point.Points < 0))
         {
             point.Points = 0x7fffffff;
         }
         PointDetailDao dao2 = new PointDetailDao();
         dao2.AddPointDetail(point);
         member.Expenditure += order.GetTotal();
         member.OrderNumber++;
         dao.Update(member);
         int historyPoint = dao2.GetHistoryPoint(member.UserId);
         List<MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List<MemberGradeInfo>;
         foreach (MemberGradeInfo info3 in from item in memberGrades
             orderby item.Points descending
             select item)
         {
             if (member.GradeId == info3.GradeId)
             {
                 break;
             }
             if (info3.Points <= historyPoint)
             {
                 member.GradeId = info3.GradeId;
                 dao.Update(member);
                 break;
             }
         }
     }
 }