|
@@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Assert;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -272,7 +273,14 @@ public class UserHitPrizeServiceImpl extends ServiceImpl<UserHitPrizeMapper, Use
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void cashPrize(Ticket ticket, Long userId, String awardsId, String prizeId) {
|
|
|
// 更新奖品已兑奖数量
|
|
|
- TicketAwardsPrize ticketAwardsPrize = ticketAwardsPrizeService.getById(prizeId);
|
|
|
+// TicketAwardsPrize ticketAwardsPrize = ticketAwardsPrizeService.getById(prizeId);
|
|
|
+ QueryWrapper<TicketAwardsPrize> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("t1.prize_id", prizeId);
|
|
|
+ List<TicketAwardsPrize> ticketAwardsPrizeList = ticketAwardsPrizeService.listByQueryWrapper(queryWrapper);
|
|
|
+ if (CollectionUtils.isEmpty(ticketAwardsPrizeList)) {
|
|
|
+ throw new ServiceException("奖品不存在");
|
|
|
+ }
|
|
|
+ TicketAwardsPrize ticketAwardsPrize = ticketAwardsPrizeList.get(0);
|
|
|
if (ticketAwardsPrize.getRemainQty() <= 0) {
|
|
|
throw new ServiceException("奖品已兑完,请重新选择");
|
|
|
}
|