@things-factory/marketplace-base 4.0.39 → 4.0.43

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.
Files changed (28) hide show
  1. package/dist-server/entities/marketplace-order-shipping.js +12 -3
  2. package/dist-server/entities/marketplace-order-shipping.js.map +1 -1
  3. package/dist-server/entities/marketplace-order.js +4 -0
  4. package/dist-server/entities/marketplace-order.js.map +1 -1
  5. package/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js +209 -102
  6. package/dist-server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.js.map +1 -1
  7. package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js +213 -114
  8. package/dist-server/graphql/resolvers/marketplace-order/sync-marketplace-order.js.map +1 -1
  9. package/dist-server/graphql/resolvers/marketplace-report/marketplace-sales-report.js +13 -2
  10. package/dist-server/graphql/resolvers/marketplace-report/marketplace-sales-report.js.map +1 -1
  11. package/dist-server/graphql/types/marketplace-order-shipping/marketplace-order-shipping-patch.js +1 -0
  12. package/dist-server/graphql/types/marketplace-order-shipping/marketplace-order-shipping-patch.js.map +1 -1
  13. package/dist-server/graphql/types/marketplace-order-shipping/marketplace-order-shipping.js +2 -0
  14. package/dist-server/graphql/types/marketplace-order-shipping/marketplace-order-shipping.js.map +1 -1
  15. package/dist-server/graphql/types/marketplace-order-shipping/new-marketplace-order-shipping.js +1 -0
  16. package/dist-server/graphql/types/marketplace-order-shipping/new-marketplace-order-shipping.js.map +1 -1
  17. package/dist-server/graphql/types/marketplace-report/marketplace-sales-report.js +9 -1
  18. package/dist-server/graphql/types/marketplace-report/marketplace-sales-report.js.map +1 -1
  19. package/package.json +5 -5
  20. package/server/entities/marketplace-order-shipping.ts +7 -0
  21. package/server/entities/marketplace-order.ts +3 -0
  22. package/server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.ts +322 -168
  23. package/server/graphql/resolvers/marketplace-order/sync-marketplace-order.ts +311 -168
  24. package/server/graphql/resolvers/marketplace-report/marketplace-sales-report.ts +14 -2
  25. package/server/graphql/types/marketplace-order-shipping/marketplace-order-shipping-patch.ts +1 -0
  26. package/server/graphql/types/marketplace-order-shipping/marketplace-order-shipping.ts +2 -0
  27. package/server/graphql/types/marketplace-order-shipping/new-marketplace-order-shipping.ts +1 -0
  28. package/server/graphql/types/marketplace-report/marketplace-sales-report.ts +9 -1
@@ -4,6 +4,7 @@ import { User } from '@things-factory/auth-base'
4
4
  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
+ import { Product, ProductBundle, ProductBundleSetting } from '@things-factory/product-base'
7
8
  import { Domain } from '@things-factory/shell'
8
9
 
9
10
  import {
@@ -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 this.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
@@ -316,14 +345,18 @@ export const syncMarketplaceOrder = {
316
345
  }
317
346
 
318
347
  let orderTotalWeight: number = 0
319
- let foundVariation
348
+ let foundVariations = []
320
349
  for (var j = 0; j < order.orderItems.length; j++) {
321
350
  var item = order.orderItems[j]
322
- foundVariation = await tx.getRepository(MarketplaceProductVariation).findOne({
351
+ let foundVariation = await tx.getRepository(MarketplaceProductVariation).findOne({
323
352
  where: { domain: marketplaceStore.domain, variationId: item.variationId },
324
353
  relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
325
354
  })
326
355
 
356
+ if (foundVariation) {
357
+ foundVariations.push(foundVariation)
358
+ }
359
+
327
360
  if (!foundVariation) {
328
361
  let newVariation: any = {
329
362
  variationId: item.variationId,
@@ -411,158 +444,192 @@ export const syncMarketplaceOrder = {
411
444
  if (nonMatchedOrderItems.length > 0 && !cancelStatuses.includes(marketplaceOrder.status)) {
412
445
  await Promise.all(
413
446
  nonMatchedOrderItems.map(async item => {
414
- if (foundVariation.sku) {
415
- let allVariations: MarketplaceProductVariation[] = await tx
416
- .getRepository(MarketplaceProductVariation)
417
- .find({
418
- where: { domain: foundVariation.domain, sku: foundVariation.sku },
419
- relations: [
420
- 'domain',
421
- 'marketplaceProduct',
422
- 'marketplaceProduct.marketplaceStore',
423
- 'marketplaceProduct.marketplaceStore.marketplaceDistributors'
424
- ]
425
- })
426
-
427
- let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
428
- variation =>
429
- variation.id != foundVariation.id &&
430
- variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
431
- )
432
-
433
- variationsFromOtherStores.map(async variation => {
434
- variation.reserveQty -= item.qty
435
-
436
- variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
437
- })
447
+ for (var foundVariation of foundVariations) {
448
+ if (foundVariation.sku) {
449
+ let allVariations: MarketplaceProductVariation[] = await tx
450
+ .getRepository(MarketplaceProductVariation)
451
+ .find({
452
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
453
+ relations: [
454
+ 'domain',
455
+ 'marketplaceProduct',
456
+ 'marketplaceProduct.marketplaceStore',
457
+ 'marketplaceProduct.marketplaceStore.marketplaceDistributors'
458
+ ]
459
+ })
460
+
461
+ let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
462
+ variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
463
+ )
464
+
465
+ await Promise.all(
466
+ activeVariations.map(async variation => {
467
+ await this.calculateReserveQtyForBundle(
468
+ tx,
469
+ variation,
470
+ marketplaceOrder.domain,
471
+ item.qty,
472
+ '-'
473
+ )
474
+
475
+ variation.reserveQty -= item.qty
476
+ variation.qty += item.qty
477
+
478
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
479
+ })
480
+ )
481
+ }
438
482
  }
439
-
440
- foundVariation.qty += item.qty
441
- foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
442
483
  })
443
484
  )
444
485
 
445
486
  await tx.getRepository(MarketplaceOrderItem).delete(nonMatchedOrderItems)
446
487
  }
447
488
 
448
- existingOrderItems = await Promise.all(
449
- marketplaceOrderItems.map(async item => {
450
- const matchedOrderItem = existingOrderItems.find(
451
- itm =>
452
- itm.name == item.name &&
453
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
454
- )
455
- if (matchedOrderItem) {
456
- if (foundVariation.sku) {
457
- let allVariations: MarketplaceProductVariation[] = await tx
458
- .getRepository(MarketplaceProductVariation)
459
- .find({
460
- where: { domain: foundVariation.domain, sku: foundVariation.sku },
461
- relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
462
- })
463
-
464
- let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
465
- variation =>
466
- variation.id != foundVariation.id &&
467
- variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
468
- )
469
-
470
- variationsFromOtherStores.map(async variation => {
471
- variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
472
- ? variation.reserveQty + matchedOrderItem.qty
473
- : variation.reserveQty - item.qty + matchedOrderItem.qty
474
-
475
- variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
476
- })
489
+ if (!cancelStatuses.includes(marketplaceOrder.status)) {
490
+ existingOrderItems = await Promise.all(
491
+ marketplaceOrderItems.map(async item => {
492
+ const matchedOrderItem = existingOrderItems.find(
493
+ itm =>
494
+ itm.name == item.name &&
495
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
496
+ )
497
+ if (matchedOrderItem) {
498
+ for (var foundVariation of foundVariations) {
499
+ if (foundVariation.sku) {
500
+ let allVariations: MarketplaceProductVariation[] = await tx
501
+ .getRepository(MarketplaceProductVariation)
502
+ .find({
503
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
504
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
505
+ })
506
+
507
+ let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
508
+ variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
509
+ )
510
+
511
+ await Promise.all(
512
+ activeVariations.map(async variation => {
513
+ if (!existingMarketplaceOrder?.releaseOrderId && matchedOrderItem.qty - item.qty != 0) {
514
+ await this.calculateReserveQtyForBundle(
515
+ tx,
516
+ variation,
517
+ marketplaceOrder.domain,
518
+ matchedOrderItem.qty - item.qty
519
+ )
520
+ }
521
+
522
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
523
+ ? variation.reserveQty
524
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
525
+
526
+ variation.qty = existingMarketplaceOrder?.releaseOrderId
527
+ ? variation.qty
528
+ : variation.qty + item.qty - matchedOrderItem.qty
529
+
530
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
531
+ })
532
+ )
533
+ }
534
+ }
535
+ return {
536
+ ...matchedOrderItem,
537
+ ...item,
538
+ updater: user
539
+ }
477
540
  }
478
-
479
- foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
480
- ? foundVariation.qty - matchedOrderItem.qty
481
- : foundVariation.qty + item.qty - matchedOrderItem.qty
482
- foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
483
-
484
- return {
485
- ...matchedOrderItem,
486
- ...item,
487
- updater: user
488
- }
489
- }
490
- })
491
- )
541
+ })
542
+ )
543
+ }
492
544
  } else {
493
- existingOrderItems = await Promise.all(
494
- marketplaceOrderItems.map(async item => {
495
- const matchedOrderItem = existingOrderItems.find(
496
- itm =>
497
- itm.name == item.name &&
498
- itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
499
- )
500
- if (matchedOrderItem) {
501
- if (foundVariation.sku) {
502
- let allVariations: MarketplaceProductVariation[] = await tx
503
- .getRepository(MarketplaceProductVariation)
504
- .find({
505
- where: { domain: foundVariation.domain, sku: foundVariation.sku },
506
- relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
507
- })
508
-
509
- let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
510
- variation =>
511
- variation.id != foundVariation.id &&
512
- variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
513
- )
514
-
515
- variationsFromOtherStores.map(async variation => {
516
- variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
517
- ? variation.reserveQty + matchedOrderItem.qty
518
- : variation.reserveQty - item.qty + matchedOrderItem.qty
519
-
520
- variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
521
- })
522
- }
523
-
524
- foundVariation.qty = existingMarketplaceOrder?.releaseOrderId
525
- ? foundVariation.qty - matchedOrderItem.qty
526
- : foundVariation.qty + item.qty - matchedOrderItem.qty
527
- foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
528
-
529
- return {
530
- ...matchedOrderItem,
531
- ...item,
532
- updater: user
533
- }
534
- } else {
535
- if (foundVariation.sku) {
536
- let allVariations: MarketplaceProductVariation[] = await tx
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
- })
545
+ if (!cancelStatuses.includes(marketplaceOrder.status)) {
546
+ existingOrderItems = await Promise.all(
547
+ marketplaceOrderItems.map(async item => {
548
+ const matchedOrderItem = existingOrderItems.find(
549
+ itm =>
550
+ itm.name == item.name &&
551
+ itm.marketplaceProductVariation.variationId == item.marketplaceProductVariation.variationId
552
+ )
553
+ if (matchedOrderItem) {
554
+ for (var foundVariation of foundVariations) {
555
+ if (foundVariation.sku) {
556
+ let allVariations: MarketplaceProductVariation[] = await tx
557
+ .getRepository(MarketplaceProductVariation)
558
+ .find({
559
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
560
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
561
+ })
562
+
563
+ let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
564
+ variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
565
+ )
566
+
567
+ await Promise.all(
568
+ activeVariations.map(async variation => {
569
+ if (!existingMarketplaceOrder?.releaseOrderId && matchedOrderItem.qty - item.qty != 0) {
570
+ await this.calculateReserveQtyForBundle(
571
+ tx,
572
+ variation,
573
+ marketplaceOrder.domain,
574
+ matchedOrderItem.qty - item.qty
575
+ )
576
+ }
577
+
578
+ variation.reserveQty = existingMarketplaceOrder?.releaseOrderId
579
+ ? variation.reserveQty
580
+ : variation.reserveQty - item.qty + matchedOrderItem.qty
581
+
582
+ variation.qty = existingMarketplaceOrder?.releaseOrderId
583
+ ? variation.qty
584
+ : variation.qty + item.qty - matchedOrderItem.qty
585
+
586
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
587
+ })
588
+ )
589
+ }
590
+ }
591
+ return {
592
+ ...matchedOrderItem,
593
+ ...item,
594
+ updater: user
595
+ }
596
+ } else {
597
+ for (var foundVariation of foundVariations) {
598
+ if (foundVariation.sku) {
599
+ let allVariations: MarketplaceProductVariation[] = await tx
600
+ .getRepository(MarketplaceProductVariation)
601
+ .find({
602
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
603
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
604
+ })
605
+
606
+ let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
607
+ variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
608
+ )
609
+
610
+ await Promise.all(
611
+ activeVariations.map(async variation => {
612
+ await this.calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty)
613
+
614
+ variation.reserveQty += item.qty
615
+
616
+ if (variation.qty - item.qty >= 0) {
617
+ variation.qty -= item.qty
618
+ }
619
+
620
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
621
+ })
622
+ )
623
+ }
624
+ }
625
+ return {
626
+ ...item,
627
+ updater: user
628
+ }
554
629
  }
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
- )
630
+ })
631
+ )
632
+ }
566
633
  }
567
634
 
568
635
  marketplaceOrderItems = existingOrderItems
@@ -575,35 +642,42 @@ export const syncMarketplaceOrder = {
575
642
  }
576
643
  }
577
644
  } else {
578
- if (foundVariation.sku) {
579
- let allVariations: MarketplaceProductVariation[] = await tx
580
- .getRepository(MarketplaceProductVariation)
581
- .find({
582
- where: { domain: foundVariation.domain, sku: foundVariation.sku },
583
- relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
584
- })
645
+ if (!cancelStatuses.includes(marketplaceOrder.status)) {
646
+ for (var foundVariation of foundVariations) {
647
+ if (foundVariation.sku) {
648
+ let allVariations: MarketplaceProductVariation[] = await tx
649
+ .getRepository(MarketplaceProductVariation)
650
+ .find({
651
+ where: { domain: foundVariation.domain, sku: foundVariation.sku },
652
+ relations: ['domain', 'marketplaceProduct', 'marketplaceProduct.marketplaceStore']
653
+ })
585
654
 
586
- let variationsFromOtherStores: MarketplaceProductVariation[] = allVariations.filter(
587
- variation =>
588
- variation.id != foundVariation.id &&
589
- variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
590
- )
655
+ let activeVariations: MarketplaceProductVariation[] = allVariations.filter(
656
+ variation => variation.marketplaceProduct.marketplaceStore.status != 'TERMINATED'
657
+ )
658
+ let item = order.orderItems.find(e => e.variationId == foundVariation.variationId)
659
+ await Promise.all(
660
+ activeVariations.map(async variation => {
661
+ await this.calculateReserveQtyForBundle(tx, variation, marketplaceOrder.domain, item.qty)
591
662
 
592
- variationsFromOtherStores.map(async variation => {
593
- variation.reserveQty += item.qty
663
+ variation.reserveQty += item.qty
594
664
 
595
- variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
596
- })
597
- }
665
+ if (variation.qty - item.qty >= 0) {
666
+ variation.qty -= item.qty
667
+ }
598
668
 
599
- foundVariation.qty -= item.qty
600
- foundVariation = await tx.getRepository(MarketplaceProductVariation).save(foundVariation)
669
+ variation = await tx.getRepository(MarketplaceProductVariation).save(variation)
670
+ })
671
+ )
672
+ }
601
673
 
602
- if (order?.orderShipping) {
603
- savedMarketplaceOrderShipping.totalWeight = orderTotalWeight
604
- savedMarketplaceOrderShipping = await tx
605
- .getRepository(MarketplaceOrderShipping)
606
- .save(savedMarketplaceOrderShipping)
674
+ if (order?.orderShipping) {
675
+ savedMarketplaceOrderShipping.totalWeight = orderTotalWeight
676
+ savedMarketplaceOrderShipping = await tx
677
+ .getRepository(MarketplaceOrderShipping)
678
+ .save(savedMarketplaceOrderShipping)
679
+ }
680
+ }
607
681
  }
608
682
  }
609
683
 
@@ -618,6 +692,75 @@ export const syncMarketplaceOrder = {
618
692
  hasMorePage = more
619
693
  }
620
694
 
695
+ if (marketplaceStore.platform === 'shopee') {
696
+ let pageNo: number = 0
697
+ let hasMore = true
698
+ let perPage: number = 100
699
+ var payoutDateList = []
700
+
701
+ while (hasMore) {
702
+ const { result: payoutDates, more } = await StoreAPI.getStoreOrderPayoutDates(marketplaceStore, {
703
+ fromDate,
704
+ toDate,
705
+ pagination: { page: pageNo, limit: perPage }
706
+ })
707
+
708
+ payoutDateList.push(...payoutDates)
709
+ if (more) pageNo++
710
+ hasMore = more
711
+ }
712
+
713
+ await Promise.all(
714
+ payoutDateList.map(async item => {
715
+ await tx.getRepository(MarketplaceOrder).update(
716
+ {
717
+ orderNo: item.orderNo
718
+ },
719
+ {
720
+ payoutDate: item.payoutDate
721
+ }
722
+ )
723
+ })
724
+ )
725
+ }
621
726
  return true
622
727
  }
623
728
  }
729
+
730
+ export async function calculateReserveQtyForBundle(tx, variation, domain, qty, operator = '+') {
731
+ const productBundle: ProductBundle = await tx.getRepository(ProductBundle).findOne({
732
+ where: { sku: variation.sku, domain }
733
+ })
734
+
735
+ if (productBundle) {
736
+ const productBundleSettings: ProductBundleSetting[] = await tx.getRepository(ProductBundleSetting).find({
737
+ where: { productBundle },
738
+ relations: ['productBundle', 'product']
739
+ })
740
+
741
+ for (let setting of productBundleSettings) {
742
+ const product: Product = await tx.getRepository(Product).findOne({
743
+ where: { id: setting.product.id }
744
+ })
745
+
746
+ const mpvs: MarketplaceProductVariation[] = await tx.getRepository(MarketplaceProductVariation).find({
747
+ where: { domain, sku: product.sku },
748
+ relations: ['domain']
749
+ })
750
+
751
+ for (let mpv of mpvs) {
752
+ if (operator === '+') {
753
+ mpv.reserveQty += setting.bundleQty * qty
754
+ if (mpv.qty - setting.bundleQty * qty >= 0) {
755
+ mpv.qty -= setting.bundleQty * qty
756
+ }
757
+ }
758
+ if (operator === '-') {
759
+ mpv.reserveQty -= setting.bundleQty * qty
760
+ mpv.qty += setting.bundleQty * qty
761
+ }
762
+ await tx.getRepository(MarketplaceProductVariation).save(mpv)
763
+ }
764
+ }
765
+ }
766
+ }
@@ -74,6 +74,7 @@ export const marketplaceSalesReportsResolver = {
74
74
  orderNo: item.mo_name,
75
75
  orderCreatedAt: item.mo_order_created_at,
76
76
  buyerUsername: item.mo_buyer_username,
77
+ payoutDate: item.mo_payout_date,
77
78
  payTime: item.mo_pay_time,
78
79
  totalAmount: item.mo_total_amount,
79
80
  refundAmount: item.mro_amount,
@@ -117,11 +118,22 @@ export const marketplaceSalesReportsResolver = {
117
118
  shippingFeeDiscountSeller: item.moi_shipping_fee_discount_seller,
118
119
  promotionalChargesFlexiCombo: item.moi_promotional_charges_flexi_combo,
119
120
  autoShippingSubsidyMarketplace: item.moi_auto_shipping_subsidy_marketplace,
120
- grandTotal: item.moi_orders_marketplace_fees_total + item.moi_orders_marketing_fees_total + item.moi_orders_sales_total + item.moi_orders_logistics_total,
121
+ grandTotal:
122
+ item.moi_orders_marketplace_fees_total +
123
+ item.moi_orders_marketing_fees_total +
124
+ item.moi_orders_sales_total +
125
+ item.moi_orders_logistics_total,
121
126
  originalShippingFee: item.moi_original_shipping_fee,
122
127
  taxAmount: item.moi_tax_amount,
123
128
  itemCommissionFee: item.moi_commission_fee,
124
- variationSku: item.mpv_variation_sku
129
+ variationSku: item.mpv_variation_sku,
130
+ address1: item.mos_address_1,
131
+ address2: item.mos_address_2,
132
+ address3: item.mos_address_3,
133
+ city: item.mos_city,
134
+ state: item.mos_state,
135
+ postcode: item.mos_post_code,
136
+ trackingNo: item.moi_tracking_code
125
137
  }
126
138
  })
127
139
 
@@ -40,6 +40,7 @@ export const MarketplaceOrderShippingPatch = gql`
40
40
  parcelType: Int
41
41
  goodsType: Int
42
42
  deliveryMethod: Int
43
+ releaseOrderId: String
43
44
  cuFlag: String
44
45
  }
45
46
  `
@@ -48,6 +48,8 @@ export const MarketplaceOrderShipping = gql`
48
48
  actualShippingFee: Float
49
49
  marketplaceShippingFeeVoucher: Float
50
50
  sellerShippingFeeVoucher: Float
51
+ releaseOrderId: String
52
+ fulfillmentCenter: FulfillmentCenter
51
53
  updater: User
52
54
  creator: User
53
55
  updatedAt: String
@@ -35,6 +35,7 @@ export const NewMarketplaceOrderShipping = gql`
35
35
  collectionType: String
36
36
  collectionCurrency: String
37
37
  collectionAmount: Float
38
+ releaseOrderId: String
38
39
  orderType: String
39
40
  freightType: Int
40
41
  parcelType: Int
@@ -7,7 +7,7 @@ export const MarketplaceSalesReport = gql`
7
7
  shippingRebate: Float
8
8
  commissionFee: Float
9
9
  serviceFee: Float
10
- transactionFee: String
10
+ transactionFee: Float
11
11
  totalRealeasedAmount: Float
12
12
  voucherCode: String
13
13
  shippingMode: String
@@ -15,6 +15,7 @@ export const MarketplaceSalesReport = gql`
15
15
  orderNo: String
16
16
  orderCreatedAt: String
17
17
  buyerUsername: String
18
+ payoutDate: String
18
19
  payTime: String
19
20
  totalAmount: Float
20
21
  refundAmount: Float
@@ -55,5 +56,12 @@ export const MarketplaceSalesReport = gql`
55
56
  fulfillmentCenter: String
56
57
  variationSku: String
57
58
  itemCommissionFee: Float
59
+ address1: String
60
+ address2: String
61
+ address3: String
62
+ city: String
63
+ state: String
64
+ postcode: String
65
+ trackingNo: String
58
66
  }
59
67
  `