pay
This commit is contained in:
@@ -4,6 +4,7 @@ import { OrdersService } from './orders.service';
|
||||
import { AuthGuard } from '../auth/guards/auth.guard';
|
||||
import { UserId } from '../../common/decorators/user-id.decorator';
|
||||
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||
import { AdminAuthGuard } from '../auth/guards/adminAuth.guard';
|
||||
|
||||
@ApiTags('orders')
|
||||
@Controller()
|
||||
@@ -22,8 +23,16 @@ export class OrdersController {
|
||||
@ApiBearerAuth()
|
||||
@Get('public/orders')
|
||||
@ApiOperation({ summary: 'Get all orders' })
|
||||
findAll() {
|
||||
return this.ordersService.findAll();
|
||||
findAll(@RestId() restId: string) {
|
||||
return this.ordersService.findAll(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/orders')
|
||||
@ApiOperation({ summary: 'Get all orders' })
|
||||
findAllAdmin(@RestId() restId: string) {
|
||||
return this.ordersService.findAll(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
|
||||
@@ -37,7 +37,7 @@ export class OrdersService {
|
||||
throw new BadRequestException('Payment method is required for checkout');
|
||||
}
|
||||
|
||||
const { paymentUrl } = await this.paymentsService.initializePayment(order.paymentMethod.id, order.total, order.id);
|
||||
const { paymentUrl } = await this.paymentsService.startPayment(order.id);
|
||||
|
||||
await this.cartService.clearCart(userId, restaurantId);
|
||||
|
||||
@@ -234,10 +234,10 @@ export class OrdersService {
|
||||
};
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
async findAll(restId: string) {
|
||||
const orders = await this.em.find(
|
||||
Order,
|
||||
{},
|
||||
{ restaurant: { id: restId } },
|
||||
{ populate: ['user', 'restaurant', 'deliveryMethod', 'address', 'paymentMethod'] },
|
||||
);
|
||||
if (!orders) {
|
||||
|
||||
Reference in New Issue
Block a user