浏览代码

fix:红包剩余数量问题

zhangqin 1 月之前
父节点
当前提交
c6ba48003d

+ 10 - 0
fs-common/src/main/java/com/fs/common/core/redis/RedisUtil.java

@@ -223,6 +223,16 @@ public class RedisUtil {
         return redisTemplate.opsForHash().entries(key);
     }
 
+    /**
+     * 获取哈希表中数量
+     *
+     * @param key 哈希表键
+     * @return 键值对映射
+     */
+    public Long size(String key) {
+        return redisTemplate.opsForHash().size(key);
+    }
+
     // ======================== ZSet 操作 ========================
 
     /**

+ 1 - 1
fs-service-system/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java

@@ -319,7 +319,7 @@ public class LiveRedConfServiceImpl implements ILiveRedConfService {
         // 更新数据库
         Date now = new Date();
         Integer remaining = getRemaining(red.getRedId());
-        red.setTotalSend(red.getTotalLots() - remaining);
+        red.setTotalSend(redisUtil.size(String.format(LiveKeysConstant.LIVE_HOME_PAGE_CONFIG_RED, red.getLiveId(), red.getRedId())));
         red.setRemaining(remaining);
         red.setUpdateTime(now);
         baseMapper.updateLiveRedConf(red);