@things-factory/operato-hub 4.3.185 → 4.3.186
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/client/actions/hub.js +0 -5
- package/dist-server/graphql/resolvers/synchronization/get-lmd-awb.js +137 -0
- package/dist-server/graphql/resolvers/synchronization/get-lmd-awb.js.map +1 -0
- 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/types/synchronization/index.js +1 -0
- package/dist-server/graphql/types/synchronization/index.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +33 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/utils/params.js +3 -1
- package/dist-server/routers/api/restful-apis/v1/utils/params.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js +33 -1
- package/dist-server/routers/api/restful-apis/v1/warehouse/add-release-order.js.map +1 -1
- package/dist-server/routers/xilnex-router.js +1 -0
- package/dist-server/routers/xilnex-router.js.map +1 -1
- package/package.json +18 -18
- package/server/graphql/resolvers/synchronization/get-lmd-awb.ts +178 -0
- package/server/graphql/resolvers/synchronization/index.ts +3 -1
- package/server/graphql/types/synchronization/index.ts +1 -0
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +52 -2
- package/server/routers/api/restful-apis/v1/utils/params.ts +3 -1
- package/server/routers/api/restful-apis/v1/warehouse/add-release-order.ts +42 -2
- package/server/routers/xilnex-router.ts +1 -0
|
@@ -8,6 +8,7 @@ import { syncProductsToAccountResolver } from './sync-products-to-account'
|
|
|
8
8
|
import { syncProductsToSellercraftResolver } from './sync-products-to-sellercraft'
|
|
9
9
|
import { createDatShipments } from './create-dat-shipments'
|
|
10
10
|
import { autoUpdateAllMarketplaceProductVariationQuantityResolver } from './auto-update-all-marketplace-product-variation-quantity'
|
|
11
|
+
import { getLmdAwbResolver } from './get-lmd-awb'
|
|
11
12
|
|
|
12
13
|
export const Query = {
|
|
13
14
|
...fetchSyncProductsResolver,
|
|
@@ -22,5 +23,6 @@ export const Mutation = {
|
|
|
22
23
|
...syncAllProductsToSellercraftResolver,
|
|
23
24
|
...sellercraftPackMarketplaceOrderResolver,
|
|
24
25
|
...createDatShipments,
|
|
25
|
-
...autoUpdateAllMarketplaceProductVariationQuantityResolver
|
|
26
|
+
...autoUpdateAllMarketplaceProductVariationQuantityResolver,
|
|
27
|
+
...getLmdAwbResolver
|
|
26
28
|
}
|
|
@@ -17,6 +17,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
17
17
|
syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
|
|
18
18
|
syncAllProductsToSellercraft: Boolean @transaction
|
|
19
19
|
sellercraftPackMarketplaceOrder: Boolean @transaction
|
|
20
|
+
getLmdAwb: Boolean @transaction
|
|
20
21
|
createDatShipments: Boolean @transaction
|
|
21
22
|
autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
|
|
22
23
|
sendEmails: Boolean @transaction
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EntityManager,
|
|
3
|
+
getConnection,
|
|
4
|
+
getRepository,
|
|
5
|
+
In,
|
|
6
|
+
Not,
|
|
7
|
+
Repository,
|
|
8
|
+
SelectQueryBuilder,
|
|
9
|
+
ILike,
|
|
10
|
+
Brackets
|
|
11
|
+
} from 'typeorm'
|
|
2
12
|
import { v4 as uuidv4 } from 'uuid'
|
|
3
13
|
|
|
4
14
|
import { restfulApiRouter as router } from '@things-factory/api'
|
|
@@ -30,6 +40,7 @@ import {
|
|
|
30
40
|
import { Setting } from '@things-factory/setting-base'
|
|
31
41
|
import { Domain } from '@things-factory/shell'
|
|
32
42
|
import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
43
|
+
import { LastMileDelivery } from '@things-factory/integration-lmd'
|
|
33
44
|
|
|
34
45
|
import { ValidationError } from '../../../../errors/index'
|
|
35
46
|
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
@@ -116,7 +127,8 @@ router.post(
|
|
|
116
127
|
paidAmount: bodyReq?.paidAmount,
|
|
117
128
|
discountAmount: bodyReq?.discountAmount,
|
|
118
129
|
taxAmount: bodyReq?.taxAmount,
|
|
119
|
-
shippingFee: bodyReq?.shippingFee
|
|
130
|
+
shippingFee: bodyReq?.shippingFee,
|
|
131
|
+
lmdOption: bodyReq?.lmdOption
|
|
120
132
|
}
|
|
121
133
|
|
|
122
134
|
// check existing order
|
|
@@ -492,6 +504,12 @@ async function createReleaseGood(
|
|
|
492
504
|
})
|
|
493
505
|
: null
|
|
494
506
|
|
|
507
|
+
// assign lmd
|
|
508
|
+
let lmd: any = null
|
|
509
|
+
if (releaseGood?.lmdOption) {
|
|
510
|
+
lmd = await autoAssignLmd(domain, deliveryCountry?.id, releaseGood?.postalCode)
|
|
511
|
+
}
|
|
512
|
+
|
|
495
513
|
newReleaseGood = {
|
|
496
514
|
name: roNoSetting
|
|
497
515
|
? await generateId({ domain, type: ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
|
|
@@ -545,6 +563,8 @@ async function createReleaseGood(
|
|
|
545
563
|
discountAmount: releaseGood?.discountAmount,
|
|
546
564
|
taxAmount: releaseGood?.taxAmount,
|
|
547
565
|
shippingFee: releaseGood?.shippingFee,
|
|
566
|
+
lmdOption: releaseGood?.lmdOption,
|
|
567
|
+
lastMileDelivery: lmd,
|
|
548
568
|
creator: user,
|
|
549
569
|
updater: user,
|
|
550
570
|
acceptedBy: user,
|
|
@@ -1123,3 +1143,33 @@ async function assignToInventory(orderProducts: OrderProduct[], customerBizplace
|
|
|
1123
1143
|
|
|
1124
1144
|
return orderProducts
|
|
1125
1145
|
}
|
|
1146
|
+
|
|
1147
|
+
async function autoAssignLmd(domain, countryId, postalCode) {
|
|
1148
|
+
const qb: SelectQueryBuilder<LastMileDelivery> = getRepository(LastMileDelivery)
|
|
1149
|
+
.createQueryBuilder('lmd')
|
|
1150
|
+
.leftJoinAndSelect('lmd.lastMileDeliverySettings', 'lmds')
|
|
1151
|
+
.innerJoinAndSelect('lmds.geoCountry', 'gc')
|
|
1152
|
+
.where('lmd.domain_id = :domainId', { domainId: domain.id })
|
|
1153
|
+
.andWhere('lower(lmd.status) = :status', { status: 'active' })
|
|
1154
|
+
.andWhere('gc.id = :gcId', { gcId: countryId })
|
|
1155
|
+
.andWhere(
|
|
1156
|
+
new Brackets(qb => {
|
|
1157
|
+
qb.where(`lmds.include_postal_code = ''`)
|
|
1158
|
+
.orWhere('lmds.include_postal_code is null')
|
|
1159
|
+
.orWhere('lmds.include_postal_code like :includePostCode', { includePostCode: `%${postalCode}%` })
|
|
1160
|
+
})
|
|
1161
|
+
)
|
|
1162
|
+
.andWhere(
|
|
1163
|
+
new Brackets(qb => {
|
|
1164
|
+
qb.where(`lmds.exclude_postal_code = ''`)
|
|
1165
|
+
.orWhere('lmds.exclude_postal_code is null')
|
|
1166
|
+
.orWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` })
|
|
1167
|
+
})
|
|
1168
|
+
)
|
|
1169
|
+
// .andWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` })
|
|
1170
|
+
.orderBy('lmd.rank')
|
|
1171
|
+
|
|
1172
|
+
const lmdResult: LastMileDelivery = await qb.getOne()
|
|
1173
|
+
|
|
1174
|
+
return lmdResult
|
|
1175
|
+
}
|
|
@@ -188,6 +188,7 @@ export const params = {
|
|
|
188
188
|
'deliverTo.state',
|
|
189
189
|
'deliverTo.phone1',
|
|
190
190
|
'deliverTo.phone2',
|
|
191
|
+
'deliverTo.email',
|
|
191
192
|
'marketplaceOrderStatus',
|
|
192
193
|
'airwayBill',
|
|
193
194
|
'invoice',
|
|
@@ -217,7 +218,8 @@ export const params = {
|
|
|
217
218
|
'platformName',
|
|
218
219
|
'discountAmount',
|
|
219
220
|
'taxAmount',
|
|
220
|
-
'shippingFee'
|
|
221
|
+
'shippingFee',
|
|
222
|
+
'lmdOption'
|
|
221
223
|
],
|
|
222
224
|
'cancel-release-order': ['bizplaceId', 'roId', 'orderNo', 'orderNo2', 'orderNo3', 'remark'],
|
|
223
225
|
'update-release-order-details': [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityManager, getConnection, getRepository, In, Not, Repository, SelectQueryBuilder, ILike } from 'typeorm'
|
|
1
|
+
import { EntityManager, getConnection, getRepository, In, Not, Repository, SelectQueryBuilder, ILike, Brackets } from 'typeorm'
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid'
|
|
3
3
|
|
|
4
4
|
import { restfulApiRouter as router } from '@things-factory/api'
|
|
@@ -29,6 +29,7 @@ import { Setting } from '@things-factory/setting-base'
|
|
|
29
29
|
import { Domain } from '@things-factory/shell'
|
|
30
30
|
import { Inventory, INVENTORY_STATUS, LOCATION_TYPE } from '@things-factory/warehouse-base'
|
|
31
31
|
import { GeoCountry } from '@things-factory/geography'
|
|
32
|
+
import { LastMileDelivery } from '@things-factory/integration-lmd'
|
|
32
33
|
|
|
33
34
|
import { businessMiddleware, loggingMiddleware, validationMiddleware } from '../middlewares'
|
|
34
35
|
import { ApiError, ApiErrorHandler, throwInternalServerError } from '../utils/error-util'
|
|
@@ -120,6 +121,7 @@ router.post(
|
|
|
120
121
|
discountAmount: bodyReq?.discountAmount,
|
|
121
122
|
taxAmount: bodyReq?.taxAmount,
|
|
122
123
|
shippingFee: bodyReq?.shippingFee,
|
|
124
|
+
lmdOption: bodyReq?.lmdOption,
|
|
123
125
|
shippingOrder: {
|
|
124
126
|
shipName: bodyReq?.shippingOrder.shipName,
|
|
125
127
|
containerNo: bodyReq?.shippingOrder.containerNo,
|
|
@@ -414,6 +416,12 @@ async function createReleaseGood(
|
|
|
414
416
|
})
|
|
415
417
|
: null
|
|
416
418
|
|
|
419
|
+
// assign lmd
|
|
420
|
+
let lmd: any = null
|
|
421
|
+
if (releaseGood?.lmdOption) {
|
|
422
|
+
lmd = await autoAssignLmd(domain, deliveryCountry?.id, releaseGood?.postalCode)
|
|
423
|
+
}
|
|
424
|
+
|
|
417
425
|
newReleaseGood = {
|
|
418
426
|
name: roNoSetting
|
|
419
427
|
? await generateId({ domain, type: ORDER_NUMBER_RULE_TYPE.RO_NUMBER, seed: {} })
|
|
@@ -470,7 +478,9 @@ async function createReleaseGood(
|
|
|
470
478
|
updater: user,
|
|
471
479
|
acceptedBy: user,
|
|
472
480
|
acceptedAt: new Date(),
|
|
473
|
-
shippingOrder: shippingOrder ? shippingOrder : null
|
|
481
|
+
shippingOrder: shippingOrder ? shippingOrder : null,
|
|
482
|
+
lastMileDelivery: lmd,
|
|
483
|
+
lmdOption: releaseGood.lmdOption
|
|
474
484
|
}
|
|
475
485
|
|
|
476
486
|
let resultReleaseGood = await tx.getRepository(ReleaseGood).save(newReleaseGood)
|
|
@@ -981,3 +991,33 @@ async function assignToInventory(orderProducts: OrderProduct[], customerBizplace
|
|
|
981
991
|
|
|
982
992
|
return orderProducts
|
|
983
993
|
}
|
|
994
|
+
|
|
995
|
+
async function autoAssignLmd(domain, countryId, postalCode) {
|
|
996
|
+
const qb: SelectQueryBuilder<LastMileDelivery> = getRepository(LastMileDelivery)
|
|
997
|
+
.createQueryBuilder('lmd')
|
|
998
|
+
.leftJoinAndSelect('lmd.lastMileDeliverySettings', 'lmds')
|
|
999
|
+
.innerJoinAndSelect('lmds.geoCountry', 'gc')
|
|
1000
|
+
.where('lmd.domain_id = :domainId', { domainId: domain.id })
|
|
1001
|
+
.andWhere('lower(lmd.status) = :status', { status: 'active' })
|
|
1002
|
+
.andWhere('gc.id = :gcId', { gcId: countryId })
|
|
1003
|
+
.andWhere(
|
|
1004
|
+
new Brackets(qb => {
|
|
1005
|
+
qb.where(`lmds.include_postal_code = ''`)
|
|
1006
|
+
.orWhere('lmds.include_postal_code is null')
|
|
1007
|
+
.orWhere('lmds.include_postal_code like :includePostCode', { includePostCode: `%${postalCode}%` })
|
|
1008
|
+
})
|
|
1009
|
+
)
|
|
1010
|
+
.andWhere(
|
|
1011
|
+
new Brackets(qb => {
|
|
1012
|
+
qb.where(`lmds.exclude_postal_code = ''`)
|
|
1013
|
+
.orWhere('lmds.exclude_postal_code is null')
|
|
1014
|
+
.orWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` })
|
|
1015
|
+
})
|
|
1016
|
+
)
|
|
1017
|
+
// .andWhere('lmds.exclude_postal_code not like :excludePostCode', { excludePostCode: `%${postalCode}%` })
|
|
1018
|
+
.orderBy('lmd.rank')
|
|
1019
|
+
|
|
1020
|
+
const lmdResult: LastMileDelivery = await qb.getOne()
|
|
1021
|
+
|
|
1022
|
+
return lmdResult
|
|
1023
|
+
}
|
|
@@ -447,6 +447,7 @@ xilnexRouter.post('/webhook-xilnex-transfer-note', async (context, next) => {
|
|
|
447
447
|
palletQty: 1,
|
|
448
448
|
totalUomValue: `${(productDetail.uomValue * item.confirmedQty).toFixed(2)} ${productDetail.uom}`,
|
|
449
449
|
status: 'PENDING',
|
|
450
|
+
refItemId: item.orderItemId,
|
|
450
451
|
arrivalNotice,
|
|
451
452
|
domain: warehouseDomain,
|
|
452
453
|
bizplace: customerBizplace
|