@things-factory/marketplace-base 3.8.29 → 3.8.35
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/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js +184 -102
- package/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js.map +1 -1
- package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js +188 -114
- package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js.map +1 -1
- package/package.json +3 -2
- package/server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.ts +286 -174
- package/server/graphql/resolvers/marketplace-order/sync-marketplace-order.ts +275 -170
|
@@ -5,6 +5,7 @@ import { Bizplace, getCustomerBizplaces } from '@things-factory/biz-base'
|
|
|
5
5
|
import { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'
|
|
6
6
|
import { MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
7
7
|
import { Domain } from '@things-factory/shell'
|
|
8
|
+
import { Product, ProductBundle, ProductBundleSetting } from '@things-factory/product-base'
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
MarketplaceOrder,
|
|
@@ -119,6 +120,34 @@ export const syncMarketplaceOrder = {
|
|
|
119
120
|
updater: user
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
if (
|
|
124
|
+
!marketplaceOrder?.releaseOrderId &&
|
|
125
|
+
cancelStatuses.includes(marketplaceOrder.status) &&
|
|
126
|
+
!cancelStatuses.includes(existingMarketplaceOrder.status)
|
|
127
|
+
) {
|
|
128
|
+
for (let item of marketplaceOrder.marketplaceOrderItems) {
|
|
129
|
+
let foundVariations = await tx.getRepository(MarketplaceProductVariation).find({
|
|
130
|
+
where: { domain: marketplaceOrder.domain, sku: item.marketplaceProductVariation.sku },
|
|
131
|
+
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
let activeVariations: MarketplaceProductVariation[] = foundVariations.filter(
|
|
135
|
+
variation =>
|
|
136
|
+
variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED' && variation.sku != null
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
await Promise.all(
|
|
140
|
+
activeVariations.map(async variation => {
|
|
141
|
+
await calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty, '-')
|
|
142
|
+
|
|
143
|
+
variation.reserveQty -= item.qty
|
|
144
|
+
variation.qty += item.qty
|
|
145
|
+
await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
122
151
|
if (marketplaceOrder?.releaseOrderId) {
|
|
123
152
|
const fulfillmentCenter: FulfillmentCenter = marketplaceOrder.fulfillmentCenter
|
|
124
153
|
const centerId: string = fulfillmentCenter.centerId
|
|
@@ -219,8 +248,6 @@ export const syncMarketplaceOrder = {
|
|
|
219
248
|
}
|
|
220
249
|
}
|
|
221
250
|
|
|
222
|
-
marketplaceOrder = await tx.getRepository(MarketplaceOrder).save(marketplaceOrder)
|
|
223
|
-
|
|
224
251
|
let savedMarketplaceOrderShipping: MarketplaceOrderShipping = new MarketplaceOrderShipping()
|
|
225
252
|
let savedMarketplaceOrderShippings: MarketplaceOrderShipping[] = []
|
|
226
253
|
|
|
@@ -316,14 +343,18 @@ export const syncMarketplaceOrder = {
|
|
|
316
343
|
}
|
|
317
344
|
|
|
318
345
|
let orderTotalWeight: number = 0
|
|
319
|
-
let
|
|
346
|
+
let foundVariations = []
|
|
320
347
|
for (var j = 0; j < order.orderItems.length; j++) {
|
|
321
348
|
var item = order.orderItems[j]
|
|
322
|
-
foundVariation = await tx.getRepository(MarketplaceProductVariation).findOne({
|
|
349
|
+
let foundVariation = await tx.getRepository(MarketplaceProductVariation).findOne({
|
|
323
350
|
where: { domain: marketplaceStore.domain, variationId: item.variationId },
|
|
324
351
|
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
325
352
|
})
|
|
326
353
|
|
|
354
|
+
if (foundVariation) {
|
|
355
|
+
foundVariations.push(foundVariation)
|
|
356
|
+
}
|
|
357
|
+
|
|
327
358
|
if (!foundVariation) {
|
|
328
359
|
let newVariation: any = {
|
|
329
360
|
variationId: item.variationId,
|
|
@@ -411,158 +442,186 @@ export const syncMarketplaceOrder = {
|
|
|
411
442
|
if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status)) {
|
|
412
443
|
await Promise.all(
|
|
413
444
|
nonMatchedOrderItems.map(async item => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
variation.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
445
|
+
for (var foundVariation of foundVariations) {
|
|
446
|
+
if (foundVariation.sku) {
|
|
447
|
+
let allVariations: MarketplaceProductVariation[] = await tx
|
|
448
|
+
.getRepository(MarketplaceProductVariation)
|
|
449
|
+
.find({
|
|
450
|
+
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
451
|
+
relations: [
|
|
452
|
+
'domain',
|
|
453
|
+
'marketplaceProduct',
|
|
454
|
+
'marketplaceProduct.marketplaceStore',
|
|
455
|
+
'marketplaceProduct.marketplaceStore.marketplaceDistributors'
|
|
456
|
+
]
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
|
|
460
|
+
variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
await Promise.all(
|
|
464
|
+
activeVariations.map(async variation => {
|
|
465
|
+
await calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty, '-')
|
|
466
|
+
|
|
467
|
+
variation.reserveQty -= item.qty
|
|
468
|
+
variation.qty += item.qty
|
|
469
|
+
|
|
470
|
+
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
471
|
+
})
|
|
472
|
+
)
|
|
473
|
+
}
|
|
438
474
|
}
|
|
439
|
-
|
|
440
|
-
foundVariation.qty += item.qty
|
|
441
|
-
foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
|
|
442
475
|
})
|
|
443
476
|
)
|
|
444
477
|
|
|
445
478
|
await tx.getRepository(MarketplaceOrderItem).delete(nonMatchedOrderItems)
|
|
446
479
|
}
|
|
447
480
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
itm
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
|
|
458
|
-
.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
if (!cancelStatuses.includes(marketplaceOrder.status)) {
|
|
482
|
+
existingOrderItems = await Promise.all(
|
|
483
|
+
marketplaceOrderItems.map(async item => {
|
|
484
|
+
const matchedOrderItem = existingOrderItems.find(
|
|
485
|
+
itm =>
|
|
486
|
+
itm.name == item.name &&
|
|
487
|
+
itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
|
|
488
|
+
)
|
|
489
|
+
if (matchedOrderItem) {
|
|
490
|
+
for (var foundVariation of foundVariations) {
|
|
491
|
+
if (foundVariation.sku) {
|
|
492
|
+
let allVariations: MarketplaceProductVariation[] = await tx
|
|
493
|
+
.getRepository(MarketplaceProductVariation)
|
|
494
|
+
.find({
|
|
495
|
+
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
496
|
+
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
|
|
500
|
+
variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
await Promise.all(
|
|
504
|
+
activeVariations.map(async variation => {
|
|
505
|
+
if (!existingMarketplaceOrder?.releaseOrderId && matchedOrderItem.qty - item.qty != 0) {
|
|
506
|
+
await calculateReserveQtyForBundle(
|
|
507
|
+
tx,
|
|
508
|
+
variation,
|
|
509
|
+
marketplaceOrder.domain,
|
|
510
|
+
matchedOrderItem.qty - item.qty
|
|
511
|
+
)
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
|
|
515
|
+
? variation.reserveQty
|
|
516
|
+
: variation.reserveQty - item.qty + matchedOrderItem.qty
|
|
517
|
+
|
|
518
|
+
variation.qty = existingMarketplaceOrder?.releaseOrderId
|
|
519
|
+
? variation.qty
|
|
520
|
+
: variation.qty + item.qty - matchedOrderItem.qty
|
|
521
|
+
|
|
522
|
+
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
523
|
+
})
|
|
524
|
+
)
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
...matchedOrderItem,
|
|
529
|
+
...item,
|
|
530
|
+
updater: user
|
|
531
|
+
}
|
|
488
532
|
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
533
|
+
})
|
|
534
|
+
)
|
|
535
|
+
}
|
|
492
536
|
} else {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
itm
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
.
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
537
|
+
if (!cancelStatuses.includes(marketplaceOrder.status)) {
|
|
538
|
+
existingOrderItems = await Promise.all(
|
|
539
|
+
marketplaceOrderItems.map(async item => {
|
|
540
|
+
const matchedOrderItem = existingOrderItems.find(
|
|
541
|
+
itm =>
|
|
542
|
+
itm.name == item.name &&
|
|
543
|
+
itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
|
|
544
|
+
)
|
|
545
|
+
if (matchedOrderItem) {
|
|
546
|
+
for (var foundVariation of foundVariations) {
|
|
547
|
+
if (foundVariation.sku) {
|
|
548
|
+
let allVariations: MarketplaceProductVariation[] = await tx
|
|
549
|
+
.getRepository(MarketplaceProductVariation)
|
|
550
|
+
.find({
|
|
551
|
+
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
552
|
+
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
553
|
+
})
|
|
554
|
+
|
|
555
|
+
let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
|
|
556
|
+
variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
await Promise.all(
|
|
560
|
+
activeVariations.map(async variation => {
|
|
561
|
+
if (!existingMarketplaceOrder?.releaseOrderId && matchedOrderItem.qty - item.qty != 0) {
|
|
562
|
+
await calculateReserveQtyForBundle(
|
|
563
|
+
tx,
|
|
564
|
+
variation,
|
|
565
|
+
marketplaceOrder.domain,
|
|
566
|
+
matchedOrderItem.qty - item.qty
|
|
567
|
+
)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
|
|
571
|
+
? variation.reserveQty
|
|
572
|
+
: variation.reserveQty - item.qty + matchedOrderItem.qty
|
|
573
|
+
|
|
574
|
+
variation.qty = existingMarketplaceOrder?.releaseOrderId
|
|
575
|
+
? variation.qty
|
|
576
|
+
: variation.qty + item.qty - matchedOrderItem.qty
|
|
577
|
+
|
|
578
|
+
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
579
|
+
})
|
|
580
|
+
)
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
...matchedOrderItem,
|
|
585
|
+
...item,
|
|
586
|
+
updater: user
|
|
587
|
+
}
|
|
588
|
+
} else {
|
|
589
|
+
for (var foundVariation of foundVariations) {
|
|
590
|
+
if (foundVariation.sku) {
|
|
591
|
+
let allVariations: MarketplaceProductVariation[] = await tx
|
|
592
|
+
.getRepository(MarketplaceProductVariation)
|
|
593
|
+
.find({
|
|
594
|
+
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
595
|
+
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
596
|
+
})
|
|
597
|
+
|
|
598
|
+
let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
|
|
599
|
+
variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
await Promise.all(
|
|
603
|
+
activeVariations.map(async variation => {
|
|
604
|
+
await calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty)
|
|
605
|
+
|
|
606
|
+
variation.reserveQty += item.qty
|
|
607
|
+
|
|
608
|
+
if (variation.qty - item.qty >= 0) {
|
|
609
|
+
variation.qty -= item.qty
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
613
|
+
})
|
|
614
|
+
)
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
...item,
|
|
619
|
+
updater: user
|
|
620
|
+
}
|
|
533
621
|
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
.getRepository(MarketplaceProductVariation)
|
|
538
|
-
.find({
|
|
539
|
-
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
540
|
-
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
541
|
-
})
|
|
542
|
-
|
|
543
|
-
let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
|
|
544
|
-
variation =>
|
|
545
|
-
variation.id != foundVariation.id &&
|
|
546
|
-
variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
variationsFromOtherStores.map(async variation => {
|
|
550
|
-
variation.reserveQty += item.qty
|
|
551
|
-
|
|
552
|
-
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
553
|
-
})
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
foundVariation.qty -= item.qty
|
|
557
|
-
foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
|
|
558
|
-
|
|
559
|
-
return {
|
|
560
|
-
...item,
|
|
561
|
-
updater: user
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
})
|
|
565
|
-
)
|
|
622
|
+
})
|
|
623
|
+
)
|
|
624
|
+
}
|
|
566
625
|
}
|
|
567
626
|
|
|
568
627
|
marketplaceOrderItems = existingOrderItems
|
|
@@ -575,38 +634,46 @@ export const syncMarketplaceOrder = {
|
|
|
575
634
|
}
|
|
576
635
|
}
|
|
577
636
|
} else {
|
|
578
|
-
if (
|
|
579
|
-
|
|
580
|
-
.
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
637
|
+
if (!cancelStatuses.includes(marketplaceOrder.status)) {
|
|
638
|
+
for (var foundVariation of foundVariations) {
|
|
639
|
+
if (foundVariation.sku) {
|
|
640
|
+
let allVariations: MarketplaceProductVariation[] = await tx
|
|
641
|
+
.getRepository(MarketplaceProductVariation)
|
|
642
|
+
.find({
|
|
643
|
+
where: { domain: foundVariation.domain, sku: foundVariation.sku },
|
|
644
|
+
relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
|
|
645
|
+
})
|
|
585
646
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
647
|
+
let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
|
|
648
|
+
variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
|
|
649
|
+
)
|
|
650
|
+
let item = order.orderItems.find(e => e.variationId == foundVariation.variationId)
|
|
651
|
+
await Promise.all(
|
|
652
|
+
activeVariations.map(async variation => {
|
|
653
|
+
await calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty)
|
|
591
654
|
|
|
592
|
-
|
|
593
|
-
variation.reserveQty += item.qty
|
|
655
|
+
variation.reserveQty += item.qty
|
|
594
656
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
657
|
+
if (variation.qty - item.qty >= 0) {
|
|
658
|
+
variation.qty -= item.qty
|
|
659
|
+
}
|
|
598
660
|
|
|
599
|
-
|
|
600
|
-
|
|
661
|
+
variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
|
|
662
|
+
})
|
|
663
|
+
)
|
|
664
|
+
}
|
|
601
665
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
666
|
+
if (order?.orderShipping) {
|
|
667
|
+
savedMarketplaceOrderShipping.totalWeight = orderTotalWeight
|
|
668
|
+
savedMarketplaceOrderShipping = await tx
|
|
669
|
+
.getRepository(MarketplaceOrderShipping)
|
|
670
|
+
.save(savedMarketplaceOrderShipping)
|
|
671
|
+
}
|
|
672
|
+
}
|
|
607
673
|
}
|
|
608
674
|
}
|
|
609
675
|
|
|
676
|
+
await tx.getRepository(MarketplaceOrder).save(marketplaceOrder)
|
|
610
677
|
await tx.getRepository(MarketplaceOrderItem).save(marketplaceOrderItems)
|
|
611
678
|
|
|
612
679
|
if (i == marketplaceOrders.length - 1) {
|
|
@@ -652,3 +719,41 @@ export const syncMarketplaceOrder = {
|
|
|
652
719
|
return true
|
|
653
720
|
}
|
|
654
721
|
}
|
|
722
|
+
|
|
723
|
+
async function calculateReserveQtyForBundle(tx, variation, domain, qty, operator = '+') {
|
|
724
|
+
const productBundle: ProductBundle = await tx.getRepository(ProductBundle).findOne({
|
|
725
|
+
where: { sku: variation.sku, domain }
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
if (productBundle) {
|
|
729
|
+
const productBundleSettings: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({
|
|
730
|
+
where: { productBundle },
|
|
731
|
+
relations: ['productBundle', 'product']
|
|
732
|
+
})
|
|
733
|
+
|
|
734
|
+
for (let setting of productBundleSettings) {
|
|
735
|
+
const product: Product = await tx.getRepository(Product).findOne({
|
|
736
|
+
where: { id: setting.product.id }
|
|
737
|
+
})
|
|
738
|
+
|
|
739
|
+
const mpvs: MarketplaceProductVariation[] = await tx.getRepository(MarketplaceProductVariation).find({
|
|
740
|
+
where: { domain, sku: product.sku },
|
|
741
|
+
relations: ['domain']
|
|
742
|
+
})
|
|
743
|
+
|
|
744
|
+
for (let mpv of mpvs) {
|
|
745
|
+
if (operator === '+') {
|
|
746
|
+
mpv.reserveQty += setting.bundleQty * qty
|
|
747
|
+
if (mpv.qty - setting.bundleQty * qty >= 0) {
|
|
748
|
+
mpv.qty -= setting.bundleQty * qty
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (operator === '-') {
|
|
752
|
+
mpv.reserveQty -= setting.bundleQty * qty
|
|
753
|
+
mpv.qty += setting.bundleQty * qty
|
|
754
|
+
}
|
|
755
|
+
await tx.getRepository(MarketplaceProductVariation).save(mpv)
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|