master:档口访问量功能完善;
parent
ac0720f3f4
commit
47dea21304
|
|
@ -300,6 +300,9 @@ public class CacheConstants {
|
|||
* 充值单号缓存
|
||||
*/
|
||||
public static final String RECHARGE_BILL_NO_CACHE = "recharge_bill_no_cache:";
|
||||
|
||||
/**
|
||||
* 档口访问次数
|
||||
*/
|
||||
public static final String STORE_VISIT_COUNT = "store_visit_count";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -804,6 +804,32 @@ public class XktTask {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 凌晨2:05更新档口访问量
|
||||
*/
|
||||
@Transactional
|
||||
public void updateStoreVisitCount() {
|
||||
// 档口访问量
|
||||
Map<String, Long> storeVisitMap = redisCache.getCacheMap(CacheConstants.STORE_VISIT_COUNT);
|
||||
if (MapUtil.isEmpty(storeVisitMap)) {
|
||||
return;
|
||||
}
|
||||
List<Store> storeList = this.storeMapper.selectList(new LambdaQueryWrapper<Store>()
|
||||
.eq(Store::getDelFlag, Constants.UNDELETED));
|
||||
if (CollectionUtils.isEmpty(storeList)) {
|
||||
return;
|
||||
}
|
||||
storeList.forEach(store -> {
|
||||
Long viewCount = storeVisitMap.getOrDefault(store.getId().toString(), 0L);
|
||||
Long existViewCount = ObjectUtils.defaultIfNull(store.getViewCount(), 0L);
|
||||
store.setViewCount(existViewCount + viewCount);
|
||||
// 清除当日缓存
|
||||
redisCache.deleteCacheMapValue(CacheConstants.STORE_VISIT_COUNT, store.getId().toString());
|
||||
});
|
||||
// 更新档口访问量
|
||||
this.storeMapper.updateById(storeList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每晚22:00:10 更新广告位竞价状态 将biddingTempStatus赋值给biddingStatus
|
||||
|
|
|
|||
|
|
@ -144,5 +144,9 @@ public class Store extends XktBaseEntity {
|
|||
* 库存系统 1步橘 2天友 3发货宝
|
||||
*/
|
||||
private Integer stockSys;
|
||||
/**
|
||||
* 档口浏览量
|
||||
*/
|
||||
private Long viewCount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,6 +217,8 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreAppResDTO getAppInfo(Long storeId) {
|
||||
// 档口访问次数+1
|
||||
redisCache.valueIncr(CacheConstants.STORE_VISIT_COUNT, storeId);
|
||||
Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>()
|
||||
.eq(Store::getId, storeId).eq(Store::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
|
||||
|
|
@ -480,6 +482,8 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreSimpleResDTO getSimpleInfo(Long storeId) {
|
||||
// 档口访问次数+1
|
||||
redisCache.valueIncr(CacheConstants.STORE_VISIT_COUNT, storeId);
|
||||
StoreSimpleResDTO simpleDTO = this.storeMapper.getSimpleInfo(storeId);
|
||||
// 获取档口LOGO
|
||||
if (ObjectUtils.isNotEmpty(simpleDTO.getStoreLogoId())) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue