@things-factory/integration-marketplace 4.2.1 → 4.2.2
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/controllers/magento/apis/get-store-order.js +20 -0
- package/dist-server/controllers/magento/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/magento/apis/get-store-orders.js +31 -3
- package/dist-server/controllers/magento/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-product-categories.js +41 -0
- package/dist-server/controllers/magento/apis/get-store-product-categories.js.map +1 -0
- package/dist-server/controllers/magento/apis/get-store-products.js +29 -10
- package/dist-server/controllers/magento/apis/get-store-products.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-stock-item.js +1 -1
- package/dist-server/controllers/magento/apis/get-store-stock-item.js.map +1 -1
- package/dist-server/controllers/magento/apis/index.js +5 -0
- package/dist-server/controllers/magento/apis/index.js.map +1 -1
- package/dist-server/controllers/magento/apis/update-order-status.js +57 -0
- package/dist-server/controllers/magento/apis/update-order-status.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-price.js +28 -0
- package/dist-server/controllers/magento/apis/update-store-product-price.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-stock.js +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-stock.js.map +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-variation-price.js +28 -0
- package/dist-server/controllers/magento/apis/update-store-product-variation-price.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-order-status.js +17 -15
- package/dist-server/controllers/woocommerce/apis/update-order-status.js.map +1 -1
- package/package.json +2 -2
- package/server/controllers/magento/apis/get-store-order.ts +15 -0
- package/server/controllers/magento/apis/get-store-orders.ts +32 -3
- package/server/controllers/magento/apis/get-store-product-categories.ts +36 -0
- package/server/controllers/magento/apis/get-store-products.ts +35 -10
- package/server/controllers/magento/apis/get-store-stock-item.ts +1 -1
- package/server/controllers/magento/apis/index.ts +5 -0
- package/server/controllers/magento/apis/update-order-status.ts +53 -0
- package/server/controllers/magento/apis/update-store-product-price.ts +24 -0
- package/server/controllers/magento/apis/update-store-product-stock.ts +1 -1
- package/server/controllers/magento/apis/update-store-product-variation-price.ts +24 -0
- package/server/controllers/magento/apis/update-store-product-variation-stock.ts +1 -1
- package/server/controllers/woocommerce/apis/update-order-status.ts +18 -14
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStoreOrder = void 0;
|
|
4
|
+
function getStoreOrder() {
|
|
5
|
+
return {
|
|
6
|
+
path: '/orders/{id}',
|
|
7
|
+
method: 'get',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
let { id } = req;
|
|
10
|
+
return {
|
|
11
|
+
resource: { id }
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.getStoreOrder = getStoreOrder;
|
|
20
|
+
//# sourceMappingURL=get-store-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-order.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-order.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,KAAK;QACb,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;YAChB,OAAO;gBACL,QAAQ,EAAE,EAAE,EAAE,EAAE;aACjB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAdD,sCAcC"}
|
|
@@ -49,14 +49,18 @@ function getStoreOrders() {
|
|
|
49
49
|
let result;
|
|
50
50
|
let docRefNo = orderNo;
|
|
51
51
|
let orderItems = items.map(item => {
|
|
52
|
-
var { item_id: name, product_id, qty_ordered: qty, price } = item;
|
|
52
|
+
var { item_id: name, product_id, qty_ordered: qty, price, original_price, price, tax_amount, tax_invoiced } = item;
|
|
53
53
|
return {
|
|
54
54
|
name,
|
|
55
55
|
variationId: product_id,
|
|
56
56
|
qty,
|
|
57
57
|
paidPrice: price,
|
|
58
58
|
orderNo,
|
|
59
|
-
docRefNo
|
|
59
|
+
docRefNo,
|
|
60
|
+
total: price,
|
|
61
|
+
totalTax: tax_invoiced,
|
|
62
|
+
subtotal: original_price,
|
|
63
|
+
subtotalTax: tax_amount
|
|
60
64
|
};
|
|
61
65
|
});
|
|
62
66
|
result = {
|
|
@@ -83,10 +87,34 @@ function getStoreOrders() {
|
|
|
83
87
|
postCode: postcode,
|
|
84
88
|
city,
|
|
85
89
|
country: country_id === 'MY' ? 'Malaysia' : country_id,
|
|
86
|
-
collectionCurrency:
|
|
90
|
+
collectionCurrency: order.order_currency_code,
|
|
87
91
|
attentionTo: `${firstname} ${middlename} ${lastname}`
|
|
88
92
|
};
|
|
89
93
|
result.orderShipping = orderShipping;
|
|
94
|
+
// For SC mapping
|
|
95
|
+
result.shipping = {
|
|
96
|
+
address_1: street,
|
|
97
|
+
postcode: postcode,
|
|
98
|
+
country: country_id,
|
|
99
|
+
city,
|
|
100
|
+
first_name: firstname,
|
|
101
|
+
last_name: lastname,
|
|
102
|
+
phone: telephone,
|
|
103
|
+
email: order.customer_email
|
|
104
|
+
};
|
|
105
|
+
let billingAddress = order === null || order === void 0 ? void 0 : order.billing_address;
|
|
106
|
+
result.billing = {
|
|
107
|
+
address_1: billingAddress.street,
|
|
108
|
+
postcode: billingAddress.postcode,
|
|
109
|
+
country: billingAddress.country_id,
|
|
110
|
+
city: billingAddress.city,
|
|
111
|
+
first_name: billingAddress.firstname,
|
|
112
|
+
last_name: billingAddress.lastname,
|
|
113
|
+
phone: billingAddress.telephone,
|
|
114
|
+
email: billingAddress.email
|
|
115
|
+
};
|
|
116
|
+
result.firstName = order.customer_firstname;
|
|
117
|
+
result.lastName = order.customer_lastname;
|
|
90
118
|
}
|
|
91
119
|
return result;
|
|
92
120
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAChD,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;YACrD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;YACnD,kEAAkE;YAClE,oCAAoC;YACpC,2BAA2B;YAE3B,IAAI,OAAO,GAAQ;gBACjB,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,KAAK;gBACf,aAAa,EAAE;oBACb;wBACE,OAAO,EAAE;4BACP;gCACE,KAAK,EAAE,YAAY;gCACnB,KAAK,EAAE,cAAc;gCACrB,cAAc,EAAE,MAAM;6BACvB;yBACF;qBACF;oBACD;wBACE,OAAO,EAAE;4BACP;gCACE,KAAK,EAAE,YAAY;gCACnB,KAAK,EAAE,cAAc;gCACrB,cAAc,EAAE,IAAI;6BACrB;yBACF;qBACF;iBACF;aACF,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC5B,oBAAoB;YAEpB,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;YAE3B,MAAM,OAAO,GAAU,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;;gBACxC,MAAM,EACJ,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,EACrB,mBAAmB,EAAE,QAAQ,EAC7B,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,MAAM,EACN,KAAK,EACN,GAAG,KAAK,CAAA;gBAET,IAAI,MAAW,CAAA;gBACf,IAAI,QAAQ,GAAG,OAAO,CAAA;gBAEtB,IAAI,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAChC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAChD,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;YACrD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;YACnD,kEAAkE;YAClE,oCAAoC;YACpC,2BAA2B;YAE3B,IAA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,GAAG;wBAChB,SAAS,EAAE,MAAM;wBACjB,QAAQ,EAAE,QAAQ;wBAClB,OAAO,EAAE,UAAU;wBACnB,IAAI;wBACJ,UAAU,EAAE,SAAS;wBACrB,SAAS,EAAE,QAAQ;wBACnB,KAAK,EAAE,SAAS;wBAChB,KAAK,EAAE,KAAK,CAAC,cAAc;qBAC5B,CAAA;oBACD,IAAI,cAAc,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAA;oBAC3C,MAAM,CAAC,OAAO,GAAG;wBACf,SAAS,EAAE,cAAc,CAAC,MAAM;wBAChC,QAAQ,EAAE,cAAc,CAAC,QAAQ;wBACjC,OAAO,EAAE,cAAc,CAAC,UAAU;wBAClC,IAAI,EAAE,cAAc,CAAC,IAAI;wBACzB,UAAU,EAAE,cAAc,CAAC,SAAS;wBACpC,SAAS,EAAE,cAAc,CAAC,QAAQ;wBAClC,KAAK,EAAE,cAAc,CAAC,SAAS;wBAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;qBAC5B,CAAA;oBACD,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,kBAAkB,CAAA;oBAC3C,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAA;iBAC1C;gBAED,OAAO,MAAM,CAAA;YACf,CAAC,CAAC,CAAA;YAEF,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC;AAxJD,wCAwJC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStoreProductCategories = void 0;
|
|
4
|
+
function getStoreProductCategories() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'get',
|
|
7
|
+
path: '/categories',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
const resource = {};
|
|
10
|
+
const payload = {};
|
|
11
|
+
return { resource, payload };
|
|
12
|
+
},
|
|
13
|
+
normalize(res) {
|
|
14
|
+
let results = res.children_data;
|
|
15
|
+
results = mapCategories(results, []);
|
|
16
|
+
results = results.map(result => {
|
|
17
|
+
let { id, name, parent_id, is_active, children_data } = result;
|
|
18
|
+
return {
|
|
19
|
+
id,
|
|
20
|
+
name,
|
|
21
|
+
parent: parent_id,
|
|
22
|
+
isActive: is_active
|
|
23
|
+
// childrenCategories: children_data
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return { results: results };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.getStoreProductCategories = getStoreProductCategories;
|
|
31
|
+
function mapCategories(results, arr) {
|
|
32
|
+
var _a;
|
|
33
|
+
for (let result of results) {
|
|
34
|
+
if (((_a = result.children_data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
35
|
+
mapCategories(result.children_data, arr);
|
|
36
|
+
}
|
|
37
|
+
arr.push(result);
|
|
38
|
+
}
|
|
39
|
+
return arr;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=get-store-product-categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-product-categories.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-product-categories.ts"],"names":[],"mappings":";;;AAAA,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,WAAW,CAAC,GAAG;YACb,MAAM,QAAQ,GAAQ,EAAE,CAAA;YACxB,MAAM,OAAO,GAAQ,EAAE,CAAA;YACvB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;QAC9B,CAAC;QACD,SAAS,CAAC,GAAG;YACX,IAAI,OAAO,GAAG,GAAG,CAAC,aAAa,CAAA;YAC/B,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YACpC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC7B,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;gBAC9D,OAAO;oBACL,EAAE;oBACF,IAAI;oBACJ,MAAM,EAAE,SAAS;oBACjB,QAAQ,EAAE,SAAS;oBACrB,sCAAsC;iBACrC,CAAA;YACH,CAAC,CAAC,CAAA;YACF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC;AAzBD,8DAyBC;AAED,SAAS,aAAa,CAAC,OAAO,EAAE,GAAG;;IACjC,KAAK,IAAI,MAAM,IAAI,OAAO,EAAE;QACxB,IAAI,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM,IAAG,CAAC,EAAE;YACpC,aAAa,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;SACzC;QACD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -17,8 +17,10 @@ function getStoreProducts() {
|
|
|
17
17
|
return { payload };
|
|
18
18
|
},
|
|
19
19
|
async normalize(res, { store }) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
20
21
|
// return res.products
|
|
21
22
|
let { items, total_count } = res;
|
|
23
|
+
let parentLinkList = (_a = items.map(e => { return { id: e.id, children: e.extension_attributes.configurable_product_links }; })) === null || _a === void 0 ? void 0 : _a.filter(e => e.children);
|
|
22
24
|
let activeMarketplaceDistributors = [];
|
|
23
25
|
if (store === null || store === void 0 ? void 0 : store.marketplaceDistributors) {
|
|
24
26
|
activeMarketplaceDistributors = store.marketplaceDistributors.filter(marketplaceDistributor => marketplaceDistributor.status === 'ACTIVE');
|
|
@@ -26,24 +28,34 @@ function getStoreProducts() {
|
|
|
26
28
|
let results = [];
|
|
27
29
|
for (var i = 0; i < items.length; i++) {
|
|
28
30
|
const product = items[i];
|
|
29
|
-
const stockItems = await store_api_1.StoreAPI.getStoreStockItem(store, {
|
|
30
|
-
sku: product.sku,
|
|
31
|
-
distributors: activeMarketplaceDistributors
|
|
32
|
-
});
|
|
33
31
|
let totalProductQty = 0;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
try {
|
|
33
|
+
const stockItems = await store_api_1.StoreAPI.getStoreStockItem(store, {
|
|
34
|
+
sku: product.sku,
|
|
35
|
+
distributors: activeMarketplaceDistributors
|
|
36
|
+
});
|
|
37
|
+
stockItems.map(stockItem => {
|
|
38
|
+
if (stockItem.sku === product.sku) {
|
|
39
|
+
totalProductQty += stockItem.qty;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch (e) { }
|
|
39
44
|
const productVariations = await store_api_1.StoreAPI.getStoreProductVariations(store, { sku: product.sku });
|
|
40
45
|
const result = {
|
|
41
46
|
itemId: product.id,
|
|
47
|
+
parentId: ((_b = parentLinkList.find(e => e.children.includes(product.id))) === null || _b === void 0 ? void 0 : _b.id) || 0,
|
|
42
48
|
isku: product.sku,
|
|
43
49
|
name: product.name,
|
|
44
50
|
type: product.type_id,
|
|
45
51
|
hasVariation: false,
|
|
46
52
|
attributes: [],
|
|
53
|
+
images: ((_d = (_c = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _c === void 0 ? void 0 : _c.find(att => att.attribute_code == 'image')) === null || _d === void 0 ? void 0 : _d.value)
|
|
54
|
+
? [
|
|
55
|
+
`${store.storeURL}pub/media/catalog/product${(_f = (_e = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _e === void 0 ? void 0 : _e.find(att => att.attribute_code == 'image')) === null || _f === void 0 ? void 0 : _f.value}`
|
|
56
|
+
]
|
|
57
|
+
: [],
|
|
58
|
+
categoryId: (_g = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _g === void 0 ? void 0 : _g.find(att => att.attribute_code == 'category_ids').value[0],
|
|
47
59
|
variations: productVariations.length > 0
|
|
48
60
|
? productVariations.map(variant => {
|
|
49
61
|
const { stock_id: variantStockId, qty: variantQty } = variant.extension_attributes.stock_item;
|
|
@@ -72,7 +84,14 @@ function getStoreProducts() {
|
|
|
72
84
|
sellPrice: product.price,
|
|
73
85
|
marketplaceStatus: product.status,
|
|
74
86
|
primaryUnit: 'lbs',
|
|
75
|
-
primaryUnitValue: product.weight
|
|
87
|
+
primaryUnitValue: product.weight,
|
|
88
|
+
length: ((_j = (_h = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _h === void 0 ? void 0 : _h.find(att => att.attribute_code == 'ts_dimensions_length')) === null || _j === void 0 ? void 0 : _j.value) *
|
|
89
|
+
25.4 || 0,
|
|
90
|
+
width: ((_l = (_k = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _k === void 0 ? void 0 : _k.find(att => att.attribute_code == 'ts_dimensions_width')) === null || _l === void 0 ? void 0 : _l.value) *
|
|
91
|
+
25.4 || 0,
|
|
92
|
+
height: ((_o = (_m = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _m === void 0 ? void 0 : _m.find(att => att.attribute_code == 'ts_dimensions_height')) === null || _o === void 0 ? void 0 : _o.value) *
|
|
93
|
+
25.4 || 0,
|
|
94
|
+
weight: product.weight * 453.59237 || 0
|
|
76
95
|
}
|
|
77
96
|
]
|
|
78
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,2GAA2G;;;AAE3G,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC9B,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;YAE3D,IAAI,OAAO,GAAQ;gBACjB,WAAW,EAAE,IAAI,GAAG,CAAC;gBACrB,QAAQ,EAAE,KAAK;aAChB,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE
|
|
1
|
+
{"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,2GAA2G;;;AAE3G,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC9B,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;YAE3D,IAAI,OAAO,GAAQ;gBACjB,WAAW,EAAE,IAAI,GAAG,CAAC;gBACrB,QAAQ,EAAE,KAAK;aAChB,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;;YAC5B,sBAAsB;YACtB,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAA;YAEhC,IAAI,cAAc,GAAG,MAAA,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAE,OAAO,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,oBAAoB,CAAC,0BAA0B,EAAC,CAAA,CAAA,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC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I,CAAC;6BACxC;yBACF;iBACR,CAAA;gBAED,OAAO,CAAC,IAAI,mBAAM,MAAM,EAAG,CAAA;aAC5B;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;QACxC,CAAC;KACF,CAAA;AACH,CAAC;AApHD,4CAoHC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-store-stock-item.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-stock-item.ts"],"names":[],"mappings":";AAAA,iIAAiI;;;AAEjI,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAEjC,IAAI,YAAY,GAAQ;gBACtB;oBACE,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,GAAG;4BACV,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF;aACF,CAAA;YAED,IAAI,YAAY,EAAE;
|
|
1
|
+
{"version":3,"file":"get-store-stock-item.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-stock-item.ts"],"names":[],"mappings":";AAAA,iIAAiI;;;AAEjI,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAEjC,IAAI,YAAY,GAAQ;gBACtB;oBACE,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,GAAG;4BACV,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF;aACF,CAAA;YAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;gBAEzE,YAAY,CAAC,IAAI,CAAC;oBAChB,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,aAAa;4BACpB,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE;4BACjC,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF,CAAC,CAAA;aACH;YAED,IAAI,OAAO,GAAQ;gBACjB,aAAa,EAAE,YAAY;aAC5B,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;YACrB,IAAI,MAAM,GAAU;gBAClB;oBACE,GAAG,EAAE,EAAE;oBACP,UAAU,EAAE,EAAE;oBACd,GAAG,EAAE,CAAC;oBACN,MAAM,EAAE,EAAE;iBACX;aACF,CAAA;YAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBACxB,OAAO;wBACL,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,UAAU,EAAE,IAAI,CAAC,WAAW;wBAC5B,GAAG,EAAE,IAAI,CAAC,QAAQ;wBAClB,MAAM,EAAE,IAAI,CAAC,MAAM;qBACpB,CAAA;gBACH,CAAC,CAAC,CAAA;aACH;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC;AA/DD,8CA+DC"}
|
|
@@ -21,4 +21,9 @@ __exportStar(require("./create-order-refund"), exports);
|
|
|
21
21
|
__exportStar(require("./create-order-ship"), exports);
|
|
22
22
|
__exportStar(require("./update-store-product-stock"), exports);
|
|
23
23
|
__exportStar(require("./update-store-product-variation-stock"), exports);
|
|
24
|
+
__exportStar(require("./get-store-product-categories"), exports);
|
|
25
|
+
__exportStar(require("./update-order-status"), exports);
|
|
26
|
+
__exportStar(require("./get-store-order"), exports);
|
|
27
|
+
__exportStar(require("./update-store-product-price"), exports);
|
|
28
|
+
__exportStar(require("./update-store-product-variation-price"), exports);
|
|
24
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,yDAAsC;AACtC,yDAAsC;AACtC,wDAAqC;AACrC,sDAAmC;AACnC,+DAA4C;AAC5C,yEAAsD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,yDAAsC;AACtC,yDAAsC;AACtC,wDAAqC;AACrC,sDAAmC;AACnC,+DAA4C;AAC5C,yEAAsD;AACtD,iEAA8C;AAC9C,wDAAqC;AACrC,oDAAiC;AACjC,+DAA4C;AAC5C,yEAAsD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateOrderStatus = void 0;
|
|
4
|
+
const store_api_1 = require("../../store-api");
|
|
5
|
+
function updateOrderStatus() {
|
|
6
|
+
return {
|
|
7
|
+
method: 'post',
|
|
8
|
+
path: '/order/{subpath}',
|
|
9
|
+
async denormalize(req, { store }) {
|
|
10
|
+
let { orderId, status, trackingNo, carrier } = req;
|
|
11
|
+
let pr;
|
|
12
|
+
if (status == 'SHIPPED' || status == 'READY_TO_SHIP' || status == 'PROCESSING' || status == 'PACKED') {
|
|
13
|
+
let order = await store_api_1.StoreAPI.getStoreOrder(store, { id: orderId });
|
|
14
|
+
pr = {
|
|
15
|
+
resource: {
|
|
16
|
+
subpath: `${orderId}/ship`
|
|
17
|
+
},
|
|
18
|
+
payload: {
|
|
19
|
+
items: order.items.map(e => { return { order_item_id: e.item_id, qty: e.qty_ordered }; }),
|
|
20
|
+
tracks: [
|
|
21
|
+
{
|
|
22
|
+
carrier_code: carrier,
|
|
23
|
+
track_number: trackingNo,
|
|
24
|
+
title: carrier
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
arguments: {
|
|
28
|
+
extension_attributes: {
|
|
29
|
+
source_code: 'default'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else if (status == 'DELIVERED' || status == 'CLOSED') {
|
|
36
|
+
pr = {
|
|
37
|
+
resource: {
|
|
38
|
+
subpath: `${orderId}/invoice`
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else if (status == 'REFUND_COMPLETE' || status == 'RETURN_COMPLETE') {
|
|
43
|
+
pr = {
|
|
44
|
+
resource: {
|
|
45
|
+
subpath: `${orderId}/refund`
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return pr;
|
|
50
|
+
},
|
|
51
|
+
normalize(res) {
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.updateOrderStatus = updateOrderStatus;
|
|
57
|
+
//# sourceMappingURL=update-order-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-order-status.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAE1C,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,kBAAkB;QACxB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,U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DD,8CAkDC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateStoreProductPrice = void 0;
|
|
4
|
+
function updateStoreProductPrice() {
|
|
5
|
+
return {
|
|
6
|
+
path: '/products/base-prices',
|
|
7
|
+
method: 'post',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
let { sellPrice, variationSku } = req;
|
|
10
|
+
return {
|
|
11
|
+
payload: {
|
|
12
|
+
prices: [
|
|
13
|
+
{
|
|
14
|
+
price: sellPrice,
|
|
15
|
+
sku: variationSku,
|
|
16
|
+
store_id: 0
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
normalize(res) {
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.updateStoreProductPrice = updateStoreProductPrice;
|
|
28
|
+
//# sourceMappingURL=update-store-product-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-price.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,uBAAuB;IACrC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAErC,OAAO;gBACL,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN;4BACE,KAAK,EAAE,SAAS;4BAChB,GAAG,EAAE,YAAY;4BACjB,QAAQ,EAAE,CAAC;yBACZ;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,0DAuBC"}
|
|
@@ -8,7 +8,7 @@ function updateStoreProductStock() {
|
|
|
8
8
|
method: 'post',
|
|
9
9
|
path: '/inventory/source-items',
|
|
10
10
|
denormalize(req) {
|
|
11
|
-
const { variationSku, qty, distributors } = req[0];
|
|
11
|
+
const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {};
|
|
12
12
|
let sourceItems = [];
|
|
13
13
|
if (distributors.length > 0) {
|
|
14
14
|
distributors.map(distributor => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAEtF,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,0DAsCC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateStoreProductVariationPrice = void 0;
|
|
4
|
+
function updateStoreProductVariationPrice() {
|
|
5
|
+
return {
|
|
6
|
+
path: '/products/base-prices',
|
|
7
|
+
method: 'post',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
let { sellPrice, variationSku } = req;
|
|
10
|
+
return {
|
|
11
|
+
payload: {
|
|
12
|
+
prices: [
|
|
13
|
+
{
|
|
14
|
+
price: sellPrice,
|
|
15
|
+
sku: variationSku,
|
|
16
|
+
store_id: 0
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
normalize(res) {
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.updateStoreProductVariationPrice = updateStoreProductVariationPrice;
|
|
28
|
+
//# sourceMappingURL=update-store-product-variation-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-price.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAErC,OAAO;gBACL,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN;4BACE,KAAK,EAAE,SAAS;4BAChB,GAAG,EAAE,YAAY;4BACjB,QAAQ,EAAE,CAAC;yBACZ;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,4EAuBC"}
|
|
@@ -8,7 +8,7 @@ function updateStoreProductVariationStock() {
|
|
|
8
8
|
method: 'post',
|
|
9
9
|
path: '/inventory/source-items',
|
|
10
10
|
denormalize(req) {
|
|
11
|
-
const { variationSku, qty, distributors } = req[0];
|
|
11
|
+
const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {};
|
|
12
12
|
let sourceItems = [];
|
|
13
13
|
if (distributors.length > 0) {
|
|
14
14
|
distributors.map(distributor => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAErF,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,4EAsCC"}
|
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.updateOrderStatus = void 0;
|
|
6
6
|
const store_api_1 = require("../../store-api");
|
|
7
|
+
const ORDER_STATUS = {
|
|
8
|
+
PAYMENT_PENDING: 'pending',
|
|
9
|
+
PROCESSING: 'processing',
|
|
10
|
+
PACKED: 'processing',
|
|
11
|
+
READY_TO_SHIP: 'processing',
|
|
12
|
+
SHIPPED: 'processing',
|
|
13
|
+
CONFIRMED: 'processing',
|
|
14
|
+
DELIVERED: 'completed',
|
|
15
|
+
CLOSED: 'completed',
|
|
16
|
+
CANCELLED: 'cancelled',
|
|
17
|
+
REFUND_COMPLETE: 'refunded',
|
|
18
|
+
RETURN_COMPLETE: 'refunded',
|
|
19
|
+
REVERSE_SHIPMENT_FAILED: 'failed',
|
|
20
|
+
SHIPMENT_LOST_OR_DAMAGED: 'failed',
|
|
21
|
+
PAYMENT_PENDING_TIMEOUT: 'failed'
|
|
22
|
+
};
|
|
7
23
|
function updateOrderStatus(req) {
|
|
8
24
|
return {
|
|
9
25
|
method: 'put',
|
|
@@ -11,21 +27,7 @@ function updateOrderStatus(req) {
|
|
|
11
27
|
async denormalize(req, { store }) {
|
|
12
28
|
var { status, orderId } = req || {};
|
|
13
29
|
const order = await store_api_1.StoreAPI.getStoreOrder(store, { orderId });
|
|
14
|
-
let orderStatus = status;
|
|
15
|
-
if (orderStatus == 'PACKED') {
|
|
16
|
-
if (order.status == 'pending') {
|
|
17
|
-
orderStatus = 'on-hold';
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
orderStatus = order.status;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (orderStatus == 'READY_TO_SHIP') {
|
|
24
|
-
orderStatus = 'completed';
|
|
25
|
-
}
|
|
26
|
-
if (orderStatus == 'CANCELLED') {
|
|
27
|
-
orderStatus = 'cancelled';
|
|
28
|
-
}
|
|
30
|
+
let orderStatus = ORDER_STATUS[`${status}`] || order.status;
|
|
29
31
|
return { resource: { orderId: orderId }, payload: { status: orderStatus } };
|
|
30
32
|
},
|
|
31
33
|
normalize(res) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,SAAgB,iBAAiB,CAAC,GAAG;IACnC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,MAAM,YAAY,GAAG;IACnB,eAAe,EAAE,SAAS;IAC1B,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,YAAY;IACpB,aAAa,EAAE,YAAY;IAC3B,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,WAAW;IACnB,SAAS,EAAE,WAAW;IACtB,eAAe,EAAE,UAAU;IAC3B,eAAe,EAAE,UAAU;IAC3B,uBAAuB,EAAE,QAAQ;IACjC,wBAAwB,EAAE,QAAQ;IAClC,uBAAuB,EAAE,QAAQ;CAClC,CAAA;AAED,SAAgB,iBAAiB,CAAC,GAAG;IACnC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,YAAY,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAA;YAE3D,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAA;QAC7E,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,8CAiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-marketplace",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"nock": "^13.0.2",
|
|
53
53
|
"should": "^13.2.3"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "29a63a11161cd2b9692f9e9aafbf4d34b17a6a7b"
|
|
56
56
|
}
|
|
@@ -63,7 +63,7 @@ export function getStoreOrders() {
|
|
|
63
63
|
let docRefNo = orderNo
|
|
64
64
|
|
|
65
65
|
let orderItems = items.map(item => {
|
|
66
|
-
var { item_id: name, product_id, qty_ordered: qty, price } = item
|
|
66
|
+
var { item_id: name, product_id, qty_ordered: qty, price, original_price, price, tax_amount, tax_invoiced } = item
|
|
67
67
|
|
|
68
68
|
return {
|
|
69
69
|
name,
|
|
@@ -71,7 +71,11 @@ export function getStoreOrders() {
|
|
|
71
71
|
qty,
|
|
72
72
|
paidPrice: price,
|
|
73
73
|
orderNo,
|
|
74
|
-
docRefNo
|
|
74
|
+
docRefNo,
|
|
75
|
+
total: price,
|
|
76
|
+
totalTax: tax_invoiced,
|
|
77
|
+
subtotal: original_price,
|
|
78
|
+
subtotalTax: tax_amount
|
|
75
79
|
}
|
|
76
80
|
})
|
|
77
81
|
|
|
@@ -110,11 +114,36 @@ export function getStoreOrders() {
|
|
|
110
114
|
postCode: postcode,
|
|
111
115
|
city,
|
|
112
116
|
country: country_id === 'MY' ? 'Malaysia' : country_id,
|
|
113
|
-
collectionCurrency:
|
|
117
|
+
collectionCurrency: order.order_currency_code,
|
|
114
118
|
attentionTo: `${firstname} ${middlename} ${lastname}`
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
result.orderShipping = orderShipping
|
|
122
|
+
|
|
123
|
+
// For SC mapping
|
|
124
|
+
result.shipping = {
|
|
125
|
+
address_1: street,
|
|
126
|
+
postcode: postcode,
|
|
127
|
+
country: country_id,
|
|
128
|
+
city,
|
|
129
|
+
first_name: firstname,
|
|
130
|
+
last_name: lastname,
|
|
131
|
+
phone: telephone,
|
|
132
|
+
email: order.customer_email
|
|
133
|
+
}
|
|
134
|
+
let billingAddress = order?.billing_address
|
|
135
|
+
result.billing = {
|
|
136
|
+
address_1: billingAddress.street,
|
|
137
|
+
postcode: billingAddress.postcode,
|
|
138
|
+
country: billingAddress.country_id,
|
|
139
|
+
city: billingAddress.city,
|
|
140
|
+
first_name: billingAddress.firstname,
|
|
141
|
+
last_name: billingAddress.lastname,
|
|
142
|
+
phone: billingAddress.telephone,
|
|
143
|
+
email: billingAddress.email
|
|
144
|
+
}
|
|
145
|
+
result.firstName = order.customer_firstname
|
|
146
|
+
result.lastName = order.customer_lastname
|
|
118
147
|
}
|
|
119
148
|
|
|
120
149
|
return result
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function getStoreProductCategories() {
|
|
2
|
+
return {
|
|
3
|
+
method: 'get',
|
|
4
|
+
path: '/categories',
|
|
5
|
+
denormalize(req) {
|
|
6
|
+
const resource: any = {}
|
|
7
|
+
const payload: any = {}
|
|
8
|
+
return { resource, payload }
|
|
9
|
+
},
|
|
10
|
+
normalize(res) {
|
|
11
|
+
let results = res.children_data
|
|
12
|
+
results = mapCategories(results, [])
|
|
13
|
+
results = results.map(result => {
|
|
14
|
+
let { id, name, parent_id, is_active, children_data } = result
|
|
15
|
+
return {
|
|
16
|
+
id,
|
|
17
|
+
name,
|
|
18
|
+
parent: parent_id,
|
|
19
|
+
isActive: is_active
|
|
20
|
+
// childrenCategories: children_data
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
return { results: results }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function mapCategories(results, arr) {
|
|
29
|
+
for (let result of results) {
|
|
30
|
+
if (result.children_data?.length > 0) {
|
|
31
|
+
mapCategories(result.children_data, arr)
|
|
32
|
+
}
|
|
33
|
+
arr.push(result)
|
|
34
|
+
}
|
|
35
|
+
return arr
|
|
36
|
+
}
|
|
@@ -21,6 +21,8 @@ export function getStoreProducts() {
|
|
|
21
21
|
// return res.products
|
|
22
22
|
let { items, total_count } = res
|
|
23
23
|
|
|
24
|
+
let parentLinkList = items.map(e => {return {id: e.id, children: e.extension_attributes.configurable_product_links}})?.filter(e => e.children)
|
|
25
|
+
|
|
24
26
|
let activeMarketplaceDistributors: any[] = []
|
|
25
27
|
if (store?.marketplaceDistributors) {
|
|
26
28
|
activeMarketplaceDistributors = store.marketplaceDistributors.filter(
|
|
@@ -32,26 +34,39 @@ export function getStoreProducts() {
|
|
|
32
34
|
|
|
33
35
|
for (var i = 0; i < items.length; i++) {
|
|
34
36
|
const product: any = items[i]
|
|
35
|
-
const stockItems: any[] = await StoreAPI.getStoreStockItem(store, {
|
|
36
|
-
sku: product.sku,
|
|
37
|
-
distributors: activeMarketplaceDistributors
|
|
38
|
-
})
|
|
39
37
|
|
|
40
38
|
let totalProductQty: number = 0
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const stockItems: any[] = await StoreAPI.getStoreStockItem(store, {
|
|
42
|
+
sku: product.sku,
|
|
43
|
+
distributors: activeMarketplaceDistributors
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
stockItems.map(stockItem => {
|
|
47
|
+
if (stockItem.sku === product.sku) {
|
|
48
|
+
totalProductQty += stockItem.qty
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
} catch (e) {}
|
|
46
52
|
const productVariations: any[] = await StoreAPI.getStoreProductVariations(store, { sku: product.sku })
|
|
47
53
|
|
|
48
54
|
const result = {
|
|
49
55
|
itemId: product.id,
|
|
56
|
+
parentId: parentLinkList.find(e => e.children.includes(product.id))?.id || 0,
|
|
50
57
|
isku: product.sku,
|
|
51
58
|
name: product.name,
|
|
52
59
|
type: product.type_id,
|
|
53
60
|
hasVariation: false,
|
|
54
61
|
attributes: [],
|
|
62
|
+
images: product?.custom_attributes?.find(att => att.attribute_code == 'image')?.value
|
|
63
|
+
? [
|
|
64
|
+
`${store.storeURL}pub/media/catalog/product${
|
|
65
|
+
product?.custom_attributes?.find(att => att.attribute_code == 'image')?.value
|
|
66
|
+
}`
|
|
67
|
+
]
|
|
68
|
+
: [],
|
|
69
|
+
categoryId: product?.custom_attributes?.find(att => att.attribute_code == 'category_ids').value[0],
|
|
55
70
|
variations:
|
|
56
71
|
productVariations.length > 0
|
|
57
72
|
? productVariations.map(variant => {
|
|
@@ -82,7 +97,17 @@ export function getStoreProducts() {
|
|
|
82
97
|
sellPrice: product.price,
|
|
83
98
|
marketplaceStatus: product.status,
|
|
84
99
|
primaryUnit: 'lbs',
|
|
85
|
-
primaryUnitValue: product.weight
|
|
100
|
+
primaryUnitValue: product.weight,
|
|
101
|
+
length:
|
|
102
|
+
product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_length')?.value *
|
|
103
|
+
25.4 || 0,
|
|
104
|
+
width:
|
|
105
|
+
product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_width')?.value *
|
|
106
|
+
25.4 || 0,
|
|
107
|
+
height:
|
|
108
|
+
product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_height')?.value *
|
|
109
|
+
25.4 || 0,
|
|
110
|
+
weight: product.weight * 453.59237 || 0
|
|
86
111
|
}
|
|
87
112
|
]
|
|
88
113
|
}
|
|
@@ -9,3 +9,8 @@ export * from './create-order-refund'
|
|
|
9
9
|
export * from './create-order-ship'
|
|
10
10
|
export * from './update-store-product-stock'
|
|
11
11
|
export * from './update-store-product-variation-stock'
|
|
12
|
+
export * from './get-store-product-categories'
|
|
13
|
+
export * from './update-order-status'
|
|
14
|
+
export * from './get-store-order'
|
|
15
|
+
export * from './update-store-product-price'
|
|
16
|
+
export * from './update-store-product-variation-price'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { StoreAPI } from '../../store-api'
|
|
2
|
+
|
|
3
|
+
export function updateOrderStatus() {
|
|
4
|
+
return {
|
|
5
|
+
method: 'post',
|
|
6
|
+
path: '/order/{subpath}',
|
|
7
|
+
async denormalize(req, { store }) {
|
|
8
|
+
let { orderId, status, trackingNo, carrier } = req
|
|
9
|
+
let pr: any
|
|
10
|
+
if (status == 'SHIPPED' || status == 'READY_TO_SHIP' || status == 'PROCESSING' || status == 'PACKED') {
|
|
11
|
+
|
|
12
|
+
let order = await StoreAPI.getStoreOrder(store, { id: orderId })
|
|
13
|
+
|
|
14
|
+
pr = {
|
|
15
|
+
resource: {
|
|
16
|
+
subpath: `${orderId}/ship`
|
|
17
|
+
},
|
|
18
|
+
payload: {
|
|
19
|
+
items: order.items.map(e => { return {order_item_id: e.item_id, qty: e.qty_ordered} }),
|
|
20
|
+
tracks: [
|
|
21
|
+
{
|
|
22
|
+
carrier_code: carrier,
|
|
23
|
+
track_number: trackingNo,
|
|
24
|
+
title: carrier
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
arguments: {
|
|
28
|
+
extension_attributes: {
|
|
29
|
+
source_code: 'default'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else if (status == 'DELIVERED' || status == 'CLOSED') {
|
|
35
|
+
pr = {
|
|
36
|
+
resource: {
|
|
37
|
+
subpath: `${orderId}/invoice`
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else if (status == 'REFUND_COMPLETE' || status == 'RETURN_COMPLETE') {
|
|
41
|
+
pr = {
|
|
42
|
+
resource: {
|
|
43
|
+
subpath: `${orderId}/refund`
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return pr
|
|
48
|
+
},
|
|
49
|
+
normalize(res) {
|
|
50
|
+
return res
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function updateStoreProductPrice() {
|
|
2
|
+
return {
|
|
3
|
+
path: '/products/base-prices',
|
|
4
|
+
method: 'post',
|
|
5
|
+
denormalize(req) {
|
|
6
|
+
let { sellPrice, variationSku } = req
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
payload: {
|
|
10
|
+
prices: [
|
|
11
|
+
{
|
|
12
|
+
price: sellPrice,
|
|
13
|
+
sku: variationSku,
|
|
14
|
+
store_id: 0
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
normalize(res) {
|
|
21
|
+
return res
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -6,7 +6,7 @@ export function updateStoreProductStock() {
|
|
|
6
6
|
method: 'post',
|
|
7
7
|
path: '/inventory/source-items',
|
|
8
8
|
denormalize(req) {
|
|
9
|
-
const { variationSku, qty, distributors } = req[0]
|
|
9
|
+
const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {}
|
|
10
10
|
|
|
11
11
|
let sourceItems: any[] = []
|
|
12
12
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function updateStoreProductVariationPrice() {
|
|
2
|
+
return {
|
|
3
|
+
path: '/products/base-prices',
|
|
4
|
+
method: 'post',
|
|
5
|
+
denormalize(req) {
|
|
6
|
+
let { sellPrice, variationSku } = req
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
payload: {
|
|
10
|
+
prices: [
|
|
11
|
+
{
|
|
12
|
+
price: sellPrice,
|
|
13
|
+
sku: variationSku,
|
|
14
|
+
store_id: 0
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
normalize(res) {
|
|
21
|
+
return res
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -6,7 +6,7 @@ export function updateStoreProductVariationStock() {
|
|
|
6
6
|
method: 'post',
|
|
7
7
|
path: '/inventory/source-items',
|
|
8
8
|
denormalize(req) {
|
|
9
|
-
const { variationSku, qty, distributors } = req[0]
|
|
9
|
+
const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {}
|
|
10
10
|
|
|
11
11
|
let sourceItems: any[] = []
|
|
12
12
|
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
import { StoreAPI } from '../../store-api'
|
|
5
5
|
|
|
6
|
+
const ORDER_STATUS = {
|
|
7
|
+
PAYMENT_PENDING: 'pending',
|
|
8
|
+
PROCESSING: 'processing',
|
|
9
|
+
PACKED: 'processing',
|
|
10
|
+
READY_TO_SHIP: 'processing',
|
|
11
|
+
SHIPPED: 'processing',
|
|
12
|
+
CONFIRMED: 'processing',
|
|
13
|
+
DELIVERED: 'completed',
|
|
14
|
+
CLOSED: 'completed',
|
|
15
|
+
CANCELLED: 'cancelled',
|
|
16
|
+
REFUND_COMPLETE: 'refunded',
|
|
17
|
+
RETURN_COMPLETE: 'refunded',
|
|
18
|
+
REVERSE_SHIPMENT_FAILED: 'failed',
|
|
19
|
+
SHIPMENT_LOST_OR_DAMAGED: 'failed',
|
|
20
|
+
PAYMENT_PENDING_TIMEOUT: 'failed'
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
export function updateOrderStatus(req) {
|
|
7
24
|
return {
|
|
8
25
|
method: 'put',
|
|
@@ -12,20 +29,7 @@ export function updateOrderStatus(req) {
|
|
|
12
29
|
|
|
13
30
|
const order = await StoreAPI.getStoreOrder(store, { orderId })
|
|
14
31
|
|
|
15
|
-
let orderStatus = status
|
|
16
|
-
if (orderStatus == 'PACKED') {
|
|
17
|
-
if (order.status == 'pending') {
|
|
18
|
-
orderStatus = 'on-hold'
|
|
19
|
-
} else {
|
|
20
|
-
orderStatus = order.status
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (orderStatus == 'READY_TO_SHIP') {
|
|
24
|
-
orderStatus = 'completed'
|
|
25
|
-
}
|
|
26
|
-
if (orderStatus == 'CANCELLED') {
|
|
27
|
-
orderStatus = 'cancelled'
|
|
28
|
-
}
|
|
32
|
+
let orderStatus = ORDER_STATUS[`${status}`] || order.status
|
|
29
33
|
|
|
30
34
|
return { resource: { orderId: orderId }, payload: { status: orderStatus } }
|
|
31
35
|
},
|