cloudcommerce 0.27.0 → 0.28.0
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/CHANGELOG.md +20 -0
- package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
- package/ecomplus-stores/barra-doce/functions/ssr/content/layout.json +13 -13
- package/ecomplus-stores/barra-doce/functions/ssr/content/pages/home.json +10 -10
- package/ecomplus-stores/barra-doce/functions/ssr/content/pages/products.json +17 -0
- package/ecomplus-stores/barra-doce/functions/ssr/content/settings.json +8 -8
- package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/AccountMenu.vue +11 -11
- package/ecomplus-stores/barra-doce/functions/ssr/src/components/ShopFooter.vue +24 -24
- package/ecomplus-stores/barra-doce/functions/ssr/src/layouts/PageFooter.astro +4 -4
- package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/barra-doce/package.json +2 -2
- package/ecomplus-stores/monocard/functions/many/package.json +3 -3
- package/ecomplus-stores/monocard/functions/ssr/content/layout.json +11 -11
- package/ecomplus-stores/monocard/functions/ssr/content/pages/home.json +16 -16
- package/ecomplus-stores/monocard/functions/ssr/content/pages/products.json +2 -4
- package/ecomplus-stores/monocard/functions/ssr/content/settings.json +11 -11
- package/ecomplus-stores/monocard/functions/ssr/package.json +6 -6
- package/ecomplus-stores/monocard/functions/ssr/src/components/AccountMenu.vue +1 -1
- package/ecomplus-stores/monocard/functions/ssr/src/components/DocDescription.vue +33 -0
- package/ecomplus-stores/monocard/functions/ssr/src/components/FeatureTabs.vue +3 -3
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopFooter.vue +3 -3
- package/ecomplus-stores/monocard/functions/ssr/src/components/ShopHeader.vue +5 -13
- package/ecomplus-stores/monocard/functions/ssr/src/layouts/PageFooter.astro +2 -2
- package/ecomplus-stores/monocard/functions/ssr/src/main/Home.astro +1 -1
- package/ecomplus-stores/monocard/functions/ssr/src/main/Sections.astro +1 -1
- package/ecomplus-stores/monocard/functions/with-apps/package.json +3 -3
- package/ecomplus-stores/monocard/package.json +2 -2
- package/package.json +2 -2
- package/packages/api/package.json +1 -1
- package/packages/apps/affilate-program/package.json +1 -1
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +1 -1
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/lib/functios-lib/utils.js +1 -1
- package/packages/apps/emails/lib/functios-lib/utils.js.map +1 -1
- package/packages/apps/emails/package.json +1 -1
- package/packages/apps/emails/src/functios-lib/utils.ts +1 -1
- package/packages/apps/fb-conversions/package.json +1 -1
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +1 -1
- package/packages/apps/galaxpay/package.json +1 -1
- package/packages/apps/google-analytics/package.json +1 -1
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/lib/functions-lib/cron-add-points.d.ts +2 -0
- package/packages/apps/loyalty-points/lib/functions-lib/cron-add-points.js +98 -0
- package/packages/apps/loyalty-points/lib/functions-lib/cron-add-points.js.map +1 -0
- package/packages/apps/loyalty-points/lib/functions-lib/handle-loyalty-points-event.js +59 -23
- package/packages/apps/loyalty-points/lib/functions-lib/handle-loyalty-points-event.js.map +1 -1
- package/packages/apps/loyalty-points/lib/loyalty-create-transaction.js +9 -4
- package/packages/apps/loyalty-points/lib/loyalty-create-transaction.js.map +1 -1
- package/packages/apps/loyalty-points/lib/loyalty-list-payments.js +7 -2
- package/packages/apps/loyalty-points/lib/loyalty-list-payments.js.map +1 -1
- package/packages/apps/loyalty-points/lib/loyalty-points-events.d.ts +3 -1
- package/packages/apps/loyalty-points/lib/loyalty-points-events.js +9 -0
- package/packages/apps/loyalty-points/lib/loyalty-points-events.js.map +1 -1
- package/packages/apps/loyalty-points/package.json +3 -2
- package/packages/apps/loyalty-points/src/functions-lib/cron-add-points.ts +104 -0
- package/packages/apps/loyalty-points/src/functions-lib/handle-loyalty-points-event.ts +67 -25
- package/packages/apps/loyalty-points/src/loyalty-create-transaction.ts +11 -4
- package/packages/apps/loyalty-points/src/loyalty-list-payments.ts +9 -2
- package/packages/apps/loyalty-points/src/loyalty-points-events.ts +12 -1
- package/packages/apps/melhor-envio/package.json +1 -1
- package/packages/apps/mercadopago/assets/onload-expression.js +5 -1
- package/packages/apps/mercadopago/assets/onload-expression.min.js +1 -1
- package/packages/apps/mercadopago/lib/mp-create-transaction.js +16 -6
- package/packages/apps/mercadopago/lib/mp-create-transaction.js.map +1 -1
- package/packages/apps/mercadopago/package.json +1 -1
- package/packages/apps/mercadopago/src/mp-create-transaction.ts +19 -7
- package/packages/apps/pagarme/package.json +1 -1
- package/packages/apps/paghiper/package.json +1 -1
- package/packages/apps/pix/package.json +1 -1
- package/packages/apps/tiny-erp/package.json +1 -1
- package/packages/apps/webhooks/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/lib/config.js +2 -2
- package/packages/config/lib/config.js.map +1 -1
- package/packages/config/package.json +1 -1
- package/packages/config/src/config.ts +2 -2
- package/packages/emails/package.json +1 -1
- package/packages/eslint/package.json +1 -1
- package/packages/events/package.json +1 -1
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +1 -1
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +1 -1
- package/packages/passport/package.json +1 -1
- package/packages/ssr/package.json +1 -1
- package/packages/storefront/config/storefront.cms.js +2 -2
- package/packages/storefront/package.json +1 -1
- package/packages/storefront/src/lib/components/ContentClearfix.vue +1 -1
- package/packages/storefront/src/lib/components/PaymentMethodFlag.vue +1 -1
- package/packages/storefront/src/lib/composables/use-pitch-bar.ts +2 -2
- package/packages/storefront/src/lib/content.d.ts +5 -5
- package/packages/storefront/src/lib/layouts/Base.astro +4 -4
- package/packages/storefront/src/lib/layouts/BaseHead.astro +7 -7
- package/packages/storefront/src/lib/layouts/use-page-header.ts +9 -4
- package/packages/storefront/src/lib/layouts/use-page-main.ts +13 -33
- package/packages/test-base/package.json +1 -1
- package/packages/types/index.ts +14 -14
- package/packages/types/package.json +1 -1
- package/ecomplus-stores/monocard/functions/ssr/src/components/DocDescription.astro +0 -30
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
},
|
|
18
18
|
"main": "index.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cloudcommerce/api": "^0.
|
|
21
|
-
"@cloudcommerce/firebase": "^0.
|
|
22
|
-
"@cloudcommerce/ssr": "^0.
|
|
20
|
+
"@cloudcommerce/api": "^0.27.0",
|
|
21
|
+
"@cloudcommerce/firebase": "^0.27.0",
|
|
22
|
+
"@cloudcommerce/ssr": "^0.27.0",
|
|
23
23
|
"@vueuse/motion": "2.0.0-beta.22"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@cloudcommerce/i18n": "^0.
|
|
27
|
-
"@cloudcommerce/storefront": "^0.
|
|
28
|
-
"@cloudcommerce/types": "^0.
|
|
26
|
+
"@cloudcommerce/i18n": "^0.27.0",
|
|
27
|
+
"@cloudcommerce/storefront": "^0.27.0",
|
|
28
|
+
"@cloudcommerce/types": "^0.27.0",
|
|
29
29
|
"@fontsource-variable/inter": "^5.0.8",
|
|
30
30
|
"@iconify-json/ri": "^1.1.8",
|
|
31
31
|
"@iconify-json/wpf": "^1.1.4",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section v-if="html" class="ui-section">
|
|
3
|
+
<details class="[&_i]:open:rotate-180" open>
|
|
4
|
+
<summary role="button" class="text-base-700 hover:text-base-800
|
|
5
|
+
[&>i]:hover:text-primary my-4 list-none text-2xl
|
|
6
|
+
font-medium lowercase md:my-5">
|
|
7
|
+
<i class="i-chevron-down mr-1"></i>
|
|
8
|
+
<span>{{ title || $t.i19description }}</span>
|
|
9
|
+
</summary>
|
|
10
|
+
<ContentClearfix :html="html" />
|
|
11
|
+
</details>
|
|
12
|
+
</section>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import type {
|
|
17
|
+
Products,
|
|
18
|
+
Categories,
|
|
19
|
+
Brands,
|
|
20
|
+
Collections,
|
|
21
|
+
} from '@cloudcommerce/api/types';
|
|
22
|
+
import ContentClearfix from '@@sf/components/ContentClearfix.vue';
|
|
23
|
+
|
|
24
|
+
export interface Props {
|
|
25
|
+
apiDoc?: Partial<Products | Categories | Brands | Collections>;
|
|
26
|
+
title?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
30
|
+
apiDoc: () => globalThis.$storefront.apiContext?.doc as Products,
|
|
31
|
+
});
|
|
32
|
+
const html = computed(() => props.apiDoc.body_html || props.apiDoc.body_text);
|
|
33
|
+
</script>
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
<div class="mt-5 flex gap-3 lg:gap-4
|
|
136
136
|
text-xl lg:text-2xl font-brand lowercase">
|
|
137
137
|
<a
|
|
138
|
-
:href="$settings.metafields?.
|
|
138
|
+
:href="$settings.metafields?.monocardSlug"
|
|
139
139
|
class="primary border-4 border-primary
|
|
140
140
|
hover:border-primary-bold active:primary-bold
|
|
141
141
|
rounded-full px-4 py-1.5 lg:px-7 lg:py-3"
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
Monte seu Monocard
|
|
144
144
|
</a>
|
|
145
145
|
<a
|
|
146
|
-
:href="$settings.metafields?.
|
|
146
|
+
:href="$settings.metafields?.businessLpUrl"
|
|
147
147
|
class="hidden sm:block
|
|
148
148
|
bg-transparent text-black border-4 border-primary
|
|
149
149
|
hover:bg-primary-100 hover:border-primary-bold active:primary-bold
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
</span>
|
|
226
226
|
</a>
|
|
227
227
|
<a
|
|
228
|
-
:href="$settings.metafields?.
|
|
228
|
+
:href="$settings.metafields?.businessLpUrl"
|
|
229
229
|
class="grow sm:grow-0
|
|
230
230
|
bg-transparent text-black border-4 border-primary
|
|
231
231
|
hover:bg-primary-100 hover:border-primary-bold active:primary-bold
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
<div class="flex flex-wrap md:flex-nowrap justify-end items-center
|
|
83
83
|
gap-4 text-2xl mx-auto md:mx-0 overflow-x-auto md:overflow-hidden">
|
|
84
84
|
<PaymentMethodFlag
|
|
85
|
-
v-for="paymentMethod in $settings.
|
|
85
|
+
v-for="paymentMethod in $settings.paymentMethods"
|
|
86
86
|
:key="paymentMethod"
|
|
87
87
|
:flag="paymentMethod"
|
|
88
88
|
class="!text-base-50"
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
<div class="mt-7 text-xs text-center md:text-left
|
|
93
93
|
md:flex justify-between gap-4">
|
|
94
94
|
<div class="mb-3 md:mb-0">
|
|
95
|
-
@ {{ new Date().getFullYear() }} {{ $settings.
|
|
95
|
+
@ {{ new Date().getFullYear() }} {{ $settings.corporateName }}
|
|
96
96
|
{{ $settings.address ? `/ ${$settings.address}` : '' }}
|
|
97
|
-
/ {{ $settings.
|
|
97
|
+
/ {{ $settings.docNumber }}
|
|
98
98
|
</div>
|
|
99
99
|
<ALink href="https://www.ecomplus.io/" class="italic text-[rgb(239,235,240)]">
|
|
100
100
|
powered by <b>E-Com Plus</b>
|
|
@@ -89,7 +89,6 @@ import {
|
|
|
89
89
|
watch,
|
|
90
90
|
onMounted,
|
|
91
91
|
defineAsyncComponent,
|
|
92
|
-
getCurrentInstance,
|
|
93
92
|
} from 'vue';
|
|
94
93
|
import { watchOnce } from '@vueuse/core';
|
|
95
94
|
import { totalItems } from '@@sf/state/shopping-cart';
|
|
@@ -134,18 +133,11 @@ onMounted(() => {
|
|
|
134
133
|
delayedTotalItems.value = newTotalItems;
|
|
135
134
|
}, { immediate: true });
|
|
136
135
|
});
|
|
137
|
-
const vm = getCurrentInstance();
|
|
138
|
-
const metafields = {
|
|
139
|
-
support_url: '',
|
|
140
|
-
business_lp_url: '',
|
|
141
|
-
monocard_slug: '',
|
|
142
|
-
monodot_slug: '',
|
|
143
|
-
...vm?.appContext.app.config.globalProperties.$settings.metafields,
|
|
144
|
-
};
|
|
145
136
|
const headerNavLinks = {
|
|
146
|
-
supportUrl:
|
|
147
|
-
businessLpUrl:
|
|
148
|
-
monocardSlug:
|
|
149
|
-
monodotSlug:
|
|
137
|
+
supportUrl: '',
|
|
138
|
+
businessLpUrl: '',
|
|
139
|
+
monocardSlug: '',
|
|
140
|
+
monodotSlug: '',
|
|
141
|
+
...globalThis.$storefront.settings.metafields
|
|
150
142
|
};
|
|
151
143
|
</script>
|
|
@@ -11,11 +11,11 @@ const layoutContent = await getContent('layout');
|
|
|
11
11
|
const {
|
|
12
12
|
footer: {
|
|
13
13
|
stamps,
|
|
14
|
-
|
|
14
|
+
pagesList,
|
|
15
15
|
},
|
|
16
16
|
} = layoutContent;
|
|
17
17
|
let pageLinks: ShopFooterProps['pageLinks'];
|
|
18
|
-
if (pagesList?.
|
|
18
|
+
if (pagesList?.isActive) {
|
|
19
19
|
if (pagesList.links?.length) {
|
|
20
20
|
pageLinks = pagesList.links;
|
|
21
21
|
} else {
|
|
@@ -30,7 +30,7 @@ const { settings } = routeContext;
|
|
|
30
30
|
basis-1/2 lg:basis-auto rounded-full px-4 py-2.5 xl:px-7 xl:py-4">
|
|
31
31
|
Compre agora
|
|
32
32
|
</a>
|
|
33
|
-
<a role="button" href={settings.metafields.
|
|
33
|
+
<a role="button" href={settings.metafields.businessLpUrl}
|
|
34
34
|
class="bg-primary/40 text-primary-900 lg:border-4 border-primary/20
|
|
35
35
|
hover:primary hover:border-primary-bold active:primary-bold
|
|
36
36
|
basis-1/2 lg:basis-auto rounded-full px-4 py-2.5 xl:px-7 xl:py-4">
|
|
@@ -3,7 +3,7 @@ import { usePageSections } from '@@sf/layouts/use-page-main';
|
|
|
3
3
|
import BannersGrid from '~/components/BannersGrid.astro';
|
|
4
4
|
import ProductShelf from '~/components/ProductShelf.vue';
|
|
5
5
|
import Breadcrumbs from '~/components/Breadcrumbs.astro';
|
|
6
|
-
import DocDescription from '~/components/DocDescription.
|
|
6
|
+
import DocDescription from '~/components/DocDescription.vue';
|
|
7
7
|
|
|
8
8
|
const { routeContext } = Astro.locals;
|
|
9
9
|
const { sections } = await usePageSections({
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cloudcommerce/events": "^0.
|
|
19
|
-
"@cloudcommerce/firebase": "^0.
|
|
20
|
-
"@cloudcommerce/modules": "^0.
|
|
18
|
+
"@cloudcommerce/events": "^0.27.0",
|
|
19
|
+
"@cloudcommerce/firebase": "^0.27.0",
|
|
20
|
+
"@cloudcommerce/modules": "^0.27.0"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"url": "https://github.com/ecomplus/cloud-commerce/issues"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@cloudcommerce/cli": "^0.
|
|
26
|
+
"@cloudcommerce/cli": "^0.27.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@cloudcommerce/eslint": "^0.
|
|
29
|
+
"@cloudcommerce/eslint": "^0.27.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcommerce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
|
|
6
6
|
"main": "packages/api/lib/index.js",
|
|
7
7
|
"author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"vite": "^4.4.9",
|
|
31
31
|
"vitest": "^0.34.6",
|
|
32
32
|
"zx": "^7.2.3",
|
|
33
|
-
"@cloudcommerce/eslint": "0.
|
|
33
|
+
"@cloudcommerce/eslint": "0.28.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"fix-install": "bash scripts/pre-install.sh && pnpm i",
|
|
@@ -20,7 +20,7 @@ const getStore = () => {
|
|
|
20
20
|
lang: settingsContent.lang,
|
|
21
21
|
domain: settingsContent.domain,
|
|
22
22
|
name: settingsContent.name,
|
|
23
|
-
corporate_name: settingsContent.
|
|
23
|
+
corporate_name: settingsContent.corporateName || settingsContent.name,
|
|
24
24
|
contact_email: settingsContent.email,
|
|
25
25
|
logo: {
|
|
26
26
|
url: `https://${settingsContent.domain}${settingsContent.logo}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/functios-lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,MAAM,sBAAsB,GAAG,CAC7B,OAAmB,EACnB,WAAmB,EACnB,eAAuC,EACvC,UAAkB,EAClB,EAAE;IACF,MAAM,cAAc,GAAW,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;IAElF,MAAM,IAAI,GAAG;QACX,iBAAiB,EAAE,IAAI;KACxB,CAAC;IACF,OAAO,GAAG,CAAC,KAAK,CAAC,UAAU,OAAO,IAAI,WAAW,IAAI,cAAc,EAAE,EAAE,IAAI,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IACrC,OAAO,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACvD,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;QAChC,OAAO,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AAC;IACzC,OAAO;QACL,IAAI,EAAE,eAAe,CAAC,IAAI;QAC1B,MAAM,EAAE,eAAe,CAAC,MAAM;QAC9B,IAAI,EAAE,eAAe,CAAC,IAAI;QAC1B,cAAc,EAAE,eAAe,CAAC,aAAa,IAAI,eAAe,CAAC,IAAI;QACrE,aAAa,EAAE,eAAe,CAAC,KAAK;QACpC,IAAI,EAAE;YACJ,GAAG,EAAE,WAAW,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE;SAChE;QACD,OAAO,EAAE,eAAe,CAAC,OAAO;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,QAAQ,GACT,CAAC"}
|
|
@@ -29,7 +29,7 @@ const getStore = () => {
|
|
|
29
29
|
lang: settingsContent.lang,
|
|
30
30
|
domain: settingsContent.domain,
|
|
31
31
|
name: settingsContent.name,
|
|
32
|
-
corporate_name: settingsContent.
|
|
32
|
+
corporate_name: settingsContent.corporateName || settingsContent.name,
|
|
33
33
|
contact_email: settingsContent.email,
|
|
34
34
|
logo: {
|
|
35
35
|
url: `https://${settingsContent.domain}${settingsContent.logo}`,
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import logger from 'firebase-functions/logger';
|
|
2
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
+
import api from '@cloudcommerce/api';
|
|
4
|
+
|
|
5
|
+
const addPoints = async () => {
|
|
6
|
+
const d = new Date();
|
|
7
|
+
// double checking paid orders after 5 days
|
|
8
|
+
d.setDate(d.getDate() - 5);
|
|
9
|
+
const db = getFirestore();
|
|
10
|
+
const snapshot = await db.collection('pointsToAdd')
|
|
11
|
+
.where('queuedAt', '<=', d)
|
|
12
|
+
.orderBy('queuedAt')
|
|
13
|
+
.get();
|
|
14
|
+
const { docs } = snapshot;
|
|
15
|
+
logger.info(`${docs.length} points to add`);
|
|
16
|
+
for (let i = 0; i < docs.length; i++) {
|
|
17
|
+
const { customerId, pointEntries } = docs[i].data();
|
|
18
|
+
const orderId = docs[i].ref.id;
|
|
19
|
+
let order;
|
|
20
|
+
try {
|
|
21
|
+
// eslint-disable-next-line no-await-in-loop
|
|
22
|
+
order = (await api.get(`orders/${orderId}`)).data;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
const status = error.response?.status;
|
|
25
|
+
if (status > 400 && status < 500) {
|
|
26
|
+
logger.warn(`failed reading order ${orderId}`, {
|
|
27
|
+
status,
|
|
28
|
+
response: error.response?.data,
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (order && Array.isArray(pointEntries) && pointEntries.length) {
|
|
35
|
+
const currentStatus = order.financial_status && order.financial_status.current;
|
|
36
|
+
if (currentStatus === 'paid') {
|
|
37
|
+
const tryAddPoints = (data) => {
|
|
38
|
+
logger.info(`POST ${JSON.stringify(data)} ${customerId}`);
|
|
39
|
+
return api.post(`customers/${customerId}/loyalty_points_entries`, data);
|
|
40
|
+
};
|
|
41
|
+
const pointsEndpoint = `/customers/${customerId}/loyalty_points_entries`;
|
|
42
|
+
for (let ii = 0; ii < pointEntries.length; ii++) {
|
|
43
|
+
const pointsEntry = pointEntries[ii];
|
|
44
|
+
try {
|
|
45
|
+
// eslint-disable-next-line no-await-in-loop
|
|
46
|
+
await tryAddPoints(pointsEntry);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
const status = err.response?.status;
|
|
49
|
+
if (status === 403) {
|
|
50
|
+
// delete older points entry and retry
|
|
51
|
+
const findUrl = `${pointsEndpoint}`
|
|
52
|
+
+ `?valid_thru<=${(new Date().toISOString())}&sort=active_points&limit=1`;
|
|
53
|
+
try {
|
|
54
|
+
// eslint-disable-next-line no-await-in-loop
|
|
55
|
+
await api.get(findUrl)
|
|
56
|
+
.then(({ data }) => {
|
|
57
|
+
const pointsList = data.result;
|
|
58
|
+
if (pointsList.length) {
|
|
59
|
+
const endpoint = `${pointsEndpoint}/${pointsList[0]._id}`;
|
|
60
|
+
return api.delete(endpoint)
|
|
61
|
+
.then(() => {
|
|
62
|
+
return tryAddPoints(pointsEntry);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.warn(`failed cleaning/adding points retry to ${orderId}`, {
|
|
69
|
+
customerId,
|
|
70
|
+
pointsEntry,
|
|
71
|
+
url: error.config?.url,
|
|
72
|
+
method: error.config?.method,
|
|
73
|
+
status: error.response?.status,
|
|
74
|
+
response: error.response?.data,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
} else if (status > 400 && status < 500) {
|
|
78
|
+
logger.warn(`failed adding points to ${orderId}`, {
|
|
79
|
+
customerId,
|
|
80
|
+
pointsEndpoint,
|
|
81
|
+
pointsEntry,
|
|
82
|
+
status,
|
|
83
|
+
response: err.response.data,
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// eslint-disable-next-line no-await-in-loop
|
|
93
|
+
await docs[i].ref.delete();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default addPoints;
|
|
98
|
+
// # sourceMappingURL=cron-add-points.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-add-points.js","sourceRoot":"","sources":["../../src/functions-lib/cron-add-points.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAGrC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;IACrB,2CAA2C;IAC3C,CAAC,CAAC,OAAO,CAAC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AAU,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;wCAC1D,OAAO,GAAG,CAAC,MAAM,CAAC,QAAoB,CAAC;6CACpC,IAAI,CAAC,GAAG,EAAE;4CACT,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;wCACnC,CAAC,CAAC,CAAC;qCACN;oCACD,OAAO,IAAI,CAAC;gCACd,CAAC,CAAC,CAAC;6BACN;4BAAC,OAAO,KAAU,EAAE;gCACnB,MAAM,CAAC,IAAI,CAAC,0CAA0C,OAAO,EAAE,EAAE;oCAC/D,UAAU;oCACV,WAAW;oCACX,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG;oCACtB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM;oCAC5B,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM;oCAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI;iCAC/B,CAAC,CAAC;6BACJ;yBACF;6BAAM,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE;4BACvC,MAAM,CAAC,IAAI,CAAC,2BAA2B,OAAO,EAAE,EAAE;gCAChD,UAAU;gCACV,cAAc;gCACd,WAAW;gCACX,MAAM;gCACN,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;6BAC5B,CAAC,CAAC;yBACJ;6BAAM;4BACL,MAAM,GAAG,CAAC;yBACX;qBACF;iBACF;aACF;SACF;QACD,4CAA4C;QAC5C,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;KAC5B;AACH,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import api from '@cloudcommerce/api';
|
|
2
|
-
import { getFirestore } from 'firebase-admin/firestore';
|
|
2
|
+
import { getFirestore, Timestamp } from 'firebase-admin/firestore';
|
|
3
3
|
import logger from 'firebase-functions/logger';
|
|
4
|
+
import ecomUtils from '@ecomplus/utils';
|
|
4
5
|
import getProgramId from './get-program-id.js';
|
|
5
6
|
|
|
6
7
|
const ECHO_SUCCESS = 'SUCCESS';
|
|
@@ -79,32 +80,67 @@ const handleLoyaltyPointsEvent = async (order, programRules) => {
|
|
|
79
80
|
if (pointsList) {
|
|
80
81
|
const hasEarnedPoints = haveEarnedPoints(pointsList, orderId);
|
|
81
82
|
if (isPaid && !hasEarnedPoints) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const docRef = getFirestore().doc(`pointsToAdd/${orderId}`);
|
|
84
|
+
const docSnapshot = await docRef.get();
|
|
85
|
+
if (!docSnapshot.exists) {
|
|
86
|
+
const pointEntries = [];
|
|
87
|
+
for (let i = 0; i < programRules.length; i++) {
|
|
88
|
+
const rule = programRules[i];
|
|
89
|
+
if (rule.earn_percentage === 0) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!rule.min_subtotal_to_earn
|
|
93
|
+
|| (amount?.subtotal && rule.min_subtotal_to_earn <= amount.subtotal)) {
|
|
94
|
+
let subtotal = amount.subtotal;
|
|
95
|
+
if (Array.isArray(rule.category_ids) && rule.category_ids.length) {
|
|
96
|
+
if (!order.items || !order.items.length) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// eslint-disable-next-line no-await-in-loop
|
|
100
|
+
const { data: { result } } = await api.get('search/v1', {
|
|
101
|
+
limit: order.items.length,
|
|
102
|
+
params: {
|
|
103
|
+
_id: order.items.map((item) => item.product_id),
|
|
104
|
+
'categories._id': rule.category_ids,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
// eslint-disable-next-line no-await-in-loop
|
|
108
|
+
order.items.forEach((item) => {
|
|
109
|
+
if (!result.find(({ _id }) => _id === item.product_id)) {
|
|
110
|
+
subtotal -= (ecomUtils.price(item) * item.quantity);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
86
114
|
const pointsValue = ((rule.earn_percentage || 1) / 100)
|
|
87
|
-
* (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
* (subtotal - (amount.discount || 0));
|
|
116
|
+
if (pointsValue > 0) {
|
|
117
|
+
let validThru;
|
|
118
|
+
if (rule.expiration_days > 0) {
|
|
119
|
+
const d = new Date();
|
|
120
|
+
d.setDate(d.getDate() + 2 + rule.expiration_days);
|
|
121
|
+
validThru = d.toISOString();
|
|
122
|
+
}
|
|
123
|
+
const data = {
|
|
124
|
+
name: rule.name,
|
|
125
|
+
program_id: getProgramId(rule, i),
|
|
126
|
+
earned_points: pointsValue,
|
|
127
|
+
active_points: pointsValue,
|
|
128
|
+
ratio: rule.ratio || 1,
|
|
129
|
+
order_id: orderId,
|
|
130
|
+
};
|
|
131
|
+
if (validThru) {
|
|
132
|
+
Object.assign(data, { valid_thru: validThru });
|
|
133
|
+
}
|
|
134
|
+
pointEntries.push(data);
|
|
93
135
|
}
|
|
94
|
-
const data = {
|
|
95
|
-
name: rule.name,
|
|
96
|
-
program_id: getProgramId(rule, i),
|
|
97
|
-
earned_points: pointsValue,
|
|
98
|
-
active_points: pointsValue,
|
|
99
|
-
ratio: rule.ratio || 1,
|
|
100
|
-
valid_thru: validThru,
|
|
101
|
-
order_id: orderId,
|
|
102
|
-
}; // TODO: set the correct type
|
|
103
|
-
// eslint-disable-next-line no-await-in-loop
|
|
104
|
-
await api.post(`customers/${customerId}/loyalty_points_entries`, data);
|
|
105
|
-
return responsePubSub(ECHO_SUCCESS);
|
|
106
136
|
}
|
|
107
137
|
}
|
|
138
|
+
await docRef.set({
|
|
139
|
+
customerId,
|
|
140
|
+
pointEntries,
|
|
141
|
+
queuedAt: Timestamp.now(),
|
|
142
|
+
});
|
|
143
|
+
return responsePubSub(ECHO_SUCCESS);
|
|
108
144
|
}
|
|
109
145
|
}
|
|
110
146
|
if (isCancelled && hasEarnedPoints) {
|