init
This commit is contained in:
@@ -61,6 +61,14 @@ public class UserGiftServiceImpl extends ServiceImpl<UserGiftMapper, UserGift> i
|
|||||||
if(gift == null){
|
if(gift == null){
|
||||||
throw new ServiceException("礼物不存在");
|
throw new ServiceException("礼物不存在");
|
||||||
}
|
}
|
||||||
|
User toUser = userService.getById(query.getToUserId());
|
||||||
|
Anchor anchor = anchorService.getByUserId(query.getToUserId());
|
||||||
|
if(toUser == null){
|
||||||
|
throw new ServiceException("主播不存在");
|
||||||
|
}
|
||||||
|
if(anchor == null){
|
||||||
|
throw new ServiceException("只能给主播送礼物哦");
|
||||||
|
}
|
||||||
String guardLock = LockManager.getSendGuardLock(fromUserId);
|
String guardLock = LockManager.getSendGuardLock(fromUserId);
|
||||||
RLock lock = redissonClient.getLock(guardLock);
|
RLock lock = redissonClient.getLock(guardLock);
|
||||||
if(lock.isLocked()){
|
if(lock.isLocked()){
|
||||||
@@ -71,8 +79,6 @@ public class UserGiftServiceImpl extends ServiceImpl<UserGiftMapper, UserGift> i
|
|||||||
try {
|
try {
|
||||||
lock.lock(3, TimeUnit.SECONDS);
|
lock.lock(3, TimeUnit.SECONDS);
|
||||||
User fromUser = userService.getById(fromUserId);
|
User fromUser = userService.getById(fromUserId);
|
||||||
User toUser = userService.getById(query.getToUserId());
|
|
||||||
Anchor anchor = anchorService.getByUserId(query.getToUserId());
|
|
||||||
Long price = gift.getPrice();
|
Long price = gift.getPrice();
|
||||||
Long traceId = IdManager.nextId();
|
Long traceId = IdManager.nextId();
|
||||||
Long giftAmount = query.getGiftCount() * price;
|
Long giftAmount = query.getGiftCount() * price;
|
||||||
|
|||||||
Reference in New Issue
Block a user