/// <summary> /// 保存商品分类 /// </summary> public string SaveItemCategory() { var responseData = new ResponseData(); int modelTypeId = (Int32)Utils.GetIntVal(FormatParamValue(Request("modelTypeId"))); string modelTypeName = FormatParamValue(Request("modelTypeName")); if (modelTypeId == 0) { responseData.success = false; responseData.msg = "模板ID不能为空"; return(responseData.ToJSON()); } if (string.IsNullOrEmpty(modelTypeName)) { responseData.success = false; responseData.msg = "模板名称不能为空"; return(responseData.ToJSON()); } var itemCategory = this.CurrentContext.Request["categoryList"].DeserializeJSONTo <List <ItemCategoryEntity> >(); if (itemCategory != null && itemCategory.Count > 0) { //分组ID var groupId = itemCategory.FirstOrDefault().groupId; var adAreaBll = new MHAdAreaBLL(this.CurrentUserInfo); var categoryAreaBll = new MHCategoryAreaBLL(this.CurrentUserInfo); var homeBll = new MobileHomeBLL(this.CurrentUserInfo); var homeList = homeBll.QueryByEntity(new MobileHomeEntity { CustomerId = this.CurrentUserInfo.ClientID }, null); var homeId = homeList.FirstOrDefault().HomeId; if (homeList != null && homeList.Length > 0) { //判断groupId是否为空,为空则新增,不为空则更新 //如果新增,则传入 模板ID,修改则不需要传入模板ID if (groupId == 0 || string.IsNullOrEmpty(groupId.ToString())) { //查找表中最大的groupid groupId = categoryAreaBll.GetMaxGroupId(); //在此基础上对groupid+1 groupId++; InsertItemCategory(itemCategory, groupId); } else { UpdateItemCategory(itemCategory); } var mHCategoryAreaGroup = new MHCategoryAreaGroupBLL(this.CurrentUserInfo); var categoryAreaGroup = mHCategoryAreaGroup.QueryByEntity(new MHCategoryAreaGroupEntity() { GroupValue = groupId, CustomerID = this.CurrentUserInfo.ClientID }, null); var categoryAreaGroupEntity = new MHCategoryAreaGroupEntity() { ModelTypeId = modelTypeId, ModelName = modelTypeName, GroupValue = groupId, CustomerID = this.CurrentUserInfo.ClientID }; if (categoryAreaGroup == null || !categoryAreaGroup.Any()) { categoryAreaGroupEntity.GroupId = mHCategoryAreaGroup.GetMaxGroupId(); mHCategoryAreaGroup.Create(categoryAreaGroupEntity); } else { categoryAreaGroupEntity.GroupId = categoryAreaGroup[0].GroupId; mHCategoryAreaGroup.Update(categoryAreaGroupEntity); } } else { responseData.success = false; responseData.msg = "没有查询到对应首页主表的数据"; return(responseData.ToJSON()); } #region 返回商品分类数据 var content = new CategoryEntity(); //商品分类 //获取分组ID content.modelTypeId = modelTypeId; content.modelTypeName = modelTypeName; content.groupId = groupId.ToString(); content.itemList = new List <ItemEntity>(); var dsItem = adAreaBll.GetItemList(content.groupId, homeId.ToString()); if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0) { content.itemList = DataTableToObject.ConvertToList <ItemEntity>(dsItem.Tables[0]); } #endregion responseData.success = true; responseData.data = content; return(responseData.ToJSON()); } else { responseData.success = false; responseData.data = "查无数据"; return(responseData.ToJSON()); } }
protected override HomePageConfigRD ProcessRequest(DTO.Base.APIRequest <HomePageConfigRP> pRequest) { //创建连接用户对象 var logginUserInfo = base.CurrentUserInfo; var param = pRequest.Parameters; HomePageConfigRD resData = new HomePageConfigRD(); resData.eventList = new List <EventListEntity>(); resData.secondKill = new List <EventListEntity>(); resData.groupBuy = new List <EventListEntity>(); resData.hotBuy = new List <EventListEntity>(); resData.bargain = new List <EventListEntity>(); var bllHome = new MobileHomeBLL(logginUserInfo); MobileHomeEntity entityHome = new MobileHomeEntity();; if (!string.IsNullOrEmpty(param.HomeId)) { entityHome = bllHome.QueryByEntity(new MobileHomeEntity() { CustomerId = logginUserInfo.ClientID, HomeId = new Guid(param.HomeId) }, null).FirstOrDefault(); } else { entityHome = bllHome.QueryByEntity(new MobileHomeEntity() { CustomerId = logginUserInfo.ClientID, IsActivate = 1 }, null).FirstOrDefault(); } if (entityHome == null) { resData.Success = false; resData.ErrMsg = "商城正在维护1"; return(resData); } resData.Success = true; string strHomeId = entityHome.HomeId.ToString(); resData.sortActionJson = entityHome.sortActionJson == null ? "" : entityHome.sortActionJson;//返回排序数据 #region 广告部分 List <AdAreaInfo> AdAreaList = new List <AdAreaInfo> { }; var adBll = new MHAdAreaBLL(logginUserInfo); var tempAdArealist = adBll.GetAdByHomeId(strHomeId); AdAreaList.AddRange(tempAdArealist.Select(t => new AdAreaInfo { DisplayIndex = t.DisplayIndex, ImageUrl = t.ImageUrl, ObjectID = t.ObjectId, ObjectTypeID = t.ObjectTypeId, Url = t.Url })); #endregion resData.adAreaList = AdAreaList.ToArray(); #region 搜索框 var dsSearch = adBll.GetMHSearchArea(strHomeId);//获取搜索框 if (dsSearch != null && dsSearch.Tables.Count > 0 && dsSearch.Tables[0].Rows.Count > 0) { resData.search = DataTableToObject.ConvertToObject <MHSearchAreaEntity>(dsSearch.Tables[0].Rows[0]);//转换成一个对象时,里面的参数不能是一个表,而是一行数据 } #endregion #region 活动部分 var adAreaBll = new MHAdAreaBLL(logginUserInfo); var itemEventBll = new MHItemAreaBLL(logginUserInfo); var bllCategoryAreaGroup = new MHCategoryAreaGroupBLL(this.CurrentUserInfo); var allGroup = bllCategoryAreaGroup.QueryByEntity(new MHCategoryAreaGroupEntity { CustomerID = this.CurrentUserInfo.ClientID, HomeId = strHomeId }, null); var eventGroup = allGroup.Where(a => a.ModelTypeId == 5 || a.ModelTypeId == 6 || a.ModelTypeId == 7 || a.ModelTypeId == 8 || a.ModelTypeId == 9); foreach (var item in eventGroup) { DataSet dsEvent = new DataSet(); if (item.ModelTypeId == 8) { dsEvent = itemEventBll.GetEventListItemDetails(strHomeId, item.GroupId.ToString());//获取EventList } else { dsEvent = itemEventBll.GetItemDetails(strHomeId, item.GroupId.ToString()); } if (dsEvent != null && dsEvent.Tables.Count > 0 && dsEvent.Tables[0].Rows.Count > 0) { var dsEventList = DataTableToObject.ConvertToList <ItemEventAreaInfo>(dsEvent.Tables[0]); var category = new EventListEntity { showStyle = dsEventList.FirstOrDefault().ShowStyle, shopType = dsEventList.FirstOrDefault().TypeID, displayIndex = item.DisplayIndex, areaFlag = dsEventList.FirstOrDefault().areaFlag, arrayList = dsEventList }; if (dsEventList.FirstOrDefault().areaFlag == "eventList") { resData.eventList.Add(category); } if (dsEventList.FirstOrDefault().areaFlag == "secondKill") { resData.secondKill.Add(category); } if (dsEventList.FirstOrDefault().areaFlag == "groupBuy") { resData.groupBuy.Add(category); } if (dsEventList.FirstOrDefault().areaFlag == "hotBuy") { resData.hotBuy.Add(category); } if (dsEventList.FirstOrDefault().areaFlag == "bargain") { resData.bargain.Add(category); } } } #endregion List <CategoryGroupInfo> allList = new List <CategoryGroupInfo>(); eventGroup = allGroup.Where(a => a.ModelTypeId != 5 && a.ModelTypeId != 6 && a.ModelTypeId != 7 && a.ModelTypeId != 8 && a.ModelTypeId != 9 && a.ModelTypeId != 2); if (eventGroup != null) { foreach (var groupItem in eventGroup) { var category = new CategoryGroupInfo { groupID = groupItem.GroupId, CategoryAreaList = new List <CategoryAreaInfo>() }; category.modelTypeId = groupItem.ModelTypeId; category.modelTypeName = groupItem.ModelName; category.styleType = groupItem.StyleType; category.titleName = groupItem.TitleName; category.titleStyle = groupItem.TitleStyle; category.showCount = (int)groupItem.ShowCount; category.showName = (int)groupItem.ShowName; category.showPrice = (int)groupItem.ShowPrice; category.showSalesPrice = (int)groupItem.ShowSalesPrice; category.showDiscount = (int)groupItem.ShowDiscount; category.showSalesQty = (int)groupItem.ShowSalesQty; category.displayIndex = (int)groupItem.DisplayIndex; //根据groupId和HomeId来取MHCategoryArea if (groupItem.ModelTypeId == 2) { } else { } var dsItem = adAreaBll.GetItemList(category.groupID.ToString(), entityHome.HomeId.ToString()); if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0) { category.CategoryAreaList = DataTableToObject.ConvertToList <CategoryAreaInfo>(dsItem.Tables[0]); } allList.Add(category); } } //分类组合 List <CategoryGroupInfo> lc = allList.Where(p => p.modelTypeId == 1).ToList(); if (lc != null && lc.Count != 0) { resData.categoryEntrance = lc.OrderByDescending(p => p.groupID).ToList()[0];; } //创意组合 if (allList.Where(p => p.modelTypeId == 3).ToList() != null && allList.Where(p => p.modelTypeId == 3).ToList().Count != 0) { resData.originalityList = allList.Where(p => p.modelTypeId == 3).ToList(); } //导航 List <CategoryGroupInfo> lc4 = allList.Where(p => p.modelTypeId == 4).ToList(); if (lc4 != null && lc4.Count != 0) { resData.navList = lc4.OrderByDescending(p => p.groupID).ToList()[0];; //(获取唯一的) } //商品列表 eventGroup = allGroup.Where(a => a.ModelTypeId == 2); List <ProductListInfo> productList = new List <ProductListInfo>(); if (eventGroup != null) { foreach (var groupItem in eventGroup) { var category = new ProductListInfo { CategoryAreaList = new List <ProductInfo>() }; category.modelTypeId = groupItem.ModelTypeId; category.modelTypeName = groupItem.ModelName; category.styleType = groupItem.StyleType; category.titleName = groupItem.TitleName; category.titleStyle = groupItem.TitleStyle; category.showCount = (int)groupItem.ShowCount; category.showName = (int)groupItem.ShowName; category.showPrice = (int)groupItem.ShowPrice; category.showSalesPrice = (int)groupItem.ShowSalesPrice; category.showDiscount = (int)groupItem.ShowDiscount; category.showSalesQty = (int)groupItem.ShowSalesQty; category.displayIndex = (int)groupItem.DisplayIndex; MHCategoryAreaBLL bllCategoryArea = new MHCategoryAreaBLL(logginUserInfo); int intObjectId = bllCategoryArea.GetObjectTypeIDByGroupId((int)groupItem.GroupId); DataSet dsItem = null; if (intObjectId == 4) { dsItem = adAreaBll.GetGroupProductList(groupItem.GroupId.ToString(), entityHome.HomeId.ToString(), category.showCount); } else { dsItem = adAreaBll.GetCategoryProductList(groupItem.GroupId.ToString(), entityHome.HomeId.ToString(), category.showCount); } if (dsItem != null && dsItem.Tables.Count > 0 && dsItem.Tables[0].Rows.Count > 0) { category.CategoryAreaList = DataTableToObject.ConvertToList <ProductInfo>(dsItem.Tables[0]); } productList.Add(category); } } if (productList != null && productList.Count != 0) { resData.productList = productList.ToList();; } #region 关注信息 var bllFollow = new MHFollowBLL(CurrentUserInfo); var entity = new MHFollowEntity(); var dsFollow = bllFollow.QueryByEntity(new MHFollowEntity() { HomeId = strHomeId }, null); followInfo follow = new followInfo(); follow = dsFollow.Select(f => new followInfo() { HomeId = f.HomeId, FollowId = f.FollowId.ToString(), Title = f.Title, TextId = f.TextId, TextTitle = f.TextTitle, Url = f.Url, TypeId = f.TypeId }).FirstOrDefault(); resData.follow = follow; #endregion return(resData); }