From a0078085355b82d5f57650dac4996d22cbbdf341 Mon Sep 17 00:00:00 2001 From: mfadiln2018 Date: Wed, 7 Sep 2022 19:19:55 +0700 Subject: [PATCH] fix: get list by categories all where partner is null --- src/product/product.service.ts | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/product/product.service.ts b/src/product/product.service.ts index c84baac..0d328f1 100644 --- a/src/product/product.service.ts +++ b/src/product/product.service.ts @@ -333,19 +333,19 @@ export class ProductService { status: 'ACTIVE', }, ) - .where( - `product.supplier_id = :supplier_id`, - { - supplier_id: supplier, - }, - ) + // .where( + // `product.supplier_id = :supplier_id`, + // { + // supplier_id: supplier, + // }, + // ) .where( `history_status.partner_id is NULL`, { partner_id: null, }, ) - .where( + .andWhere( 'supplier.status = TRUE', { status: true, @@ -356,6 +356,7 @@ export class ProductService { .addSelect('(current_price.price + current_price.mark_up_price) as price') .addSelect('product.supplier_id', 'supplier') .addSelect('supplier.status', 'status') + .addSelect('history_status.partner_id', 'partner') .orderBy('price', 'ASC') .distinct(); @@ -406,11 +407,16 @@ export class ProductService { const baseQuery = await this.productRepository .createQueryBuilder('product') .leftJoin('product.sub_categories', 'sub_categories') - .leftJoinAndSelect( - 'product.supplier', - 'supplier', - 'supplier.status = true', - ) + .leftJoin('product.supplier', 'supplier') + // .leftJoinAndSelect( + // 'product.supplier', + // 'supplier', + // 'supplier.status = true', + // { + // status: true + // } + // + // ) .innerJoinAndMapOne( 'product.currentPrice', 'product.priceHistory', @@ -435,11 +441,15 @@ export class ProductService { .where(`history_status.status = 'ACTIVE'`, { status: 'ACTIVE', }) + .andWhere('supplier.status = TRUE', { + status: true + }) .select(['product.id']) .addSelect([ 'product.name', 'product.code', 'product.type', + 'product.supplier_id', 'sub_categories.name', 'current_price.admin_price as admin_price', 'current_price.mark_up_price as markup_price',