public List <GroupBuyInfo> SearchList(int currentPage, int pageSize, GroupBuySearchInfo searchInfo, ref int count) { using (var conn = new SqlConnection(connectString)) { ShopMssqlPagerClass pc = new ShopMssqlPagerClass(); pc.TableName = @"(select a.*,b.username as GroupUserName,b.photo as GroupUserAvatar,d.ProductName,d.ProductPrice,e.Photo as ProductPhoto,c.Id as GroupOrderId,c.OrderStatus as GroupOrderStatus,c.IsRefund from [GroupBuy] a inner join [usr] b on a.[Leader] = b.[Id] inner join [Order] c on a.[Id]=c.[FavorableActivityId] and a.[Leader]=c.[UserId] and c.[IsActivity]=2 inner join [orderdetail] d on d.[OrderId]=c.[Id] inner join [Product] e on e.[Id]=a.[ProductId]) tmp"; pc.Fields = "*"; pc.CurrentPage = currentPage; pc.PageSize = pageSize; pc.OrderField = "[Id]"; pc.OrderType = OrderType.Desc; pc.MssqlCondition = PrepareCondition(searchInfo); count = pc.Count; return(conn.Query <GroupBuyInfo>(pc).ToList()); } }
protected override void PageLoad() { base.PageLoad(); int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 10; int count = 0; GroupBuySearchInfo groupBuySearch = new GroupBuySearchInfo(); groupBuySearch.Status = GroupBuyStatus.Normal; groupBuyList = GroupBuyBLL.ReadGroupBuyList(currentPage, pageSize, groupBuySearch, ref count); commonPagerClass.CurrentPage = currentPage; commonPagerClass.PageSize = pageSize; commonPagerClass.Count = count; commonPagerClass.FirstPage = "<<首页"; commonPagerClass.PreviewPage = "<<上一页"; commonPagerClass.NextPage = "下一页>>"; commonPagerClass.LastPage = "末页>>"; commonPagerClass.ListType = false; commonPagerClass.DisCount = false; commonPagerClass.PrenextType = true; string productIDList = string.Empty; string idList = string.Empty; foreach (GroupBuyInfo groupBuy in groupBuyList) { productIDList += "," + groupBuy.ProductID.ToString(); idList += "," + groupBuy.ID.ToString(); } if (productIDList != string.Empty) { productIDList = productIDList.Substring(1); } if (idList != string.Empty) { idList = idList.Substring(1); } //读取商品 if (productIDList != string.Empty) { ProductSearchInfo productSearch = new ProductSearchInfo(); productSearch.InProductID = productIDList; productList = ProductBLL.SearchProductList(productSearch); } //读取购买人数 if (idList != string.Empty) { dicCount = UserGroupBuyBLL.ReadUserGroupBuyCount(idList); } Title = "商品团购"; }
protected override void PageLoad() { base.PageLoad(); topNav = 2; status = RequestHelper.GetQueryString <int>("status") < -2 ? 0 : RequestHelper.GetQueryString <int>("status"); GroupBuySearchInfo searchInfo = new GroupBuySearchInfo(); searchInfo.Status = status; dataList = GroupBuyBLL.SearchList(1, pageSize, searchInfo, ref Count); dataList.ForEach(k => k.GroupUserName = System.Web.HttpUtility.UrlDecode(k.GroupUserName, System.Text.Encoding.UTF8)); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadGroupBuy", PowerCheckType.Single); status = RequestHelper.GetQueryString <int>("status") < -2?0:RequestHelper.GetQueryString <int>("status"); GroupBuySearchInfo searchInfo = new GroupBuySearchInfo(); searchInfo.Status = status; List <GroupBuyInfo> dataList = GroupBuyBLL.SearchList(CurrentPage, PageSize, searchInfo, ref Count); dataList.ForEach(k => k.GroupUserName = HttpUtility.UrlDecode(k.GroupUserName, System.Text.Encoding.UTF8)); BindControl(dataList, RecordList, MyPager); } }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void PageLoad() { base.PageLoad(); int id = RequestHelper.GetQueryString <int>("ID"); groupBuy = GroupBuyBLL.ReadGroupBuy(id); TimeSpan timeSpan = groupBuy.EndDate - RequestHelper.DateNow; leftTime = timeSpan.Days * 24 * 3600 + timeSpan.Hours * 3600 + timeSpan.Minutes * 60 + timeSpan.Seconds; buyCount = UserGroupBuyBLL.ReadUserGroupBuyCount(id); product = ProductBLL.ReadProduct(groupBuy.ProductID); Title = product.Name + " - 商品团购"; int count = 0; GroupBuySearchInfo groupBuySearch = new GroupBuySearchInfo(); groupBuySearch.Status = GroupBuyStatus.Normal; groupBuyList = GroupBuyBLL.ReadGroupBuyList(1, 8, groupBuySearch, ref count); string productIDList = string.Empty; string idList = string.Empty; foreach (GroupBuyInfo groupBuyInfo in groupBuyList) { if (productIDList == string.Empty) { productIDList = groupBuyInfo.ProductID.ToString(); idList = groupBuyInfo.ID.ToString(); } else { productIDList += "," + groupBuyInfo.ProductID.ToString(); idList += "," + groupBuyInfo.ID.ToString(); } } //读取商品 if (productIDList != string.Empty) { ProductSearchInfo productSearch = new ProductSearchInfo(); productSearch.InProductID = productIDList; productList = ProductBLL.SearchProductList(productSearch); } }
public List <GroupBuyInfo> SearchList(GroupBuySearchInfo searchInfo) { using (var conn = new SqlConnection(connectString)) { string sql = @"select * from (select a.*,b.username as GroupUserName,b.photo as GroupUserAvatar,d.ProductName,d.ProductPrice,e.Photo as ProductPhoto,c.Id as GroupOrderId,c.OrderStatus as GroupOrderStatus,c.IsRefund from [GroupBuy] a inner join [usr] b on a.[Leader] = b.[Id] inner join [Order] c on a.[Id]=c.[FavorableActivityId] and a.[Leader]=c.[UserId] and c.[IsActivity]=2 inner join [orderdetail] d on d.[OrderId]=c.[Id] inner join [Product] e on e.[Id]=a.[ProductId]) tmp"; string condition = PrepareCondition(searchInfo).ToString(); if (!string.IsNullOrEmpty(condition)) { sql += " where " + condition; } sql += " Order By Id desc"; return(conn.Query <GroupBuyInfo>(sql).ToList()); } }
public MssqlCondition PrepareCondition(GroupBuySearchInfo searchInfo) { MssqlCondition mssqlCondition = new MssqlCondition(); if (searchInfo.ProductId > 0) { mssqlCondition.Add("[ProductId]", searchInfo.ProductId, ConditionType.Equal); } if (searchInfo.Leader > 0) { mssqlCondition.Add("[Leader]", searchInfo.Leader, ConditionType.Equal); } if (searchInfo.NotLeader > 0) { mssqlCondition.Add("[Leader]", searchInfo.NotLeader, ConditionType.NoEqual); } mssqlCondition.Add("[StartTime]", searchInfo.StartTime, ConditionType.MoreOrEqual); mssqlCondition.Add("[EndTime]", searchInfo.EndTime, ConditionType.LessOrEqual); //拼团失败(逾期未拼满) if (searchInfo.Status == (int)GroupBuyStatus.Fail) { mssqlCondition.Add(" [EndTime]<getdate() and [SignCount]<[Quantity]"); } //拼团成功(有效期内已拼满) if (searchInfo.Status == (int)GroupBuyStatus.Success) { mssqlCondition.Add(" [StartTime]<=getdate() and [EndTime]>=getdate() and [SignCount]>=[Quantity]"); } //拼团进行中(在有效期内未拼满) if (searchInfo.Status == (int)GroupBuyStatus.Going) { mssqlCondition.Add(" [StartTime]<=getdate() and [EndTime]>=getdate() and [SignCount]<[Quantity]"); } return(mssqlCondition); }
public static List <GroupBuyInfo> SearchList(int currentPage, int pageSize, GroupBuySearchInfo searchInfo, ref int count) { return(dal.SearchList(currentPage, pageSize, searchInfo, ref count)); }
public static List <GroupBuyInfo> SearchList(GroupBuySearchInfo searchInfo) { return(dal.SearchList(searchInfo)); }
public ActionResult Detail(int id) { int userGrade = UserGradeBLL.ReadByMoney(0).Id; int uid = RequestHelper.GetForm <int>("uid"); var user = UserBLL.ReadUserMore(uid); if (user.Id > 0) { userGrade = UserGradeBLL.ReadByMoney(user.MoneyUsed).Id; user.UserName = HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8); } if (id <= 0) { return(Json(new { ok = false, error = "该产品未上市" })); } string fromwhere = RequestHelper.GetQueryString <string>("fw"); ProductInfo product = ProductBLL.Read(id); if (product.IsSale == (int)BoolType.False || product.IsDelete == 1) { return(Json(new { ok = false, error = "该产品未上市" })); } #region 如果商品没有小程序码 则生成并保存 if (string.IsNullOrWhiteSpace(product.Qrcode)) { string product_miniProramCode = string.Empty; CreateMiniProgramCode(product.Id, ref product_miniProramCode, product.Qrcode); if (!string.IsNullOrWhiteSpace(product_miniProramCode)) {//如果调用接口成功生成小程序码(因为只有发布后才能使用此微信接口) Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("[Qrcode]", product_miniProramCode); ProductBLL.UpdatePart("[Product]", dict, product.Id); product.Qrcode = product_miniProramCode; } } #endregion //更新查看数量 if (CookiesHelper.ReadCookie("productview" + product.Id + "") == null) { ProductBLL.ChangeViewCount(id, 1); CookiesHelper.AddCookie("productview" + product.Id + "", product.Id.ToString()); } ProductCommentSearchInfo proCommSear = new ProductCommentSearchInfo(); var proComm = ProductCommentBLL.SearchProductCommentList(proCommSear = new ProductCommentSearchInfo { ProductId = product.Id, Status = (int)CommentStatus.Show }); var procomlist = new List <VirtualProductCommend>(); foreach (var item in proComm) { VirtualProductCommend vpc = new VirtualProductCommend() { id = item.Id, name = HttpUtility.UrlDecode(item.UserName, Encoding.UTF8), avator = ShopCommon.ShowImage(UserBLL.Read(item.UserId).Photo), lv = item.Rank, date = item.PostDate, content = item.Content, imglist = ProductPhotoBLL.ReadList(item.Id, 3), adminreply = item.AdminReplyContent, replydate = item.AdminReplyDate }; procomlist.Add(vpc); } //产品价格 int hotCount = 0; var currentMemberPrice = ProductBLL.GetCurrentPrice(product.SalePrice, userGrade); var prorecommend = ProductBLL.SearchList(1, 8, new ProductSearchInfo { IsSale = (int)BoolType.True, IsTop = (int)BoolType.True, IsDelete = (int)BoolType.False, NotInProductId = product.Id.ToString() }, ref hotCount); var prorelist = new List <ProductVirtualModel>(); foreach (var item in prorecommend) { var vp = new ProductVirtualModel() { id = item.Id, name = item.Name, img = ShopCommon.ShowImage(item.Photo.Replace("Original", "150-150")), imgbig = ShopCommon.ShowImage(item.Photo.Replace("Original", "350-350")), imgorg = ShopCommon.ShowImage(item.Photo), price = ProductBLL.GetCurrentPrice(item.SalePrice, userGrade), marketprice = item.MarketPrice, click = item.ViewCount, like = item.LikeNum, totalstore = item.StandardType == (int)ProductStandardType.Single ? ProductTypeStandardRecordBLL.GetSumStorageByProduct(item.Id) : item.TotalStorageCount, //ordercount = item.OrderCount //是否启用不限库存,分别计算销量 ordercount = item.UnlimitedStorage == 1 ? OrderBLL.GetProductOrderCountDaily(item.Id, item.StandardType, DateTime.Now) : item.OrderCount }; prorelist.Add(vp); } //产品图片 List <ProductPhotoInfo> productPhotoList = new List <ProductPhotoInfo>(); ProductPhotoInfo productPhoto = new ProductPhotoInfo(); productPhoto.Name = product.Name; productPhoto.ImageUrl = product.Photo; productPhotoList.Add(productPhoto); productPhotoList.AddRange(ProductPhotoBLL.ReadList(id, 0)); productPhotoList.ForEach(k => k.ImageUrl = k.ImageUrl.Replace("75-75", "Original")); //属性 var attributeRecordList = ProductTypeAttributeRecordBLL.ReadList(id); #region 产品规格 List <ProductTypeStandardInfo> standardList = new List <ProductTypeStandardInfo>(); string standardRecordValueList = "|"; var standardRecordList = ProductTypeStandardRecordBLL.ReadListByProduct(product.Id, product.StandardType); decimal maxPrice = product.SalePrice; if (standardRecordList.Count > 0) { string[] standardIDArray = standardRecordList[0].StandardIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < standardIDArray.Length; i++) { int standardID = Convert.ToInt32(standardIDArray[i]); ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(standardID); string[] valueArray = standard.ValueList.Split(';'); string valueList = string.Empty; for (int k = 0; k < valueArray.Length; k++) { foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList) { if (standardRecord.MarketPrice > maxPrice) { maxPrice = standardRecord.MarketPrice; } string[] tempValueArray = standardRecord.ValueList.Split(';'); if (valueArray[k] == tempValueArray[i]) { valueList += valueArray[k] + ";"; break; } } } if (valueList != string.Empty) { valueList = valueList.Substring(0, valueList.Length - 1); } standard.ValueList = valueList; standardList.Add(standard); } //规格值 foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList) { standardRecordValueList += standardRecord.ProductId + ";" + standardRecord.ValueList + "|"; } } #endregion #region 正在开的团(进行中,排除本人开的团) GroupBuySearchInfo gpsearch = new GroupBuySearchInfo { ProductId = product.Id, //NotLeader = user.Id, Status = (int)GroupBuyStatus.Going }; List <GroupBuyInfo> gpList = GroupBuyBLL.SearchList(gpsearch); gpList.ForEach(k => k.groupSignList = GroupSignBLL.ReadListByGroupId(k.Id)); gpList.ForEach(k => k.GroupUserName = System.Web.HttpUtility.UrlDecode(k.GroupUserName, Encoding.UTF8)); #endregion return(Json(new { ok = true, product = new { id = product.Id, img = ShopCommon.ShowImage(product.Photo.Replace("Original", "350-350")), imgorg = ShopCommon.ShowImage(product.Photo), title = product.Name, summary = product.Summary, price = currentMemberPrice, marketprice = product.MarketPrice, intro = string.IsNullOrEmpty(product.Introduction1_Mobile) ? product.Introduction1 : product.Introduction1_Mobile, remark = product.Remark, totalstore = product.StandardType == (int)ProductStandardType.Single ? ProductTypeStandardRecordBLL.GetSumStorageByProduct(product.Id) : product.TotalStorageCount, ordercount = product.UnlimitedStorage == 1 ? OrderBLL.GetProductOrderCountDaily(product.Id, product.StandardType, DateTime.Now) : product.OrderCount, unlimitedstorage = product.UnlimitedStorage, virtualordercount = product.VirtualOrderCount, usevirtualorder = product.UseVirtualOrder, opengroup = product.OpenGroup, groupprice = product.GroupPrice, groupquantity = product.GroupQuantity, qrcode = product.Qrcode, groupphoto = string.IsNullOrWhiteSpace(product.GroupPhoto) ? product.Photo : product.GroupPhoto }, standardList = standardList, standardRecordValueList = standardRecordValueList, attributeRecordList = attributeRecordList, productPhotoList = productPhotoList, prorecommend = prorelist, proComm = procomlist, maxPrice = maxPrice, groupList = gpList }, JsonRequestBehavior.AllowGet)); }