@things-factory/marketplace-base 8.0.7 → 9.0.0-beta.12
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/server/constants/attachment.ts +0 -3
- package/server/constants/index.ts +0 -4
- package/server/constants/order.ts +0 -11
- package/server/constants/platform.ts +0 -7
- package/server/constants/product.ts +0 -5
- package/server/constants/reserve-qty-order-statuses.ts +0 -7
- package/server/controllers/index.ts +0 -0
- package/server/entities/index.ts +0 -45
- package/server/entities/marketplace-order-item.ts +0 -137
- package/server/entities/marketplace-order-shipping-item.ts +0 -55
- package/server/entities/marketplace-order-shipping.ts +0 -168
- package/server/entities/marketplace-order.ts +0 -141
- package/server/entities/marketplace-product-attribute.ts +0 -83
- package/server/entities/marketplace-product-category.ts +0 -53
- package/server/entities/marketplace-product-variation-price.ts +0 -63
- package/server/entities/marketplace-product-variation.ts +0 -147
- package/server/entities/marketplace-product.ts +0 -164
- package/server/entities/marketplace-refund-order-item.ts +0 -56
- package/server/entities/marketplace-refund-order.ts +0 -51
- package/server/entities/marketplace-setting.ts +0 -49
- package/server/entities/store-replenishment-item.ts +0 -48
- package/server/entities/store-replenishment.ts +0 -79
- package/server/graphql/index.ts +0 -9
- package/server/graphql/resolvers/index.ts +0 -14
- package/server/graphql/resolvers/marketplace-order/auto-initialise-logistics-by-batch.ts +0 -164
- package/server/graphql/resolvers/marketplace-order/auto-update-order-ready-to-ship.ts +0 -136
- package/server/graphql/resolvers/marketplace-order/cancel-marketplace-order.ts +0 -64
- package/server/graphql/resolvers/marketplace-order/create-marketplace-order-note.ts +0 -21
- package/server/graphql/resolvers/marketplace-order/dashboard-marketplace-orders.ts +0 -82
- package/server/graphql/resolvers/marketplace-order/dashboard-marketplace-sales-average.ts +0 -82
- package/server/graphql/resolvers/marketplace-order/dashboard-marketplace-sales.ts +0 -93
- package/server/graphql/resolvers/marketplace-order/delete-marketplace-orders.ts +0 -17
- package/server/graphql/resolvers/marketplace-order/generate-marketplace-order.ts +0 -180
- package/server/graphql/resolvers/marketplace-order/get-address-list.ts +0 -9
- package/server/graphql/resolvers/marketplace-order/get-branch-list.ts +0 -9
- package/server/graphql/resolvers/marketplace-order/get-etrax-order-document.ts +0 -49
- package/server/graphql/resolvers/marketplace-order/get-logistics-param.ts +0 -47
- package/server/graphql/resolvers/marketplace-order/get-order-document.ts +0 -149
- package/server/graphql/resolvers/marketplace-order/get-store-logistics.ts +0 -9
- package/server/graphql/resolvers/marketplace-order/get-time-slot.ts +0 -9
- package/server/graphql/resolvers/marketplace-order/index.ts +0 -75
- package/server/graphql/resolvers/marketplace-order/initialise-lazada-logistics-by-batch.ts +0 -165
- package/server/graphql/resolvers/marketplace-order/initialise-logistics-by-batch.ts +0 -41
- package/server/graphql/resolvers/marketplace-order/initialise-logistics.ts +0 -29
- package/server/graphql/resolvers/marketplace-order/initialise-shopee-logistics-by-batch.ts +0 -97
- package/server/graphql/resolvers/marketplace-order/marketplace-order.ts +0 -12
- package/server/graphql/resolvers/marketplace-order/marketplace-orders-for-batch-init.ts +0 -52
- package/server/graphql/resolvers/marketplace-order/marketplace-orders-for-export.ts +0 -63
- package/server/graphql/resolvers/marketplace-order/marketplace-orders.ts +0 -56
- package/server/graphql/resolvers/marketplace-order/set-marketplace-order-delivered.ts +0 -25
- package/server/graphql/resolvers/marketplace-order/set-marketplace-order-failed-delivery.ts +0 -25
- package/server/graphql/resolvers/marketplace-order/set-own-shipping-provider-by-orders.ts +0 -39
- package/server/graphql/resolvers/marketplace-order/split-orders-by-batch.ts +0 -245
- package/server/graphql/resolvers/marketplace-order/sync-all-marketplace-order.ts +0 -39
- package/server/graphql/resolvers/marketplace-order/sync-marketplace-order.ts +0 -940
- package/server/graphql/resolvers/marketplace-order/sync-marketplace-orders-by-platform.ts +0 -31
- package/server/graphql/resolvers/marketplace-order/sync-shopee-awb.ts +0 -49
- package/server/graphql/resolvers/marketplace-order/update-marketplace-order.ts +0 -35
- package/server/graphql/resolvers/marketplace-order/update-order-ready-to-ship.ts +0 -142
- package/server/graphql/resolvers/marketplace-order-item/create-marketplace-order-item.ts +0 -14
- package/server/graphql/resolvers/marketplace-order-item/delete-marketplace-order-item.ts +0 -10
- package/server/graphql/resolvers/marketplace-order-item/delete-marketplace-order-items.ts +0 -17
- package/server/graphql/resolvers/marketplace-order-item/index.ts +0 -22
- package/server/graphql/resolvers/marketplace-order-item/marketplace-order-item.ts +0 -14
- package/server/graphql/resolvers/marketplace-order-item/marketplace-order-items.ts +0 -15
- package/server/graphql/resolvers/marketplace-order-item/update-marketplace-order-item.ts +0 -18
- package/server/graphql/resolvers/marketplace-order-item/update-multiple-marketplace-order-item.ts +0 -44
- package/server/graphql/resolvers/marketplace-order-shipping/create-marketplace-order-shipping.ts +0 -14
- package/server/graphql/resolvers/marketplace-order-shipping/delete-marketplace-order-shipping.ts +0 -10
- package/server/graphql/resolvers/marketplace-order-shipping/delete-marketplace-order-shippings.ts +0 -17
- package/server/graphql/resolvers/marketplace-order-shipping/index.ts +0 -23
- package/server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shipping.ts +0 -25
- package/server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shippings-for-batch-init.ts +0 -88
- package/server/graphql/resolvers/marketplace-order-shipping/marketplace-order-shippings.ts +0 -43
- package/server/graphql/resolvers/marketplace-order-shipping/update-marketplace-order-shipping.ts +0 -32
- package/server/graphql/resolvers/marketplace-order-shipping/update-multiple-marketplace-order-shipping.ts +0 -44
- package/server/graphql/resolvers/marketplace-order-shipping-item/create-marketplace-order-shipping-item.ts +0 -14
- package/server/graphql/resolvers/marketplace-order-shipping-item/delete-marketplace-order-shipping-item.ts +0 -10
- package/server/graphql/resolvers/marketplace-order-shipping-item/delete-marketplace-order-shipping-items.ts +0 -15
- package/server/graphql/resolvers/marketplace-order-shipping-item/index.ts +0 -20
- package/server/graphql/resolvers/marketplace-order-shipping-item/marketplace-order-shipping-item.ts +0 -21
- package/server/graphql/resolvers/marketplace-order-shipping-item/marketplace-order-shipping-items.ts +0 -14
- package/server/graphql/resolvers/marketplace-order-shipping-item/update-marketplace-order-shipping-item.ts +0 -18
- package/server/graphql/resolvers/marketplace-order-shipping-item/update-multiple-marketplace-order-shipping-item.ts +0 -44
- package/server/graphql/resolvers/marketplace-product/create-marketplace-product.ts +0 -35
- package/server/graphql/resolvers/marketplace-product/delete-marketplace-product.ts +0 -10
- package/server/graphql/resolvers/marketplace-product/delete-marketplace-products.ts +0 -17
- package/server/graphql/resolvers/marketplace-product/index.ts +0 -27
- package/server/graphql/resolvers/marketplace-product/marketplace-product.ts +0 -24
- package/server/graphql/resolvers/marketplace-product/marketplace-products.ts +0 -23
- package/server/graphql/resolvers/marketplace-product/sync-all-marketplace-store-products.ts +0 -225
- package/server/graphql/resolvers/marketplace-product/sync-marketplace-store-products.ts +0 -222
- package/server/graphql/resolvers/marketplace-product/update-marketplace-product.ts +0 -24
- package/server/graphql/resolvers/marketplace-product/upsert-marketplace-product.ts +0 -39
- package/server/graphql/resolvers/marketplace-product-attribute/create-marketplace-product-attribute.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-attribute/delete-marketplace-product-attribute.ts +0 -10
- package/server/graphql/resolvers/marketplace-product-attribute/delete-marketplace-product-attributes.ts +0 -17
- package/server/graphql/resolvers/marketplace-product-attribute/index.ts +0 -22
- package/server/graphql/resolvers/marketplace-product-attribute/marketplace-product-attribute.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-attribute/marketplace-product-attributes.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-attribute/update-marketplace-product-attribute.ts +0 -18
- package/server/graphql/resolvers/marketplace-product-attribute/update-multiple-marketplace-product-attribute.ts +0 -44
- package/server/graphql/resolvers/marketplace-product-category/create-marketplace-product-category.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-category/delete-marketplace-product-categories.ts +0 -17
- package/server/graphql/resolvers/marketplace-product-category/delete-marketplace-product-category.ts +0 -10
- package/server/graphql/resolvers/marketplace-product-category/index.ts +0 -22
- package/server/graphql/resolvers/marketplace-product-category/marketplace-product-categories.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-category/marketplace-product-category.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-category/update-marketplace-product-category.ts +0 -18
- package/server/graphql/resolvers/marketplace-product-category/update-multiple-marketplace-product-category.ts +0 -44
- package/server/graphql/resolvers/marketplace-product-variation/create-marketplace-product-variation.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-variation/delete-marketplace-product-variation.ts +0 -10
- package/server/graphql/resolvers/marketplace-product-variation/delete-marketplace-product-variations.ts +0 -17
- package/server/graphql/resolvers/marketplace-product-variation/index.ts +0 -30
- package/server/graphql/resolvers/marketplace-product-variation/link-warehouse-marketplace-product-variations.ts +0 -59
- package/server/graphql/resolvers/marketplace-product-variation/marketplace-product-variation.ts +0 -14
- package/server/graphql/resolvers/marketplace-product-variation/marketplace-product-variations.ts +0 -79
- package/server/graphql/resolvers/marketplace-product-variation/update-marketplace-product-variation.ts +0 -32
- package/server/graphql/resolvers/marketplace-product-variation/update-multiple-marketplace-product-variation-quantity.ts +0 -76
- package/server/graphql/resolvers/marketplace-product-variation/update-multiple-marketplace-product-variations.ts +0 -49
- package/server/graphql/resolvers/marketplace-product-variation-price/create-marketplace-product-variation-price.ts +0 -16
- package/server/graphql/resolvers/marketplace-product-variation-price/delete-marketplace-product-variation-price.ts +0 -13
- package/server/graphql/resolvers/marketplace-product-variation-price/delete-marketplace-product-variation-prices.ts +0 -18
- package/server/graphql/resolvers/marketplace-product-variation-price/index.ts +0 -19
- package/server/graphql/resolvers/marketplace-product-variation-price/marketplace-product-variation-price-query.ts +0 -52
- package/server/graphql/resolvers/marketplace-product-variation-price/update-marketplace-product-variation-price.ts +0 -20
- package/server/graphql/resolvers/marketplace-product-variation-price/update-multiple-marketplace-product-variation-price.ts +0 -49
- package/server/graphql/resolvers/marketplace-refund-order/index.ts +0 -9
- package/server/graphql/resolvers/marketplace-refund-order/sync-all-marketplace-refund-orders.ts +0 -122
- package/server/graphql/resolvers/marketplace-refund-order/sync-marketplace-refund-orders.ts +0 -106
- package/server/graphql/resolvers/marketplace-report/index.ts +0 -7
- package/server/graphql/resolvers/marketplace-report/marketplace-sales-report.ts +0 -143
- package/server/graphql/resolvers/store-replenishment/create-store-replenishment.ts +0 -16
- package/server/graphql/resolvers/store-replenishment/delete-store-replenishment.ts +0 -13
- package/server/graphql/resolvers/store-replenishment/delete-store-replenishments.ts +0 -18
- package/server/graphql/resolvers/store-replenishment/index.ts +0 -19
- package/server/graphql/resolvers/store-replenishment/store-replenishment-query.ts +0 -52
- package/server/graphql/resolvers/store-replenishment/update-multiple-store-replenishment.ts +0 -49
- package/server/graphql/resolvers/store-replenishment/update-store-replenishment.ts +0 -20
- package/server/graphql/resolvers/store-replenishment-item/create-store-replenishment-item.ts +0 -16
- package/server/graphql/resolvers/store-replenishment-item/delete-store-replenishment-item.ts +0 -13
- package/server/graphql/resolvers/store-replenishment-item/delete-store-replenishment-items.ts +0 -18
- package/server/graphql/resolvers/store-replenishment-item/index.ts +0 -19
- package/server/graphql/resolvers/store-replenishment-item/store-replenishment-item-query.ts +0 -52
- package/server/graphql/resolvers/store-replenishment-item/update-multiple-store-replenishment-item.ts +0 -49
- package/server/graphql/resolvers/store-replenishment-item/update-store-replenishment-item.ts +0 -20
- package/server/graphql/types/index.ts +0 -13
- package/server/graphql/types/marketplace-order/dashboard-order.ts +0 -13
- package/server/graphql/types/marketplace-order/full-logistics-detail.ts +0 -10
- package/server/graphql/types/marketplace-order/index.ts +0 -69
- package/server/graphql/types/marketplace-order/logistics-detail.ts +0 -8
- package/server/graphql/types/marketplace-order/logistics-info.ts +0 -27
- package/server/graphql/types/marketplace-order/logistics-init.ts +0 -9
- package/server/graphql/types/marketplace-order/logistics-time.ts +0 -9
- package/server/graphql/types/marketplace-order/logistics.ts +0 -21
- package/server/graphql/types/marketplace-order/marketplace-logistics.ts +0 -11
- package/server/graphql/types/marketplace-order/marketplace-order-export.ts +0 -19
- package/server/graphql/types/marketplace-order/marketplace-order-list.ts +0 -8
- package/server/graphql/types/marketplace-order/marketplace-order-patch.ts +0 -14
- package/server/graphql/types/marketplace-order/marketplace-order.ts +0 -40
- package/server/graphql/types/marketplace-order/new-marketplace-order.ts +0 -22
- package/server/graphql/types/marketplace-order/order-address.ts +0 -16
- package/server/graphql/types/marketplace-order/order-document.ts +0 -13
- package/server/graphql/types/marketplace-order-item/index.ts +0 -21
- package/server/graphql/types/marketplace-order-item/marketplace-order-item-list.ts +0 -8
- package/server/graphql/types/marketplace-order-item/marketplace-order-item-patch.ts +0 -10
- package/server/graphql/types/marketplace-order-item/marketplace-order-item.ts +0 -32
- package/server/graphql/types/marketplace-order-item/new-marketplace-order-item.ts +0 -17
- package/server/graphql/types/marketplace-order-shipping/index.ts +0 -31
- package/server/graphql/types/marketplace-order-shipping/marketplace-order-shipping-list.ts +0 -8
- package/server/graphql/types/marketplace-order-shipping/marketplace-order-shipping-patch.ts +0 -45
- package/server/graphql/types/marketplace-order-shipping/marketplace-order-shipping.ts +0 -59
- package/server/graphql/types/marketplace-order-shipping/new-marketplace-order-shipping.ts +0 -44
- package/server/graphql/types/marketplace-order-shipping-item/index.ts +0 -32
- package/server/graphql/types/marketplace-order-shipping-item/marketplace-order-shipping-item-list.ts +0 -8
- package/server/graphql/types/marketplace-order-shipping-item/marketplace-order-shipping-item-patch.ts +0 -13
- package/server/graphql/types/marketplace-order-shipping-item/marketplace-order-shipping-item.ts +0 -16
- package/server/graphql/types/marketplace-order-shipping-item/new-marketplace-order-shipping-item.ts +0 -12
- package/server/graphql/types/marketplace-product/index.ts +0 -28
- package/server/graphql/types/marketplace-product/marketplace-product-list.ts +0 -8
- package/server/graphql/types/marketplace-product/marketplace-product-patch.ts +0 -24
- package/server/graphql/types/marketplace-product/marketplace-product.ts +0 -30
- package/server/graphql/types/marketplace-product/new-marketplace-product.ts +0 -24
- package/server/graphql/types/marketplace-product-attribute/index.ts +0 -35
- package/server/graphql/types/marketplace-product-attribute/marketplace-product-attribute-list.ts +0 -8
- package/server/graphql/types/marketplace-product-attribute/marketplace-product-attribute-patch.ts +0 -10
- package/server/graphql/types/marketplace-product-attribute/marketplace-product-attribute.ts +0 -20
- package/server/graphql/types/marketplace-product-attribute/new-marketplace-product-attribute.ts +0 -13
- package/server/graphql/types/marketplace-product-category/index.ts +0 -28
- package/server/graphql/types/marketplace-product-category/marketplace-product-category-list.ts +0 -8
- package/server/graphql/types/marketplace-product-category/marketplace-product-category-patch.ts +0 -10
- package/server/graphql/types/marketplace-product-category/marketplace-product-category.ts +0 -17
- package/server/graphql/types/marketplace-product-category/new-marketplace-product-category.ts +0 -10
- package/server/graphql/types/marketplace-product-variation/index.ts +0 -47
- package/server/graphql/types/marketplace-product-variation/marketplace-product-variation-list.ts +0 -8
- package/server/graphql/types/marketplace-product-variation/marketplace-product-variation-patch.ts +0 -32
- package/server/graphql/types/marketplace-product-variation/marketplace-product-variation.ts +0 -35
- package/server/graphql/types/marketplace-product-variation/new-marketplace-product-variation.ts +0 -26
- package/server/graphql/types/marketplace-product-variation/warehouse-product.ts +0 -9
- package/server/graphql/types/marketplace-product-variation-price/index.ts +0 -21
- package/server/graphql/types/marketplace-product-variation-price/marketplace-product-variation-price-list.ts +0 -8
- package/server/graphql/types/marketplace-product-variation-price/marketplace-product-variation-price-patch.ts +0 -17
- package/server/graphql/types/marketplace-product-variation-price/marketplace-product-variation-price.ts +0 -21
- package/server/graphql/types/marketplace-product-variation-price/new-marketplace-product-variation-price.ts +0 -14
- package/server/graphql/types/marketplace-refund-order/index.ts +0 -16
- package/server/graphql/types/marketplace-refund-order/marketplace-refund-order-list.ts +0 -8
- package/server/graphql/types/marketplace-refund-order/marketplace-refund-order.ts +0 -17
- package/server/graphql/types/marketplace-report/index.ts +0 -10
- package/server/graphql/types/marketplace-report/marketplace-sales-report-list.ts +0 -8
- package/server/graphql/types/marketplace-report/marketplace-sales-report.ts +0 -67
- package/server/graphql/types/store-replenishment/index.ts +0 -21
- package/server/graphql/types/store-replenishment/new-store-replenishment.ts +0 -8
- package/server/graphql/types/store-replenishment/store-replenishment-list.ts +0 -8
- package/server/graphql/types/store-replenishment/store-replenishment-patch.ts +0 -10
- package/server/graphql/types/store-replenishment/store-replenishment.ts +0 -24
- package/server/graphql/types/store-replenishment-item/index.ts +0 -21
- package/server/graphql/types/store-replenishment-item/new-store-replenishment-item.ts +0 -8
- package/server/graphql/types/store-replenishment-item/store-replenishment-item-list.ts +0 -8
- package/server/graphql/types/store-replenishment-item/store-replenishment-item-patch.ts +0 -10
- package/server/graphql/types/store-replenishment-item/store-replenishment-item.ts +0 -15
- package/server/index.ts +0 -6
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -26
- package/server/utils/index.ts +0 -1
- package/server/utils/no-generator.ts +0 -25
- package/tsconfig.json +0 -9
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createMarketplaceProductVariationResolver } from './create-marketplace-product-variation'
|
|
2
|
-
import { deleteMarketplaceProductVariationResolver } from './delete-marketplace-product-variation'
|
|
3
|
-
import { deleteMarketplaceProductVariationsResolver } from './delete-marketplace-product-variations'
|
|
4
|
-
import { linkWarehouseMarketplaceProductVariationsResolver } from './link-warehouse-marketplace-product-variations'
|
|
5
|
-
import { marketplaceProductVariationResolver } from './marketplace-product-variation'
|
|
6
|
-
import { marketplaceProductVariationsResolver } from './marketplace-product-variations'
|
|
7
|
-
import {
|
|
8
|
-
updateMarketplaceProductVariation,
|
|
9
|
-
updateMarketplaceProductVariationResolver
|
|
10
|
-
} from './update-marketplace-product-variation'
|
|
11
|
-
import { updateMultipleMarketplaceProductVariationQuantityResolver } from './update-multiple-marketplace-product-variation-quantity'
|
|
12
|
-
import { updateMultipleMarketplaceProducVariationsResolver } from './update-multiple-marketplace-product-variations'
|
|
13
|
-
|
|
14
|
-
export const MarketplaceProductVariationResolver = {
|
|
15
|
-
Query: {
|
|
16
|
-
...marketplaceProductVariationsResolver,
|
|
17
|
-
...marketplaceProductVariationResolver
|
|
18
|
-
},
|
|
19
|
-
Mutation: {
|
|
20
|
-
...updateMarketplaceProductVariationResolver,
|
|
21
|
-
...createMarketplaceProductVariationResolver,
|
|
22
|
-
...deleteMarketplaceProductVariationResolver,
|
|
23
|
-
...deleteMarketplaceProductVariationsResolver,
|
|
24
|
-
...updateMultipleMarketplaceProductVariationQuantityResolver,
|
|
25
|
-
...linkWarehouseMarketplaceProductVariationsResolver,
|
|
26
|
-
...updateMultipleMarketplaceProducVariationsResolver
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { updateMarketplaceProductVariation }
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { SelectQueryBuilder } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
4
|
-
import { updateMarketplaceProductVariation } from './index'
|
|
5
|
-
|
|
6
|
-
export const linkWarehouseMarketplaceProductVariationsResolver = {
|
|
7
|
-
async linkWarehouseMarketplaceProductVariations(
|
|
8
|
-
_: any,
|
|
9
|
-
{ marketplaceStoreId, sku, patches },
|
|
10
|
-
context: any
|
|
11
|
-
): Promise<any> {
|
|
12
|
-
const { tx } = context.state
|
|
13
|
-
|
|
14
|
-
const qb: SelectQueryBuilder<MarketplaceProductVariation> = tx
|
|
15
|
-
.getRepository(MarketplaceProductVariation)
|
|
16
|
-
.createQueryBuilder('mpv')
|
|
17
|
-
.innerJoinAndSelect('mpv.marketplaceProduct', 'mp')
|
|
18
|
-
.where('mpv.sku = :sku', { sku })
|
|
19
|
-
.andWhere('mp.marketplace_store_id = :marketplaceStoreId', { marketplaceStoreId })
|
|
20
|
-
|
|
21
|
-
let existingMarketplaceProductVariation = await qb.getMany()
|
|
22
|
-
|
|
23
|
-
let newMarketplaceProductVariationLink: MarketplaceProductVariation[] = patches.reduce((acc, curr) => {
|
|
24
|
-
if (!existingMarketplaceProductVariation.find(itm => itm.id == curr.id)) {
|
|
25
|
-
acc.push({ id: curr.id })
|
|
26
|
-
}
|
|
27
|
-
return acc
|
|
28
|
-
}, [])
|
|
29
|
-
|
|
30
|
-
let removeMarketplaceProductVariationLink: MarketplaceProductVariation[] =
|
|
31
|
-
existingMarketplaceProductVariation.reduce((acc, curr) => {
|
|
32
|
-
if (!patches.find(itm => itm.id == curr.id)) {
|
|
33
|
-
acc.push({ id: curr.id })
|
|
34
|
-
}
|
|
35
|
-
return acc
|
|
36
|
-
}, [])
|
|
37
|
-
|
|
38
|
-
if (newMarketplaceProductVariationLink.length > 0) {
|
|
39
|
-
for (let i = 0; i < newMarketplaceProductVariationLink.length; i++) {
|
|
40
|
-
const patch: MarketplaceProductVariation = { ...newMarketplaceProductVariationLink[i], sku }
|
|
41
|
-
await updateMarketplaceProductVariation(newMarketplaceProductVariationLink[i].id, patch, context.state.user, tx)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (removeMarketplaceProductVariationLink.length > 0) {
|
|
46
|
-
for (let i = 0; i < removeMarketplaceProductVariationLink.length; i++) {
|
|
47
|
-
const patch: MarketplaceProductVariation = { ...removeMarketplaceProductVariationLink[i], sku: null }
|
|
48
|
-
await updateMarketplaceProductVariation(
|
|
49
|
-
removeMarketplaceProductVariationLink[i].id,
|
|
50
|
-
patch,
|
|
51
|
-
context.state.user,
|
|
52
|
-
tx
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
59
|
-
}
|
package/server/graphql/resolvers/marketplace-product-variation/marketplace-product-variation.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const marketplaceProductVariationResolver = {
|
|
6
|
-
async marketplaceProductVariation(_: any, { name }, context: ResolverContext) {
|
|
7
|
-
const repository = getRepository(MarketplaceProductVariation)
|
|
8
|
-
|
|
9
|
-
return await getRepository(MarketplaceProductVariation).findOne({
|
|
10
|
-
where: { domain: { id: context.state.domain.id }, name },
|
|
11
|
-
relations: ['domain', 'creator', 'updater']
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
}
|
package/server/graphql/resolvers/marketplace-product-variation/marketplace-product-variations.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { SelectQueryBuilder } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { buildQuery, getRepository, ListParam } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const marketplaceProductVariationsResolver = {
|
|
8
|
-
async marketplaceProductVariations(_: any, params: ListParam, context: ResolverContext) {
|
|
9
|
-
const customFilterNames = ['marketplaceStoreId', 'sku', 'unAssignedSku']
|
|
10
|
-
const customFilters = params.filters.filter(x => customFilterNames.indexOf(x.name) >= 0)
|
|
11
|
-
|
|
12
|
-
params.filters = params.filters.filter(x => customFilterNames.indexOf(x.name) < 0)
|
|
13
|
-
|
|
14
|
-
params.sortings = params.sortings.map(sorting => {
|
|
15
|
-
let field = sorting.name.split('|')
|
|
16
|
-
if (field.length > 1) {
|
|
17
|
-
switch (field[0]) {
|
|
18
|
-
case 'marketplaceProduct':
|
|
19
|
-
return {
|
|
20
|
-
...sorting,
|
|
21
|
-
name: `mp.${field[1]}`
|
|
22
|
-
}
|
|
23
|
-
case 'marketplaceStoreProduct':
|
|
24
|
-
return {
|
|
25
|
-
...sorting,
|
|
26
|
-
name: `msp.${field[1]}`
|
|
27
|
-
}
|
|
28
|
-
case 'marketplaceStore':
|
|
29
|
-
return {
|
|
30
|
-
...sorting,
|
|
31
|
-
name: `ms.${field[1]}`
|
|
32
|
-
}
|
|
33
|
-
default:
|
|
34
|
-
return {
|
|
35
|
-
...sorting
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return sorting
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// const convertedParams = convertListParams(params)
|
|
43
|
-
|
|
44
|
-
let qb: SelectQueryBuilder<MarketplaceProductVariation> =
|
|
45
|
-
getRepository(MarketplaceProductVariation).createQueryBuilder('mpv')
|
|
46
|
-
buildQuery(qb, params, context)
|
|
47
|
-
|
|
48
|
-
qb.innerJoinAndSelect('mpv.marketplaceProduct', 'mp')
|
|
49
|
-
qb.innerJoinAndSelect('mp.marketplaceStore', 'ms')
|
|
50
|
-
|
|
51
|
-
qb.addOrderBy('ms.name', 'ASC')
|
|
52
|
-
qb.addOrderBy('mp.name', 'ASC')
|
|
53
|
-
qb.addOrderBy('mpv.name', 'ASC')
|
|
54
|
-
|
|
55
|
-
let marketplaceStoreId = customFilters.find(x => x.name == 'marketplaceStoreId')
|
|
56
|
-
if (marketplaceStoreId)
|
|
57
|
-
qb.andWhere('mp.marketplace_store_id = :storeId::uuid', {
|
|
58
|
-
storeId: marketplaceStoreId.value
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
let unAssignedSku = customFilters.find(x => x.name == 'unAssignedSku')
|
|
62
|
-
let sku = customFilters.find(x => x.name == 'sku')
|
|
63
|
-
if (unAssignedSku) {
|
|
64
|
-
if (unAssignedSku.value) {
|
|
65
|
-
qb.andWhere(`"mpv"."sku" IS NULL`)
|
|
66
|
-
} else {
|
|
67
|
-
qb.andWhere(`"mpv"."sku" IS NOT NULL`)
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
if (sku) {
|
|
71
|
-
qb.andWhere('mpv.sku = :sku', { sku: sku.value })
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const [items, total] = await qb.getManyAndCount()
|
|
76
|
-
|
|
77
|
-
return { items, total }
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EntityManager, Repository } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { getRepository } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const updateMarketplaceProductVariationResolver = {
|
|
8
|
-
async updateMarketplaceProductVariation(_: any, { id, patch }, context: ResolverContext) {
|
|
9
|
-
try {
|
|
10
|
-
return updateMarketplaceProductVariation(id, patch, context.state.user)
|
|
11
|
-
} catch (error) {
|
|
12
|
-
throw error
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function updateMarketplaceProductVariation(
|
|
18
|
-
id: string,
|
|
19
|
-
patch: MarketplaceProductVariation,
|
|
20
|
-
user: any,
|
|
21
|
-
trxMgr?: EntityManager
|
|
22
|
-
) {
|
|
23
|
-
const marketplaceProductVariationRepo: Repository<MarketplaceProductVariation> =
|
|
24
|
-
trxMgr?.getRepository(MarketplaceProductVariation) || getRepository(MarketplaceProductVariation)
|
|
25
|
-
const product = await marketplaceProductVariationRepo.findOneBy({ id })
|
|
26
|
-
|
|
27
|
-
return marketplaceProductVariationRepo.save({
|
|
28
|
-
...product,
|
|
29
|
-
...patch,
|
|
30
|
-
updater: user
|
|
31
|
-
})
|
|
32
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { StoreAPI } from '@things-factory/integration-marketplace'
|
|
2
|
-
|
|
3
|
-
import { MARKETPLACE_PLATFORM } from '../../../constants'
|
|
4
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
5
|
-
|
|
6
|
-
export const updateMultipleMarketplaceProductVariationQuantityResolver = {
|
|
7
|
-
async updateMultipleMarketplaceProductVariationQuantity(_: any, { patches }, context: ResolverContext) {
|
|
8
|
-
try {
|
|
9
|
-
if (patches && patches.length > 0) {
|
|
10
|
-
const { tx } = context.state
|
|
11
|
-
|
|
12
|
-
await Promise.all(
|
|
13
|
-
patches.map(async itm => {
|
|
14
|
-
const repoProductVariation = tx.getRepository(MarketplaceProductVariation)
|
|
15
|
-
|
|
16
|
-
let productVariation = await repoProductVariation.findOne({
|
|
17
|
-
where: { id: itm.id },
|
|
18
|
-
relations: [
|
|
19
|
-
'marketplaceProduct',
|
|
20
|
-
'marketplaceProduct.marketplaceStore',
|
|
21
|
-
'marketplaceProduct.marketplaceStore.marketplaceDistributors',
|
|
22
|
-
'creator',
|
|
23
|
-
'updater'
|
|
24
|
-
]
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const marketplaceStore = productVariation?.marketplaceProduct?.marketplaceStore
|
|
28
|
-
const hasVariation = productVariation?.marketplaceProduct?.hasVariation
|
|
29
|
-
|
|
30
|
-
if (marketplaceStore) {
|
|
31
|
-
//Lazada Product quantity data update -> {sku, qty}
|
|
32
|
-
//Shopee Product quantity data update -> variation = false: {itemId, qty} | variation = true: {itemId, variationId, qty}
|
|
33
|
-
let adjustQty = itm.qty
|
|
34
|
-
let productVariationLocationId = productVariation.locationId
|
|
35
|
-
if (marketplaceStore.platform === MARKETPLACE_PLATFORM.SHOPIFY) {
|
|
36
|
-
adjustQty = itm.qty - productVariation.qty
|
|
37
|
-
|
|
38
|
-
let locationIds: any[] = JSON.parse(productVariationLocationId)
|
|
39
|
-
productVariationLocationId = locationIds[0].location_id
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (hasVariation) {
|
|
43
|
-
await StoreAPI.updateStoreProductVariationStock(marketplaceStore, [
|
|
44
|
-
{
|
|
45
|
-
itemId: productVariation.marketplaceProduct.itemId,
|
|
46
|
-
variationId: productVariation.variationId,
|
|
47
|
-
qty: adjustQty,
|
|
48
|
-
locationId: productVariationLocationId,
|
|
49
|
-
inventoryItemId: productVariation.inventoryItemId
|
|
50
|
-
}
|
|
51
|
-
])
|
|
52
|
-
} else {
|
|
53
|
-
await StoreAPI.updateStoreProductStock(marketplaceStore, [
|
|
54
|
-
{
|
|
55
|
-
itemId: productVariation.marketplaceProduct.itemId,
|
|
56
|
-
variationId: productVariation.variationId,
|
|
57
|
-
variationSku: productVariation.variationSku,
|
|
58
|
-
qty: adjustQty,
|
|
59
|
-
distributors: marketplaceStore.marketplaceDistributors
|
|
60
|
-
}
|
|
61
|
-
])
|
|
62
|
-
}
|
|
63
|
-
await repoProductVariation.save({ ...productVariation, qty: itm.qty })
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
return true
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error('No data found.')
|
|
71
|
-
}
|
|
72
|
-
} catch (ex) {
|
|
73
|
-
throw ex
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariation } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const updateMultipleMarketplaceProducVariationsResolver = {
|
|
6
|
-
async updateMultipleMarketplaceProductVariations(_: any, { patches }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
let results = []
|
|
10
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
11
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
12
|
-
const marketplaceProductVariationRepo = getRepository(MarketplaceProductVariation)
|
|
13
|
-
|
|
14
|
-
if (_createRecords.length > 0) {
|
|
15
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
16
|
-
const newRecord = _createRecords[i]
|
|
17
|
-
|
|
18
|
-
const result = await marketplaceProductVariationRepo.save({
|
|
19
|
-
...newRecord,
|
|
20
|
-
domain: domain,
|
|
21
|
-
creator: user,
|
|
22
|
-
updater: user
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
results.push({ ...result, cuFlag: '+' })
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (_updateRecords.length > 0) {
|
|
30
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
31
|
-
const newRecord = _updateRecords[i]
|
|
32
|
-
const marketplaceProductVariationPrice = await marketplaceProductVariationRepo.findOneBy({
|
|
33
|
-
domain: { id: domain.id },
|
|
34
|
-
id: newRecord.id
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const result = await marketplaceProductVariationRepo.save({
|
|
38
|
-
...marketplaceProductVariationPrice,
|
|
39
|
-
...newRecord,
|
|
40
|
-
updater: user
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariationPrice } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const createMarketplaceProductVariationPrice = {
|
|
6
|
-
async createMarketplaceProductVariationPrice(_: any, { marketplaceProductVariationPrice }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
return await getRepository(MarketplaceProductVariationPrice).save({
|
|
10
|
-
...marketplaceProductVariationPrice,
|
|
11
|
-
domain,
|
|
12
|
-
creator: user,
|
|
13
|
-
updater: user
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariationPrice } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const deleteMarketplaceProductVariationPrice = {
|
|
6
|
-
async deleteMarketplaceProductVariationPrice(_: any, { name }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
await getRepository(MarketplaceProductVariationPrice).delete({ domain: { id: domain.id }, name })
|
|
10
|
-
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { In } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { getRepository } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { MarketplaceProductVariationPrice } from '../../../entities'
|
|
6
|
-
|
|
7
|
-
export const deleteMarketplaceProductVariationPrices = {
|
|
8
|
-
async deleteMarketplaceProductVariationPrices(_: any, { names }, context: ResolverContext) {
|
|
9
|
-
const { domain, user } = context.state
|
|
10
|
-
|
|
11
|
-
await getRepository(MarketplaceProductVariationPrice).delete({
|
|
12
|
-
domain: { id: domain.id },
|
|
13
|
-
name: In(names)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
return true
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Query, MarketplaceProductVariationPrice } from './marketplace-product-variation-price-query'
|
|
2
|
-
|
|
3
|
-
import { updateMarketplaceProductVariationPrice } from './update-marketplace-product-variation-price'
|
|
4
|
-
import { updateMultipleMarketplaceProductVariationPrice } from './update-multiple-marketplace-product-variation-price'
|
|
5
|
-
import { createMarketplaceProductVariationPrice } from './create-marketplace-product-variation-price'
|
|
6
|
-
import { deleteMarketplaceProductVariationPrice } from './delete-marketplace-product-variation-price'
|
|
7
|
-
import { deleteMarketplaceProductVariationPrices } from './delete-marketplace-product-variation-prices'
|
|
8
|
-
|
|
9
|
-
export const MarketplaceProductVariationPriceResolver = {
|
|
10
|
-
MarketplaceProductVariationPrice,
|
|
11
|
-
Query,
|
|
12
|
-
Mutation: {
|
|
13
|
-
...updateMarketplaceProductVariationPrice,
|
|
14
|
-
...updateMultipleMarketplaceProductVariationPrice,
|
|
15
|
-
...createMarketplaceProductVariationPrice,
|
|
16
|
-
...deleteMarketplaceProductVariationPrice,
|
|
17
|
-
...deleteMarketplaceProductVariationPrices
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { convertListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariationPrice as MarketplaceProductVariationPriceEntity } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const Query = {
|
|
6
|
-
async marketplaceProductVariationPrice(_: any, { name }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
const repository = getRepository(MarketplaceProductVariationPriceEntity)
|
|
9
|
-
|
|
10
|
-
return await repository.findOne({
|
|
11
|
-
where: { domain: { id: domain.id }, name }
|
|
12
|
-
})
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
async marketplaceProductVariationPrices(_: any, params: ListParam, context: ResolverContext) {
|
|
16
|
-
const convertedParams = convertListParams(params)
|
|
17
|
-
const [items, total] = await getRepository(MarketplaceProductVariationPriceEntity).findAndCount({
|
|
18
|
-
...convertedParams
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return { items, total }
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const MarketplaceProductVariationPrice = {
|
|
26
|
-
async domain(marketplaceProductVariationPrice) {
|
|
27
|
-
return (
|
|
28
|
-
await getRepository(MarketplaceProductVariationPriceEntity).findOne({
|
|
29
|
-
where: { id: marketplaceProductVariationPrice.id },
|
|
30
|
-
relations: ['domain']
|
|
31
|
-
})
|
|
32
|
-
)?.domain
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
async updater(marketplaceProductVariationPrice) {
|
|
36
|
-
return (
|
|
37
|
-
await getRepository(MarketplaceProductVariationPriceEntity).findOne({
|
|
38
|
-
where: { id: marketplaceProductVariationPrice.id },
|
|
39
|
-
relations: ['updater']
|
|
40
|
-
})
|
|
41
|
-
)?.updater
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
async creator(marketplaceProductVariationPrice) {
|
|
45
|
-
return (
|
|
46
|
-
await getRepository(MarketplaceProductVariationPriceEntity).findOne({
|
|
47
|
-
where: { id: marketplaceProductVariationPrice.id },
|
|
48
|
-
relations: ['creator']
|
|
49
|
-
})
|
|
50
|
-
)?.creator
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariationPrice } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const updateMarketplaceProductVariationPrice = {
|
|
6
|
-
async updateMarketplaceProductVariationPrice(_: any, { name, patch }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
const repository = getRepository(MarketplaceProductVariationPrice)
|
|
10
|
-
const marketplaceProductVariationPrice = await repository.findOne({
|
|
11
|
-
where: { domain: { id: domain.id }, name }
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
return await repository.save({
|
|
15
|
-
...marketplaceProductVariationPrice,
|
|
16
|
-
...patch,
|
|
17
|
-
updater: user
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { getRepository } from '@things-factory/shell'
|
|
2
|
-
|
|
3
|
-
import { MarketplaceProductVariationPrice } from '../../../entities'
|
|
4
|
-
|
|
5
|
-
export const updateMultipleMarketplaceProductVariationPrice = {
|
|
6
|
-
async updateMultipleMarketplaceProductVariationPrice(_: any, { patches }, context: ResolverContext) {
|
|
7
|
-
const { domain, user } = context.state
|
|
8
|
-
|
|
9
|
-
let results = []
|
|
10
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
11
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
12
|
-
const marketplaceProductVariationPriceRepo = getRepository(MarketplaceProductVariationPrice)
|
|
13
|
-
|
|
14
|
-
if (_createRecords.length > 0) {
|
|
15
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
16
|
-
const newRecord = _createRecords[i]
|
|
17
|
-
|
|
18
|
-
const result = await marketplaceProductVariationPriceRepo.save({
|
|
19
|
-
...newRecord,
|
|
20
|
-
domain: domain,
|
|
21
|
-
creator: user,
|
|
22
|
-
updater: user
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
results.push({ ...result, cuFlag: '+' })
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (_updateRecords.length > 0) {
|
|
30
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
31
|
-
const newRecord = _updateRecords[i]
|
|
32
|
-
const marketplaceProductVariationPrice = await marketplaceProductVariationPriceRepo.findOneBy({
|
|
33
|
-
domain: { id: domain.id },
|
|
34
|
-
id: newRecord.id
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const result = await marketplaceProductVariationPriceRepo.save({
|
|
38
|
-
...marketplaceProductVariationPrice,
|
|
39
|
-
...newRecord,
|
|
40
|
-
updater: user
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return results
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { syncMarketplaceRefundOrders } from './sync-marketplace-refund-orders'
|
|
2
|
-
import { syncAllMarketplaceRefundOrders } from './sync-all-marketplace-refund-orders'
|
|
3
|
-
|
|
4
|
-
export const MarketplaceRefundOrderResolver = {
|
|
5
|
-
Mutation: {
|
|
6
|
-
...syncMarketplaceRefundOrders,
|
|
7
|
-
...syncAllMarketplaceRefundOrders
|
|
8
|
-
}
|
|
9
|
-
}
|
package/server/graphql/resolvers/marketplace-refund-order/sync-all-marketplace-refund-orders.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { MarketplaceStore, StoreAPI } from '@things-factory/integration-marketplace'
|
|
2
|
-
import { Domain, getRepository } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { MarketplaceProductVariation, MarketplaceRefundOrder, MarketplaceRefundOrderItem } from '../../../entities'
|
|
5
|
-
|
|
6
|
-
export const syncAllMarketplaceRefundOrders = {
|
|
7
|
-
async syncAllMarketplaceRefundOrders(
|
|
8
|
-
_: any,
|
|
9
|
-
{ companyDomainId, fromDate, toDate, blackListStores },
|
|
10
|
-
context: ResolverContext
|
|
11
|
-
) {
|
|
12
|
-
const { user, tx } = context.state
|
|
13
|
-
|
|
14
|
-
const companyDomain: Domain = await getRepository(Domain).findOneBy({ id: companyDomainId })
|
|
15
|
-
|
|
16
|
-
// Step 1: get all available marketplace-store
|
|
17
|
-
const marketplaceStores: MarketplaceStore[] = await StoreAPI.getMarketplaceStores(companyDomain)
|
|
18
|
-
|
|
19
|
-
// Step 2: get marketplace refund orders based on each marketplace-store
|
|
20
|
-
if (marketplaceStores?.length === 0) throw new Error('No active marketplace store')
|
|
21
|
-
let whiteListStores: MarketplaceStore[] = marketplaceStores
|
|
22
|
-
|
|
23
|
-
if (blackListStores && blackListStores?.length) {
|
|
24
|
-
whiteListStores = marketplaceStores.filter(store => blackListStores.indexOf(store.name) < 0)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
for (var i = 0; i < whiteListStores?.length; i++) {
|
|
28
|
-
const marketplaceStore = whiteListStores[i]
|
|
29
|
-
const domain: Domain = marketplaceStore.domain
|
|
30
|
-
|
|
31
|
-
let page: number = 0
|
|
32
|
-
let hasMorePage: boolean = true
|
|
33
|
-
var limit: number = 100
|
|
34
|
-
|
|
35
|
-
while (hasMorePage) {
|
|
36
|
-
const { results: marketplaceRefundOrders, more } = await StoreAPI.getStoreRefundOrders(marketplaceStore, {
|
|
37
|
-
fromDate,
|
|
38
|
-
toDate,
|
|
39
|
-
pagination: { page, limit }
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
if (marketplaceRefundOrders?.length > 0) {
|
|
43
|
-
for (var m = 0; m < marketplaceRefundOrders.length; m++) {
|
|
44
|
-
var refundOrder = marketplaceRefundOrders[i]
|
|
45
|
-
|
|
46
|
-
let marketplaceRefundOrder: MarketplaceRefundOrder = new MarketplaceRefundOrder()
|
|
47
|
-
marketplaceRefundOrder.name = refundOrder.name
|
|
48
|
-
marketplaceRefundOrder.orderNo = refundOrder.orderNo
|
|
49
|
-
marketplaceRefundOrder.amount = refundOrder.amount
|
|
50
|
-
marketplaceRefundOrder.status = refundOrder.status
|
|
51
|
-
marketplaceRefundOrder.originalOrderNo = refundOrder.originalOrderNo
|
|
52
|
-
marketplaceRefundOrder.domain = marketplaceStore.domain
|
|
53
|
-
marketplaceRefundOrder.creator = user
|
|
54
|
-
marketplaceRefundOrder.updater = user
|
|
55
|
-
|
|
56
|
-
const existingRefundOrder: MarketplaceRefundOrder = await getRepository(MarketplaceRefundOrder).findOne({
|
|
57
|
-
where: { domain: { id: marketplaceStore.domain.id }, name: refundOrder.name },
|
|
58
|
-
relations: ['domain', 'marketplaceRefundOrderItems']
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
if (existingRefundOrder) {
|
|
62
|
-
marketplaceRefundOrder = {
|
|
63
|
-
...existingRefundOrder,
|
|
64
|
-
...marketplaceRefundOrder,
|
|
65
|
-
updater: user
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
marketplaceRefundOrder = await getRepository(MarketplaceRefundOrder).save(marketplaceRefundOrder)
|
|
69
|
-
|
|
70
|
-
refundOrder.items.forEach(async item => {
|
|
71
|
-
let existingVariation: MarketplaceProductVariation = await getRepository(
|
|
72
|
-
MarketplaceProductVariation
|
|
73
|
-
).findOne({
|
|
74
|
-
where: { domain: { id: marketplaceStore.domain.id }, name: item.variationId }
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
if (marketplaceStore.platform === 'lazada') {
|
|
78
|
-
existingVariation = await getRepository(MarketplaceProductVariation).findOne({
|
|
79
|
-
where: { domain: { id: marketplaceStore.domain.id }, channelSku: item.channelSku }
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let marketplaceRefundOrderItem: MarketplaceRefundOrderItem = new MarketplaceRefundOrderItem()
|
|
84
|
-
|
|
85
|
-
marketplaceRefundOrderItem.name = item.name
|
|
86
|
-
marketplaceRefundOrderItem.orderItemId = item.orderItemId
|
|
87
|
-
marketplaceRefundOrderItem.price = item.price
|
|
88
|
-
marketplaceRefundOrderItem.qty = item.qty
|
|
89
|
-
marketplaceRefundOrderItem.status = item.status
|
|
90
|
-
marketplaceRefundOrderItem.domain = marketplaceStore.domain
|
|
91
|
-
marketplaceRefundOrderItem.creator = user
|
|
92
|
-
marketplaceRefundOrderItem.updater = user
|
|
93
|
-
marketplaceRefundOrderItem.marketplaceRefundOrder = marketplaceRefundOrder
|
|
94
|
-
marketplaceRefundOrderItem.marketplaceProductVariation = existingVariation
|
|
95
|
-
|
|
96
|
-
const existingRefundOrderItem: MarketplaceRefundOrderItem = await getRepository(
|
|
97
|
-
MarketplaceRefundOrderItem
|
|
98
|
-
).findOne({
|
|
99
|
-
where: { domain: { id: marketplaceStore.domain.id }, name: item.name },
|
|
100
|
-
relations: ['domain']
|
|
101
|
-
})
|
|
102
|
-
if (existingRefundOrderItem) {
|
|
103
|
-
marketplaceRefundOrderItem = {
|
|
104
|
-
...existingRefundOrderItem,
|
|
105
|
-
...marketplaceRefundOrderItem,
|
|
106
|
-
updater: user
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
marketplaceRefundOrderItem = await getRepository(MarketplaceRefundOrderItem).save(
|
|
111
|
-
marketplaceRefundOrderItem
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (more) page++
|
|
117
|
-
hasMorePage = more
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return true
|
|
121
|
-
}
|
|
122
|
-
}
|