feat:更新缓存
This commit is contained in:
1 parent
7f8f160863
commit
a4fce1c895
8 files changed
+62
-4
No files matched your search
+3
@@ -141,6 +141,9 @@ public interface CacheConstants {
|
||||
|
||||
String WALLET_RULE_PRICE_CONFIG_DETAIL = "wallet:detail:rule_price_config";
|
||||
|
||||
// 用户消费机的额外价格
|
||||
String WALLET_USER_DISCOUNTS_LIST = "wallet:detail:user_discounts_list";
|
||||
|
||||
/* ************************************* end 钱包相关 end ************************************* */
|
||||
|
||||
/* ************************************* start 第三方对接相关 start ************************************* */
|
||||
|
||||
+1
-1
@@ -461,7 +461,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
|
||||
|
||||
private void disposeList(HardDoorFlowVo detail) {
|
||||
// 用户
|
||||
List<UserVO> usrList = remoteUserService.getUserDeptByIds(List.of(detail.getUserId())).getData();
|
||||
List<UserVO> usrList = remoteUserService.getInnerUserDeptByIds(List.of(detail.getUserId())).getData();
|
||||
if (ObjectUtil.isNotEmpty(usrList)) {
|
||||
DataUtil.convertUserDept(detail, usrList.get(0));
|
||||
}
|
||||
|
||||
+5
-3
@@ -444,9 +444,11 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
}
|
||||
}
|
||||
// 商户
|
||||
MchManageVo mchDetail = remoteMchService.getById(totalList.getMerchantId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchDetail)) {
|
||||
WalletDataUtil.convertMch(totalList, mchDetail);
|
||||
if (ObjectUtil.isNotEmpty(totalList.getMerchantId())) {
|
||||
MchManageVo mchDetail = remoteMchService.getById(totalList.getMerchantId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchDetail)) {
|
||||
WalletDataUtil.convertMch(totalList, mchDetail);
|
||||
}
|
||||
}
|
||||
return totalList;
|
||||
}
|
||||
|
||||
+5
@@ -90,6 +90,10 @@ public interface RemoteUserService {
|
||||
@PostMapping("/user/inner/list")
|
||||
R<List<SysUser>> getInnerUserById(@RequestBody List<Long> userIds);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/user/inner/user-dept")
|
||||
R<List<UserVO>> getInnerUserDeptByIds(@RequestBody List<Long> userIds);
|
||||
|
||||
@PostMapping("/user/user-dept")
|
||||
R<List<UserVO>> getUserDeptByIds(@RequestBody List<Long> userIds);
|
||||
|
||||
@@ -197,6 +201,7 @@ public interface RemoteUserService {
|
||||
|
||||
/**
|
||||
* 根据角色编码查询用户列表
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
|
||||
+7
@@ -469,6 +469,13 @@ public class SysUserController {
|
||||
return R.ok(userService.list(Wrappers.<SysUser>lambdaQuery().in(SysUser::getUserId, userIds)));
|
||||
}
|
||||
|
||||
@Inner
|
||||
@PostMapping("/inner/user-dept")
|
||||
public R<List<UserVO>> getInnerUserDeptByIds(@RequestBody List<Long> userIds) {
|
||||
return R.ok(userService.getUserDeptByIds(userIds));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/user-dept")
|
||||
public R<List<UserVO>> getUserDeptByIds(@RequestBody List<Long> userIds) {
|
||||
return R.ok(userService.getUserDeptByIds(userIds));
|
||||
|
||||
+31
@@ -75,10 +75,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.poi.ss.usermodel.PictureData;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@@ -90,6 +95,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -116,6 +122,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
private final SysDeptService sysDeptService;
|
||||
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Lazy
|
||||
private final SysUserFaceService sysUserFaceService;
|
||||
private final SysUserFaceMapper sysUserFaceMapper;
|
||||
@@ -372,6 +380,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUser.setNickname(userDto.getNickname());
|
||||
sysUser.setName(userDto.getName());
|
||||
sysUser.setEmail(userDto.getEmail());
|
||||
deleteDiscountsCacheByUserId(userDto.getUserId());
|
||||
return R.ok(this.updateById(sysUser));
|
||||
}
|
||||
|
||||
@@ -425,6 +434,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
remoteWalletService.createWallet(userDto.getUserId());
|
||||
remoteWalletService.userChange(userDto.getUserId(), Boolean.FALSE);
|
||||
});
|
||||
|
||||
deleteDiscountsCacheByUserId(userDto.getUserId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@@ -993,6 +1004,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
if (isConsent) {
|
||||
// 创建用户默认钱包
|
||||
remoteWalletService.createWallet(detail.getUserId());
|
||||
deleteDiscountsCacheByUserId(detail.getUserId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -1056,4 +1068,23 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
public void deleteDiscountsCacheByUserId(Long userId) {
|
||||
if (ObjectUtil.isEmpty(userId)) return;
|
||||
String pattern = CacheConstants.WALLET_USER_DISCOUNTS_LIST + "::" + userId + ":*";
|
||||
Set<String> keys = new HashSet<>();
|
||||
stringRedisTemplate.execute((RedisCallback<Void>) connection -> {
|
||||
Cursor<byte[]> cursor = connection.scan(
|
||||
ScanOptions.scanOptions().match(pattern).count(1000).build()
|
||||
);
|
||||
while (cursor.hasNext()) {
|
||||
keys.add(new String(cursor.next(), StandardCharsets.UTF_8));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
if (!keys.isEmpty()) {
|
||||
stringRedisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+9
@@ -1,5 +1,6 @@
|
||||
package com.bsd.pjcloud.wallet.controller;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||
@@ -8,6 +9,7 @@ import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletXfjDiscounts;
|
||||
import com.bsd.pjcloud.wallet.service.WalletSettingService;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -56,7 +58,14 @@ public class WalletSettingController {
|
||||
/* ************************************* end app end ************************************* */
|
||||
|
||||
/* ************************************* start android start ************************************* */
|
||||
|
||||
@GetMapping("/ad/get-discounts-list")
|
||||
@Cacheable(
|
||||
value = CacheConstants.WALLET_USER_DISCOUNTS_LIST,
|
||||
key = "#userId + ':' + #hardId",
|
||||
condition = "#userId != null && #hardId != null",
|
||||
unless = "#result == null || #result.data == null"
|
||||
)
|
||||
public R<List<WalletXfjDiscounts>> androidGetDiscountsList(@RequestParam String hardId, @RequestParam Long userId) {
|
||||
return R.ok(walletSettingService.androidGetDiscountsList(hardId, userId));
|
||||
}
|
||||
|
||||
+1
@@ -86,6 +86,7 @@ public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, W
|
||||
list = setting.getFzbDefaultXfjDiscounts();
|
||||
}
|
||||
}
|
||||
list = list.stream().filter(item -> ObjectUtil.isNotEmpty(item.getEnable()) && ObjectUtil.equals(YesNoEnum.YES.getCode(), item.getEnable())).toList();
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
discountsList.addAll(
|
||||
list.stream().map(item -> {
|
||||
|
||||
Reference in new issue
Block a user