@things-factory/marketplace-base 4.3.15 → 4.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/marketplace-base",
3
- "version": "4.3.15",
3
+ "version": "4.3.16",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -29,5 +29,5 @@
29
29
  "@things-factory/product-base": "^4.3.14",
30
30
  "@things-factory/shell": "^4.3.14"
31
31
  },
32
- "gitHead": "df335351b9bbb891dc6c4eb81dc9cafecc9c39bb"
32
+ "gitHead": "62892327e53288b479a13a53043067c678cd9bfc"
33
33
  }
@@ -91,15 +91,9 @@ export const splitOrdersByBatch = {
91
91
  let marketplaceOrderShippingItem: MarketplaceOrderShippingItem = newMarketplaceOrderShippingItems[a]
92
92
  const product: Product = marketplaceOrderShippingItem.product
93
93
  const marketplaceOrderItem: MarketplaceOrderItem = marketplaceOrderShippingItem.marketplaceOrderItem
94
- const marketplaceProductVariations: MarketplaceProductVariation[] = await tx
95
- .getRepository(MarketplaceProductVariation)
96
- .find({
97
- where: { domain: marketplaceOrder.domain, sku: product.sku },
98
- relations: ['marketplaceProduct', 'marketplaceProduct.marketplaceStore']
99
- })
100
- const marketplaceProductVariation: MarketplaceProductVariation = marketplaceProductVariations.filter(
101
- mpv => mpv.marketplaceProduct.marketplaceStore.id == marketplaceOrder.marketplaceStore.id
102
- )[0]
94
+
95
+ const marketplaceProductVariation: MarketplaceProductVariation =
96
+ marketplaceOrderItem.marketplaceProductVariation
103
97
 
104
98
  if (!marketplaceProductVariation?.primaryUnitValue)
105
99
  throw new Error(marketplaceProductVariation.variationSku + ' weight is empty')
@@ -381,20 +381,26 @@ export const syncMarketplaceOrder = {
381
381
  let foundVariations = []
382
382
  for (var j = 0; j < order.orderItems.length; j++) {
383
383
  var item = order.orderItems[j]
384
- let foundVariationsQuery = await tx.getRepository(MarketplaceProductVariation).find({
385
- where: { domain: marketplaceStore.domain, variationId: item.variationId },
386
- relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
387
- })
388
384
 
389
- let foundVariation = foundVariationsQuery.find(
390
- fv => fv.marketplaceProduct && fv.marketplaceProduct.marketplaceStore.id == marketplaceStore.id
391
- )
385
+ const qb: SelectQueryBuilder<MarketplaceProductVariation> = await tx
386
+ .getRepository(MarketplaceProductVariation)
387
+ .createQueryBuilder('mpv')
388
+ .leftJoin('mpv.marketplaceProduct', 'mp')
389
+ .leftJoin('mp.marketplaceStore', 'ms')
390
+ .where('mpv.domain_id = :domainId')
391
+ .andWhere('mpv.variation_id = :variationId')
392
+ .andWhere('ms.id = :marketplaceStoreId')
393
+ .setParameters({
394
+ domainId: marketplaceStore.domain,
395
+ variationId: item.variationId,
396
+ marketplaceStoreId: marketplaceStore.id
397
+ })
398
+
399
+ let foundVariation: MarketplaceProductVariation = await qb.getOne()
392
400
 
393
401
  if (foundVariation) {
394
402
  foundVariations.push(foundVariation)
395
- }
396
-
397
- if (!foundVariation) {
403
+ } else {
398
404
  let newVariation: any = {
399
405
  variationId: item.variationId,
400
406
  name: item.variationName,