@things-factory/marketplace-base 4.3.142 → 4.3.146
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.
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOrderDocumentResolver = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
const env_1 = require("@things-factory/env");
|
|
5
6
|
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
|
6
7
|
const entities_1 = require("../../../entities");
|
|
7
8
|
const marketplace_order_1 = require("../marketplace-order");
|
|
8
|
-
const env_1 = require("@things-factory/env");
|
|
9
9
|
const shopeeConfig = env_1.config.get('marketplaceIntegrationShopee', {});
|
|
10
10
|
const { v2 } = shopeeConfig;
|
|
11
11
|
exports.getOrderDocumentResolver = {
|
|
12
12
|
async getOrderDocument(_, { orderNo, docType }, context) {
|
|
13
|
+
var _a;
|
|
13
14
|
const { tx } = context.state;
|
|
14
15
|
const foundMarketplaceOrders = await tx.getRepository(entities_1.MarketplaceOrder).find({
|
|
15
16
|
where: { orderNo: (0, typeorm_1.In)(orderNo) },
|
|
@@ -89,29 +90,43 @@ exports.getOrderDocumentResolver = {
|
|
|
89
90
|
return marketplaceOrderShippings.find(a => a.id === id);
|
|
90
91
|
});
|
|
91
92
|
if (marketplaceStore.platform == 'shopee' && v2) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
if ((_a = uniqueMarketplaceOrderShippings[0]) === null || _a === void 0 ? void 0 : _a.airwayBill) {
|
|
94
|
+
orderDocument = [
|
|
95
|
+
{
|
|
96
|
+
orderNo: uniqueMarketplaceOrderShippings[0].orderNoRef,
|
|
97
|
+
airwayBill: uniqueMarketplaceOrderShippings[0].airwayBill
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
102
|
else {
|
|
100
103
|
orderDocument = await integration_marketplace_1.StoreAPI.getStoreOrderDocument(marketplaceStore, { docRefNo, docType });
|
|
101
104
|
}
|
|
102
105
|
if (docType === 'invoice') {
|
|
103
106
|
uniqueMarketplaceOrderShippings = uniqueMarketplaceOrderShippings.map((marketplaceOrderShipping) => {
|
|
104
|
-
|
|
107
|
+
var _a;
|
|
108
|
+
return Object.assign(Object.assign({}, marketplaceOrderShipping), { invoice: (orderDocument === null || orderDocument === void 0 ? void 0 : orderDocument.length)
|
|
109
|
+
? ((_a = orderDocument[0]) === null || _a === void 0 ? void 0 : _a.airwayBill)
|
|
110
|
+
? orderDocument[0].airwayBill
|
|
111
|
+
: orderDocument[0].file
|
|
112
|
+
: null });
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
115
|
else {
|
|
108
116
|
uniqueMarketplaceOrderShippings = uniqueMarketplaceOrderShippings.map((marketplaceOrderShipping) => {
|
|
109
|
-
|
|
117
|
+
var _a;
|
|
118
|
+
return Object.assign(Object.assign({}, marketplaceOrderShipping), { airwayBill: (orderDocument === null || orderDocument === void 0 ? void 0 : orderDocument.length)
|
|
119
|
+
? ((_a = orderDocument[0]) === null || _a === void 0 ? void 0 : _a.airwayBill)
|
|
120
|
+
? orderDocument[0].airwayBill
|
|
121
|
+
: orderDocument[0].file
|
|
122
|
+
: null });
|
|
110
123
|
});
|
|
111
124
|
}
|
|
112
125
|
tx.getRepository(entities_1.MarketplaceOrderShipping).save(uniqueMarketplaceOrderShippings);
|
|
113
126
|
}
|
|
114
|
-
orderDocument
|
|
127
|
+
if (orderDocument === null || orderDocument === void 0 ? void 0 : orderDocument.length) {
|
|
128
|
+
orderDocument[0].isShopeeV2 = v2;
|
|
129
|
+
}
|
|
115
130
|
return orderDocument;
|
|
116
131
|
}
|
|
117
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-order-document.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/marketplace-order/get-order-document.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAE3C,qFAAoF;AAEpF,gDAK0B;AAC1B,4DAAoE;AAEpE,
|
|
1
|
+
{"version":3,"file":"get-order-document.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/marketplace-order/get-order-document.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAE3C,6CAA4C;AAC5C,qFAAoF;AAEpF,gDAK0B;AAC1B,4DAAoE;AAEpE,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;AACnE,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY,CAAA;AAEd,QAAA,wBAAwB,GAAG;IACtC,KAAK,CAAC,gBAAgB,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAY;;QAC/D,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;QACnD,MAAM,sBAAsB,GAAuB,MAAM,EAAE,CAAC,aAAa,CAAC,2BAAgB,CAAC,CAAC,IAAI,CAAC;YAC/F,KAAK,EAAE,EAAE,OAAO,EAAE,IAAA,YAAE,EAAC,OAAO,CAAC,EAAE;YAC/B,SAAS,EAAE;gBACT,kBAAkB;gBAClB,uBAAuB;gBACvB,qDAAqD;gBACrD,8EAA8E;aAC/E;SACF,CAAC,CAAA;QACF,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,MAAM,MAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QAE9E,IAAI,aAAa,GAAU,EAAE,CAAA;QAC7B,+CAA+C;QAC/C,MAAM,WAAW,GAAY,sBAAsB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAA;QAE7E,IAAI,WAAW,EAAE;YACf,aAAa,GAAG,MAAM,IAAA,iDAA6B,EAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;SAC1E;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AU,GAAG,EAAE,CAAA;SACjC;QAED,OAAO,aAAa,CAAA;IACtB,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/marketplace-base",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.146",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@things-factory/integration-fulfillment": "^4.3.
|
|
27
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
28
|
-
"@things-factory/product-base": "^4.3.
|
|
29
|
-
"@things-factory/shell": "^4.3.
|
|
26
|
+
"@things-factory/integration-fulfillment": "^4.3.146",
|
|
27
|
+
"@things-factory/integration-marketplace": "^4.3.146",
|
|
28
|
+
"@things-factory/product-base": "^4.3.146",
|
|
29
|
+
"@things-factory/shell": "^4.3.146"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "919fc314fca9647235fb02b8837e5c42813455bb"
|
|
32
32
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EntityManager, In } from 'typeorm'
|
|
2
2
|
|
|
3
|
+
import { config } from '@things-factory/env'
|
|
3
4
|
import { MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
4
5
|
|
|
5
6
|
import {
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
} from '../../../entities'
|
|
11
12
|
import { getETraxOrderDocumentFunction } from '../marketplace-order'
|
|
12
13
|
|
|
13
|
-
import { config } from '@things-factory/env'
|
|
14
14
|
const shopeeConfig = config.get('marketplaceIntegrationShopee', {})
|
|
15
15
|
const { v2 } = shopeeConfig
|
|
16
16
|
|
|
@@ -109,12 +109,14 @@ export const getOrderDocumentResolver = {
|
|
|
109
109
|
})
|
|
110
110
|
|
|
111
111
|
if (marketplaceStore.platform == 'shopee' && v2) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
if (uniqueMarketplaceOrderShippings[0]?.airwayBill) {
|
|
113
|
+
orderDocument = [
|
|
114
|
+
{
|
|
115
|
+
orderNo: uniqueMarketplaceOrderShippings[0].orderNoRef,
|
|
116
|
+
airwayBill: uniqueMarketplaceOrderShippings[0].airwayBill
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
118
120
|
} else {
|
|
119
121
|
orderDocument = await StoreAPI.getStoreOrderDocument(marketplaceStore, { docRefNo, docType })
|
|
120
122
|
}
|
|
@@ -124,7 +126,11 @@ export const getOrderDocumentResolver = {
|
|
|
124
126
|
(marketplaceOrderShipping: MarketplaceOrderShipping) => {
|
|
125
127
|
return {
|
|
126
128
|
...marketplaceOrderShipping,
|
|
127
|
-
invoice: orderDocument
|
|
129
|
+
invoice: orderDocument?.length
|
|
130
|
+
? orderDocument[0]?.airwayBill
|
|
131
|
+
? orderDocument[0].airwayBill
|
|
132
|
+
: orderDocument[0].file
|
|
133
|
+
: null
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
)
|
|
@@ -133,7 +139,11 @@ export const getOrderDocumentResolver = {
|
|
|
133
139
|
(marketplaceOrderShipping: MarketplaceOrderShipping) => {
|
|
134
140
|
return {
|
|
135
141
|
...marketplaceOrderShipping,
|
|
136
|
-
airwayBill: orderDocument
|
|
142
|
+
airwayBill: orderDocument?.length
|
|
143
|
+
? orderDocument[0]?.airwayBill
|
|
144
|
+
? orderDocument[0].airwayBill
|
|
145
|
+
: orderDocument[0].file
|
|
146
|
+
: null
|
|
137
147
|
}
|
|
138
148
|
}
|
|
139
149
|
)
|
|
@@ -142,7 +152,9 @@ export const getOrderDocumentResolver = {
|
|
|
142
152
|
tx.getRepository(MarketplaceOrderShipping).save(uniqueMarketplaceOrderShippings)
|
|
143
153
|
}
|
|
144
154
|
|
|
145
|
-
orderDocument
|
|
155
|
+
if (orderDocument?.length) {
|
|
156
|
+
orderDocument[0].isShopeeV2 = v2
|
|
157
|
+
}
|
|
146
158
|
|
|
147
159
|
return orderDocument
|
|
148
160
|
}
|