master:APP实力质造、商品榜、图搜热榜等功能完善;
parent
9bded7ff2b
commit
78f633d1f4
|
|
@ -12,10 +12,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -41,8 +38,8 @@ public class PictureSearchController extends XktBaseController {
|
|||
.searchProductByPic(BeanUtil.toBean(searchVO, SearchRequestDTO.class).setNum(20)), StoreProdViewVO.class));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "图搜热款列表", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/hot")
|
||||
@ApiOperation(value = "图搜热款列表", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/hot")
|
||||
public R<List<StoreProdViewVO>> searchHotList() {
|
||||
return R.ok(BeanUtil.copyToList(picSearchService.listImgSearchTopProduct(), StoreProdViewVO.class));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.ruoyi.web.controller.xkt.vo.advertRound.pc.newProd.*;
|
|||
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.store.PCStoreMidBannerVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.advertRound.pc.store.PCStoreTopBannerVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.advertRound.picSearch.PicSearchAdvertVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.website.AppStrengthSearchVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.website.IndexSearchVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.website.StoreSearchVO;
|
||||
import com.ruoyi.xkt.dto.BasePageDTO;
|
||||
|
|
@ -35,6 +36,7 @@ import com.ruoyi.xkt.dto.advertRound.pc.PCSearchDTO;
|
|||
import com.ruoyi.xkt.dto.advertRound.pc.index.PCIndexRecommendDTO;
|
||||
import com.ruoyi.xkt.dto.advertRound.pc.newProd.PCNewRecommendDTO;
|
||||
import com.ruoyi.xkt.dto.advertRound.pc.store.PCStoreRecommendDTO;
|
||||
import com.ruoyi.xkt.dto.website.AppStrengthSearchDTO;
|
||||
import com.ruoyi.xkt.dto.website.IndexSearchDTO;
|
||||
import com.ruoyi.xkt.dto.website.StoreSearchDTO;
|
||||
import com.ruoyi.xkt.service.IWebsiteAPPService;
|
||||
|
|
@ -269,8 +271,8 @@ public class WebsiteController extends XktBaseController {
|
|||
|
||||
@ApiOperation(value = "APP 实力质造专题页 档口列表", notes = "只需要传分页参数即可", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/app/strength/store")
|
||||
public R<Page<APPStrengthStoreDTO>> getAppStrengthStorePage(@Validated @RequestBody IndexSearchVO searchVO) {
|
||||
return R.ok(websiteAPPService. getAppStrengthStorePage(BeanUtil.toBean(searchVO, IndexSearchDTO.class)));
|
||||
public R<Page<APPStrengthStoreDTO>> getAppStrengthStorePage(@Validated @RequestBody AppStrengthSearchVO searchVO) {
|
||||
return R.ok(websiteAPPService. getAppStrengthStorePage(BeanUtil.toBean(searchVO, AppStrengthSearchDTO.class)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "APP 商品榜 销量列表", httpMethod = "GET", response = R.class)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
|||
@Data
|
||||
public class StoreProdViewVO {
|
||||
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
private Integer memberLevel;
|
||||
@ApiModelProperty(value = "搜索次数")
|
||||
private Long imgSearchCount;
|
||||
@ApiModelProperty(value = "同款商品数量")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.website;
|
||||
|
||||
import com.ruoyi.web.controller.xkt.vo.BasePageVO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AppStrengthSearchVO extends BasePageVO {
|
||||
|
||||
}
|
||||
|
|
@ -120,6 +120,18 @@ public class DailyTaskController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/redis/store-memeber")
|
||||
public R saveStoreMemberToRedis(SysJob sysJob) {
|
||||
task.saveStoreMemberToRedis();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/daily-prod-top-sale")
|
||||
public R dailyProdTopSale(SysJob sysJob) {
|
||||
task.dailyProdTopSale();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ public class XktTask {
|
|||
final StoreProductMapper storeProdMapper;
|
||||
final DailyProdTagMapper dailyProdTagMapper;
|
||||
final StoreProductCategoryAttributeMapper cateAttrMapper;
|
||||
final StoreProductStatisticsMapper prodStatMapper;
|
||||
final EsClientWrapper esClientWrapper;
|
||||
final AdvertMapper advertMapper;
|
||||
final AdvertRoundMapper advertRoundMapper;
|
||||
|
|
@ -509,7 +508,7 @@ public class XktTask {
|
|||
return;
|
||||
}
|
||||
// 获取 商品销售、商品浏览量、商品收藏量、商品下载量
|
||||
List<StoreProductStatistics> statisticsList = this.prodStatMapper.selectList(new LambdaQueryWrapper<StoreProductStatistics>()
|
||||
List<StoreProductStatistics> statisticsList = this.storeProdStatMapper.selectList(new LambdaQueryWrapper<StoreProductStatistics>()
|
||||
.eq(StoreProductStatistics::getDelFlag, Constants.UNDELETED));
|
||||
// 商品浏览量、下载量
|
||||
Map<Long, StoreProductStatistics> prodStatMap = statisticsList.stream().collect(Collectors.toMap(StoreProductStatistics::getStoreProdId, Function.identity()));
|
||||
|
|
@ -728,10 +727,22 @@ public class XktTask {
|
|||
expireList.forEach(x -> redisCache.deleteObject(CacheConstants.STORE_MEMBER + x.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将档口会员存到redis中
|
||||
*/
|
||||
public void saveStoreMemberToRedis() {
|
||||
List<StoreMember> memberList = this.storeMemberMapper.selectList(new LambdaQueryWrapper<StoreMember>()
|
||||
.eq(StoreMember::getDelFlag, Constants.UNDELETED));
|
||||
if (CollectionUtils.isEmpty(memberList)) {
|
||||
return;
|
||||
}
|
||||
memberList.forEach(x -> redisCache.setCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId(), x));
|
||||
}
|
||||
|
||||
/**
|
||||
* 凌晨2:50 更新APP商品销量榜、分类商品销量榜
|
||||
*/
|
||||
public void dailyProdSale() {
|
||||
public void dailyProdTopSale() {
|
||||
final Date oneMonthAgo = java.sql.Date.valueOf(LocalDate.now().minusMonths(1));
|
||||
final Date now = java.sql.Date.valueOf(LocalDate.now());
|
||||
// 销量前100的ID列表,直接放到redis中
|
||||
|
|
|
|||
|
|
@ -132,50 +132,56 @@
|
|||
|
||||
<select id="prodSaleTop50List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
|
||||
SELECT
|
||||
dsp.store_id,
|
||||
dsp.store_prod_id,
|
||||
COUNT( dsp.sale_num ) AS count
|
||||
COALESCE ( SUM( dsp.sale_num ), 0 ) AS count
|
||||
FROM
|
||||
daily_sale_product dsp
|
||||
LEFT JOIN store_product sp ON dsp.store_prod_id = sp.id
|
||||
JOIN store_product sp ON dsp.store_prod_id = sp.id
|
||||
WHERE
|
||||
dsp.del_flag = 0
|
||||
AND dsp.voucher_date BETWEEN #{oneMonthAgo} AND #{yesterday}
|
||||
GROUP BY
|
||||
dsp.store_id,
|
||||
dsp.store_prod_id
|
||||
ORDER BY
|
||||
COUNT( dsp.sale_num ) DESC
|
||||
LIMIT 100
|
||||
count DESC
|
||||
LIMIT 50
|
||||
</select>
|
||||
|
||||
<select id="prodCateSaleTop50List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
|
||||
WITH ranked_products AS (
|
||||
SELECT
|
||||
dsp.store_id,
|
||||
sp.prod_cate_id,
|
||||
dsp.store_prod_id,
|
||||
spc.`name` AS prodCateName,
|
||||
COUNT( dsp.sale_num ) AS sale_count,
|
||||
ROW_NUMBER() OVER ( PARTITION BY sp.prod_cate_id ORDER BY COUNT( dsp.sale_num ) DESC ) AS rank_in_category
|
||||
COALESCE ( SUM( dsp.sale_num ), 0 ) AS count,
|
||||
ROW_NUMBER() OVER ( PARTITION BY sp.prod_cate_id ORDER BY COALESCE ( SUM( dsp.sale_num ), 0 ) DESC ) AS rank_in_category
|
||||
FROM
|
||||
daily_sale_product dsp
|
||||
LEFT JOIN store_product sp ON dsp.store_prod_id = sp.id
|
||||
LEFT JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
|
||||
LEFT JOIN store_product sp ON dsp.store_prod_id = sp.id
|
||||
LEFT JOIN sys_product_category spc ON sp.prod_cate_id = spc.id
|
||||
WHERE
|
||||
dsp.del_flag = 0
|
||||
GROUP BY
|
||||
sp.prod_cate_id,
|
||||
dsp.store_prod_id
|
||||
dsp.store_prod_id,
|
||||
dsp.store_id,
|
||||
spc.`name`
|
||||
) SELECT
|
||||
store_id,
|
||||
prod_cate_id,
|
||||
store_prod_id,
|
||||
sale_count,
|
||||
prodCateName
|
||||
FROM
|
||||
prodCateName,
|
||||
count
|
||||
FROM
|
||||
ranked_products
|
||||
WHERE
|
||||
WHERE
|
||||
rank_in_category <= 50
|
||||
ORDER BY
|
||||
ORDER BY
|
||||
prod_cate_id,
|
||||
sale_count DESC;
|
||||
count DESC;
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ public class APPProdCateTop3DTO {
|
|||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class APPPCTProdDTO {
|
||||
@ApiModelProperty(value = "1推广图")
|
||||
private Integer displayType;
|
||||
@ApiModelProperty(value = "主图")
|
||||
private String mainPicUrl;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "推广图路径")
|
||||
private String fileUrl;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class APPProdSaleDTO {
|
||||
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class StoreProdViewDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口会员级别")
|
||||
private Integer memberLevel;
|
||||
@ApiModelProperty(value = "搜索次数")
|
||||
private Integer imgSearchCount;
|
||||
@ApiModelProperty(value = "同款商品数量")
|
||||
|
|
@ -38,7 +40,5 @@ public class StoreProdViewDTO {
|
|||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
// @ApiModelProperty(value = "档口标签列表")
|
||||
// private List<String> storeTagList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.xkt.dto.website;
|
||||
|
||||
import com.ruoyi.xkt.dto.BasePageDTO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AppStrengthSearchDTO extends BasePageDTO {
|
||||
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import com.ruoyi.xkt.dto.advertRound.app.prod.APPProdSaleDTO;
|
|||
import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthProdDTO;
|
||||
import com.ruoyi.xkt.dto.advertRound.app.strength.APPStrengthStoreDTO;
|
||||
import com.ruoyi.xkt.dto.es.ESProductDTO;
|
||||
import com.ruoyi.xkt.dto.website.AppStrengthSearchDTO;
|
||||
import com.ruoyi.xkt.dto.website.IndexSearchDTO;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -111,7 +112,7 @@ public interface IWebsiteAPPService {
|
|||
* @param searchDTO 搜索入参
|
||||
* @return Page<APPStrengthStoreDTO>
|
||||
*/
|
||||
Page<APPStrengthStoreDTO> getAppStrengthStorePage(IndexSearchDTO searchDTO);
|
||||
Page<APPStrengthStoreDTO> getAppStrengthStorePage(AppStrengthSearchDTO searchDTO);
|
||||
|
||||
/**
|
||||
* APP 商品榜 销量前100 商品列表
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.ruoyi.common.core.redis.RedisCache;
|
|||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.xkt.domain.PictureSearch;
|
||||
import com.ruoyi.xkt.domain.StoreMember;
|
||||
import com.ruoyi.xkt.domain.SysFile;
|
||||
import com.ruoyi.xkt.dto.advertRound.picSearch.PicSearchAdvertDTO;
|
||||
import com.ruoyi.xkt.dto.picture.ProductImgSearchCountDTO;
|
||||
|
|
@ -113,7 +114,13 @@ public class PictureSearchServiceImpl implements IPictureSearchService {
|
|||
return picSearchHotList;
|
||||
}
|
||||
// 重新缓存数据到redis
|
||||
return this.cacheImgSearchTopProduct();
|
||||
picSearchHotList = this.cacheImgSearchTopProduct();
|
||||
picSearchHotList.forEach(x -> {
|
||||
// 查询档口会员等级
|
||||
StoreMember member = this.redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId());
|
||||
x.setMemberLevel(ObjectUtils.isNotEmpty(member) ? member.getLevel() : null);
|
||||
});
|
||||
return picSearchHotList;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,7 +140,8 @@ public class PictureSearchServiceImpl implements IPictureSearchService {
|
|||
storeProdViewAttrList = storeProdViewAttrList.stream().map(x -> {
|
||||
//根据主图搜索同类商品
|
||||
List<ProductMatchDTO> pmList = pictureService.searchProductByPicKey(x.getMainPicUrl(), 1000);
|
||||
return x.setSameProdCount(pmList.size()).setImgSearchCount(ObjectUtils.defaultIfNull(searchCountMap.get(x.getStoreProdId()), 0));
|
||||
return x.setTags(StrUtil.split(x.getTagStr(), ",")).setSameProdCount(pmList.size())
|
||||
.setImgSearchCount(ObjectUtils.defaultIfNull(searchCountMap.get(x.getStoreProdId()), 0));
|
||||
})
|
||||
.sorted(Comparator.comparing(StoreProdViewDTO::getImgSearchCount).reversed())
|
||||
.limit(100)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.ruoyi.xkt.dto.es.ESProductDTO;
|
|||
import com.ruoyi.xkt.dto.storeProduct.StoreProdPriceAndMainPicAndTagDTO;
|
||||
import com.ruoyi.xkt.dto.storeProduct.StoreProdPriceAndMainPicDTO;
|
||||
import com.ruoyi.xkt.dto.useSearchHistory.UserSearchHistoryDTO;
|
||||
import com.ruoyi.xkt.dto.website.AppStrengthSearchDTO;
|
||||
import com.ruoyi.xkt.dto.website.IndexSearchDTO;
|
||||
import com.ruoyi.xkt.enums.AdBiddingStatus;
|
||||
import com.ruoyi.xkt.enums.AdDisplayType;
|
||||
|
|
@ -327,13 +328,22 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
if (CollectionUtils.isEmpty(keyList)) {
|
||||
return Page.empty(searchDTO.getPageSize(), searchDTO.getPageNum());
|
||||
}
|
||||
List<String> storeIdList = keyList.stream().map(key -> {
|
||||
StoreMember member = this.redisCache.getCacheObject(key);
|
||||
return member.getStoreId().toString();
|
||||
}).collect(Collectors.toList());
|
||||
// 设置档口
|
||||
searchDTO.setStoreIdList(new ArrayList<>(keyList));
|
||||
searchDTO.setStoreIdList(storeIdList);
|
||||
Page<ESProductDTO> page = this.search(searchDTO);
|
||||
if (CollectionUtils.isEmpty(page.getList())) {
|
||||
return Page.empty(searchDTO.getPageSize(), searchDTO.getPageNum());
|
||||
}
|
||||
List<APPStrengthProdDTO> list = BeanUtil.copyToList(page.getList(), APPStrengthProdDTO.class);
|
||||
// 设置档口会员等级
|
||||
list.forEach(x -> {
|
||||
StoreMember storeMember = this.redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId());
|
||||
x.setMemberLevel(ObjectUtils.isNotEmpty(storeMember) ? storeMember.getLevel() : null);
|
||||
});
|
||||
return new Page<>(page.getPageNum(), page.getPageSize(), page.getPages(), page.getTotal(), list);
|
||||
}
|
||||
|
||||
|
|
@ -345,15 +355,19 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Page<APPStrengthStoreDTO> getAppStrengthStorePage(IndexSearchDTO searchDTO) {
|
||||
public Page<APPStrengthStoreDTO> getAppStrengthStorePage(AppStrengthSearchDTO searchDTO) {
|
||||
// 获取有哪些会员档口
|
||||
Collection<String> keyList = this.redisCache.scanKeys(CacheConstants.STORE_MEMBER + "*");
|
||||
if (CollectionUtils.isEmpty(keyList)) {
|
||||
return Page.empty(searchDTO.getPageSize(), searchDTO.getPageNum());
|
||||
}
|
||||
List<Long> storeIdList = keyList.stream().map(key -> {
|
||||
StoreMember member = this.redisCache.getCacheObject(key);
|
||||
return member.getStoreId();
|
||||
}).collect(Collectors.toList());
|
||||
PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize());
|
||||
List<Store> storeList = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
|
||||
.eq(Store::getDelFlag, Constants.UNDELETED).in(Store::getId, new ArrayList<>(keyList))
|
||||
.eq(Store::getDelFlag, Constants.UNDELETED).in(Store::getId, storeIdList)
|
||||
.orderByDesc(Store::getStoreWeight));
|
||||
if (CollectionUtils.isEmpty(storeList)) {
|
||||
return Page.empty(searchDTO.getPageSize(), searchDTO.getPageNum());
|
||||
|
|
@ -368,6 +382,11 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
List<APPStrengthStoreDTO> list = storeList.stream().map(store -> BeanUtil.toBean(store, APPStrengthStoreDTO.class)
|
||||
.setFocus(focusStoreIdMap.containsKey(store.getId())))
|
||||
.collect(Collectors.toList());
|
||||
// 设置档口会员等级
|
||||
list.forEach(x -> {
|
||||
StoreMember storeMember = this.redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId());
|
||||
x.setMemberLevel(ObjectUtils.isNotEmpty(storeMember) ? storeMember.getLevel() : null);
|
||||
});
|
||||
return Page.convert(new PageInfo<>(list));
|
||||
}
|
||||
|
||||
|
|
@ -380,11 +399,11 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
@Transactional(readOnly = true)
|
||||
public List<APPProdSaleDTO> getAppProdSaleTop100List() throws IOException {
|
||||
// 从redis中获取销量前100的商品
|
||||
List<DailyStoreProdSaleDTO> top100ProdList = redisCache.getCacheObject(CacheConstants.TOP_50_SALE_PROD);
|
||||
if (CollectionUtils.isEmpty(top100ProdList)) {
|
||||
List<DailyStoreProdSaleDTO> top50ProdList = redisCache.getCacheObject(CacheConstants.TOP_50_SALE_PROD);
|
||||
if (CollectionUtils.isEmpty(top50ProdList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> prodIdList = top100ProdList.stream().map(DailyStoreProdSaleDTO::getStoreProdId).map(String::valueOf).collect(Collectors.toList());
|
||||
List<String> prodIdList = top50ProdList.stream().map(DailyStoreProdSaleDTO::getStoreProdId).map(String::valueOf).collect(Collectors.toList());
|
||||
// 构建入参
|
||||
IndexSearchDTO searchDTO = new IndexSearchDTO();
|
||||
searchDTO.setProdIdList(prodIdList);
|
||||
|
|
@ -400,14 +419,17 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
.eq(UserFavorites::getDelFlag, Constants.UNDELETED).in(UserFavorites::getStoreProdId, prodIdList)
|
||||
.eq(UserFavorites::getUserId, userId)).stream().collect(Collectors
|
||||
.toMap(x -> x.getStoreProdId().toString(), Function.identity()));
|
||||
return top100ProdList.stream()
|
||||
return top50ProdList.stream()
|
||||
.filter(x -> ObjectUtils.isNotEmpty(esProdMap.get(x.getStoreProdId().toString())))
|
||||
.map(x -> BeanUtil.toBean(esProdMap.get(x.getStoreProdId().toString()), APPProdSaleDTO.class)
|
||||
// 是否为档口会员
|
||||
.setMemberLevel(redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId()))
|
||||
// 是否收藏商品
|
||||
.setCollectProd(ObjectUtils.isNotEmpty(collectMap.get(x.getStoreProdId().toString()))
|
||||
? Boolean.TRUE : Boolean.FALSE))
|
||||
.map(x -> {
|
||||
StoreMember storeMember = this.redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId());
|
||||
return BeanUtil.toBean(esProdMap.get(x.getStoreProdId().toString()), APPProdSaleDTO.class)
|
||||
// 是否为档口会员
|
||||
.setMemberLevel(ObjectUtils.isNotEmpty(storeMember) ? storeMember.getLevel() : null)
|
||||
// 是否收藏商品
|
||||
.setCollectProd(ObjectUtils.isNotEmpty(collectMap.get(x.getStoreProdId().toString()))
|
||||
? Boolean.TRUE : Boolean.FALSE);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
@ -419,22 +441,22 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<APPProdCateTop3DTO> getAppCateProdSaleTop3List() throws IOException {
|
||||
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_50_SALE_PROD);
|
||||
if (CollectionUtils.isEmpty(cateSaleTop100ProdList)) {
|
||||
List<DailyStoreProdSaleDTO> cateSaleTop50ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_50_SALE_PROD);
|
||||
if (CollectionUtils.isEmpty(cateSaleTop50ProdList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 商品分类ID 和 分类名称的map
|
||||
Map<Long, String> prodCateNameMap = cateSaleTop100ProdList.stream().collect(Collectors
|
||||
.toMap(DailyStoreProdSaleDTO::getProdCateId, DailyStoreProdSaleDTO::getProdCateName));
|
||||
Map<Long, String> prodCateNameMap = cateSaleTop50ProdList.stream().collect(Collectors
|
||||
.toMap(DailyStoreProdSaleDTO::getProdCateId, DailyStoreProdSaleDTO::getProdCateName, (s1, s2) -> s2));
|
||||
// 每一个分类ID与分类销量前3 的商品ID列表
|
||||
Map<Long, List<String>> cateProdIdMap = new HashMap<>();
|
||||
// 所有的商品销量榜
|
||||
List<String> prodIdList = new ArrayList<>();
|
||||
cateSaleTop100ProdList.stream().collect(Collectors.groupingBy(DailyStoreProdSaleDTO::getProdCateId))
|
||||
cateSaleTop50ProdList.stream().collect(Collectors.groupingBy(DailyStoreProdSaleDTO::getProdCateId))
|
||||
.forEach((prodCateId, list) -> {
|
||||
// 每一个分类销量前3 的 id 列表
|
||||
List<String> top3ProdIdList = list.stream().sorted(Comparator.comparing(DailyStoreProdSaleDTO::getCount).reversed())
|
||||
.limit(3).map(String::valueOf).collect(Collectors.toList());
|
||||
.limit(3).map(DailyStoreProdSaleDTO::getStoreProdId).map(String::valueOf).collect(Collectors.toList());
|
||||
prodIdList.addAll(top3ProdIdList);
|
||||
cateProdIdMap.put(prodCateId, top3ProdIdList);
|
||||
});
|
||||
|
|
@ -448,17 +470,28 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
|
|||
// ES 中存的 商品信息
|
||||
Map<String, ESProductDTO> esProdMap = page.getList().stream().collect(Collectors.toMap(ESProductDTO::getStoreProdId, Function.identity()));
|
||||
// 商品分类销量map
|
||||
Map<Long, Integer> cateCountMap = cateSaleTop100ProdList.stream().collect(Collectors
|
||||
Map<Long, Integer> cateCountMap = cateSaleTop50ProdList.stream().collect(Collectors
|
||||
.groupingBy(DailyStoreProdSaleDTO::getProdCateId, Collectors.summingInt(DailyStoreProdSaleDTO::getCount)));
|
||||
// 按照cateCountMap 的 value 倒序排,并且只取key 的集合
|
||||
List<Long> cateIdList = cateCountMap.entrySet().stream().sorted(Map.Entry.<Long, Integer>comparingByValue().reversed())
|
||||
.map(Map.Entry::getKey).collect(Collectors.toList());
|
||||
// 每一个分类前3的列表
|
||||
return cateIdList.stream().map(prodCateId -> new APPProdCateTop3DTO()
|
||||
.setProdCateId(prodCateId).setProdCateName(prodCateNameMap.get(prodCateId))
|
||||
.setProdList(CollectionUtils.isEmpty(cateProdIdMap.get(prodCateId)) ? new ArrayList<>()
|
||||
: BeanUtil.copyToList(cateProdIdMap.get(prodCateId).stream()
|
||||
.map(esProdMap::get).collect(Collectors.toList()), APPProdCateTop3DTO.APPPCTProdDTO.class)))
|
||||
return cateIdList.stream().map(prodCateId -> {
|
||||
APPProdCateTop3DTO cateTop3DTO = new APPProdCateTop3DTO().setProdCateId(prodCateId).setProdCateName(prodCateNameMap.get(prodCateId));
|
||||
List<String> top3ProdIdList = cateProdIdMap.get(prodCateId);
|
||||
if (CollectionUtils.isEmpty(top3ProdIdList)) {
|
||||
return cateTop3DTO;
|
||||
}
|
||||
List<APPProdCateTop3DTO.APPPCTProdDTO> tempList = new ArrayList<>();
|
||||
for (int i = 0; i < top3ProdIdList.size(); i++) {
|
||||
ESProductDTO esProd = esProdMap.get(top3ProdIdList.get(i));
|
||||
if (ObjectUtils.isEmpty(esProd)) {
|
||||
continue;
|
||||
}
|
||||
tempList.add(BeanUtil.toBean(esProd, APPProdCateTop3DTO.APPPCTProdDTO.class).setOrderNum(i + 1));
|
||||
}
|
||||
return cateTop3DTO.setProdList(tempList);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,10 +190,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
MIN( spcp.price ) AS price
|
||||
FROM
|
||||
store_product sp
|
||||
LEFT JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
|
||||
LEFT JOIN sys_file sf ON spf.file_id = sf.id
|
||||
LEFT JOIN store s ON sp.store_id = s.id
|
||||
LEFT JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id AND spcp.del_flag = 0
|
||||
JOIN store_product_file spf ON sp.id = spf.store_prod_id AND spf.del_flag = 0 AND spf.file_type = 1 AND spf.order_num = 1
|
||||
JOIN sys_file sf ON spf.file_id = sf.id
|
||||
JOIN store s ON sp.store_id = s.id
|
||||
JOIN store_product_color_price spcp ON sp.id = spcp.store_prod_id AND spcp.del_flag = 0
|
||||
LEFT JOIN daily_prod_tag dpt ON sp.id = dpt.store_prod_id AND dpt.del_flag = 0
|
||||
WHERE
|
||||
sp.del_flag = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue