xiongzhu 3 anos atrás
pai
commit
0cd8332621

+ 6 - 2
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -361,7 +361,9 @@ public class CollectionService {
     public synchronized Long increaseStock(Long id, int number) {
         BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps("collectionStock::" + id);
         if (ops.get() == null) {
-            ops.setIfAbsent(Optional.ofNullable(collectionRepo.getStock(id)).orElse(0), 7, TimeUnit.DAYS);
+            Boolean success = ops.setIfAbsent(Optional.ofNullable(collectionRepo.getStock(id))
+                    .orElse(0), 7, TimeUnit.DAYS);
+            log.info("创建redis库存:{}", success);
         }
         Long stock = ops.increment(number);
         rocketMQTemplate.convertAndSend(generalProperties.getUpdateStockTopic(), id);
@@ -375,7 +377,9 @@ public class CollectionService {
     public synchronized Long increaseSale(Long id, int number) {
         BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps("collectionSale::" + id);
         if (ops.get() == null) {
-            ops.setIfAbsent(Optional.ofNullable(collectionRepo.getStock(id)).orElse(0), 7, TimeUnit.DAYS);
+            Boolean success = ops.setIfAbsent(Optional.ofNullable(collectionRepo.getStock(id))
+                    .orElse(0), 7, TimeUnit.DAYS);
+            log.info("创建redis销量:{}", success);
         }
         Long sale = ops.increment(number);
         rocketMQTemplate.convertAndSend(generalProperties.getUpdateSaleTopic(), id);