|
@@ -115,163 +115,90 @@ public class FrontStoreController {
|
|
@RequestParam(value = "sort", required = false, defaultValue = "2") Integer sort) {
|
|
@RequestParam(value = "sort", required = false, defaultValue = "2") Integer sort) {
|
|
String webSite = WebUtil.getWebSite(request);
|
|
String webSite = WebUtil.getWebSite(request);
|
|
Member member = UserUtil.getUser(request, Member.class);
|
|
Member member = UserUtil.getUser(request, Member.class);
|
|
|
|
+ List<Store> storeList = new ArrayList<>();
|
|
PagerInfo pager = WebUtil.handlerPagerInfo(request);
|
|
PagerInfo pager = WebUtil.handlerPagerInfo(request);
|
|
List<FrontStoreListVO> vos = new ArrayList<>();
|
|
List<FrontStoreListVO> vos = new ArrayList<>();
|
|
|
|
+ StoreExample storeExample = new StoreExample();
|
|
|
|
+ storeExample.setState(StoreConst.STORE_STATE_OPEN);
|
|
|
|
|
|
- //满足条件的店铺id
|
|
|
|
-// Set<Long> storeIdSet = esGoodsModel.searchStoreIdsByEs(categoryId, keyword);
|
|
|
|
-// if (CollectionUtils.isEmpty(storeIdSet)) {
|
|
|
|
-// return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
-// }
|
|
|
|
|
|
+ storeExample.setStoreNameLike(keyword);
|
|
|
|
+ storeExample.setBusinessState(StoreConst.STORE_BUSINESS_STATE_OPEN);
|
|
|
|
|
|
-// StringBuilder storeIds = new StringBuilder();
|
|
|
|
-// storeIdSet.forEach(storeId -> {
|
|
|
|
-// storeIds.append(",").append(storeId);
|
|
|
|
-// });
|
|
|
|
|
|
+ if (sort == 2) {
|
|
|
|
+ storeExample.setOrderBy("store_look_volume DESC");
|
|
|
|
+ } else {
|
|
|
|
+ storeExample.setOrderBy("store_sales_volume DESC");
|
|
|
|
+ }
|
|
if (WebSiteConstant.MEMBER_OVERSEA.equals(webSite)) {
|
|
if (WebSiteConstant.MEMBER_OVERSEA.equals(webSite)) {
|
|
- StoreExample storeExample = new StoreExample();
|
|
|
|
- storeExample.setState(StoreConst.STORE_STATE_OPEN);
|
|
|
|
-// storeExample.setStoreIdIn(storeIds.substring(1));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- storeExample.setStoreNameLike(keyword);
|
|
|
|
- storeExample.setBusinessState(StoreConst.STORE_BUSINESS_STATE_OPEN);
|
|
|
|
-
|
|
|
|
- if (sort == 2) {
|
|
|
|
- storeExample.setOrderBy("store_look_volume DESC");
|
|
|
|
- } else {
|
|
|
|
- storeExample.setOrderBy("store_sales_volume DESC");
|
|
|
|
|
|
+ storeList = storeModel.getStoreList(storeExample, pager);
|
|
|
|
+ } else {
|
|
|
|
+ if (pager != null) {
|
|
|
|
+ storeList = storeModel.getStoreCnList(storeExample, pager);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isEmpty(storeList)) {
|
|
|
|
+ //没有满足条件的店铺
|
|
|
|
+ return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
+ }
|
|
|
|
|
|
- List<Store> storeList = storeModel.getStoreList(storeExample, pager);
|
|
|
|
- if (CollectionUtils.isEmpty(storeList)) {
|
|
|
|
- //没有满足条件的店铺
|
|
|
|
- return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
|
|
+ for (Store store : storeList) {
|
|
|
|
+ //默认店铺logo
|
|
|
|
+ if (StringUtils.isEmpty(store.getStoreLogo())) {
|
|
|
|
+ store.setStoreLogo(stringRedisTemplate.opsForValue().get("default_image_store_logo"));
|
|
|
|
+ }
|
|
|
|
+ //默认店铺背景图片(取移动端横幅)
|
|
|
|
+ if (StringUtils.isEmpty(store.getStoreBannerMobile())) {
|
|
|
|
+ store.setStoreBannerMobile(stringRedisTemplate.opsForValue().get("default_image_store_backdrop"));
|
|
}
|
|
}
|
|
|
|
+ FrontStoreListVO vo = new FrontStoreListVO(store);
|
|
|
|
+ vos.add(vo);
|
|
|
|
+ }
|
|
|
|
|
|
-// StringBuilder storeIdIn = new StringBuilder();
|
|
|
|
-// storeList.forEach(store -> {
|
|
|
|
-// storeIdIn.append(",").append(store.getStoreId());
|
|
|
|
-// });
|
|
|
|
-// //一次性查询这些店铺所有上架的商品
|
|
|
|
-// List<SearchProductDTO> storeGoodsList = esGoodsModel.getStoreGoodsList(storeIdIn.substring(1), categoryId, keyword);
|
|
|
|
-//
|
|
|
|
-// //基于店铺处理商品
|
|
|
|
-// Map<Long/*storeId*/, List<StoreGoodsVO>/*按照销量倒序的商品列表*/> storeGoodsSaleMap = new HashMap<>();
|
|
|
|
-// Map<Long/*storeId*/, List<StoreGoodsVO>/*按照上架时间倒序的商品列表*/> storeGoodsOnlineMap = new HashMap<>();
|
|
|
|
-// storeGoodsList.forEach(goods -> {
|
|
|
|
-// StoreGoodsVO storeGoodsVO = new StoreGoodsVO(goods);
|
|
|
|
-// //按销量
|
|
|
|
-// if (storeGoodsSaleMap.containsKey(Long.valueOf(goods.getStoreId()))) {
|
|
|
|
-// storeGoodsSaleMap.get(Long.valueOf(goods.getStoreId())).add(storeGoodsVO);
|
|
|
|
-// } else {
|
|
|
|
-// List<StoreGoodsVO> list = new ArrayList<>();
|
|
|
|
-// list.add(storeGoodsVO);
|
|
|
|
-// storeGoodsSaleMap.put(Long.valueOf(goods.getStoreId()), list);
|
|
|
|
|
|
+// else {
|
|
|
|
+// List<StoreName> storeNameList = new ArrayList<>();
|
|
|
|
+// List<StoreSiteInfo> storeSiteInfoList = new ArrayList<>();
|
|
|
|
+// if (WebSiteConstant.MEMBER_DISTRIBUTOR.equals(webSite)) {
|
|
|
|
+// StoreNameExample storeNameExample = new StoreNameExample();
|
|
|
|
+// storeNameExample.setStoreNameLike(keyword);
|
|
|
|
+// storeNameExample.setWebSite(webSite);
|
|
|
|
+// storeNameList = storeNameModel.getStoreNameList(storeNameExample, pager);
|
|
|
|
+// if (CollectionUtils.isEmpty(storeNameList)) {
|
|
|
|
+// //没有满足条件的店铺
|
|
|
|
+// return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
+// }
|
|
|
|
+// StoreSiteInfoExample storeSiteInfoExample = new StoreSiteInfoExample();
|
|
|
|
+// storeSiteInfoExample.setStoreIdIn(storeNameList.stream().map(StoreName::getStoreId).collect(Collectors.toList()));
|
|
|
|
+// storeSiteInfoExample.setWebSite(webSite);
|
|
|
|
+// storeSiteInfoExample.setBusinessState(StoreConst.STORE_BUSINESS_STATE_OPEN);
|
|
|
|
+// storeSiteInfoList = storeSiteInfoModel.getStoreSiteInfoList(storeSiteInfoExample, null);
|
|
|
|
+// if (CollectionUtils.isEmpty(storeSiteInfoList)) {
|
|
|
|
+// //没有满足条件的店铺
|
|
|
|
+// return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
+// }
|
|
// }
|
|
// }
|
|
-//
|
|
|
|
-// //近30天上新
|
|
|
|
-// Date apartDay = TimeUtil.getDateApartDay(-30);
|
|
|
|
-// if (apartDay.before(storeGoodsVO.getOnlineTime())) {
|
|
|
|
-// if (storeGoodsOnlineMap.containsKey(Long.valueOf(goods.getStoreId()))) {
|
|
|
|
-// storeGoodsOnlineMap.get(Long.valueOf(goods.getStoreId())).add(storeGoodsVO);
|
|
|
|
-// } else {
|
|
|
|
-// List<StoreGoodsVO> list = new ArrayList<>();
|
|
|
|
-// list.add(storeGoodsVO);
|
|
|
|
-// storeGoodsOnlineMap.put(Long.valueOf(goods.getStoreId()), list);
|
|
|
|
|
|
+// for (StoreSiteInfo storeSiteInfo : storeSiteInfoList) {
|
|
|
|
+// Store store = storeModel.getStoreByStoreId(storeSiteInfo.getStoreId());
|
|
|
|
+// if (store != null) {
|
|
|
|
+// store.setStoreName(storeNameList.stream()
|
|
|
|
+// .filter(storeNameWebSite -> storeNameWebSite.getStoreId().equals(storeSiteInfo.getStoreId()))
|
|
|
|
+// .findFirst()
|
|
|
|
+// .map(StoreName::getStoreName)
|
|
|
|
+// .orElse(""));
|
|
|
|
+// store.setStoreLogo(storeSiteInfo.getStoreLogo());
|
|
|
|
+// //默认店铺logo
|
|
|
|
+// if (StringUtils.isEmpty(store.getStoreLogo())) {
|
|
|
|
+// store.setStoreLogo(stringRedisTemplate.opsForValue().get("default_image_store_logo"));
|
|
|
|
+// }
|
|
|
|
+// //默认店铺背景图片(取移动端横幅)
|
|
|
|
+// if (StringUtils.isEmpty(store.getStoreBannerMobile())) {
|
|
|
|
+// store.setStoreBannerMobile(stringRedisTemplate.opsForValue().get("default_image_store_backdrop"));
|
|
|
|
+// }
|
|
|
|
+// FrontStoreListVO vo = new FrontStoreListVO(store);
|
|
|
|
+// vos.add(vo);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
-// });
|
|
|
|
-//
|
|
|
|
-// //会员是否收藏
|
|
|
|
-// Set<Long/*storeId*/> memberFollowStoreSet = new HashSet<>();
|
|
|
|
-// if (!StringUtil.isNullOrZero(member.getMemberId())) {
|
|
|
|
-// MemberFollowStoreExample example = new MemberFollowStoreExample();
|
|
|
|
-// example.setMemberId(member.getMemberId());
|
|
|
|
-// example.setStoreIdIn(storeIdIn.substring(1));
|
|
|
|
-// List<MemberFollowStore> memberFollowStoreList = memberFollowStoreModel.getMemberFollowStoreList(example, null);
|
|
|
|
-// memberFollowStoreList.forEach(memberFollowStore -> {
|
|
|
|
-// memberFollowStoreSet.add(memberFollowStore.getStoreId());
|
|
|
|
-// });
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
- for (Store store : storeList) {
|
|
|
|
- //默认店铺logo
|
|
|
|
- if (StringUtils.isEmpty(store.getStoreLogo())) {
|
|
|
|
- store.setStoreLogo(stringRedisTemplate.opsForValue().get("default_image_store_logo"));
|
|
|
|
- }
|
|
|
|
- //默认店铺背景图片(取移动端横幅)
|
|
|
|
- if (StringUtils.isEmpty(store.getStoreBannerMobile())) {
|
|
|
|
- store.setStoreBannerMobile(stringRedisTemplate.opsForValue().get("default_image_store_backdrop"));
|
|
|
|
- }
|
|
|
|
- FrontStoreListVO vo = new FrontStoreListVO(store);
|
|
|
|
- //会员是否收藏
|
|
|
|
-// vo.setIsFollow(memberFollowStoreSet.contains(store.getStoreId()) ? "true" : "false");
|
|
|
|
-
|
|
|
|
- //查询店铺内的热销商品
|
|
|
|
-// List<StoreGoodsVO> storeGoodsSaleList = storeGoodsSaleMap.getOrDefault(store.getStoreId(), new ArrayList<>());
|
|
|
|
-// //按销量倒序
|
|
|
|
-// storeGoodsSaleList.sort((o1, o2) -> Integer.compare(o2.getActualSales(), o1.getActualSales()));
|
|
|
|
-// //店铺热销商品个数
|
|
|
|
-// vo.setHotGoodsNumber(storeGoodsSaleList.size());
|
|
|
|
-// //店铺热销商品列表
|
|
|
|
-// vo.setGoodsListVOList(storeGoodsSaleList);
|
|
|
|
-
|
|
|
|
- //查询店铺内本月上新商品
|
|
|
|
-// List<StoreGoodsVO> storeGoodsOnlineList = storeGoodsOnlineMap.getOrDefault(store.getStoreId(), new ArrayList<>());
|
|
|
|
- //按创建时间倒序
|
|
|
|
-// storeGoodsOnlineList.sort((o1, o2) -> o1.getOnlineTime().equals(o2.getOnlineTime()) ? 0 : (o1.getOnlineTime().before(o2.getOnlineTime()) ? 1 : -1));
|
|
|
|
- //本月上新商品个数
|
|
|
|
-// vo.setNewGoodsNumber(storeGoodsOnlineList.size());
|
|
|
|
- //本月上新商品列表
|
|
|
|
-// vo.setNewGoodsListVOS(storeGoodsOnlineList);
|
|
|
|
- vos.add(vo);
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
- List<StoreName> storeNameList = new ArrayList<>();
|
|
|
|
- List<StoreSiteInfo> storeSiteInfoList = new ArrayList<>();
|
|
|
|
- if (WebSiteConstant.MEMBER_DISTRIBUTOR.equals(webSite)) {
|
|
|
|
- StoreNameExample storeNameExample = new StoreNameExample();
|
|
|
|
- storeNameExample.setStoreNameLike(keyword);
|
|
|
|
- storeNameExample.setWebSite(webSite);
|
|
|
|
- storeNameList = storeNameModel.getStoreNameList(storeNameExample, pager);
|
|
|
|
- if (CollectionUtils.isEmpty(storeNameList)) {
|
|
|
|
- //没有满足条件的店铺
|
|
|
|
- return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
- }
|
|
|
|
- StoreSiteInfoExample storeSiteInfoExample = new StoreSiteInfoExample();
|
|
|
|
- storeSiteInfoExample.setStoreIdIn(storeNameList.stream().map(StoreName::getStoreId).collect(Collectors.toList()));
|
|
|
|
- storeSiteInfoExample.setWebSite(webSite);
|
|
|
|
- storeSiteInfoExample.setBusinessState(StoreConst.STORE_BUSINESS_STATE_OPEN);
|
|
|
|
- storeSiteInfoList = storeSiteInfoModel.getStoreSiteInfoList(storeSiteInfoExample, null);
|
|
|
|
- if (CollectionUtils.isEmpty(storeSiteInfoList)) {
|
|
|
|
- //没有满足条件的店铺
|
|
|
|
- return SldResponse.success(new PageVO<>(vos, pager));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (StoreSiteInfo storeSiteInfo : storeSiteInfoList) {
|
|
|
|
- Store store = storeModel.getStoreByStoreId(storeSiteInfo.getStoreId());
|
|
|
|
- if (store != null) {
|
|
|
|
- store.setStoreName(storeNameList.stream()
|
|
|
|
- .filter(storeNameWebSite -> storeNameWebSite.getStoreId().equals(storeSiteInfo.getStoreId()))
|
|
|
|
- .findFirst()
|
|
|
|
- .map(StoreName::getStoreName)
|
|
|
|
- .orElse(""));
|
|
|
|
- store.setStoreLogo(storeSiteInfo.getStoreLogo());
|
|
|
|
- //默认店铺logo
|
|
|
|
- if (StringUtils.isEmpty(store.getStoreLogo())) {
|
|
|
|
- store.setStoreLogo(stringRedisTemplate.opsForValue().get("default_image_store_logo"));
|
|
|
|
- }
|
|
|
|
- //默认店铺背景图片(取移动端横幅)
|
|
|
|
- if (StringUtils.isEmpty(store.getStoreBannerMobile())) {
|
|
|
|
- store.setStoreBannerMobile(stringRedisTemplate.opsForValue().get("default_image_store_backdrop"));
|
|
|
|
- }
|
|
|
|
- FrontStoreListVO vo = new FrontStoreListVO(store);
|
|
|
|
- vos.add(vo);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return SldResponse.success(new PageVO<>(vos, pager));
|
|
return SldResponse.success(new PageVO<>(vos, pager));
|
|
}
|
|
}
|
|
|
|
|