master:app档口访问榜接口添加;
parent
0f881d9459
commit
1f01746ceb
|
|
@ -92,12 +92,14 @@ public class StoreController extends XktBaseController {
|
|||
return R.ok(storeService.updateStoreWeight(BeanUtil.toBean(storeWeightUpdateVO, StoreWeightUpdateDTO.class)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
@ApiOperation(value = "获取档口详细信息", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/{storeId}")
|
||||
public R<StoreResVO> getInfo(@PathVariable("storeId") Long storeId) {
|
||||
return R.ok(BeanUtil.toBean(storeService.getInfo(storeId), StoreResVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store,seller,agent')||@ss.hasSupplierSubRole()")
|
||||
@ApiOperation(value = "PC 商城首页 获取档口基础信息", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/simple/{storeId}")
|
||||
public R<StoreSimpleResVO> getSimpleInfo(@PathVariable("storeId") Long storeId) {
|
||||
|
|
@ -111,6 +113,7 @@ public class StoreController extends XktBaseController {
|
|||
return R.ok(BeanUtil.toBean(storeService.getApproveInfo(storeId), StoreApproveResVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store,seller,agent')||@ss.hasSupplierSubRole()")
|
||||
@ApiOperation(value = "APP获取档口基本信息", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/app/{storeId}")
|
||||
public R<StoreAppResVO> getAppInfo(@PathVariable("storeId") Long storeId) {
|
||||
|
|
@ -180,4 +183,12 @@ public class StoreController extends XktBaseController {
|
|||
return R.ok(storeService.updateStockSys(BeanUtil.toBean(stockSysVO, StoreUpdateStockSysDTO.class)));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store,seller,agent')||@ss.hasSupplierSubRole()")
|
||||
@ApiOperation(value = "APP档口访问榜", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/app/view-rank")
|
||||
public R<StoreAppViewRankResVO> getAppViewRank() {
|
||||
return R.ok(BeanUtil.toBean(storeService.getAppViewRank(), StoreAppViewRankResVO.class));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.store;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class StoreAppViewRankResVO {
|
||||
|
||||
@ApiModelProperty(value = "档口浏览量列表")
|
||||
private List<SAVRViewCountVO> viewCountList;
|
||||
|
||||
@Data
|
||||
public static class SAVRViewCountVO {
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
private Integer memberLevel;
|
||||
@ApiModelProperty(value = "logo")
|
||||
private String logo;
|
||||
@ApiModelProperty(value = "在售商品数量")
|
||||
private Integer prodCount;
|
||||
@ApiModelProperty(value = "商品浏览量")
|
||||
private Long viewCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -304,5 +304,13 @@ public class CacheConstants {
|
|||
* 档口访问次数
|
||||
*/
|
||||
public static final String STORE_VISIT_COUNT = "store_visit_count";
|
||||
/**
|
||||
* 档口访问次数缓存
|
||||
*/
|
||||
public static final String STORE_VISIT_COUNT_CACHE = "store_visit_count_cache";
|
||||
/**
|
||||
* 档口商品访问次数缓存
|
||||
*/
|
||||
public static final String STORE_PROD_VIEW_COUNT_CACHE = "store_prod_view_count_cache";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.xkt.dto.store;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class StoreAppViewRankResDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口浏览量列表")
|
||||
private List<SAVRViewCountDTO> viewCountList;
|
||||
|
||||
@Data
|
||||
public static class SAVRViewCountDTO {
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
private Integer memberLevel;
|
||||
@ApiModelProperty(value = "logo")
|
||||
private String logo;
|
||||
@ApiModelProperty(value = "在售商品数量")
|
||||
private Integer prodCount;
|
||||
@ApiModelProperty(value = "商品浏览量")
|
||||
private Long viewCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,12 +2,14 @@ package com.ruoyi.xkt.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.Store;
|
||||
import com.ruoyi.xkt.dto.store.StoreAppViewRankResDTO;
|
||||
import com.ruoyi.xkt.dto.store.StorePageDTO;
|
||||
import com.ruoyi.xkt.dto.store.StorePageResDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreSimpleResDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -35,4 +37,11 @@ public interface StoreMapper extends BaseMapper<Store> {
|
|||
*/
|
||||
StoreSimpleResDTO getSimpleInfo(@Param("storeId") Long storeId);
|
||||
|
||||
/**
|
||||
* 获取档口访问榜 过去3个月到现在
|
||||
* @param threeMonthAgo 三个月前
|
||||
* @param yesterday 昨天
|
||||
* @return
|
||||
*/
|
||||
List<StoreAppViewRankResDTO.SAVRViewCountDTO> selectTop10AppViewCount(@Param("threeMonthAgo") Date threeMonthAgo, @Param("yesterday") Date yesterday);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,4 +191,10 @@ public interface IStoreService {
|
|||
*/
|
||||
Integer updateStockSys(StoreUpdateStockSysDTO stockSysDTO);
|
||||
|
||||
/**
|
||||
* 获取APP档口浏览量排行榜
|
||||
*
|
||||
* @return StoreAppViewRankResDTO
|
||||
*/
|
||||
StoreAppViewRankResDTO getAppViewRank();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.xkt.dto.StoreProductStatistics.StoreProdAppViewRankResDTO;
|
||||
import com.ruoyi.xkt.mapper.StoreProductStatisticsMapper;
|
||||
import com.ruoyi.xkt.service.IStoreProductStatisticsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 档口商品统计 服务层实现
|
||||
|
|
@ -20,6 +26,7 @@ import java.util.Date;
|
|||
public class StoreProductStatisticsServiceImpl implements IStoreProductStatisticsService {
|
||||
|
||||
final StoreProductStatisticsMapper prodStatisticsMapper;
|
||||
final RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 档口商品访问榜
|
||||
|
|
@ -29,9 +36,22 @@ public class StoreProductStatisticsServiceImpl implements IStoreProductStatistic
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreProdAppViewRankResDTO getAppViewRank() {
|
||||
// 从redis中获取商品访问量
|
||||
StoreProdAppViewRankResDTO redisAppViewRank = redisCache.getCacheObject(CacheConstants.STORE_PROD_VIEW_COUNT_CACHE);
|
||||
if (ObjectUtils.isNotEmpty(redisAppViewRank)) {
|
||||
return redisAppViewRank;
|
||||
}
|
||||
redisAppViewRank = new StoreProdAppViewRankResDTO();
|
||||
final Date yesterday = java.sql.Date.valueOf(LocalDate.now().minusDays(1));
|
||||
final Date threeMonthAgo = java.sql.Date.valueOf(LocalDate.now().minusDays(1).minusMonths(3));
|
||||
return new StoreProdAppViewRankResDTO().setViewCountList(prodStatisticsMapper.selectTop10ProdViewCount(threeMonthAgo, yesterday));
|
||||
List<StoreProdAppViewRankResDTO.SPAVRViewCountDTO> viewCountList = prodStatisticsMapper.selectTop10ProdViewCount(threeMonthAgo, yesterday);
|
||||
if (CollectionUtils.isEmpty(viewCountList)) {
|
||||
return redisAppViewRank;
|
||||
}
|
||||
redisAppViewRank.setViewCountList(viewCountList);
|
||||
// 放到redis中
|
||||
redisCache.setCacheObject(CacheConstants.STORE_PROD_VIEW_COUNT_CACHE, redisAppViewRank, 1, TimeUnit.DAYS);
|
||||
return redisAppViewRank;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -392,6 +393,44 @@ public class StoreServiceImpl implements IStoreService {
|
|||
return this.storeMapper.updateById(store);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APP档口浏览量排行榜
|
||||
*
|
||||
* @return StoreAppViewRankResDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreAppViewRankResDTO getAppViewRank() {
|
||||
// 从redis中获取档口访问量
|
||||
StoreAppViewRankResDTO redisAppViewRank = redisCache.getCacheObject(CacheConstants.STORE_VISIT_COUNT_CACHE);
|
||||
if (ObjectUtils.isNotEmpty(redisAppViewRank)) {
|
||||
return redisAppViewRank;
|
||||
}
|
||||
final Date yesterday = java.sql.Date.valueOf(LocalDate.now().minusDays(1));
|
||||
final Date threeMonthAgo = java.sql.Date.valueOf(LocalDate.now().minusDays(1).minusMonths(3));
|
||||
List<StoreAppViewRankResDTO.SAVRViewCountDTO> viewCountList = this.storeMapper.selectTop10AppViewCount(threeMonthAgo, yesterday);
|
||||
redisAppViewRank = new StoreAppViewRankResDTO();
|
||||
if (CollectionUtils.isEmpty(viewCountList)) {
|
||||
return redisAppViewRank;
|
||||
}
|
||||
// 获取档口商品总数
|
||||
List<StoreProduct> storeProdList = this.storeProdMapper.selectList(new LambdaQueryWrapper<StoreProduct>()
|
||||
.in(StoreProduct::getStoreId, viewCountList.stream().map(StoreAppViewRankResDTO.SAVRViewCountDTO::getStoreId).collect(Collectors.toList()))
|
||||
.eq(StoreProduct::getDelFlag, Constants.UNDELETED));
|
||||
Map<Long, Integer> prodCountMap = storeProdList.stream().collect(Collectors.groupingBy(StoreProduct::getStoreId, Collectors.summingInt(x -> 1)));
|
||||
// 获取档口会员
|
||||
viewCountList.forEach(x -> {
|
||||
// 查询档口会员等级
|
||||
StoreMember member = this.redisCache.getCacheObject(CacheConstants.STORE_MEMBER + x.getStoreId());
|
||||
x.setMemberLevel(ObjectUtils.isNotEmpty(member) ? member.getLevel() : null);
|
||||
x.setProdCount(prodCountMap.getOrDefault(x.getStoreId(), 0));
|
||||
});
|
||||
redisAppViewRank.setViewCountList(viewCountList);
|
||||
// 放到redis中
|
||||
redisCache.setCacheObject(CacheConstants.STORE_VISIT_COUNT_CACHE, redisAppViewRank, 1, TimeUnit.DAYS);
|
||||
return redisAppViewRank;
|
||||
}
|
||||
|
||||
/**
|
||||
* 档口首页今日销售额
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,5 +41,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
s.id = #{storeId}
|
||||
</select>
|
||||
|
||||
<select id="selectTop10AppViewCount">
|
||||
SELECT
|
||||
s.id AS storeId,
|
||||
s.store_name,
|
||||
sf.file_url AS logo,
|
||||
s.view_count
|
||||
FROM
|
||||
store s
|
||||
LEFT JOIN sys_file sf ON s.store_logo_id = sf.id
|
||||
WHERE
|
||||
s.del_flag = 0
|
||||
ORDER BY
|
||||
s.view_count DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue