@things-factory/integration-marketplace 4.2.2 → 4.2.7
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/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-orders.js +2 -1
- package/dist-server/controllers/magento/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-product-categories.js +9 -3
- package/dist-server/controllers/magento/apis/get-store-product-categories.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-products.js +8 -9
- package/dist-server/controllers/magento/apis/get-store-products.js.map +1 -1
- package/dist-server/controllers/magento/apis/update-order-status.js +33 -8
- package/dist-server/controllers/magento/apis/update-order-status.js.map +1 -1
- package/dist-server/controllers/tiktok/apis/echo.js +19 -0
- package/dist-server/controllers/tiktok/apis/echo.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-order.js +113 -0
- package/dist-server/controllers/tiktok/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-orders.js +48 -0
- package/dist-server/controllers/tiktok/apis/get-store-orders.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js +30 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-categories.js +28 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-categories.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product.js +91 -0
- package/dist-server/controllers/tiktok/apis/get-store-product.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-products.js +36 -0
- package/dist-server/controllers/tiktok/apis/get-store-products.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/index.js +23 -0
- package/dist-server/controllers/tiktok/apis/index.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-order-status.js +24 -0
- package/dist-server/controllers/tiktok/apis/update-order-status.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js +28 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js +32 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js.map +1 -0
- package/dist-server/controllers/tiktok/client/index.js +15 -0
- package/dist-server/controllers/tiktok/client/index.js.map +1 -0
- package/dist-server/controllers/tiktok/client/signature.js +63 -0
- package/dist-server/controllers/tiktok/client/signature.js.map +1 -0
- package/dist-server/controllers/tiktok/client/tiktok.js +93 -0
- package/dist-server/controllers/tiktok/client/tiktok.js.map +1 -0
- package/dist-server/controllers/tiktok/client/types.js +3 -0
- package/dist-server/controllers/tiktok/client/types.js.map +1 -0
- package/dist-server/controllers/tiktok/index.js +30 -0
- package/dist-server/controllers/tiktok/index.js.map +1 -0
- package/dist-server/controllers/tiktok/platform-action.js +44 -0
- package/dist-server/controllers/tiktok/platform-action.js.map +1 -0
- package/package.json +2 -2
- package/server/controllers/index.ts +1 -0
- package/server/controllers/magento/apis/get-store-orders.ts +3 -1
- package/server/controllers/magento/apis/get-store-product-categories.ts +10 -3
- package/server/controllers/magento/apis/get-store-products.ts +1 -2
- package/server/controllers/magento/apis/update-order-status.ts +37 -9
- package/server/controllers/tiktok/apis/echo.ts +14 -0
- package/server/controllers/tiktok/apis/get-store-order.ts +133 -0
- package/server/controllers/tiktok/apis/get-store-orders.ts +52 -0
- package/server/controllers/tiktok/apis/get-store-product-attributes.ts +29 -0
- package/server/controllers/tiktok/apis/get-store-product-categories.ts +27 -0
- package/server/controllers/tiktok/apis/get-store-product.ts +95 -0
- package/server/controllers/tiktok/apis/get-store-products.ts +38 -0
- package/server/controllers/tiktok/apis/index.ts +10 -0
- package/server/controllers/tiktok/apis/update-order-status.ts +20 -0
- package/server/controllers/tiktok/apis/update-store-product-variation-price.ts +24 -0
- package/server/controllers/tiktok/apis/update-store-product-variation-stock.ts +28 -0
- package/server/controllers/tiktok/client/index.ts +2 -0
- package/server/controllers/tiktok/client/signature.ts +78 -0
- package/server/controllers/tiktok/client/tiktok.ts +139 -0
- package/server/controllers/tiktok/client/types.ts +20 -0
- package/server/controllers/tiktok/index.ts +8 -0
- package/server/controllers/tiktok/platform-action.ts +48 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://bytedance.feishu.cn/docs/doccnDyz5Bbk26iOdejbBRBlLrb#ytBXoS */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStoreProducts = void 0;
|
|
5
|
+
/* status: 0-all, 1-draft, 2-pending, 3-failed, 4-live, 5-seller_deactivated,
|
|
6
|
+
6-platform-deactivated, 7-freeze, 8-deleted
|
|
7
|
+
*/
|
|
8
|
+
const store_api_1 = require("../../store-api");
|
|
9
|
+
function getStoreProducts() {
|
|
10
|
+
return {
|
|
11
|
+
method: 'post',
|
|
12
|
+
path: '/api/products/search',
|
|
13
|
+
denormalize(req) {
|
|
14
|
+
var { pagination } = req || {};
|
|
15
|
+
var { page, limit } = pagination || { page: 0, limit: 100 };
|
|
16
|
+
return {
|
|
17
|
+
payload: { page_size: limit, page_number: page + 1, search_status: 0 },
|
|
18
|
+
resource: {}
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
async normalize(res, { store }) {
|
|
22
|
+
const { data } = res;
|
|
23
|
+
const products = (data === null || data === void 0 ? void 0 : data.products) || [];
|
|
24
|
+
const total = (data === null || data === void 0 ? void 0 : data.total) || 0;
|
|
25
|
+
let results = [];
|
|
26
|
+
for (let i = 0; i < products.length; i++) {
|
|
27
|
+
const product = products[i];
|
|
28
|
+
const productDetails = await store_api_1.StoreAPI.getStoreProduct(store, { productId: product.id });
|
|
29
|
+
results.push(Object.assign({}, productDetails));
|
|
30
|
+
}
|
|
31
|
+
return { results, total };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.getStoreProducts = getStoreProducts;
|
|
36
|
+
//# sourceMappingURL=get-store-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAEzE;;EAEE;AAEF,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,sBAAsB;QAC5B,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,OAAO;gBACL,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAG,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE;gBACtE,QAAQ,EAAE,EAAE;aACb,CAAA;QACH,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;YAEpB,MAAM,QAAQ,GAAU,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,KAAI,EAAE,CAAA;YAC5C,MAAM,KAAK,GAAW,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,KAAI,CAAC,CAAA;YAEtC,IAAI,OAAO,GAAU,EAAE,CAAA;YACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACxC,MAAM,OAAO,GAAQ,QAAQ,CAAC,CAAC,CAAC,CAAA;gBAChC,MAAM,cAAc,GAAG,MAAM,oBAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;gBACvF,OAAO,CAAC,IAAI,mBAAM,cAAc,EAAG,CAAA;aACpC;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC;AA7BD,4CA6BC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./echo"), exports);
|
|
14
|
+
__exportStar(require("./get-store-order"), exports);
|
|
15
|
+
__exportStar(require("./get-store-orders"), exports);
|
|
16
|
+
__exportStar(require("./get-store-product-attributes"), exports);
|
|
17
|
+
__exportStar(require("./get-store-product-categories"), exports);
|
|
18
|
+
__exportStar(require("./get-store-product"), exports);
|
|
19
|
+
__exportStar(require("./get-store-products"), exports);
|
|
20
|
+
__exportStar(require("./update-store-product-variation-stock"), exports);
|
|
21
|
+
__exportStar(require("./update-store-product-variation-price"), exports);
|
|
22
|
+
__exportStar(require("./update-order-status"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,oDAAiC;AACjC,qDAAkC;AAClC,iEAA8C;AAC9C,iEAA8C;AAC9C,sDAAmC;AACnC,uDAAoC;AACpC,yEAAsD;AACtD,yEAAsD;AACtD,wDAAqC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateOrderStatus = void 0;
|
|
4
|
+
function updateOrderStatus() {
|
|
5
|
+
return {
|
|
6
|
+
path: '/api/order/rts',
|
|
7
|
+
method: 'post',
|
|
8
|
+
async denormalize(req, { store }) {
|
|
9
|
+
let { orderId, status } = req;
|
|
10
|
+
if (status == 'READY_TO_SHIP') {
|
|
11
|
+
return {
|
|
12
|
+
payload: {
|
|
13
|
+
order_id: orderId
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
normalize(res) {
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.updateOrderStatus = updateOrderStatus;
|
|
24
|
+
//# sourceMappingURL=update-order-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/update-order-status.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB;IAC/B,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,MAAM;QACd,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;YAE7B,IAAI,MAAM,IAAI,eAAe,EAAE;gBAC7B,OAAO;oBACL,OAAO,EAAE;wBACP,QAAQ,EAAE,OAAO;qBAClB;iBACF,CAAA;aACF;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAnBD,8CAmBC"}
|
|
@@ -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: '/api/products/prices',
|
|
7
|
+
method: 'put',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
const { variationId, sellPrice, productId } = (Array.isArray(req) ? req[0] : req) || {};
|
|
10
|
+
return {
|
|
11
|
+
payload: {
|
|
12
|
+
product_id: productId,
|
|
13
|
+
skus: [
|
|
14
|
+
{
|
|
15
|
+
id: variationId,
|
|
16
|
+
original_price: sellPrice.toString()
|
|
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/tiktok/apis/update-store-product-variation-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,KAAK;QACb,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAEvF,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU,EAAE,SAAS;oBACrB,IAAI,EAAE;wBACJ;4BACE,EAAE,EAAE,WAAW;4BACf,cAAc,EAAE,SAAS,CAAC,QAAQ,EAAE;yBACrC;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACT,OAAO,GAAG,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,4EAuBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateStoreProductVariationStock = void 0;
|
|
4
|
+
function updateStoreProductVariationStock() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'put',
|
|
7
|
+
path: '/api/products/stocks',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
const { variationId, qty, itemId } = (Array.isArray(req) ? req[0] : req) || {};
|
|
10
|
+
return {
|
|
11
|
+
payload: {
|
|
12
|
+
product_id: itemId,
|
|
13
|
+
skus: [
|
|
14
|
+
{
|
|
15
|
+
id: variationId,
|
|
16
|
+
stock_infos: [
|
|
17
|
+
{
|
|
18
|
+
available_stock: qty
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
normalize(res) {
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.updateStoreProductVariationStock = updateStoreProductVariationStock;
|
|
32
|
+
//# sourceMappingURL=update-store-product-variation-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,sBAAsB;QAC5B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAE9E,OAAO;gBACL,OAAO,EAAE;oBACP,UAAU,EAAE,MAAM;oBAClB,IAAI,EAAE;wBACJ;4BACE,EAAE,EAAE,WAAW;4BACf,WAAW,EAAE;gCACX;oCACE,eAAe,EAAE,GAAG;iCACrB;6BACF;yBACF;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA3BD,4EA2BC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./types"), exports);
|
|
14
|
+
__exportStar(require("./tiktok"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAuB;AACvB,2CAAwB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.makePublicRequestParameters = exports.signRequest = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
/**
|
|
9
|
+
* { key: value } => 'keyvalue'
|
|
10
|
+
* @param {Object} parameters
|
|
11
|
+
* @return {string} concatString
|
|
12
|
+
*/
|
|
13
|
+
const concatObjectKeyValue = (parameters) => {
|
|
14
|
+
if (!parameters)
|
|
15
|
+
return '';
|
|
16
|
+
return Object.entries(parameters)
|
|
17
|
+
.sort(([k1, v1], [k2, v2]) => (k2 > k1 ? -1 : 1))
|
|
18
|
+
.map(([k, v]) => `${k}${v}`)
|
|
19
|
+
.join('');
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Calculate a signature hash
|
|
23
|
+
* @param {string} appSecret
|
|
24
|
+
* @param {string} apiPath e.g. /order/get
|
|
25
|
+
* @param {Object} params
|
|
26
|
+
* @return {string} signature hash
|
|
27
|
+
*/
|
|
28
|
+
const signRequest = (appSecret, apiPath, params) => {
|
|
29
|
+
const hash = crypto_1.default
|
|
30
|
+
.createHmac('sha256', appSecret)
|
|
31
|
+
.update(appSecret + apiPath + concatObjectKeyValue(params) + appSecret)
|
|
32
|
+
.digest('hex');
|
|
33
|
+
return hash;
|
|
34
|
+
};
|
|
35
|
+
exports.signRequest = signRequest;
|
|
36
|
+
/**
|
|
37
|
+
* Gather system and business parameters to compute signature
|
|
38
|
+
* @param {string} appKey
|
|
39
|
+
* @param {string} appSecret
|
|
40
|
+
* @param {string} apiPath
|
|
41
|
+
* @param {string?} accessToken
|
|
42
|
+
* @param {Parameter?} payload
|
|
43
|
+
* @return {SystemParameters}
|
|
44
|
+
*/
|
|
45
|
+
function makePublicRequestParameters(appKey, appSecret, apiPath, accessToken, shopId, payload) {
|
|
46
|
+
const ts = Math.floor(new Date(new Date().toUTCString()).getTime() / 1000).toString();
|
|
47
|
+
const publicRequestParams = {
|
|
48
|
+
app_key: appKey,
|
|
49
|
+
timestamp: ts,
|
|
50
|
+
access_token: accessToken
|
|
51
|
+
};
|
|
52
|
+
let signatureParams = {
|
|
53
|
+
app_key: publicRequestParams.app_key,
|
|
54
|
+
timestamp: publicRequestParams.timestamp
|
|
55
|
+
};
|
|
56
|
+
if (shopId) {
|
|
57
|
+
publicRequestParams.shop_id = shopId;
|
|
58
|
+
signatureParams.shop_id = shopId;
|
|
59
|
+
}
|
|
60
|
+
return Object.assign(Object.assign({}, publicRequestParams), { sign: (0, exports.signRequest)(appSecret, apiPath, Object.assign(Object.assign({}, payload), signatureParams)) });
|
|
61
|
+
}
|
|
62
|
+
exports.makePublicRequestParameters = makePublicRequestParameters;
|
|
63
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/signature.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAG3B;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,UAAqB,EAAU,EAAE;IAC7D,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAC1B,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;SAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAChD,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;SAC3B,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC,CA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.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Tiktok = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
const signature_1 = require("./signature");
|
|
9
|
+
const debug = require('debug')('things-factory:integration-marketplace:tiktok');
|
|
10
|
+
class Tiktok {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = Object.assign({}, config);
|
|
13
|
+
}
|
|
14
|
+
getBaseURL() {
|
|
15
|
+
return `https://open-api.tiktokglobalshop.com`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @summary Get Method
|
|
19
|
+
* @description Using v3 API, map the consumer_key, consumer_secret to the endpoint path.
|
|
20
|
+
* X-WP-Total is to get the total items from the response
|
|
21
|
+
*/
|
|
22
|
+
async get(path, params) {
|
|
23
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config;
|
|
24
|
+
const qs = Object.entries(Object.assign(Object.assign({}, params), (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId, params)))
|
|
25
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
26
|
+
.join('&');
|
|
27
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? qs : ''}`;
|
|
28
|
+
debug('endpoint', endpoint);
|
|
29
|
+
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var result = {};
|
|
35
|
+
const resResult = await response.json();
|
|
36
|
+
result.data = resResult.data;
|
|
37
|
+
debug('response result', result);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
async post(path, data = {}) {
|
|
41
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config;
|
|
42
|
+
debug('data', data);
|
|
43
|
+
const jsondata = JSON.stringify(data);
|
|
44
|
+
const { app_key, timestamp, access_token, sign, shop_id } = (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId);
|
|
45
|
+
const qs = Object.entries({
|
|
46
|
+
app_key,
|
|
47
|
+
timestamp,
|
|
48
|
+
access_token,
|
|
49
|
+
sign,
|
|
50
|
+
shop_id
|
|
51
|
+
})
|
|
52
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
53
|
+
.join('&');
|
|
54
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`;
|
|
55
|
+
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
56
|
+
method: 'post',
|
|
57
|
+
headers: {
|
|
58
|
+
'Content-Type': 'application/json'
|
|
59
|
+
},
|
|
60
|
+
body: jsondata
|
|
61
|
+
});
|
|
62
|
+
const result = await response.json();
|
|
63
|
+
debug('response result', result);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
async put(path, data = {}) {
|
|
67
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config;
|
|
68
|
+
debug('data', data);
|
|
69
|
+
const jsondata = JSON.stringify(data);
|
|
70
|
+
const { app_key, timestamp, access_token, sign } = (0, signature_1.makePublicRequestParameters)(appKey, appSecret, path, accessToken, channelShopId);
|
|
71
|
+
const qs = Object.entries({
|
|
72
|
+
app_key,
|
|
73
|
+
timestamp,
|
|
74
|
+
access_token,
|
|
75
|
+
sign
|
|
76
|
+
})
|
|
77
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
78
|
+
.join('&');
|
|
79
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`;
|
|
80
|
+
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
81
|
+
method: 'put',
|
|
82
|
+
headers: {
|
|
83
|
+
'Content-Type': 'application/json'
|
|
84
|
+
},
|
|
85
|
+
body: jsondata
|
|
86
|
+
});
|
|
87
|
+
const result = await response.json();
|
|
88
|
+
debug('response result', result);
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Tiktok = Tiktok;
|
|
93
|
+
//# sourceMappingURL=tiktok.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiktok.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/tiktok.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,2CAAyD;AAGzD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAS/E,MAAa,MAAM;IAGjB,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED,UAAU;QACR,OAAO,uCAAuC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,MAAiB;QACvC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAErE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,iCACpB,MAAM,GACN,IAAA,uCAA2B,EAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,EAC3F;aACC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,IAAI,CAAC,GAAG,CAAC,CAAA;QAEZ,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QAC9D,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QAE3B,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,E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,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACpC,KAAK,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;QAEhC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA5HD,wBA4HC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../server/controllers/tiktok/client/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
__exportStar(require("./client"), exports);
|
|
26
|
+
const store_api_1 = require("../store-api");
|
|
27
|
+
const platform_action_1 = require("./platform-action");
|
|
28
|
+
const APIS = __importStar(require("./apis"));
|
|
29
|
+
store_api_1.StoreAPI.registerPlatform('tiktok', platform_action_1.action, APIS);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/controllers/tiktok/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwB;AAExB,4CAAuC;AAEvC,uDAA0C;AAC1C,6CAA8B;AAE9B,oBAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,wBAAM,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.action = void 0;
|
|
4
|
+
const tiktok_1 = require("./client/tiktok");
|
|
5
|
+
function substitute(path, obj) {
|
|
6
|
+
var props = [];
|
|
7
|
+
var re = /{([^}]+)}/g;
|
|
8
|
+
var text;
|
|
9
|
+
while ((text = re.exec(path))) {
|
|
10
|
+
props.push(text[1]);
|
|
11
|
+
}
|
|
12
|
+
var result = path;
|
|
13
|
+
props.forEach(prop => {
|
|
14
|
+
let value = obj[prop.trim()];
|
|
15
|
+
result = result.replace(`{${prop}}`, value === undefined ? '' : value);
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @summary Building Path Method and Payload
|
|
21
|
+
* @description After denormalise of data is done,
|
|
22
|
+
* platform API method will be called with its path and payload,
|
|
23
|
+
* this section is to build path and substitution of the resource in url as well as the payload for body request.
|
|
24
|
+
* Every Tiktok API call requires consumer_key, consumer_secret, access_token.
|
|
25
|
+
* consumer_key, consumer_secret, access_token are retrieved from tokencraft
|
|
26
|
+
* to avoid permission error from TikTok.
|
|
27
|
+
*/
|
|
28
|
+
const action = async ({ store, method = 'get', path, request }) => {
|
|
29
|
+
const client = new tiktok_1.Tiktok({
|
|
30
|
+
appKey: store.accessKey || '5p6q6g',
|
|
31
|
+
appSecret: store.accessSecret || 'c30cf452265ab418514bb81fa49fc333aecbf081',
|
|
32
|
+
accessToken: store.accessToken,
|
|
33
|
+
channelShopId: store.channelShopId
|
|
34
|
+
});
|
|
35
|
+
const { resource = {}, payload = {} } = request;
|
|
36
|
+
path = substitute(path, resource);
|
|
37
|
+
var response = await client[method](path, payload);
|
|
38
|
+
if (response.code) {
|
|
39
|
+
throw response;
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
exports.action = action;
|
|
44
|
+
//# sourceMappingURL=platform-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/tiktok/platform-action.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,GAAG,YAAY,CAAA;IACrB,IAAI,IAAI,CAAA;IAER,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KACpB;IAED,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,IAAI,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACI,MAAM,MAAM,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACvE,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,MAAM,EAAE,KAAK,CAAC,SAAS,IAAI,QAAQ;QACnC,SAAS,EAAE,KAAK,CAAC,YAAY,IAAI,0CAA0C;QAC3E,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,aAAa,EAAE,KAAK,CAAC,aAAa;KACnC,CAAC,CAAA;IAEF,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;IAE/C,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEjC,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClD,IAAI,QAAQ,CAAC,IAAI,EAAE;QACjB,MAAM,QAAQ,CAAA;KACf;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAlBY,QAAA,MAAM,UAkBlB"}
|
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.7",
|
|
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": "7a65abffbd9d05961b83bb31153b1c021ab607eb"
|
|
56
56
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export function getStoreProductCategories() {
|
|
2
2
|
return {
|
|
3
3
|
method: 'get',
|
|
4
|
-
path: '/categories',
|
|
4
|
+
path: '/categories/list',
|
|
5
5
|
denormalize(req) {
|
|
6
|
+
var { pagination } = req || {}
|
|
7
|
+
var { page = 0, limit = 100 } = pagination || {}
|
|
8
|
+
|
|
6
9
|
const resource: any = {}
|
|
7
|
-
const payload: any = {
|
|
10
|
+
const payload: any = {
|
|
11
|
+
pageSize: limit,
|
|
12
|
+
currentPage: page
|
|
13
|
+
}
|
|
8
14
|
return { resource, payload }
|
|
9
15
|
},
|
|
10
16
|
normalize(res) {
|
|
11
|
-
let results = res.
|
|
17
|
+
let results = res.items
|
|
12
18
|
results = mapCategories(results, [])
|
|
13
19
|
results = results.map(result => {
|
|
14
20
|
let { id, name, parent_id, is_active, children_data } = result
|
|
@@ -20,6 +26,7 @@ export function getStoreProductCategories() {
|
|
|
20
26
|
// childrenCategories: children_data
|
|
21
27
|
}
|
|
22
28
|
})
|
|
29
|
+
results = results.filter(cat => cat.parent != 0)
|
|
23
30
|
return { results: results }
|
|
24
31
|
}
|
|
25
32
|
}
|
|
@@ -53,7 +53,6 @@ export function getStoreProducts() {
|
|
|
53
53
|
|
|
54
54
|
const result = {
|
|
55
55
|
itemId: product.id,
|
|
56
|
-
parentId: parentLinkList.find(e => e.children.includes(product.id))?.id || 0,
|
|
57
56
|
isku: product.sku,
|
|
58
57
|
name: product.name,
|
|
59
58
|
type: product.type_id,
|
|
@@ -115,7 +114,7 @@ export function getStoreProducts() {
|
|
|
115
114
|
results.push({ ...result })
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
return { results, total: total_count }
|
|
117
|
+
return { results, total: total_count, parentLinkList }
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
}
|
|
@@ -3,20 +3,17 @@ import { StoreAPI } from '../../store-api'
|
|
|
3
3
|
export function updateOrderStatus() {
|
|
4
4
|
return {
|
|
5
5
|
method: 'post',
|
|
6
|
-
path: '/
|
|
6
|
+
path: '/{subpath}',
|
|
7
7
|
async denormalize(req, { store }) {
|
|
8
|
-
let { orderId, status, trackingNo, carrier } = req
|
|
8
|
+
let { orderId, status, trackingNo, carrier, orderItems } = req
|
|
9
9
|
let pr: any
|
|
10
10
|
if (status == 'SHIPPED' || status == 'READY_TO_SHIP' || status == 'PROCESSING' || status == 'PACKED') {
|
|
11
|
-
|
|
12
|
-
let order = await StoreAPI.getStoreOrder(store, { id: orderId })
|
|
13
|
-
|
|
14
11
|
pr = {
|
|
15
12
|
resource: {
|
|
16
|
-
subpath:
|
|
13
|
+
subpath: `order/${orderId}/ship`
|
|
17
14
|
},
|
|
18
15
|
payload: {
|
|
19
|
-
items:
|
|
16
|
+
items: unmapOrderItems(orderItems),
|
|
20
17
|
tracks: [
|
|
21
18
|
{
|
|
22
19
|
carrier_code: carrier,
|
|
@@ -34,13 +31,19 @@ export function updateOrderStatus() {
|
|
|
34
31
|
} else if (status == 'DELIVERED' || status == 'CLOSED') {
|
|
35
32
|
pr = {
|
|
36
33
|
resource: {
|
|
37
|
-
subpath:
|
|
34
|
+
subpath: `order/${orderId}/invoice`
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
} else if (status == 'REFUND_COMPLETE' || status == 'RETURN_COMPLETE') {
|
|
41
38
|
pr = {
|
|
42
39
|
resource: {
|
|
43
|
-
subpath:
|
|
40
|
+
subpath: `order/${orderId}/refund`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else if (status == 'CANCELLED') {
|
|
44
|
+
pr = {
|
|
45
|
+
resource: {
|
|
46
|
+
subpath: `orders/${orderId}/cancel`
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -51,3 +54,28 @@ export function updateOrderStatus() {
|
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
}
|
|
57
|
+
|
|
58
|
+
function unmapOrderItems(orderItems) {
|
|
59
|
+
let itemsList = []
|
|
60
|
+
let res = orderItems.map(e => {
|
|
61
|
+
return e.split('-')[0]
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
for (let item of res) {
|
|
65
|
+
let count = 0
|
|
66
|
+
|
|
67
|
+
res.forEach(element => {
|
|
68
|
+
if (element === item) {
|
|
69
|
+
count += 1
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
itemsList.push({
|
|
74
|
+
order_item_id: item,
|
|
75
|
+
qty: count
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
itemsList = itemsList.filter((value, index, self) => index === self.findIndex(t => t.order_item_id === value.order_item_id))
|
|
80
|
+
return itemsList
|
|
81
|
+
}
|