@things-factory/operato-hub 4.3.305 → 4.3.307
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/config.development.js +31 -31
- package/dist-server/graphql/resolvers/synchronization/index.js +2 -1
- package/dist-server/graphql/resolvers/synchronization/index.js.map +1 -1
- package/dist-server/graphql/resolvers/synchronization/powrup-get-airway-bill.js +70 -0
- package/dist-server/graphql/resolvers/synchronization/powrup-get-airway-bill.js.map +1 -0
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-powrup.js +1 -1
- package/dist-server/graphql/resolvers/synchronization/sync-products-to-powrup.js.map +1 -1
- package/dist-server/graphql/types/synchronization/index.js +1 -0
- package/dist-server/graphql/types/synchronization/index.js.map +1 -1
- package/package.json +5 -5
- package/server/graphql/resolvers/synchronization/index.ts +18 -16
- package/server/graphql/resolvers/synchronization/powrup-get-airway-bill.ts +82 -0
- package/server/graphql/resolvers/synchronization/sync-products-to-powrup.ts +1 -1
- package/server/graphql/types/synchronization/index.ts +1 -0
package/config.development.js
CHANGED
|
@@ -4,52 +4,45 @@ module.exports = {
|
|
|
4
4
|
useVirtualHostBasedDomain: false,
|
|
5
5
|
fallbackRoute: '/',
|
|
6
6
|
subdomainOffset: 2,
|
|
7
|
-
port:
|
|
7
|
+
port: 9200,
|
|
8
8
|
inspect: '9260',
|
|
9
|
+
ormconfig: {
|
|
10
|
+
name: 'default',
|
|
11
|
+
type: 'postgres',
|
|
12
|
+
database: '06072023',
|
|
13
|
+
username: 'postgres',
|
|
14
|
+
password: 'hatio',
|
|
15
|
+
host: '192.168.0.153',
|
|
16
|
+
port: 15432,
|
|
17
|
+
synchronize: true,
|
|
18
|
+
logging: true
|
|
19
|
+
},
|
|
9
20
|
// ormconfig: {
|
|
10
21
|
// name: 'default',
|
|
11
22
|
// type: 'postgres',
|
|
12
|
-
// database: '
|
|
23
|
+
// database: 'dev2', // dev2
|
|
13
24
|
// username: 'postgres',
|
|
14
25
|
// password: 'abcd1234',
|
|
15
26
|
// host: 'operatov3.cluster-cijhm4n1hbst.ap-southeast-1.rds.amazonaws.com',
|
|
16
27
|
// port: 55432,
|
|
17
|
-
// synchronize:
|
|
18
|
-
// logging:
|
|
28
|
+
// synchronize:false,
|
|
29
|
+
// logging: false,
|
|
30
|
+
// connectTimeoutMS: 30000,
|
|
31
|
+
// extra: { poolSize: 30 }
|
|
19
32
|
// },
|
|
20
33
|
// ormconfig: {
|
|
21
34
|
// name: 'default',
|
|
22
35
|
// type: 'postgres',
|
|
23
|
-
// database: 'v3-hub1',
|
|
24
|
-
// username: 'postgres',
|
|
25
|
-
// password: 'hatio',
|
|
26
36
|
// host: 'localhost',
|
|
27
37
|
// port: 15432,
|
|
28
|
-
//
|
|
29
|
-
// logging: true
|
|
30
|
-
// },
|
|
31
|
-
// ormconfig: {
|
|
32
|
-
// name: 'default',
|
|
33
|
-
// type: 'postgres',
|
|
34
|
-
// database: 'dev',
|
|
38
|
+
// database: 'postgres',
|
|
35
39
|
// username: 'postgres',
|
|
36
40
|
// password: 'hatio',
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
+
// synchronize: false,
|
|
42
|
+
// logging: true,
|
|
43
|
+
// connectTimeoutMS: 30000,
|
|
44
|
+
// extra: { poolSize: 30 }
|
|
41
45
|
// },
|
|
42
|
-
ormconfig: {
|
|
43
|
-
name: 'default',
|
|
44
|
-
type: 'postgres',
|
|
45
|
-
database: 'dev',
|
|
46
|
-
username: 'postgres',
|
|
47
|
-
password: 'hatio',
|
|
48
|
-
host: 'localhost',
|
|
49
|
-
port: 15432,
|
|
50
|
-
synchronize: true,
|
|
51
|
-
logging: true
|
|
52
|
-
},
|
|
53
46
|
password: {
|
|
54
47
|
lowerCase: true,
|
|
55
48
|
upperCase: false,
|
|
@@ -126,13 +119,13 @@ module.exports = {
|
|
|
126
119
|
// }
|
|
127
120
|
},
|
|
128
121
|
fulfillmentIntegrationOperato: {
|
|
129
|
-
host: '
|
|
122
|
+
host: '192.168.0.161:3000',
|
|
130
123
|
protocol: 'http',
|
|
131
124
|
platform: 'operato',
|
|
132
125
|
application: 'Operato MMS',
|
|
133
126
|
appKey: 'a9bf751e622bf146662b240d58971051',
|
|
134
127
|
appSecret: '1c385935dc131c4b902b9bbf6a4798af',
|
|
135
|
-
callback: 'http://
|
|
128
|
+
callback: 'http://192.168.0.161:5000/callback-operato'
|
|
136
129
|
},
|
|
137
130
|
marketplaceIntegrationShopee: {
|
|
138
131
|
platform: 'shopee',
|
|
@@ -155,5 +148,12 @@ module.exports = {
|
|
|
155
148
|
apiSecret: 'T139_ItMjObC82mmy7iwnNflhd2iV0kUvDBj0P_201EmA7Sj',
|
|
156
149
|
callback: 'http://operato-h.com:3000/callback-xero',
|
|
157
150
|
hostname: 'http://operato-h.com:3000/'
|
|
151
|
+
},
|
|
152
|
+
awbFileStorage: {
|
|
153
|
+
type: 's3',
|
|
154
|
+
accessKeyId: 'AKIAUQEOPWEJKL43OMZA',
|
|
155
|
+
secretAccessKey: 'OG2qS0Usg4wyjPWbfv1ahPZzP80/w8z4i8MYHl+e',
|
|
156
|
+
bucketName: 'operato-awb',
|
|
157
|
+
region: 'ap-southeast-1'
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -7,6 +7,7 @@ const fetch_sync_invoices_1 = require("./fetch-sync-invoices");
|
|
|
7
7
|
const fetch_sync_products_1 = require("./fetch-sync-products");
|
|
8
8
|
const fetch_sync_purchase_orders_1 = require("./fetch-sync-purchase-orders");
|
|
9
9
|
const get_lmd_awb_1 = require("./get-lmd-awb");
|
|
10
|
+
const powrup_get_airway_bill_1 = require("./powrup-get-airway-bill");
|
|
10
11
|
const powrup_get_tracking_no_1 = require("./powrup-get-tracking-no");
|
|
11
12
|
const powrup_pack_order_1 = require("./powrup-pack-order");
|
|
12
13
|
const sellercraft_pack_marketplace_order_1 = require("./sellercraft-pack-marketplace-order");
|
|
@@ -17,5 +18,5 @@ const sync_products_to_account_1 = require("./sync-products-to-account");
|
|
|
17
18
|
const sync_products_to_powrup_1 = require("./sync-products-to-powrup");
|
|
18
19
|
const sync_products_to_sellercraft_1 = require("./sync-products-to-sellercraft");
|
|
19
20
|
exports.Query = Object.assign(Object.assign(Object.assign({}, fetch_sync_products_1.fetchSyncProductsResolver), fetch_sync_purchase_orders_1.fetchSyncPurchaseOrdersResolver), fetch_sync_invoices_1.fetchSyncInvoicesResolver);
|
|
20
|
-
exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sync_products_to_sellercraft_1.syncProductsToSellercraftResolver), sync_products_to_powrup_1.syncProductsToPowrupResolver), sync_products_from_account_1.syncProductsFromAccountResolver), sync_products_to_account_1.syncProductsToAccountResolver), sync_all_products_to_sellercraft_1.syncAllProductsToSellercraftResolver), sync_all_products_to_powrup_1.syncAllProductsToPowrupResolver), sellercraft_pack_marketplace_order_1.sellercraftPackMarketplaceOrderResolver), create_dat_shipments_1.createDatShipments), auto_update_all_marketplace_product_variation_quantity_1.autoUpdateAllMarketplaceProductVariationQuantityResolver), get_lmd_awb_1.getLmdAwbResolver), powrup_pack_order_1.powrupPackOrderResolver), powrup_get_tracking_no_1.powrupGetTrackingNoResolver);
|
|
21
|
+
exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sync_products_to_sellercraft_1.syncProductsToSellercraftResolver), sync_products_to_powrup_1.syncProductsToPowrupResolver), sync_products_from_account_1.syncProductsFromAccountResolver), sync_products_to_account_1.syncProductsToAccountResolver), sync_all_products_to_sellercraft_1.syncAllProductsToSellercraftResolver), sync_all_products_to_powrup_1.syncAllProductsToPowrupResolver), sellercraft_pack_marketplace_order_1.sellercraftPackMarketplaceOrderResolver), create_dat_shipments_1.createDatShipments), auto_update_all_marketplace_product_variation_quantity_1.autoUpdateAllMarketplaceProductVariationQuantityResolver), get_lmd_awb_1.getLmdAwbResolver), powrup_pack_order_1.powrupPackOrderResolver), powrup_get_tracking_no_1.powrupGetTrackingNoResolver), powrup_get_airway_bill_1.powrupGetAirwayBillResolver);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,qIAAmI;AACnI,iEAA2D;AAC3D,+DAAiE;AACjE,+DAAiE;AACjE,6EAA8E;AAC9E,+CAAiD;AACjD,qEAAsE;AACtE,qEAAsE;AACtE,2DAA6D;AAC7D,6FAA8F;AAC9F,+EAA+E;AAC/E,yFAAyF;AACzF,6EAA8E;AAC9E,yEAA0E;AAC1E,uEAAwE;AACxE,iFAAkF;AAErE,QAAA,KAAK,iDACb,+CAAyB,GACzB,4DAA+B,GAC/B,+CAAyB,EAC7B;AAEY,QAAA,QAAQ,6LAChB,gEAAiC,GACjC,sDAA4B,GAC5B,4DAA+B,GAC/B,wDAA6B,GAC7B,uEAAoC,GACpC,6DAA+B,GAC/B,4EAAuC,GACvC,yCAAkB,GAClB,iHAAwD,GACxD,+BAAiB,GACjB,2CAAuB,GACvB,oDAA2B,GAC3B,oDAA2B,EAC/B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.powrupGetAirwayBillResolver = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
6
|
+
const env_1 = require("@things-factory/env");
|
|
7
|
+
const integration_powrup_1 = require("@things-factory/integration-powrup");
|
|
8
|
+
const sales_base_1 = require("@things-factory/sales-base");
|
|
9
|
+
exports.powrupGetAirwayBillResolver = {
|
|
10
|
+
async powrupGetAirwayBill(_, {}, context) {
|
|
11
|
+
try {
|
|
12
|
+
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
13
|
+
try {
|
|
14
|
+
const powrup = await tx
|
|
15
|
+
.getRepository(integration_powrup_1.Powrup)
|
|
16
|
+
.findOne({ where: { platform: integration_powrup_1.Platform.POWRUP, active: true } });
|
|
17
|
+
let orderPackageQb = await tx
|
|
18
|
+
.getRepository(sales_base_1.OrderPackage)
|
|
19
|
+
.createQueryBuilder('opk')
|
|
20
|
+
.innerJoinAndSelect('opk.releaseGood', 'rg')
|
|
21
|
+
.innerJoinAndSelect('opk.domain', 'domain')
|
|
22
|
+
.innerJoinAndSelect('opk.bizplace', 'bizplace')
|
|
23
|
+
.innerJoinAndSelect('opk.creator', 'creator')
|
|
24
|
+
.where(`rg.source = :source`, { source: auth_base_1.ApplicationType.POWRUP })
|
|
25
|
+
.andWhere(`rg.type = :rgType`, { rgType: 'b2c' })
|
|
26
|
+
.andWhere(`rg.ref_order_id NOTNULL`)
|
|
27
|
+
.andWhere(`(rg.lmd_option = false or rg.lmd_option ISNULL)`)
|
|
28
|
+
.andWhere(`rg.status NOT IN (:...status) `, {
|
|
29
|
+
status: [sales_base_1.ORDER_STATUS.CANCELLED, sales_base_1.ORDER_STATUS.PENDING_CANCEL, sales_base_1.ORDER_STATUS.DONE]
|
|
30
|
+
})
|
|
31
|
+
.andWhere(`opk.airway_bill NOTNULL`)
|
|
32
|
+
.orderBy(`rg.created_at`)
|
|
33
|
+
.limit(100);
|
|
34
|
+
let orderPackagesWithoutAirwayBill = await orderPackageQb.getMany();
|
|
35
|
+
if ((orderPackagesWithoutAirwayBill === null || orderPackagesWithoutAirwayBill === void 0 ? void 0 : orderPackagesWithoutAirwayBill.length) > 0) {
|
|
36
|
+
for (let i = 0; i < orderPackagesWithoutAirwayBill.length; i++) {
|
|
37
|
+
const orderPackage = orderPackagesWithoutAirwayBill[i];
|
|
38
|
+
try {
|
|
39
|
+
const { trackingNo, transporter, printLabels } = await integration_powrup_1.PowrupAPI.fetchDocument(powrup, {
|
|
40
|
+
context: { state: { domain: null, user: null } },
|
|
41
|
+
refOrderId: orderPackage.releaseGood.refOrderId,
|
|
42
|
+
packageId: orderPackage.packageId
|
|
43
|
+
});
|
|
44
|
+
let updateInfo;
|
|
45
|
+
if (printLabels === null || printLabels === void 0 ? void 0 : printLabels.length) {
|
|
46
|
+
printLabels.map(pl => {
|
|
47
|
+
updateInfo = Object.assign(Object.assign({}, updateInfo), { airwayBill: pl.awbUrl });
|
|
48
|
+
});
|
|
49
|
+
updateInfo = Object.assign(Object.assign({}, updateInfo), { trackingNo: trackingNo, transporter: transporter });
|
|
50
|
+
await tx.getRepository(sales_base_1.OrderPackage).update({ id: orderPackage.id }, Object.assign({}, updateInfo));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
env_1.logger.error(`powrupGetAirwayBill[GetAirwayBill][Order Package ID: ${orderPackage.id}]: ${e}`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
env_1.logger.error(`powrupGetAirwayBill[GetAirwayBill]: ${e}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
env_1.logger.error(`powrupGetAirwayBill[MainError]: ${e}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=powrup-get-airway-bill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"powrup-get-airway-bill.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/powrup-get-airway-bill.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,yDAA2D;AAC3D,6CAA4C;AA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C,EAAE;oBACV,YAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,EAAE,CAAC,CAAA;iBACzD;YACH,CAAC,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,YAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAA;SACrD;IACH,CAAC;CACF,CAAA"}
|
|
@@ -69,7 +69,7 @@ exports.syncProductsToPowrupResolver = {
|
|
|
69
69
|
stock: {
|
|
70
70
|
quantityTotal: item.available_qty < 0 ? 0 : item.available_qty,
|
|
71
71
|
quantityReserved: item.reserved_qty < 0 ? 0 : item.reserved_qty,
|
|
72
|
-
quantityBuffer:
|
|
72
|
+
quantityBuffer: 0
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-products-to-powrup.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-powrup.ts"],"names":[],"mappings":";;;AAEA,yDAAwE;AACxE,uDAAuE;AACvE,6CAA4C;AAC5C,2EAAqG;AACrG,mEAA8D;AAEjD,QAAA,4BAA4B,GAAG;IAC1C,KAAK,CAAC,oBAAoB,CAAC,CAAO,EAAE,EAAE,eAAe,EAA+B,EAAE,OAAY;;QAChG,IAAI;YACF,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;YAEnD,IAAI,IAAI,GAAW,CAAC,CAAA;YACpB,IAAI,WAAW,GAAY,IAAI,CAAA;YAC/B,MAAM,KAAK,GAAW,EAAE,CAAA;YAExB,IAAI,aAAa,GAAwB,MAAM,EAAE;iBAC9C,aAAa,CAAC,wCAAmB,CAAC;iBAClC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAA;YAEpG,MAAM,eAAe,GAAa,MAAM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,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa;oCAC9D,gBAAgB,EAAE,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY;oCAC/D,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sync-products-to-powrup.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/synchronization/sync-products-to-powrup.ts"],"names":[],"mappings":";;;AAEA,yDAAwE;AACxE,uDAAuE;AACvE,6CAA4C;AAC5C,2EAAqG;AACrG,mEAA8D;AAEjD,QAAA,4BAA4B,GAAG;IAC1C,KAAK,CAAC,oBAAoB,CAAC,CAAO,EAAE,EAAE,eAAe,EAA+B,EAAE,OAAY;;QAChG,IAAI;YACF,MAAM,EAAE,EAAE,EAAE,GAA0B,OAAO,CAAC,KAAK,CAAA;YAEnD,IAAI,IAAI,GAAW,CAAC,CAAA;YACpB,IAAI,WAAW,GAAY,IAAI,CAAA;YAC/B,MAAM,KAAK,GAAW,EAAE,CAAA;YAExB,IAAI,aAAa,GAAwB,MAAM,EAAE;iBAC9C,aAAa,CAAC,wCAAmB,CAAC;iBAClC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAA;YAEpG,MAAM,eAAe,GAAa,MAAM,IAAA,6BAAkB,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;YACrG,MAAM,WAAW,GAAgB,MAAM,EAAE;iBACtC,aAAa,CAAC,uBAAW,CAAC;iBAC1B,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,2B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AG,CAAC,EAAU,EAAE,EAAE;4BAC3B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;wBACxD,CAAC,CAAA;wBAED,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;wBAEhB,IAAI,EAAE,CAAA;wBACN,WAAW,GAAG,CAAC,CAAA,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,KAAK,KAAI,CAAC,CAAC,GAAG,IAAI,GAAG,KAAK,CAAA;wBAEnD,MAAM,8BAAS,CAAC,WAAW,CAAC,MAAM,EAAE;4BAClC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;4BACjF,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE;4BAC1C,UAAU;yBACX,CAAC,CAAA;qBACH;oBAAC,OAAO,CAAC,EAAE;wBACV,YAAM,CAAC,KAAK,CACV,6CAA6C,aAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,aAAa,CAAC,MAAM,CAAC,EAAE,SAAS,IAAI,MAAM,CAAC,EAAE,CACjI,CAAA;qBACF;iBACF;aACF;SACF;QAAC,OAAO,CAAC,EAAE;YACV,YAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,EAAE,CAAC,CAAA;SACnD;IACH,CAAC;CACF,CAAA"}
|
|
@@ -22,6 +22,7 @@ exports.Mutation = `
|
|
|
22
22
|
sellercraftPackMarketplaceOrder: Boolean @transaction
|
|
23
23
|
powrupPackOrder: Boolean @transaction
|
|
24
24
|
powrupGetTrackingNo: Boolean @transaction
|
|
25
|
+
powrupGetAirwayBill: Boolean @transaction
|
|
25
26
|
getLmdAwb: Boolean @transaction
|
|
26
27
|
createDatShipments: Boolean @transaction
|
|
27
28
|
autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/types/synchronization/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AACrD,yDAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AACnD,yEAAkE;AAClE,uEAAiF;AAEpE,QAAA,KAAK,GAAiB;;;;CAIlC,CAAA;AAEY,QAAA,QAAQ,GAAiB;;;;;;;;;;;;;;;CAerC,CAAA;AAEY,QAAA,KAAK,GAAG;IACnB,iCAAc;IACd,mCAAe;IACf,8CAAoB;IACpB,gDAAqB;IACrB,GAAG,+BAAM;IACT,iCAAc;IACd,mCAAe;IACf,GAAG,wBAAM;CACV,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.307",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@things-factory/pdf": "^4.3.281",
|
|
93
93
|
"@things-factory/product-ui": "^4.3.301",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.281",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.307",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.281",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.281",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.281",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"@things-factory/setting-ui": "^4.3.281",
|
|
108
108
|
"@things-factory/shell": "^4.3.281",
|
|
109
109
|
"@things-factory/system-ui": "^4.3.281",
|
|
110
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
111
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
110
|
+
"@things-factory/warehouse-base": "^4.3.307",
|
|
111
|
+
"@things-factory/worksheet-base": "^4.3.307",
|
|
112
112
|
"cron-parser": "^4.7.0",
|
|
113
113
|
"koa2-swagger-ui": "^5.0.2",
|
|
114
114
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"resolutions": {
|
|
121
121
|
"core-js": "^3.16.0"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "481824066e2a5721498be0b3d5570e66390b204e"
|
|
124
124
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { autoUpdateAllMarketplaceProductVariationQuantityResolver } from './auto-update-all-marketplace-product-variation-quantity'
|
|
2
|
-
import { createDatShipments } from './create-dat-shipments'
|
|
3
|
-
import { fetchSyncInvoicesResolver } from './fetch-sync-invoices'
|
|
4
|
-
import { fetchSyncProductsResolver } from './fetch-sync-products'
|
|
5
|
-
import { fetchSyncPurchaseOrdersResolver } from './fetch-sync-purchase-orders'
|
|
6
|
-
import { getLmdAwbResolver } from './get-lmd-awb'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { autoUpdateAllMarketplaceProductVariationQuantityResolver } from './auto-update-all-marketplace-product-variation-quantity'
|
|
2
|
+
import { createDatShipments } from './create-dat-shipments'
|
|
3
|
+
import { fetchSyncInvoicesResolver } from './fetch-sync-invoices'
|
|
4
|
+
import { fetchSyncProductsResolver } from './fetch-sync-products'
|
|
5
|
+
import { fetchSyncPurchaseOrdersResolver } from './fetch-sync-purchase-orders'
|
|
6
|
+
import { getLmdAwbResolver } from './get-lmd-awb'
|
|
7
|
+
import { powrupGetAirwayBillResolver } from './powrup-get-airway-bill'
|
|
8
|
+
import { powrupGetTrackingNoResolver } from './powrup-get-tracking-no'
|
|
9
|
+
import { powrupPackOrderResolver } from './powrup-pack-order'
|
|
10
|
+
import { sellercraftPackMarketplaceOrderResolver } from './sellercraft-pack-marketplace-order'
|
|
11
|
+
import { syncAllProductsToPowrupResolver } from './sync-all-products-to-powrup'
|
|
12
|
+
import { syncAllProductsToSellercraftResolver } from './sync-all-products-to-sellercraft'
|
|
13
|
+
import { syncProductsFromAccountResolver } from './sync-products-from-account'
|
|
14
|
+
import { syncProductsToAccountResolver } from './sync-products-to-account'
|
|
15
|
+
import { syncProductsToPowrupResolver } from './sync-products-to-powrup'
|
|
16
|
+
import { syncProductsToSellercraftResolver } from './sync-products-to-sellercraft'
|
|
16
17
|
|
|
17
18
|
export const Query = {
|
|
18
19
|
...fetchSyncProductsResolver,
|
|
@@ -32,5 +33,6 @@ export const Mutation = {
|
|
|
32
33
|
...autoUpdateAllMarketplaceProductVariationQuantityResolver,
|
|
33
34
|
...getLmdAwbResolver,
|
|
34
35
|
...powrupPackOrderResolver,
|
|
35
|
-
...powrupGetTrackingNoResolver
|
|
36
|
+
...powrupGetTrackingNoResolver,
|
|
37
|
+
...powrupGetAirwayBillResolver
|
|
36
38
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getConnection } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { ApplicationType } from '@things-factory/auth-base'
|
|
4
|
+
import { logger } from '@things-factory/env'
|
|
5
|
+
import { Platform, Powrup, PowrupAPI } from '@things-factory/integration-powrup'
|
|
6
|
+
import { ORDER_STATUS, OrderPackage } from '@things-factory/sales-base'
|
|
7
|
+
|
|
8
|
+
export const powrupGetAirwayBillResolver = {
|
|
9
|
+
async powrupGetAirwayBill(_: void, {}, context: any): Promise<void> {
|
|
10
|
+
try {
|
|
11
|
+
await getConnection().transaction(async tx => {
|
|
12
|
+
try {
|
|
13
|
+
const powrup: Powrup = await tx
|
|
14
|
+
.getRepository(Powrup)
|
|
15
|
+
.findOne({ where: { platform: Platform.POWRUP, active: true } })
|
|
16
|
+
|
|
17
|
+
let orderPackageQb = await tx
|
|
18
|
+
.getRepository(OrderPackage)
|
|
19
|
+
.createQueryBuilder('opk')
|
|
20
|
+
.innerJoinAndSelect('opk.releaseGood', 'rg')
|
|
21
|
+
.innerJoinAndSelect('opk.domain', 'domain')
|
|
22
|
+
.innerJoinAndSelect('opk.bizplace', 'bizplace')
|
|
23
|
+
.innerJoinAndSelect('opk.creator', 'creator')
|
|
24
|
+
.where(`rg.source = :source`, { source: ApplicationType.POWRUP })
|
|
25
|
+
.andWhere(`rg.type = :rgType`, { rgType: 'b2c' })
|
|
26
|
+
.andWhere(`rg.ref_order_id NOTNULL`)
|
|
27
|
+
.andWhere(`(rg.lmd_option = false or rg.lmd_option ISNULL)`)
|
|
28
|
+
.andWhere(`rg.status NOT IN (:...status) `, {
|
|
29
|
+
status: [ORDER_STATUS.CANCELLED, ORDER_STATUS.PENDING_CANCEL, ORDER_STATUS.DONE]
|
|
30
|
+
})
|
|
31
|
+
.andWhere(`opk.airway_bill NOTNULL`)
|
|
32
|
+
.orderBy(`rg.created_at`)
|
|
33
|
+
.limit(100)
|
|
34
|
+
|
|
35
|
+
let orderPackagesWithoutAirwayBill: OrderPackage[] = await orderPackageQb.getMany()
|
|
36
|
+
|
|
37
|
+
if (orderPackagesWithoutAirwayBill?.length > 0) {
|
|
38
|
+
for (let i = 0; i < orderPackagesWithoutAirwayBill.length; i++) {
|
|
39
|
+
const orderPackage: OrderPackage = orderPackagesWithoutAirwayBill[i]
|
|
40
|
+
try {
|
|
41
|
+
const {
|
|
42
|
+
trackingNo,
|
|
43
|
+
transporter,
|
|
44
|
+
printLabels
|
|
45
|
+
}: { trackingNo: string; transporter: string; printLabels: any[] } = await PowrupAPI.fetchDocument(
|
|
46
|
+
powrup,
|
|
47
|
+
{
|
|
48
|
+
context: { state: { domain: null, user: null } },
|
|
49
|
+
refOrderId: orderPackage.releaseGood.refOrderId,
|
|
50
|
+
packageId: orderPackage.packageId
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
let updateInfo: any
|
|
55
|
+
if (printLabels?.length) {
|
|
56
|
+
printLabels.map(pl => {
|
|
57
|
+
updateInfo = { ...updateInfo, airwayBill: pl.awbUrl }
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
updateInfo = {
|
|
61
|
+
...updateInfo,
|
|
62
|
+
trackingNo: trackingNo,
|
|
63
|
+
transporter: transporter
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
await tx.getRepository(OrderPackage).update({ id: orderPackage.id }, { ...updateInfo })
|
|
67
|
+
}
|
|
68
|
+
} catch (e) {
|
|
69
|
+
logger.error(`powrupGetAirwayBill[GetAirwayBill][Order Package ID: ${orderPackage.id}]: ${e}`)
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
logger.error(`powrupGetAirwayBill[GetAirwayBill]: ${e}`)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
} catch (e) {
|
|
79
|
+
logger.error(`powrupGetAirwayBill[MainError]: ${e}`)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -83,7 +83,7 @@ export const syncProductsToPowrupResolver = {
|
|
|
83
83
|
stock: {
|
|
84
84
|
quantityTotal: item.available_qty < 0 ? 0 : item.available_qty,
|
|
85
85
|
quantityReserved: item.reserved_qty < 0 ? 0 : item.reserved_qty,
|
|
86
|
-
quantityBuffer:
|
|
86
|
+
quantityBuffer: 0
|
|
87
87
|
}
|
|
88
88
|
})
|
|
89
89
|
})
|
|
@@ -21,6 +21,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
21
21
|
sellercraftPackMarketplaceOrder: Boolean @transaction
|
|
22
22
|
powrupPackOrder: Boolean @transaction
|
|
23
23
|
powrupGetTrackingNo: Boolean @transaction
|
|
24
|
+
powrupGetAirwayBill: Boolean @transaction
|
|
24
25
|
getLmdAwb: Boolean @transaction
|
|
25
26
|
createDatShipments: Boolean @transaction
|
|
26
27
|
autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
|