|
|
@@ -12,6 +12,8 @@ import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.json.utils.JsonUtils;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.server.common.util.CardDateUtils;
|
|
|
+import org.dromara.server.consume.cache.CardCacheManager;
|
|
|
+import org.dromara.server.consume.cache.UserAccountCacheManager;
|
|
|
import org.dromara.server.consume.cache.ValidationParam;
|
|
|
import org.dromara.server.consume.domain.bo.XfCardLimitedBo;
|
|
|
import org.dromara.server.consume.domain.vo.PtBagVo;
|
|
|
@@ -48,6 +50,8 @@ public class InitBusiness {
|
|
|
private final IXfCardLimitedService cardLimitedService;
|
|
|
private final IXfTermService xfTermService;
|
|
|
private final ValidationParam validationParam;
|
|
|
+ private final CardCacheManager cardCacheManager;
|
|
|
+ private final UserAccountCacheManager userAccountCacheManager;
|
|
|
|
|
|
@DubboReference
|
|
|
private final RemotePtParameterService remotePtParameterService;
|
|
|
@@ -165,16 +169,15 @@ public class InitBusiness {
|
|
|
*/
|
|
|
public void initUserBalance() {
|
|
|
List<PtBagVo> list = bagService.selectBalanceBag();
|
|
|
- Map<String, BigDecimal> sumMap = new HashMap<>();
|
|
|
+ Map<Long, BigDecimal> sumMap = new HashMap<>();
|
|
|
for (PtBagVo vo : list) {
|
|
|
- String userId = String.valueOf(vo.getUserId());
|
|
|
+ Long userId = vo.getUserId();
|
|
|
BigDecimal amount = vo.getBalance();
|
|
|
sumMap.merge(userId, amount, BigDecimal::add);
|
|
|
}
|
|
|
- for (Map.Entry<String, BigDecimal> entry : sumMap.entrySet()) {
|
|
|
- RedisUtils.setCacheMapValue(CacheNames.USER_TOTAL_BALANCE, entry.getKey(), entry.getValue());
|
|
|
+ for (Map.Entry<Long, BigDecimal> entry : sumMap.entrySet()) {
|
|
|
+ bagService.cacheUserTotalBalance(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
- RedisUtils.expire(CacheNames.USER_TOTAL_BALANCE, Duration.ofHours(5));
|
|
|
log.info("初始化人员余额参数完成");
|
|
|
}
|
|
|
|
|
|
@@ -194,15 +197,7 @@ public class InitBusiness {
|
|
|
public void initUserCard() {
|
|
|
List<RemoteCardVo> list = remoteCardService.selectNormalCards();
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_CARD_NO);
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_CARD_USER_ID);
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_CARD_FACTORYID);
|
|
|
-
|
|
|
- list.forEach(this::resetUserCard);
|
|
|
-
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_CARD_NO, Duration.ofHours(5));
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_CARD_USER_ID, Duration.ofHours(5));
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_CARD_FACTORYID, Duration.ofHours(5));
|
|
|
+ list.forEach(cardCacheManager::cacheCardVo);
|
|
|
}
|
|
|
log.info("初始化人员卡片参数完成");
|
|
|
}
|
|
|
@@ -214,7 +209,7 @@ public class InitBusiness {
|
|
|
*/
|
|
|
public void initUserCardByUserId(Long id) {
|
|
|
RemoteCardVo cardVo = remoteCardService.queryMainCardByUserId(id);
|
|
|
- resetUserCard(cardVo);
|
|
|
+ cardCacheManager.cacheCardVo(cardVo);
|
|
|
log.info("初始指定人员卡片参数完成,人员Id:{}", id);
|
|
|
}
|
|
|
|
|
|
@@ -229,22 +224,7 @@ public class InitBusiness {
|
|
|
&& p.getLifespan().getTime() > System.currentTimeMillis()).toList();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(filterList)) {
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_ACCOUNT_ID);
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_ACCOUNT_NUMB);
|
|
|
- RedisUtils.deleteKeys(CacheNames.PT_USER_ACCOUNT_NO);
|
|
|
-
|
|
|
- filterList.parallelStream().forEach(p -> {
|
|
|
- String strUserId = String.valueOf(p.getUserId());
|
|
|
- String strUserNo = String.valueOf(p.getUserNo());
|
|
|
- String userNumb = String.valueOf(p.getUserNumb());
|
|
|
-
|
|
|
- RedisUtils.setCacheMapValue(CacheNames.PT_USER_ACCOUNT_ID, strUserId, p);
|
|
|
- RedisUtils.setCacheMapValue(CacheNames.PT_USER_ACCOUNT_NO, strUserNo, p);
|
|
|
- RedisUtils.setCacheMapValue(CacheNames.PT_USER_ACCOUNT_NUMB, userNumb, p);
|
|
|
- });
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_ACCOUNT_ID, Duration.ofHours(5));
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_ACCOUNT_NUMB, Duration.ofHours(5));
|
|
|
- RedisUtils.expire(CacheNames.PT_USER_ACCOUNT_NO, Duration.ofHours(5));
|
|
|
+ filterList.forEach(userAccountCacheManager::cacheUserAccountVo);
|
|
|
}
|
|
|
log.info("初始化人员账户参数完成");
|
|
|
}
|
|
|
@@ -256,22 +236,11 @@ public class InitBusiness {
|
|
|
* @param id 人员Id
|
|
|
*/
|
|
|
public void initUserAccountById(Long id) {
|
|
|
- // RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoById(id);
|
|
|
- // if (ObjectUtil.isNotEmpty(accountVo)) {
|
|
|
- // List<RemoteUserAccountVo> list = RedisUtils.getCacheList(CacheNames.PT_USER_ACCOUNT_LIST);
|
|
|
- // String strUserId = String.valueOf(id);
|
|
|
- // String strUserNo = String.valueOf(accountVo.getUserNo());
|
|
|
- //
|
|
|
- // RedisUtils.delCacheMapValue(CacheNames.PT_USER_ACCOUNT_ID, strUserId);
|
|
|
- // RedisUtils.delCacheMapValue(CacheNames.PT_USER_ACCOUNT_NO, strUserNo);
|
|
|
- //
|
|
|
- // RedisUtils.setCacheMapValue(CacheNames.PT_USER_ACCOUNT_ID, strUserId, accountVo);
|
|
|
- // RedisUtils.setCacheMapValue(CacheNames.PT_USER_ACCOUNT_NO, strUserNo, accountVo);
|
|
|
- //
|
|
|
- // BigDecimal balance = bagService.getUserBalance(id);
|
|
|
- // RedisUtils.delCacheMapValue(CacheNames.PT_USER_CARD_NO, strUserId);
|
|
|
- // RedisUtils.setCacheMapValue(CacheNames.USER_TOTAL_BALANCE, strUserId, balance);
|
|
|
- // }
|
|
|
+ RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoById(id);
|
|
|
+ if (ObjectUtil.isNotEmpty(accountVo)) {
|
|
|
+ userAccountCacheManager.cacheUserAccountVo(accountVo);
|
|
|
+ }
|
|
|
+
|
|
|
log.info("初始化指定人员账户参数完成,人员Id:{}", id);
|
|
|
}
|
|
|
|
|
|
@@ -282,11 +251,7 @@ public class InitBusiness {
|
|
|
XfCardLimitedBo bo = new XfCardLimitedBo();
|
|
|
List<XfCardLimitedVo> list = cardLimitedService.queryList(bo);
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
- RedisUtils.deleteKeys(CacheNames.T_XF_CARD_LIMITED);
|
|
|
- list.forEach(p -> {
|
|
|
- RedisUtils.setCacheMapValue(CacheNames.T_XF_CARD_LIMITED, p.getCardNo().toString(), JsonUtils.toJsonString(p));
|
|
|
- });
|
|
|
- RedisUtils.expire(CacheNames.T_XF_CARD_LIMITED, Duration.ofHours(5));
|
|
|
+ list.forEach(cardLimitedService::cacheLimitedAndOther);
|
|
|
}
|
|
|
log.info("卡片消费限制参数完成");
|
|
|
}
|