master:代码调优;

pull/1121/head
liujiang 2025-07-01 10:14:49 +08:00
parent e9c87aa386
commit eb13dd4217
9 changed files with 49 additions and 26 deletions

View File

@ -36,6 +36,12 @@ public class StoreController extends XktBaseController {
final ISysUserService userService;
final TokenService tokenService;
// TODO 获取试用期即将到期的档口
// TODO 获取获取正式使用即将到期的档口
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
@ApiOperation(value = "模糊查询档口", httpMethod = "GET", response = R.class)
@Log(title = "模糊查询档口", businessType = BusinessType.UPDATE)

View File

@ -38,5 +38,8 @@ public class StoreMemberController extends XktBaseController {
return R.ok(storeMemberService.create(BeanUtil.toBean(createVO, StoreMemberCreateDTO.class)));
}
// TODO 每天获取档口会员过期提醒
// TODO 每天获取档口会员过期提醒
}

View File

@ -285,7 +285,7 @@ public class WebsiteController extends XktBaseController {
return R.ok(websiteAPPService. getAppCateProdSaleTop3List());
}
@ApiOperation(value = "APP 商品榜 分类销量 二级列表", httpMethod = "GET", response = R.class)
@ApiOperation(value = "APP 商品榜 分类销量 次级详情列表", httpMethod = "GET", response = R.class)
@GetMapping("/app/prod/cate/sub/{prodCateId}")
public R<List<APPProdCateSubDTO>> getAppCateSubProdSaleList(@PathVariable Long prodCateId) throws IOException {
return R.ok(websiteAPPService. getAppCateSubProdSaleList(prodCateId));

View File

@ -268,11 +268,11 @@ public class CacheConstants {
/**
* top100
*/
public static final String TOP_100_SALE_PROD = "top_100_sale_prod";
public static final String TOP_50_SALE_PROD = "top_50_sale_prod";
/**
* 100
*/
public static final String CATE_TOP_100_SALE_PROD = "cate_top_100_sale_prod";
public static final String CATE_TOP_50_SALE_PROD = "cate_top_50_sale_prod";
}

View File

@ -114,6 +114,12 @@ public class DailyTaskController extends BaseController {
return R.ok();
}
@PostMapping("/store-memeber")
public R expireStoreMember(SysJob sysJob) {
task.autoCloseExpireStoreMember();
return R.ok();
}

View File

@ -114,6 +114,7 @@ public class XktTask {
final NoticeMapper noticeMapper;
final UserNoticeMapper userNoticeMapper;
final UserSubscriptionsMapper userSubMapper;
final StoreMemberMapper storeMemberMapper;
/**
* 316191121
@ -710,12 +711,17 @@ public class XktTask {
* 2:45
*/
public void autoCloseExpireStoreMember() {
// TODO 更新档口过期会员 删除ES中商品标识
// TODO 更新档口过期会员 删除ES中商品标识
// TODO 更新档口过期会员 删除ES中商品标识
// this.storeMapper.updateExpireStoreMember();
final Date yesterday = java.sql.Date.valueOf(LocalDate.now().minusDays(1));
// 截止昨天,会员过期的档口
List<StoreMember> expireList = this.storeMemberMapper.selectList(new LambdaQueryWrapper<StoreMember>()
.eq(StoreMember::getDelFlag, Constants.UNDELETED).eq(StoreMember::getEndTime, yesterday));
if (CollectionUtils.isEmpty(expireList)) {
return;
}
expireList.forEach(x -> x.setDelFlag(Constants.DELETED));
this.storeMemberMapper.updateById(expireList);
// 删除redis中过期会员
expireList.forEach(x -> redisCache.deleteObject(CacheConstants.STORE_MEMBER + x.getId()));
}
/**
@ -725,17 +731,17 @@ public class XktTask {
final Date oneMonthAgo = java.sql.Date.valueOf(LocalDate.now().minusMonths(1));
final Date now = java.sql.Date.valueOf(LocalDate.now());
// 销量前100的ID列表直接放到redis中
List<DailyStoreProdSaleDTO> top100ProdList = this.dailySaleProdMapper.prodSaleTop100List(oneMonthAgo, now);
if (CollectionUtils.isNotEmpty(top100ProdList)) {
redisCache.setCacheObject(CacheConstants.TOP_100_SALE_PROD, top100ProdList);
List<DailyStoreProdSaleDTO> top50ProdList = this.dailySaleProdMapper.prodSaleTop50List(oneMonthAgo, now);
if (CollectionUtils.isNotEmpty(top50ProdList)) {
redisCache.setCacheObject(CacheConstants.TOP_50_SALE_PROD, top50ProdList);
}
// 按照商品分类来进行销量排序
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = this.dailySaleProdMapper.prodCateSaleTop100List(oneMonthAgo, now);
if (CollectionUtils.isEmpty(cateSaleTop100ProdList)) {
List<DailyStoreProdSaleDTO> cateSaleTop50ProdList = this.dailySaleProdMapper.prodCateSaleTop50List(oneMonthAgo, now);
if (CollectionUtils.isEmpty(cateSaleTop50ProdList)) {
return;
}
// 将各个分类销量数据存到redis中
redisCache.setCacheObject(CacheConstants.CATE_TOP_100_SALE_PROD, cateSaleTop100ProdList);
redisCache.setCacheObject(CacheConstants.CATE_TOP_50_SALE_PROD, cateSaleTop50ProdList);
}

View File

@ -130,7 +130,7 @@
LIMIT 10
</select>
<select id="prodSaleTop100List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
<select id="prodSaleTop50List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
SELECT
dsp.store_prod_id,
COUNT( dsp.sale_num ) AS count
@ -147,7 +147,7 @@
LIMIT 100
</select>
<select id="prodCateSaleTop100List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
<select id="prodCateSaleTop50List" resultType="com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO">
WITH ranked_products AS (
SELECT
sp.prod_cate_id,
@ -172,7 +172,7 @@
FROM
ranked_products
WHERE
rank_in_category &lt;= 100
rank_in_category &lt;= 50
ORDER BY
prod_cate_id,
sale_count DESC;

View File

@ -74,18 +74,20 @@ public interface DailySaleProductMapper extends BaseMapper<DailySaleProduct> {
/**
* 100
*
* @param oneMonthAgo
* @param yesterday
* @param yesterday
* @return List<DailyStoreProdSaleDTO>
*/
List<DailyStoreProdSaleDTO> prodSaleTop100List(@Param("oneMonthAgo") Date oneMonthAgo, @Param("yesterday") Date yesterday);
List<DailyStoreProdSaleDTO> prodSaleTop50List(@Param("oneMonthAgo") Date oneMonthAgo, @Param("yesterday") Date yesterday);
/**
*
*
* @param oneMonthAgo
* @param yesterday
* @param yesterday
* @return List<DailyStoreProdSaleDTO>
*/
List<DailyStoreProdSaleDTO> prodCateSaleTop100List(@Param("oneMonthAgo") Date oneMonthAgo, @Param("yesterday") Date yesterday);
List<DailyStoreProdSaleDTO> prodCateSaleTop50List(@Param("oneMonthAgo") Date oneMonthAgo, @Param("yesterday") Date yesterday);
}

View File

@ -380,7 +380,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
@Transactional(readOnly = true)
public List<APPProdSaleDTO> getAppProdSaleTop100List() throws IOException {
// 从redis中获取销量前100的商品
List<DailyStoreProdSaleDTO> top100ProdList = redisCache.getCacheObject(CacheConstants.TOP_100_SALE_PROD);
List<DailyStoreProdSaleDTO> top100ProdList = redisCache.getCacheObject(CacheConstants.TOP_50_SALE_PROD);
if (CollectionUtils.isEmpty(top100ProdList)) {
return Collections.emptyList();
}
@ -419,7 +419,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
@Override
@Transactional(readOnly = true)
public List<APPProdCateTop3DTO> getAppCateProdSaleTop3List() throws IOException {
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_100_SALE_PROD);
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_50_SALE_PROD);
if (CollectionUtils.isEmpty(cateSaleTop100ProdList)) {
return new ArrayList<>();
}
@ -471,7 +471,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
@Override
@Transactional(readOnly = true)
public List<APPProdCateSubDTO> getAppCateSubProdSaleList(Long prodCateId) throws IOException {
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_100_SALE_PROD);
List<DailyStoreProdSaleDTO> cateSaleTop100ProdList = redisCache.getCacheObject(CacheConstants.CATE_TOP_50_SALE_PROD);
if (CollectionUtils.isEmpty(cateSaleTop100ProdList)) {
return new ArrayList<>();
}
@ -484,7 +484,7 @@ public class WebsiteAPPServiceImpl implements IWebsiteAPPService {
searchDTO.setProdCateIdList(Collections.singletonList(prodCateId.toString()));
searchDTO.setProdIdList(prodIdList);
searchDTO.setPageNum(1);
searchDTO.setPageSize(1000);
searchDTO.setPageSize(100);
searchDTO.setSort("recommendWeight");
Page<ESProductDTO> page = this.search(searchDTO);
Long userId = SecurityUtils.getUserIdSafe();