|
|
@@ -30,10 +30,10 @@ public class TransactionServiceImpl extends ServiceImpl<TransactionRecordMapper,
|
|
|
public TransactionRecord purchase(Integer bookId, Integer buyerId, Integer quantity) {
|
|
|
Book book = bookService.getById(bookId);
|
|
|
if (book == null) {
|
|
|
- throw new RuntimeException("Book not found");
|
|
|
+ throw new RuntimeException("书籍不存在");
|
|
|
}
|
|
|
if (book.getStock() < quantity) {
|
|
|
- throw new RuntimeException("Insufficient stock");
|
|
|
+ throw new RuntimeException("库存不足");
|
|
|
}
|
|
|
|
|
|
book.setStock(book.getStock() - quantity);
|