rapida-partner 8.12.0 → 8.14.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/package.json +1 -1
- package/src/interfaces/project-backend.interface.ts +4 -0
- package/src/interfaces/store-cross-sell.interface.ts +21 -0
- package/src/interfaces/store-loyalty.interface.ts +34 -0
- package/src/interfaces/store-order.interface.ts +4 -0
- package/src/interfaces/store-settings.interface.ts +3 -1
- package/src/schemas/backend.ref.json +2 -0
- package/src/schemas/project-store.ref.json +1 -1
- package/src/schemas/store-settings.ref.json +2 -0
- package/src/utils/store-cross-sell.ts +2 -0
- package/src/utils/store-loyalty.ts +2 -0
- package/src/utils/store-references.test.ts +22 -0
- package/src/utils/store-references.ts +2 -0
package/package.json
CHANGED
|
@@ -121,6 +121,10 @@ interface IMarketplace {
|
|
|
121
121
|
// Coleções da home (módulo de rapida-projects getStoreCollectionsModule,
|
|
122
122
|
// funcionalidade "collections"): o cadastro IStoreCollection.
|
|
123
123
|
collectionsEndpoint?: string;
|
|
124
|
+
// Fidelidade (módulo de rapida-projects getStoreLoyaltyModule, funcionalidade
|
|
125
|
+
// "loyalty"): níveis (IStoreLoyaltyTier) e vantagens (IStoreLoyaltyBenefit).
|
|
126
|
+
loyaltyTiersEndpoint?: string;
|
|
127
|
+
loyaltyBenefitsEndpoint?: string;
|
|
124
128
|
}
|
|
125
129
|
|
|
126
130
|
export interface IMarketplaceProductFieldMap {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Oferta ao adicionar (funcionalidade "crossSell"): outro produto com preço
|
|
3
|
+
* especial levando este, como "Batata frita por R$ 5,00 levando este lanche".
|
|
4
|
+
* Fica no campo crossSellOffers da configuração de venda do produto de origem
|
|
5
|
+
* (form productSellingSettingForm de rapida-projects, que recebe a lista por
|
|
6
|
+
* withCrossSellInSellingSettings). Ao adicionar o produto de origem, a loja
|
|
7
|
+
* mostra as ofertas; a oferta aceita é outra linha do carrinho.
|
|
8
|
+
*
|
|
9
|
+
* O servidor só aplica offerPrice até a quantidade do produto de origem no
|
|
10
|
+
* mesmo pedido; o que passar sai pelo preço normal. O produto ofertado é
|
|
11
|
+
* simples (sem variações nem adicionais); com variação, aponte o filho.
|
|
12
|
+
*/
|
|
13
|
+
export interface IProductCrossSellOffer {
|
|
14
|
+
offerProductId: string;
|
|
15
|
+
// Preço especial por unidade; só vale se for menor que o preço normal.
|
|
16
|
+
offerPrice: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IProductCrossSellLinks {
|
|
20
|
+
crossSellOffers?: IProductCrossSellOffer[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TStoreWeekday } from "./store-settings.interface";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Nível de fidelidade da loja (funcionalidade "loyalty"), o mesmo cadastro do
|
|
5
|
+
* loyaltyTier do rapida-projects: na loja, minVisits conta os pedidos pagos do
|
|
6
|
+
* cliente nos últimos periodDays dias. O nível do cliente é o de maior
|
|
7
|
+
* minVisits que ele atinge; não é gravado, é calculado a cada consulta.
|
|
8
|
+
* Lido pela loja por IMarketplace.loyaltyTiersEndpoint.
|
|
9
|
+
*/
|
|
10
|
+
export interface IStoreLoyaltyTier {
|
|
11
|
+
name: string;
|
|
12
|
+
minVisits: number;
|
|
13
|
+
periodDays: number;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Vantagem de um nível (o mesmo cadastro do loyaltyBenefit): na loja, vira um
|
|
19
|
+
* desconto automático em % no fechamento, calculado no servidor. Fidelidade e
|
|
20
|
+
* cupom não somam: vale o maior. Sem loyaltyTierIds, vale para qualquer nível
|
|
21
|
+
* atingido. Lida pela loja por IMarketplace.loyaltyBenefitsEndpoint.
|
|
22
|
+
*/
|
|
23
|
+
export interface IStoreLoyaltyBenefit {
|
|
24
|
+
name: string;
|
|
25
|
+
discountPercentage?: number;
|
|
26
|
+
isActive: boolean;
|
|
27
|
+
loyaltyTierIds?: string[];
|
|
28
|
+
// Sem dias, vale todos os dias (no fuso STORE_LOYALTY_TIME_ZONE).
|
|
29
|
+
weekDays?: TStoreWeekday[];
|
|
30
|
+
// A loja não conhece o aniversário do cliente: vantagem só no mês de aniversário não vale na loja.
|
|
31
|
+
isBirthdayMonthOnly?: boolean;
|
|
32
|
+
validFrom?: string;
|
|
33
|
+
validUntil?: string;
|
|
34
|
+
}
|
|
@@ -101,6 +101,10 @@ export interface IStoreOrder {
|
|
|
101
101
|
// Telefone do cliente, só dígitos com DDD (Fase 8.1), para o WhatsApp do pedido.
|
|
102
102
|
customerPhone?: string;
|
|
103
103
|
items: IStoreOrderItem[];
|
|
104
|
+
// Fidelidade (funcionalidade "loyalty", Fase 7.3): nível do cliente no
|
|
105
|
+
// fechamento e o desconto que ele deu (já somado em discount).
|
|
106
|
+
loyaltyTierName?: string;
|
|
107
|
+
loyaltyDiscount?: number;
|
|
104
108
|
// Endereço de entrega, em campos próprios (os forms não aninham objetos).
|
|
105
109
|
addressZipCode?: string;
|
|
106
110
|
addressStreet?: string;
|
|
@@ -162,6 +162,8 @@
|
|
|
162
162
|
"optionsEndpoint": { "type": "string" },
|
|
163
163
|
"badgesEndpoint": { "type": "string" },
|
|
164
164
|
"collectionsEndpoint": { "type": "string" },
|
|
165
|
+
"loyaltyTiersEndpoint": { "type": "string" },
|
|
166
|
+
"loyaltyBenefitsEndpoint": { "type": "string" },
|
|
165
167
|
"productFieldMap": {
|
|
166
168
|
"type": "object",
|
|
167
169
|
"properties": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "array",
|
|
12
12
|
"items": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping", "coupons", "reviews", "returns", "openingHours", "pickup", "districtDelivery", "payOnDelivery", "itemNotes", "productOptions", "productVariants", "stockReservation", "attendees", "tickets", "productBadges", "couponShowcase", "collections"]
|
|
14
|
+
"enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping", "coupons", "reviews", "returns", "openingHours", "pickup", "districtDelivery", "payOnDelivery", "itemNotes", "productOptions", "productVariants", "stockReservation", "attendees", "tickets", "productBadges", "couponShowcase", "collections", "crossSell", "loyalty"]
|
|
15
15
|
},
|
|
16
16
|
"uniqueItems": true
|
|
17
17
|
},
|
|
@@ -138,6 +138,8 @@
|
|
|
138
138
|
"productBadgesEnabled": { "type": "boolean" },
|
|
139
139
|
"couponShowcaseEnabled": { "type": "boolean" },
|
|
140
140
|
"collectionsEnabled": { "type": "boolean" },
|
|
141
|
+
"crossSellEnabled": { "type": "boolean" },
|
|
142
|
+
"loyaltyEnabled": { "type": "boolean" },
|
|
141
143
|
"returnsEnabled": { "type": "boolean" }
|
|
142
144
|
},
|
|
143
145
|
"additionalProperties": false
|
|
@@ -79,3 +79,25 @@ describe("coleções da home", () => {
|
|
|
79
79
|
]);
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
describe("oferta ao adicionar", () => {
|
|
84
|
+
test("crossSell sem productSellingSettingsEndpoint avisa", () => {
|
|
85
|
+
const store = (marketplace: Record<string, string>): IProject =>
|
|
86
|
+
({ id: "p", title: "p", skeleton: "ecommerce", store: { segment: "food", features: ["crossSell"] }, backend: [{ marketplace }] }) as unknown as IProject;
|
|
87
|
+
expect(checkStoreReferences(store({ productSellingSettingsEndpoint: "/product-selling-settings" }))).toEqual([]);
|
|
88
|
+
expect(checkStoreReferences(store({}))).toEqual([
|
|
89
|
+
"store.features \"crossSell\" precisa de backend.marketplace.productSellingSettingsEndpoint; sem ele a funcionalidade não é gerada",
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("fidelidade", () => {
|
|
95
|
+
test("loyalty sem os dois endereços avisa", () => {
|
|
96
|
+
const store = (marketplace: Record<string, string>): IProject =>
|
|
97
|
+
({ id: "p", title: "p", skeleton: "ecommerce", store: { features: ["loyalty"] }, backend: [{ marketplace }] }) as unknown as IProject;
|
|
98
|
+
expect(checkStoreReferences(store({ loyaltyTiersEndpoint: "/loyalty-tiers", loyaltyBenefitsEndpoint: "/loyalty-benefits" }))).toEqual([]);
|
|
99
|
+
expect(checkStoreReferences(store({ loyaltyTiersEndpoint: "/loyalty-tiers" }))).toEqual([
|
|
100
|
+
"store.features \"loyalty\" precisa de backend.marketplace.loyaltyTiersEndpoint e backend.marketplace.loyaltyBenefitsEndpoint; sem eles a funcionalidade não é gerada",
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -15,6 +15,8 @@ const FEATURE_ENDPOINTS: Partial<Record<TStoreFeature, TMarketplaceEndpoint[]>>
|
|
|
15
15
|
productBadges: ["badgesEndpoint", "productSellingSettingsEndpoint"],
|
|
16
16
|
couponShowcase: ["couponsEndpoint"],
|
|
17
17
|
collections: ["collectionsEndpoint"],
|
|
18
|
+
crossSell: ["productSellingSettingsEndpoint"],
|
|
19
|
+
loyalty: ["loyaltyTiersEndpoint", "loyaltyBenefitsEndpoint"],
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
/** Funcionalidades que só existem junto com outra. */
|