@things-factory/integration-sellercraft 4.2.5 → 4.2.9
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/constants/order-status-mapping.js +16 -2
- package/dist-server/constants/order-status-mapping.js.map +1 -1
- package/dist-server/constants/platform.js +2 -1
- package/dist-server/constants/platform.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +5 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +2 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +5 -4
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +8 -4
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +135 -88
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +291 -245
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +30 -16
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
- package/package.json +3 -3
- package/server/constants/order-status-mapping.ts +16 -1
- package/server/constants/platform.ts +2 -1
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts +6 -2
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +2 -2
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +13 -11
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +8 -4
- package/server/routers/sellercraft-router.ts +130 -91
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +343 -283
- package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +30 -28
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Ctx, Mutation, Resolver } from 'type-graphql'
|
2
2
|
import { getRepository } from 'typeorm'
|
3
3
|
|
4
|
-
import { MarketplaceChannel } from './marketplace-channel'
|
5
|
-
|
6
4
|
import { config } from '@things-factory/env'
|
7
5
|
import { StoreAPI } from '@things-factory/integration-marketplace'
|
6
|
+
|
8
7
|
import { SellercraftChannelIntegrationAPI } from '../../controllers/sellercraft-channel-integration-api'
|
8
|
+
import { MarketplaceChannel } from './marketplace-channel'
|
9
9
|
|
10
10
|
@Resolver()
|
11
11
|
export class MarketplaceChannelProductMutation {
|
@@ -34,11 +34,12 @@ export class MarketplaceChannelProductMutation {
|
|
34
34
|
|
35
35
|
for (var j = 0; j < shops.length; j++) {
|
36
36
|
var store = {
|
37
|
-
accessKey: shops[j]
|
38
|
-
accessSecret: shops[j]
|
39
|
-
storeURL: shops[j]
|
37
|
+
accessKey: shops[j]?.credential?.consumer_key || '',
|
38
|
+
accessSecret: shops[j]?.credential?.consumer_secret || '',
|
39
|
+
storeURL: shops[j]?.credential?.store_url || '',
|
40
40
|
platform: channels[i].name,
|
41
|
-
accessToken: shops[j]
|
41
|
+
accessToken: shops[j]?.credential?.access_token, // Magento+, Tiktok
|
42
|
+
channelShopId: shops[j]?.channel_shop_id
|
42
43
|
}
|
43
44
|
|
44
45
|
let countryCode = shops[j].country_code
|
@@ -67,22 +68,15 @@ export class MarketplaceChannelProductMutation {
|
|
67
68
|
let limitCategory: number = 100
|
68
69
|
|
69
70
|
for (let page = 0; page < totalPagesCategory; page++) {
|
70
|
-
const { results, total } = await StoreAPI.getStoreProductCategories(store, {
|
71
|
+
const { results, total } = await StoreAPI.getStoreProductCategories(store, {
|
72
|
+
pagination: { page, limitCategory }
|
73
|
+
})
|
71
74
|
totalPagesCategory = Math.ceil(total / limitCategory)
|
72
75
|
categoryResult.push(...results)
|
73
76
|
}
|
74
77
|
|
75
78
|
let mappedProducts = productResult.map(item => {
|
76
|
-
let {
|
77
|
-
categoryId,
|
78
|
-
itemId: productId,
|
79
|
-
name,
|
80
|
-
brand,
|
81
|
-
isVerified,
|
82
|
-
images,
|
83
|
-
attributes,
|
84
|
-
variations
|
85
|
-
} = item
|
79
|
+
let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item
|
86
80
|
|
87
81
|
variations = variations.map(variation => {
|
88
82
|
let {
|
@@ -90,7 +84,7 @@ export class MarketplaceChannelProductMutation {
|
|
90
84
|
variationId,
|
91
85
|
name,
|
92
86
|
isEnabled: isEnabled,
|
93
|
-
|
87
|
+
isSellable: isSellable,
|
94
88
|
attributes,
|
95
89
|
stockLocked,
|
96
90
|
qty: stockReported,
|
@@ -170,18 +164,26 @@ export class MarketplaceChannelProductMutation {
|
|
170
164
|
}
|
171
165
|
})
|
172
166
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
167
|
+
try {
|
168
|
+
mappedCategories = mappedCategories.map(category => {
|
169
|
+
if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
|
170
|
+
category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId)
|
171
|
+
}
|
172
|
+
return category
|
173
|
+
})
|
179
174
|
|
180
|
-
|
181
|
-
|
182
|
-
|
175
|
+
await SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
|
176
|
+
categories: mappedCategories
|
177
|
+
})
|
178
|
+
} catch (e) {}
|
183
179
|
|
184
|
-
|
180
|
+
try {
|
181
|
+
for (let k = 0, l = mappedProducts.length; k < l; k++) {
|
182
|
+
await SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
|
183
|
+
products: [mappedProducts[k]]
|
184
|
+
})
|
185
|
+
}
|
186
|
+
} catch (e) {}
|
185
187
|
}
|
186
188
|
|
187
189
|
return true
|