Просмотр исходного кода

fix(core): Exclude seller orders when counting promotion usage (#4070)

Twilight 22 часов назад
Родитель
Сommit
fe72cdb9cd
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      packages/core/src/service/services/promotion.service.ts

+ 5 - 2
packages/core/src/service/services/promotion.service.ts

@@ -8,6 +8,7 @@ import {
     CreatePromotionResult,
     CreatePromotionResult,
     DeletionResponse,
     DeletionResponse,
     DeletionResult,
     DeletionResult,
+    OrderType,
     RemovePromotionsFromChannelInput,
     RemovePromotionsFromChannelInput,
     UpdatePromotionInput,
     UpdatePromotionInput,
     UpdatePromotionResult,
     UpdatePromotionResult,
@@ -349,7 +350,8 @@ export class PromotionService {
             .where('promotion.id = :promotionId', { promotionId })
             .where('promotion.id = :promotionId', { promotionId })
             .andWhere('order.customer = :customerId', { customerId })
             .andWhere('order.customer = :customerId', { customerId })
             .andWhere('order.state != :state', { state: 'Cancelled' as OrderState })
             .andWhere('order.state != :state', { state: 'Cancelled' as OrderState })
-            .andWhere('order.active = :active', { active: false });
+            .andWhere('order.active = :active', { active: false })
+            .andWhere('order.type != :type', { type: OrderType.Seller });
 
 
         return qb.getCount();
         return qb.getCount();
     }
     }
@@ -361,7 +363,8 @@ export class PromotionService {
             .leftJoin('order.promotions', 'promotion')
             .leftJoin('order.promotions', 'promotion')
             .where('promotion.id = :promotionId', { promotionId })
             .where('promotion.id = :promotionId', { promotionId })
             .andWhere('order.state != :state', { state: 'Cancelled' as OrderState })
             .andWhere('order.state != :state', { state: 'Cancelled' as OrderState })
-            .andWhere('order.active = :active', { active: false });
+            .andWhere('order.active = :active', { active: false })
+            .andWhere('order.type != :type', { type: OrderType.Seller });
 
 
         return qb.getCount();
         return qb.getCount();
     }
     }