@things-factory/integration-sellercraft 4.3.62 → 4.3.69
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/index.js +5 -1
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/controllers/index.js +5 -1
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/sellercraft/apis/index.js +5 -1
- package/dist-server/controllers/sellercraft/apis/index.js.map +1 -1
- package/dist-server/controllers/sellercraft/index.js +5 -1
- package/dist-server/controllers/sellercraft/index.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/index.js +5 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/index.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/index.js +5 -1
- package/dist-server/controllers/sellercraft-channel-integration/index.js.map +1 -1
- package/dist-server/index.js +5 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/index.js +5 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +263 -264
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/package.json +15 -15
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +324 -326
@@ -60,7 +60,7 @@ export class MarketplaceChannelOrderMutation {
|
|
60
60
|
let hasMorePage: boolean = true
|
61
61
|
let lastOrderId: string
|
62
62
|
let cursor: string
|
63
|
-
var limit: number =
|
63
|
+
var limit: number = 20
|
64
64
|
|
65
65
|
while (hasMorePage) {
|
66
66
|
const {
|
@@ -77,341 +77,339 @@ export class MarketplaceChannelOrderMutation {
|
|
77
77
|
nextCursor: cursor
|
78
78
|
})
|
79
79
|
|
80
|
-
|
80
|
+
var sellercraftStore = { ...store, platform: 'sellercraftChannelIntegration' }
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
cursor = nextCursor
|
85
|
-
}
|
86
|
-
|
87
|
-
var sellercraftStore = { ...store, platform: 'sellercraftChannelIntegration' }
|
88
|
-
|
89
|
-
let mappedOrderResult = orderResult.map(order => {
|
90
|
-
let id = store.platform == 'magento' || store.platform == 'shopify' ? order.name : order.orderNo
|
91
|
-
let {
|
92
|
-
firstName: custFirstName,
|
93
|
-
lastName: custLastName,
|
94
|
-
orderCreatedAt: createdAt,
|
95
|
-
orderUpdatedAt: updatedAt,
|
96
|
-
status,
|
97
|
-
sellercraftStatus,
|
98
|
-
isSOF,
|
99
|
-
orderLineList,
|
100
|
-
sellercraftDisplayOrderNo
|
101
|
-
} = order
|
102
|
-
|
103
|
-
let {
|
104
|
-
first_name: billFirstName,
|
105
|
-
last_name: billLastName,
|
106
|
-
address_1: billAddress1,
|
107
|
-
address_2: billAddress2,
|
108
|
-
address_3: billAddress3,
|
109
|
-
address_4: billAddress4,
|
110
|
-
address_5: billAddress5,
|
111
|
-
city: billCity,
|
112
|
-
postcode: billPostalCode,
|
113
|
-
country: billCountry,
|
114
|
-
phone: billPhone1,
|
115
|
-
phone_2: billPhone2
|
116
|
-
} = order?.billing
|
117
|
-
|
118
|
-
let {
|
119
|
-
first_name: shipFirstName,
|
120
|
-
last_name: shipLastName,
|
121
|
-
address_1: shipAddress1,
|
122
|
-
address_2: shipAddress2,
|
123
|
-
address_3: shipAddress3,
|
124
|
-
address_4: shipAddress4,
|
125
|
-
address_5: shipAddress5,
|
126
|
-
city: shipCity,
|
127
|
-
postcode: shipPostalCode,
|
128
|
-
country: shipCountry,
|
129
|
-
phone: shipPhone1,
|
130
|
-
phone_2: shipPhone2
|
131
|
-
} = order.shipping
|
132
|
-
|
133
|
-
let orderPackage = order?.orderPackage || {}
|
134
|
-
|
135
|
-
let orderItems = order.orderItems.map(item => {
|
82
|
+
let mappedOrderResult = marketplaceOrders.map(order => {
|
83
|
+
let id = store.platform == 'magento' || store.platform == 'shopify' ? order.name : order.orderNo
|
136
84
|
let {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
85
|
+
firstName: custFirstName,
|
86
|
+
lastName: custLastName,
|
87
|
+
orderCreatedAt: createdAt,
|
88
|
+
orderUpdatedAt: updatedAt,
|
89
|
+
status,
|
90
|
+
sellercraftStatus,
|
91
|
+
isSOF,
|
92
|
+
orderLineList,
|
93
|
+
sellercraftDisplayOrderNo
|
94
|
+
} = order
|
95
|
+
|
96
|
+
let {
|
97
|
+
first_name: billFirstName,
|
98
|
+
last_name: billLastName,
|
99
|
+
address_1: billAddress1,
|
100
|
+
address_2: billAddress2,
|
101
|
+
address_3: billAddress3,
|
102
|
+
address_4: billAddress4,
|
103
|
+
address_5: billAddress5,
|
104
|
+
city: billCity,
|
105
|
+
postcode: billPostalCode,
|
106
|
+
country: billCountry,
|
107
|
+
phone: billPhone1,
|
108
|
+
phone_2: billPhone2
|
109
|
+
} = order?.billing
|
110
|
+
|
111
|
+
let {
|
112
|
+
first_name: shipFirstName,
|
113
|
+
last_name: shipLastName,
|
114
|
+
address_1: shipAddress1,
|
115
|
+
address_2: shipAddress2,
|
116
|
+
address_3: shipAddress3,
|
117
|
+
address_4: shipAddress4,
|
118
|
+
address_5: shipAddress5,
|
119
|
+
city: shipCity,
|
120
|
+
postcode: shipPostalCode,
|
121
|
+
country: shipCountry,
|
122
|
+
phone: shipPhone1,
|
123
|
+
phone_2: shipPhone2
|
124
|
+
} = order.shipping
|
125
|
+
|
126
|
+
let orderPackage = order?.orderPackage || {}
|
127
|
+
|
128
|
+
let orderItems = order.orderItems.map(item => {
|
129
|
+
let {
|
130
|
+
name: id,
|
131
|
+
variationId: variationId,
|
132
|
+
slaExpiresAt,
|
133
|
+
total,
|
134
|
+
totalTax,
|
135
|
+
subtotal,
|
136
|
+
subtotalTax,
|
137
|
+
qty
|
138
|
+
} = item
|
139
|
+
|
140
|
+
return {
|
141
|
+
id,
|
142
|
+
variationId,
|
143
|
+
currency: order.orderShipping.collectionCurrency,
|
144
|
+
createdAt: order.orderCreatedAt,
|
145
|
+
updatedAt: order.orderUpdatedAt,
|
146
|
+
charges: [
|
147
|
+
{
|
148
|
+
name: 'CHARGES_MARKETING',
|
149
|
+
grossAmount: 0,
|
150
|
+
nettAmount: 0
|
151
|
+
},
|
152
|
+
{
|
153
|
+
name: 'CLAIMS_DAMAGE',
|
154
|
+
grossAmount: 0,
|
155
|
+
nettAmount: 0
|
156
|
+
},
|
157
|
+
{
|
158
|
+
name: 'CLAIMS_LOST',
|
159
|
+
grossAmount: 0,
|
160
|
+
nettAmount: 0
|
161
|
+
},
|
162
|
+
{
|
163
|
+
name: 'COMMISSION_PLATFORM',
|
164
|
+
grossAmount: 0,
|
165
|
+
nettAmount: 0
|
166
|
+
},
|
167
|
+
{
|
168
|
+
name: 'DEPOSIT_PRESALE',
|
169
|
+
grossAmount: 0,
|
170
|
+
nettAmount: 0
|
171
|
+
},
|
172
|
+
{
|
173
|
+
name: 'FEE_MISCELLANEOUS',
|
174
|
+
grossAmount: 0,
|
175
|
+
nettAmount: 0
|
176
|
+
},
|
177
|
+
{
|
178
|
+
name: 'FEE_TRANSACTION',
|
179
|
+
grossAmount: 0,
|
180
|
+
nettAmount: 0
|
181
|
+
},
|
182
|
+
{
|
183
|
+
name: 'PRICE_NORMAL_SELLING',
|
184
|
+
grossAmount: total,
|
185
|
+
nettAmount: subtotal
|
186
|
+
},
|
187
|
+
{
|
188
|
+
name: 'PRICE_RECOMMENDED_RETAIL',
|
189
|
+
grossAmount: 0,
|
190
|
+
nettAmount: 0
|
191
|
+
},
|
192
|
+
{
|
193
|
+
name: 'PROMOTIONS_CUSTOMER_RECEIVED',
|
194
|
+
grossAmount: 0,
|
195
|
+
nettAmount: 0
|
196
|
+
},
|
197
|
+
{
|
198
|
+
name: 'PROMOTIONS_REBATE_PLATFORM',
|
199
|
+
grossAmount: 0,
|
200
|
+
nettAmount: 0
|
201
|
+
},
|
202
|
+
{
|
203
|
+
name: 'PROMOTIONS_REBATE_SELLER',
|
204
|
+
grossAmount: 0,
|
205
|
+
nettAmount: 0
|
206
|
+
},
|
207
|
+
{
|
208
|
+
name: 'REVERSAL_CHARGES_MARKETING',
|
209
|
+
grossAmount: 0,
|
210
|
+
nettAmount: 0
|
211
|
+
},
|
212
|
+
{
|
213
|
+
name: 'REVERSAL_COMMISSION',
|
214
|
+
grossAmount: 0,
|
215
|
+
nettAmount: 0
|
216
|
+
},
|
217
|
+
{
|
218
|
+
name: 'REVERSAL_FEE_MISCELLANEOUS',
|
219
|
+
grossAmount: 0,
|
220
|
+
nettAmount: 0
|
221
|
+
},
|
222
|
+
{
|
223
|
+
name: 'REVERSAL_PROMOTIONS_CUSTOMER_RECEIVED',
|
224
|
+
grossAmount: 0,
|
225
|
+
nettAmount: 0
|
226
|
+
},
|
227
|
+
{
|
228
|
+
name: 'REVERSAL_SELLER_RETURN_REFUND_AMOUNT',
|
229
|
+
grossAmount: 0,
|
230
|
+
nettAmount: 0
|
231
|
+
},
|
232
|
+
{
|
233
|
+
name: 'REVERSAL_SHIPPING_CUSTOMER_PAID',
|
234
|
+
grossAmount: 0,
|
235
|
+
nettAmount: 0
|
236
|
+
},
|
237
|
+
{
|
238
|
+
name: 'REVERSAL_SHIPPING_REBATE_PLATFORM',
|
239
|
+
grossAmount: 0,
|
240
|
+
nettAmount: 0
|
241
|
+
},
|
242
|
+
{
|
243
|
+
name: 'REVERSAL_SHIPPING_SELLER_PAID',
|
244
|
+
grossAmount: 0,
|
245
|
+
nettAmount: 0
|
246
|
+
},
|
247
|
+
{
|
248
|
+
name: 'SHIPPING_COST_TOTAL',
|
249
|
+
grossAmount: 0,
|
250
|
+
nettAmount: 0
|
251
|
+
},
|
252
|
+
{
|
253
|
+
name: 'SHIPPING_CUSTOMER_PAID',
|
254
|
+
grossAmount: 0,
|
255
|
+
nettAmount: 0
|
256
|
+
},
|
257
|
+
{
|
258
|
+
name: 'SHIPPING_REBATE_PLATFORM',
|
259
|
+
grossAmount: 0,
|
260
|
+
nettAmount: 0
|
261
|
+
},
|
262
|
+
{
|
263
|
+
name: 'SHIPPING_SELLER_PAID',
|
264
|
+
grossAmount: 0,
|
265
|
+
nettAmount: 0
|
266
|
+
},
|
267
|
+
{
|
268
|
+
name: 'TAXES',
|
269
|
+
grossAmount: totalTax,
|
270
|
+
nettAmount: subtotalTax
|
271
|
+
},
|
272
|
+
{
|
273
|
+
name: 'VOUCHERS_CUSTOMER_RECEIVED',
|
274
|
+
grossAmount: 0,
|
275
|
+
nettAmount: 0
|
276
|
+
},
|
277
|
+
{
|
278
|
+
name: 'VOUCHERS_REBATE_PLATFORM',
|
279
|
+
grossAmount: 0,
|
280
|
+
nettAmount: 0
|
281
|
+
},
|
282
|
+
{
|
283
|
+
name: 'VOUCHERS_REBATE_SELLER',
|
284
|
+
grossAmount: 0,
|
285
|
+
nettAmount: 0
|
286
|
+
}
|
287
|
+
],
|
288
|
+
slaExpiresAt,
|
289
|
+
qty
|
290
|
+
}
|
291
|
+
})
|
292
|
+
|
293
|
+
let mappedOrderItems = []
|
294
|
+
orderItems.map(oi => {
|
295
|
+
for (let i = 0; i < oi.qty; i++) {
|
296
|
+
let orderLine
|
297
|
+
if (orderLineList) {
|
298
|
+
orderLine = orderLineList?.find(ol => ol.sku_id == oi.variationId) || null
|
299
|
+
orderLineList = orderLineList.filter(ol => ol.order_line_id != orderLine.order_line_id)
|
300
|
+
}
|
301
|
+
mappedOrderItems.push({
|
302
|
+
...oi,
|
303
|
+
id: orderLine ? orderLine.order_line_id : `${oi.id}-${i + 1}`
|
304
|
+
})
|
305
|
+
}
|
306
|
+
})
|
307
|
+
|
147
308
|
return {
|
309
|
+
custFirstName,
|
310
|
+
custLastName,
|
311
|
+
createdAt,
|
312
|
+
updatedAt,
|
148
313
|
id,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
grossAmount: 0,
|
182
|
-
nettAmount: 0
|
183
|
-
},
|
184
|
-
{
|
185
|
-
name: 'FEE_TRANSACTION',
|
186
|
-
grossAmount: 0,
|
187
|
-
nettAmount: 0
|
188
|
-
},
|
189
|
-
{
|
190
|
-
name: 'PRICE_NORMAL_SELLING',
|
191
|
-
grossAmount: total,
|
192
|
-
nettAmount: subtotal
|
193
|
-
},
|
194
|
-
{
|
195
|
-
name: 'PRICE_RECOMMENDED_RETAIL',
|
196
|
-
grossAmount: 0,
|
197
|
-
nettAmount: 0
|
198
|
-
},
|
199
|
-
{
|
200
|
-
name: 'PROMOTIONS_CUSTOMER_RECEIVED',
|
201
|
-
grossAmount: 0,
|
202
|
-
nettAmount: 0
|
203
|
-
},
|
204
|
-
{
|
205
|
-
name: 'PROMOTIONS_REBATE_PLATFORM',
|
206
|
-
grossAmount: 0,
|
207
|
-
nettAmount: 0
|
208
|
-
},
|
209
|
-
{
|
210
|
-
name: 'PROMOTIONS_REBATE_SELLER',
|
211
|
-
grossAmount: 0,
|
212
|
-
nettAmount: 0
|
213
|
-
},
|
214
|
-
{
|
215
|
-
name: 'REVERSAL_CHARGES_MARKETING',
|
216
|
-
grossAmount: 0,
|
217
|
-
nettAmount: 0
|
218
|
-
},
|
219
|
-
{
|
220
|
-
name: 'REVERSAL_COMMISSION',
|
221
|
-
grossAmount: 0,
|
222
|
-
nettAmount: 0
|
223
|
-
},
|
224
|
-
{
|
225
|
-
name: 'REVERSAL_FEE_MISCELLANEOUS',
|
226
|
-
grossAmount: 0,
|
227
|
-
nettAmount: 0
|
228
|
-
},
|
229
|
-
{
|
230
|
-
name: 'REVERSAL_PROMOTIONS_CUSTOMER_RECEIVED',
|
231
|
-
grossAmount: 0,
|
232
|
-
nettAmount: 0
|
233
|
-
},
|
234
|
-
{
|
235
|
-
name: 'REVERSAL_SELLER_RETURN_REFUND_AMOUNT',
|
236
|
-
grossAmount: 0,
|
237
|
-
nettAmount: 0
|
238
|
-
},
|
239
|
-
{
|
240
|
-
name: 'REVERSAL_SHIPPING_CUSTOMER_PAID',
|
241
|
-
grossAmount: 0,
|
242
|
-
nettAmount: 0
|
243
|
-
},
|
244
|
-
{
|
245
|
-
name: 'REVERSAL_SHIPPING_REBATE_PLATFORM',
|
246
|
-
grossAmount: 0,
|
247
|
-
nettAmount: 0
|
248
|
-
},
|
249
|
-
{
|
250
|
-
name: 'REVERSAL_SHIPPING_SELLER_PAID',
|
251
|
-
grossAmount: 0,
|
252
|
-
nettAmount: 0
|
253
|
-
},
|
254
|
-
{
|
255
|
-
name: 'SHIPPING_COST_TOTAL',
|
256
|
-
grossAmount: 0,
|
257
|
-
nettAmount: 0
|
258
|
-
},
|
259
|
-
{
|
260
|
-
name: 'SHIPPING_CUSTOMER_PAID',
|
261
|
-
grossAmount: 0,
|
262
|
-
nettAmount: 0
|
263
|
-
},
|
264
|
-
{
|
265
|
-
name: 'SHIPPING_REBATE_PLATFORM',
|
266
|
-
grossAmount: 0,
|
267
|
-
nettAmount: 0
|
268
|
-
},
|
269
|
-
{
|
270
|
-
name: 'SHIPPING_SELLER_PAID',
|
271
|
-
grossAmount: 0,
|
272
|
-
nettAmount: 0
|
273
|
-
},
|
274
|
-
{
|
275
|
-
name: 'TAXES',
|
276
|
-
grossAmount: totalTax,
|
277
|
-
nettAmount: subtotalTax
|
278
|
-
},
|
279
|
-
{
|
280
|
-
name: 'VOUCHERS_CUSTOMER_RECEIVED',
|
281
|
-
grossAmount: 0,
|
282
|
-
nettAmount: 0
|
283
|
-
},
|
284
|
-
{
|
285
|
-
name: 'VOUCHERS_REBATE_PLATFORM',
|
286
|
-
grossAmount: 0,
|
287
|
-
nettAmount: 0
|
288
|
-
},
|
289
|
-
{
|
290
|
-
name: 'VOUCHERS_REBATE_SELLER',
|
291
|
-
grossAmount: 0,
|
292
|
-
nettAmount: 0
|
293
|
-
}
|
294
|
-
],
|
295
|
-
slaExpiresAt,
|
296
|
-
qty
|
314
|
+
sellercraftDisplayOrderNo,
|
315
|
+
billFirstName,
|
316
|
+
billLastName,
|
317
|
+
billAddress1: billAddress1?.toString() || shipAddress1?.toString(),
|
318
|
+
billAddress2: billAddress2 || shipAddress2,
|
319
|
+
billAddress3: billAddress3 || shipAddress3,
|
320
|
+
billAddress4: billAddress4 || shipAddress4,
|
321
|
+
billAddress5: billAddress5 || shipAddress5,
|
322
|
+
billCity: billCity || shipCity,
|
323
|
+
billPostalCode: billPostalCode || shipPostalCode,
|
324
|
+
billCountry: billCountry || shipCountry,
|
325
|
+
billPhone1: billPhone1 || shipPhone1,
|
326
|
+
billPhone2: billPhone2 || shipPhone2,
|
327
|
+
shipFirstName,
|
328
|
+
shipLastName,
|
329
|
+
shipAddress1: shipAddress1?.toString(),
|
330
|
+
shipAddress2,
|
331
|
+
shipAddress3,
|
332
|
+
shipAddress4,
|
333
|
+
shipAddress5,
|
334
|
+
shipCity,
|
335
|
+
shipPostalCode,
|
336
|
+
shipCountry,
|
337
|
+
shipPhone1,
|
338
|
+
shipPhone2,
|
339
|
+
mappedOrderItems,
|
340
|
+
channelShopId,
|
341
|
+
organisationId,
|
342
|
+
status: sellercraftStatus || status,
|
343
|
+
isSOF: isSOF ? isSOF : false,
|
344
|
+
orderPackage,
|
345
|
+
charges: getOrderCharges(mappedOrderItems)
|
297
346
|
}
|
298
347
|
})
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
348
|
+
|
349
|
+
if (mappedOrderResult.length > 0) {
|
350
|
+
while (mappedOrderResult.length > 0) {
|
351
|
+
let spliceResult = mappedOrderResult.splice(
|
352
|
+
0,
|
353
|
+
mappedOrderResult.length >= 20 ? 20 : mappedOrderResult.length
|
354
|
+
)
|
355
|
+
|
356
|
+
try {
|
357
|
+
await SellercraftChannelIntegrationAPI.ingestChannelOrder(sellercraftStore, {
|
358
|
+
orders: spliceResult
|
359
|
+
})
|
360
|
+
} catch (e) {
|
361
|
+
errors.push({
|
362
|
+
name: 'Order Ingestion Error',
|
363
|
+
msg: JSON.stringify(e) || {}
|
364
|
+
})
|
307
365
|
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
366
|
+
|
367
|
+
await Promise.all(
|
368
|
+
spliceResult.map(async result => {
|
369
|
+
if (!result?.isSOF && result?.orderPackage?.packageId) {
|
370
|
+
let orderPackage: any = result.orderPackage
|
371
|
+
let newOrderPackage: any = {
|
372
|
+
channelShopId,
|
373
|
+
nativeOrderId: result.id,
|
374
|
+
nativePackageId: orderPackage.packageId,
|
375
|
+
shippingTrackingCode: orderPackage.trackingNumber,
|
376
|
+
shippingTypeValue: orderPackage?.shippingType
|
377
|
+
? orderPackage.shippingType
|
378
|
+
: SHIPPING_TYPE.DROP_SHIPPING,
|
379
|
+
warehouseCode: SHIPPING_TYPE.DROP_SHIPPING,
|
380
|
+
shipper: {
|
381
|
+
name: orderPackage.shippingProvider,
|
382
|
+
isCodSupported: orderPackage?.isCodSupport ? orderPackage.isCodSupport : false
|
383
|
+
},
|
384
|
+
documents: orderPackage?.orderDocument || [],
|
385
|
+
shipperLastMile: {
|
386
|
+
name: orderPackage.shippingProvider,
|
387
|
+
isCodSupported: orderPackage?.isCodSupport ? orderPackage.isCodSupport : false
|
388
|
+
},
|
389
|
+
orderItemIds: orderPackage?.orderListIdList
|
390
|
+
? orderPackage.orderListIdList
|
391
|
+
: result.mappedOrderItems.map(orderItem => orderItem.id)
|
392
|
+
}
|
393
|
+
try {
|
394
|
+
await SellercraftChannelIntegrationAPI.ingestChannelOrderPackage(
|
395
|
+
sellercraftStore,
|
396
|
+
newOrderPackage
|
397
|
+
)
|
398
|
+
} catch (e) {
|
399
|
+
errors.push({
|
400
|
+
name: 'Order Package Ingestion Error',
|
401
|
+
msg: JSON.stringify(e) || {}
|
402
|
+
})
|
403
|
+
}
|
404
|
+
}
|
405
|
+
})
|
406
|
+
)
|
312
407
|
}
|
313
|
-
})
|
314
|
-
|
315
|
-
return {
|
316
|
-
custFirstName,
|
317
|
-
custLastName,
|
318
|
-
createdAt,
|
319
|
-
updatedAt,
|
320
|
-
id,
|
321
|
-
sellercraftDisplayOrderNo,
|
322
|
-
billFirstName,
|
323
|
-
billLastName,
|
324
|
-
billAddress1: billAddress1?.toString() || shipAddress1?.toString(),
|
325
|
-
billAddress2: billAddress2 || shipAddress2,
|
326
|
-
billAddress3: billAddress3 || shipAddress3,
|
327
|
-
billAddress4: billAddress4 || shipAddress4,
|
328
|
-
billAddress5: billAddress5 || shipAddress5,
|
329
|
-
billCity: billCity || shipCity,
|
330
|
-
billPostalCode: billPostalCode || shipPostalCode,
|
331
|
-
billCountry: billCountry || shipCountry,
|
332
|
-
billPhone1: billPhone1 || shipPhone1,
|
333
|
-
billPhone2: billPhone2 || shipPhone2,
|
334
|
-
shipFirstName,
|
335
|
-
shipLastName,
|
336
|
-
shipAddress1: shipAddress1?.toString(),
|
337
|
-
shipAddress2,
|
338
|
-
shipAddress3,
|
339
|
-
shipAddress4,
|
340
|
-
shipAddress5,
|
341
|
-
shipCity,
|
342
|
-
shipPostalCode,
|
343
|
-
shipCountry,
|
344
|
-
shipPhone1,
|
345
|
-
shipPhone2,
|
346
|
-
mappedOrderItems,
|
347
|
-
channelShopId,
|
348
|
-
organisationId,
|
349
|
-
status: sellercraftStatus || status,
|
350
|
-
isSOF: isSOF ? isSOF : false,
|
351
|
-
orderPackage,
|
352
|
-
charges: getOrderCharges(mappedOrderItems)
|
353
408
|
}
|
354
|
-
})
|
355
|
-
|
356
|
-
if (mappedOrderResult.length > 0) {
|
357
|
-
while (mappedOrderResult.length > 0) {
|
358
|
-
let spliceResult = mappedOrderResult.splice(
|
359
|
-
0,
|
360
|
-
mappedOrderResult.length >= 20 ? 20 : mappedOrderResult.length
|
361
|
-
)
|
362
|
-
|
363
|
-
try {
|
364
|
-
await SellercraftChannelIntegrationAPI.ingestChannelOrder(sellercraftStore, {
|
365
|
-
orders: spliceResult
|
366
|
-
})
|
367
|
-
} catch (e) {
|
368
|
-
errors.push({
|
369
|
-
name: 'Order Ingestion Error',
|
370
|
-
msg: JSON.stringify(e) || {}
|
371
|
-
})
|
372
|
-
}
|
373
409
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
let orderPackage: any = result.orderPackage
|
378
|
-
let newOrderPackage: any = {
|
379
|
-
channelShopId,
|
380
|
-
nativeOrderId: result.id,
|
381
|
-
nativePackageId: orderPackage.packageId,
|
382
|
-
shippingTrackingCode: orderPackage.trackingNumber,
|
383
|
-
shippingTypeValue: orderPackage?.shippingType
|
384
|
-
? orderPackage.shippingType
|
385
|
-
: SHIPPING_TYPE.DROP_SHIPPING,
|
386
|
-
warehouseCode: SHIPPING_TYPE.DROP_SHIPPING,
|
387
|
-
shipper: {
|
388
|
-
name: orderPackage.shippingProvider,
|
389
|
-
isCodSupported: orderPackage?.isCodSupport ? orderPackage.isCodSupport : false
|
390
|
-
},
|
391
|
-
documents: orderPackage?.orderDocument || [],
|
392
|
-
shipperLastMile: {
|
393
|
-
name: orderPackage.shippingProvider,
|
394
|
-
isCodSupported: orderPackage?.isCodSupport ? orderPackage.isCodSupport : false
|
395
|
-
},
|
396
|
-
orderItemIds: orderPackage?.orderListIdList
|
397
|
-
? orderPackage.orderListIdList
|
398
|
-
: result.mappedOrderItems.map(orderItem => orderItem.id)
|
399
|
-
}
|
400
|
-
try {
|
401
|
-
await SellercraftChannelIntegrationAPI.ingestChannelOrderPackage(
|
402
|
-
sellercraftStore,
|
403
|
-
newOrderPackage
|
404
|
-
)
|
405
|
-
} catch (e) {
|
406
|
-
errors.push({
|
407
|
-
name: 'Order Package Ingestion Error',
|
408
|
-
msg: JSON.stringify(e) || {}
|
409
|
-
})
|
410
|
-
}
|
411
|
-
}
|
412
|
-
})
|
413
|
-
)
|
414
|
-
}
|
410
|
+
if (more) page++
|
411
|
+
hasMorePage = more
|
412
|
+
cursor = nextCursor
|
415
413
|
}
|
416
414
|
} catch (e) {
|
417
415
|
errors.push({
|