Commit c7fd5fac authored by tangtuo's avatar tangtuo

修改判断用户是否已经领取纪念币的方法

parent 13907747
...@@ -56,6 +56,14 @@ ...@@ -56,6 +56,14 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -29,7 +29,7 @@ public class RedisConstant { ...@@ -29,7 +29,7 @@ public class RedisConstant {
/** /**
* 纪念版nft领取成员列表 * 纪念版nft领取成员列表
*/ */
public static final String COMMEMORATE_NFT_MEMBERS_PREFIX = "commemorateNft:members:"; public static final String COMMEMORATE_NFT_MEMBERS_PREFIX = "commemorate-nft:members:";
......
...@@ -119,9 +119,12 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper, ...@@ -119,9 +119,12 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper,
} }
// 先判断当前用户有没有领取过此纪念版nft // 先判断当前用户有没有领取过此纪念版nft
if (redisUtil.sIsMember(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString())) { if (redisUtil.zScore(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString()) != null) {
throw GlobalException.newException(ResultCode.FAILED, "此纪念版nft每个用户只能领取一次"); throw GlobalException.newException(ResultCode.FAILED, "此纪念版nft每个用户只能领取一次");
} }
/*if (redisUtil.sIsMember(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString())) {
throw GlobalException.newException(ResultCode.FAILED, "此纪念版nft每个用户只能领取一次");
}*/
// 获取此纪念版nft发行数的信号量 // 获取此纪念版nft发行数的信号量
RSemaphore semaphore = redisson.getSemaphore(RedisConstant.COMMEMORATE_NFT_PREFIX + id); RSemaphore semaphore = redisson.getSemaphore(RedisConstant.COMMEMORATE_NFT_PREFIX + id);
// 判断纪念版nft有没有被领取完 // 判断纪念版nft有没有被领取完
...@@ -161,7 +164,8 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper, ...@@ -161,7 +164,8 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper,
nft.setIsCommemorate(SystemConstant.BOOLEAN_DATA_TRUE); nft.setIsCommemorate(SystemConstant.BOOLEAN_DATA_TRUE);
nftService.save(nft); nftService.save(nft);
// 领取完毕,把当前用户id加入到纪念版nft的领取记录中 // 领取完毕,把当前用户id加入到纪念版nft的领取记录中
redisUtil.sAdd(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString()); redisUtil.zAdd(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString(), availablePermits);
//redisUtil.sAdd(RedisConstant.COMMEMORATE_NFT_MEMBERS_PREFIX + id, user.getId().toString());
return true; return true;
} finally { } finally {
lock.unlock(); lock.unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment