瀏覽代碼

fix: 消费服务
1.原始消费记录入缓存方式修改

luoyb 10 月之前
父節點
當前提交
151b1c7071

+ 5 - 5
ruoyi-server/ruoyi-server-consume/src/main/java/org/dromara/server/consume/check/ConsumeRequestCheck.java

@@ -173,22 +173,22 @@ public class ConsumeRequestCheck {
      * @return 如果原始消费记录ID重复,返回包含错误信息的响应对象;否则返回成功的响应对象
      */
     private R<ErrorInfo> checkRepeatOriginalId(ConsumptionBo bo) {
-
         String originalId = bo.getOriginalId();
         if (ObjectUtil.isEmpty(originalId)) {
             originalId = RecordIdUtils.getRecordId(bo.getConsumeDate(), bo.getTermNo().intValue(),
                 bo.getTermRecordId().intValue(), bo.getUserNo().intValue(), 0);
         }
-        String originalIdCache = RedisUtils.getCacheMapValue(CacheNames.XF_ORIGINAL_ID, originalId);
-        if (originalIdCache != null && originalIdCache.equals(originalId)) {
+        //String originalIdCache = RedisUtils.getCacheObject(CacheNames.XF_ORIGINAL_ID+ ":"+ originalId);
+        //if (originalIdCache != null && originalIdCache.equals(originalId)) {
+        if (RedisUtils.hasKey(CacheNames.XF_ORIGINAL_ID+ ":"+ originalId)) {
             return commonCheck.createErrorResponse(400, ApiErrorTypeConstants.CONSUME_CHECK_FAIL, "原始消费记录存在",
                 MessageFormat.format("原始消费记录已存在:{0}", originalId));
         }
         bo.setOriginalId(originalId);
 
         // 将当笔原始消费记录标识放入缓存,4小时过期
-        RedisUtils.setCacheMapValue(CacheNames.XF_ORIGINAL_ID, originalId, originalId);
-        RedisUtils.expire(CacheNames.XF_ORIGINAL_ID, Duration.ofHours(4));
+        RedisUtils.setCacheObject(CacheNames.XF_ORIGINAL_ID+ ":"+ originalId, "",Duration.ofHours(1));
+        //RedisUtils.expire(CacheNames.XF_ORIGINAL_ID, Duration.ofHours(4));
 
         return R.ok();
     }