|
|
@@ -19,13 +19,18 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
@Override
|
|
|
public Order createOrder(int userId, int productId, PlatformType platformType, double price) {
|
|
|
+ Order existOrder=orderRepository.findByUserIdAndProductIdAndPlatformType(userId,productId,platformType);
|
|
|
+ if (existOrder !=null)
|
|
|
+ return null;
|
|
|
Order order=new Order(price,platformType,userId,productId, OrderStatus.PROCESSING, LocalDateTime.now());
|
|
|
- Order newOrder=orderRepository.saveAndFlush(order);
|
|
|
- return newOrder;
|
|
|
+ order=orderRepository.saveAndFlush(order);
|
|
|
+ return order;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean hasOrder(int userId, int productId, PlatformType platformType) {
|
|
|
+ if (orderRepository.findByUserIdAndProductIdAndPlatformType(userId,productId,platformType) !=null)
|
|
|
+ return true;
|
|
|
return false;
|
|
|
}
|
|
|
|