order
This commit is contained in:
@@ -92,6 +92,7 @@ export class OrderService {
|
||||
em.assign(order, rest)
|
||||
|
||||
for (const item of items) {
|
||||
|
||||
if (item.id) { // update
|
||||
const currentItem = order.items.find(i => Number(i.id) == item.id)
|
||||
|
||||
@@ -101,7 +102,7 @@ export class OrderService {
|
||||
|
||||
const { designerId, productId, ...itemRest } = item
|
||||
|
||||
let newProduct: Product | undefined
|
||||
let newProduct=currentItem.product
|
||||
|
||||
if (productId && productId !== currentItem.product.id) {
|
||||
|
||||
@@ -145,11 +146,12 @@ export class OrderService {
|
||||
|
||||
em.persist(newOrderItem)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await em.flush()
|
||||
|
||||
this.logger.log("Order updated as admin")
|
||||
this.logger.log(`order #${order.orderNumber} was updated as Admin`)
|
||||
|
||||
return order
|
||||
})
|
||||
@@ -444,6 +446,7 @@ export class OrderService {
|
||||
const admin = adminId ? await this.adminService.findOrFail(adminId) : undefined
|
||||
const products = await this.productService.findProductsByIds(items.map(item => item.productId))
|
||||
const desiners = await this.adminService.findByIds(items.map(item => item.designerId).filter(id => id != null))
|
||||
|
||||
const productMap = new Map(
|
||||
products.map(p => [Number(p.id), p])
|
||||
);
|
||||
|
||||
@@ -94,9 +94,7 @@ export class ProductService {
|
||||
const products = await this.productRepository.find({
|
||||
id: { $in: productIds }
|
||||
})
|
||||
if (productIds.length !== products.length) {
|
||||
throw new BadRequestException("some products not found")
|
||||
}
|
||||
|
||||
return products
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user