update order
This commit is contained in:
@@ -93,7 +93,7 @@ export class OrderController {
|
|||||||
@UseGuards(AuthGuard)
|
@UseGuards(AuthGuard)
|
||||||
@ApiOperation({ summary: 'Update Order ' })
|
@ApiOperation({ summary: 'Update Order ' })
|
||||||
updateOrder(@Param('orderId') orderId: string, @Body() dto: UpdateOrderDtoAsAdmin) {
|
updateOrder(@Param('orderId') orderId: string, @Body() dto: UpdateOrderDtoAsAdmin) {
|
||||||
return this.orderService.updateOrder(orderId, dto);
|
return this.orderService.updateOrderAsAdmin(orderId, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('admin/orders/:orderId')
|
@Delete('admin/orders/:orderId')
|
||||||
|
|||||||
@@ -118,10 +118,9 @@ export class OrderService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateOrder(orderId: string, dto: IUpdateOrder) {
|
async updateOrder(order: Order, dto: IUpdateOrder) {
|
||||||
const { attachments, adminId, designerId, enableTax, estimatedDays, paymentMethod, status, userId } = dto
|
const { attachments, adminId, designerId, enableTax, estimatedDays, paymentMethod, status, userId } = dto
|
||||||
|
|
||||||
const order = await this.findOneOrFail(orderId)
|
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
const user = await this.userService.findById(userId)
|
const user = await this.userService.findById(userId)
|
||||||
@@ -178,6 +177,18 @@ export class OrderService {
|
|||||||
return order
|
return order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateOrderAsAdmin(orderId: string, dto: IUpdateOrder) {
|
||||||
|
const order = await this.findOneOrFail(orderId)
|
||||||
|
|
||||||
|
await this.updateOrder(order, dto)
|
||||||
|
|
||||||
|
const updateOrder = await this.calculateOrder(order)
|
||||||
|
|
||||||
|
await this.em.flush()
|
||||||
|
|
||||||
|
return updateOrder
|
||||||
|
}
|
||||||
|
|
||||||
async addOrderItemAsUser(userId: string, orderId: string, dto: CreateOrderItemAsUserDto) {
|
async addOrderItemAsUser(userId: string, orderId: string, dto: CreateOrderItemAsUserDto) {
|
||||||
|
|
||||||
const order = await this.findOneOrFail(orderId)
|
const order = await this.findOneOrFail(orderId)
|
||||||
|
|||||||
Reference in New Issue
Block a user