Numéro de carte plus court (MEP + 8 caractères), affiché sur les cartes Apple Wallet et Google Wallet ; compte de démonstration App Review (SQL) ; correction de la saisie manuelle (le « S » était supprimé)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
43f63de9a3
commit
6506055ae3
6 changed files with 77 additions and 11 deletions
|
|
@ -0,0 +1,56 @@
|
||||||
|
-- Compte de démonstration pour App Review (Apple) — à exécuter UNE fois dans phpMyAdmin
|
||||||
|
-- sur la base monespacepro. Magasin « Café Démo » actif d'emblée, formule Pro, sans Stripe,
|
||||||
|
-- abonnement valable 3 mois (aucune tâche ne le coupe automatiquement à l'échéance : voir la note en bas).
|
||||||
|
-- Connexion app : demo.apple@gmail.com (mot de passe = celui du hachage argon2 ci-dessous).
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SET @store := 'demoapplestore000000001';
|
||||||
|
SET @design := 'demoapplecard0000000001';
|
||||||
|
SET @cust := 'demoapplecust0000000001';
|
||||||
|
SET @now := UTC_TIMESTAMP(3);
|
||||||
|
|
||||||
|
INSERT INTO `Store`
|
||||||
|
(`id`, `slug`, `name`, `addressLine`, `postalCode`, `city`, `siret`, `contactName`, `contactEmail`, `contactPhone`,
|
||||||
|
`status`, `billingSuspended`, `maxAmountCents`, `minScanIntervalSec`, `createdAt`, `updatedAt`)
|
||||||
|
VALUES
|
||||||
|
(@store, 'cafe-demo-a9k2', 'Café Démo', '1 rue de la Démo', '35000', 'Rennes', '35600000000048', 'Tony Averty',
|
||||||
|
'demo.apple@gmail.com', '0612345678', 'ACTIVE', false, 50000, 300, @now, @now);
|
||||||
|
|
||||||
|
INSERT INTO `Subscription`
|
||||||
|
(`id`, `storeId`, `status`, `plan`, `interval`, `legacyPrice`, `cancelAtPeriodEnd`, `currentPeriodEnd`, `updatedAt`)
|
||||||
|
VALUES
|
||||||
|
('demoapplesub00000000001', @store, 'ACTIVE', 'PRO', 'MONTH', false, false, DATE_ADD(@now, INTERVAL 3 MONTH), @now);
|
||||||
|
|
||||||
|
INSERT INTO `CardDesign`
|
||||||
|
(`id`, `storeId`, `programName`, `backgroundColor`, `foregroundColor`, `labelColor`, `pointsMode`, `pointsPerEuro`, `updatedAt`)
|
||||||
|
VALUES
|
||||||
|
(@design, @store, 'Carte Café Démo', '#0E7A66', '#FFFFFF', '#D1D5DB', 'STAMP', 1.00, @now);
|
||||||
|
|
||||||
|
INSERT INTO `Reward` (`id`, `cardDesignId`, `label`, `cost`, `active`)
|
||||||
|
VALUES ('demoapplerew0000000001', @design, 'Un café offert', 10, true);
|
||||||
|
|
||||||
|
INSERT INTO `StaffUser`
|
||||||
|
(`id`, `storeId`, `email`, `displayName`, `passwordHash`, `role`, `active`, `tokenVersion`, `createdAt`)
|
||||||
|
VALUES
|
||||||
|
('demoapplestaff00000001', @store, 'demo.apple@gmail.com', 'Tony Averty',
|
||||||
|
'$argon2id$v=19$m=65536,t=3,p=4$1ooFWhMtIbYvzipnM++uMw$4gTPLEz9tCb8Qt+GWPGg3Bj9vnEGLstX5drwgrrnqRA',
|
||||||
|
'MANAGER', true, 0, @now);
|
||||||
|
|
||||||
|
-- Client de démonstration (à chercher par son prénom « Camille » ou par le numéro de carte ci-dessous)
|
||||||
|
INSERT INTO `Customer` (`id`, `firstName`, `email`, `consentAt`, `createdAt`)
|
||||||
|
VALUES (@cust, 'Camille', 'camille.demo@example.com', @now, @now);
|
||||||
|
|
||||||
|
INSERT INTO `LoyaltyCard`
|
||||||
|
(`id`, `storeId`, `customerId`, `serial`, `authToken`, `accessKey`, `balance`, `passUpdatedAt`, `createdAt`, `updatedAt`)
|
||||||
|
VALUES
|
||||||
|
('demoapplecardc00000001', @store, @cust, 'MEPK7M2QX9R',
|
||||||
|
REPLACE(UUID(), '-', ''), CONCAT(REPLACE(UUID(), '-', ''), REPLACE(UUID(), '-', '')), 0, @now, @now, @now);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
-- Numéro de carte à reporter dans les remarques de vérification Apple : MEP K7M2 QX9R
|
||||||
|
-- (le contenu du QR est le numéro de série « MEPK7M2QX9R »).
|
||||||
|
--
|
||||||
|
-- À l'échéance des 3 mois, couper le compte à la main :
|
||||||
|
-- UPDATE `Store` SET `status` = 'CLOSED' WHERE `id` = 'demoapplestore000000001';
|
||||||
|
|
@ -13,11 +13,19 @@ import { referralLink, referralOffered } from '../wallet/wallet.types';
|
||||||
/** Alphabet sans caractères ambigus : le numéro peut être lu à voix haute au comptoir. */
|
/** Alphabet sans caractères ambigus : le numéro peut être lu à voix haute au comptoir. */
|
||||||
const SERIAL_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
const SERIAL_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
||||||
|
|
||||||
|
/** Numéro court (« MEP » + 8 caractères) : il n'a de sens que dans le magasin qui scanne la carte. */
|
||||||
function randomSerial() {
|
function randomSerial() {
|
||||||
const bytes = randomBytes(16);
|
const bytes = randomBytes(8);
|
||||||
return 'MEP' + [...bytes].map((b) => SERIAL_ALPHABET[b % SERIAL_ALPHABET.length]).join('');
|
return 'MEP' + [...bytes].map((b) => SERIAL_ALPHABET[b % SERIAL_ALPHABET.length]).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function uniqueSerial(prisma: PrismaService) {
|
||||||
|
for (;;) {
|
||||||
|
const serial = randomSerial();
|
||||||
|
if (!(await prisma.loyaltyCard.findUnique({ where: { serial }, select: { id: true } }))) return serial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const token = () => randomBytes(24).toString('base64url');
|
const token = () => randomBytes(24).toString('base64url');
|
||||||
|
|
||||||
/** « tony.prive@gmail.com » → « t•••@g•••.com » */
|
/** « tony.prive@gmail.com » → « t•••@g•••.com » */
|
||||||
|
|
@ -67,7 +75,7 @@ export class EnrollmentService {
|
||||||
const card = await this.prisma.loyaltyCard.create({
|
const card = await this.prisma.loyaltyCard.create({
|
||||||
data: {
|
data: {
|
||||||
...(referrer && { referredBy: { connect: { id: referrer.id } } }),
|
...(referrer && { referredBy: { connect: { id: referrer.id } } }),
|
||||||
serial: randomSerial(),
|
serial: await uniqueSerial(this.prisma),
|
||||||
authToken: token(),
|
authToken: token(),
|
||||||
accessKey: token(),
|
accessKey: token(),
|
||||||
store: { connect: { id: store.id } },
|
store: { connect: { id: store.id } },
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,10 @@ export class ApplePassService {
|
||||||
],
|
],
|
||||||
// Face avant : la prochaine récompense. Pas de message de notification ici : quand deux champs
|
// Face avant : la prochaine récompense. Pas de message de notification ici : quand deux champs
|
||||||
// à message changent ensemble (solde + récompense), l'iPhone affiche « Carte de fidélité modifiée ».
|
// à message changent ensemble (solde + récompense), l'iPhone affiche « Carte de fidélité modifiée ».
|
||||||
...(nextReward && {
|
auxiliaryFields: [
|
||||||
auxiliaryFields: [{ key: 'next-reward', label: 'PROCHAINE RÉCOMPENSE', value: nextReward }],
|
...(nextReward ? [{ key: 'next-reward', label: 'PROCHAINE RÉCOMPENSE', value: nextReward }] : []),
|
||||||
}),
|
{ key: 'number', label: 'N° DE CARTE', value: readableSerial(card.serial), textAlignment: 'PKTextAlignmentRight' },
|
||||||
|
],
|
||||||
backFields: [
|
backFields: [
|
||||||
// Toujours présent : quand sa valeur change (nouvelle campagne), l'iPhone affiche le message sur l'écran verrouillé.
|
// Toujours présent : quand sa valeur change (nouvelle campagne), l'iPhone affiche le message sur l'écran verrouillé.
|
||||||
{ key: 'news', label: newsLabels(card.store).label, value: newsText(card) ?? newsLabels(card.store).empty, changeMessage: '%@' },
|
{ key: 'news', label: newsLabels(card.store).label, value: newsText(card) ?? newsLabels(card.store).empty, changeMessage: '%@' },
|
||||||
|
|
|
||||||
|
|
@ -131,12 +131,13 @@ export class GoogleWalletService {
|
||||||
id: this.objectId(card.serial),
|
id: this.objectId(card.serial),
|
||||||
classId: this.classId(card.storeId),
|
classId: this.classId(card.storeId),
|
||||||
state: 'ACTIVE',
|
state: 'ACTIVE',
|
||||||
accountId: card.serial,
|
accountId: readableSerial(card.serial),
|
||||||
accountName: card.customer.firstName,
|
accountName: card.customer.firstName,
|
||||||
loyaltyPoints: { label: unitLabel(card), balance: { int: card.balance } },
|
loyaltyPoints: { label: unitLabel(card), balance: { int: card.balance } },
|
||||||
barcode: { type: 'QR_CODE', value: card.serial, alternateText: readableSerial(card.serial) },
|
barcode: { type: 'QR_CODE', value: card.serial, alternateText: readableSerial(card.serial) },
|
||||||
textModulesData: [
|
textModulesData: [
|
||||||
...(next ? [{ id: 'next_reward', header: 'Prochaine récompense', body: next }] : []),
|
...(next ? [{ id: 'next_reward', header: 'Prochaine récompense', body: next }] : []),
|
||||||
|
{ id: 'card_number', header: 'Numéro de carte', body: readableSerial(card.serial) },
|
||||||
{ id: 'rewards', header: 'Toutes les récompenses', body: rewardsText(card) },
|
{ id: 'rewards', header: 'Toutes les récompenses', body: rewardsText(card) },
|
||||||
],
|
],
|
||||||
linksModuleData: {
|
linksModuleData: {
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ export function referralLink(webUrl: string, card: CardWithContext) {
|
||||||
return card.referralCode ? `${webUrl}/c/${card.store.slug}?parrain=${card.referralCode}` : null;
|
return card.referralCode ? `${webUrl}/c/${card.store.slug}?parrain=${card.referralCode}` : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Numéro de carte lisible sous le QR (« MEP ABCD EFGH JKLM NPQR ») : saisie manuelle au comptoir si le scan échoue. */
|
/** Numéro de carte lisible (« MEP ABCD EFGH ») : saisie manuelle au comptoir si le scan échoue. Les anciennes cartes ont 16 caractères. */
|
||||||
export function readableSerial(serial: string) {
|
export function readableSerial(serial: string) {
|
||||||
return serial.replace(/^(MEP)(.{4})(.{4})(.{4})(.{4})$/, '$1 $2 $3 $4 $5');
|
return serial.replace(/^(MEP)((?:.{4})+)$/, (_, p: string, rest: string) => `${p} ${rest.match(/.{4}/g)!.join(' ')}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ import { font, useColors } from '../src/theme';
|
||||||
import { Icon } from '../src/icons';
|
import { Icon } from '../src/icons';
|
||||||
|
|
||||||
/** Les numéros de carte commencent par « MEP » (voir le back-end). */
|
/** Les numéros de carte commencent par « MEP » (voir le back-end). */
|
||||||
const SERIAL = /^MEP[A-Z2-9]{16}$/;
|
const SERIAL = /^MEP(?:[A-Z2-9]{8}|[A-Z2-9]{16})$/;
|
||||||
const FRAME = 260;
|
const FRAME = 260;
|
||||||
const DIM = 'rgba(0,0,0,0.55)';
|
const DIM = 'rgba(0,0,0,0.55)';
|
||||||
/** Saisie manuelle : espaces et tirets ignorés (« MEP ABCD EFGH… » est affiché sous le QR de la carte). */
|
/** Saisie manuelle : espaces et tirets ignorés (« MEP ABCD EFGH… » est affiché sous le QR de la carte). */
|
||||||
const normalize = (v: string) => v.toUpperCase().replace(/[s-]/g, '');
|
const normalize = (v: string) => v.toUpperCase().replace(/[\s-]/g, '');
|
||||||
|
|
||||||
/** Résultat de la recherche d'un client (e-mail masqué par le serveur). */
|
/** Résultat de la recherche d'un client (e-mail masqué par le serveur). */
|
||||||
interface Found {
|
interface Found {
|
||||||
|
|
@ -101,7 +101,7 @@ export default function Scan() {
|
||||||
style={{ borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, fontSize: 17, color: c.text, backgroundColor: c.bg, fontFamily: font.semibold }}
|
style={{ borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, fontSize: 17, color: c.text, backgroundColor: c.bg, fontFamily: font.semibold }}
|
||||||
/>
|
/>
|
||||||
{typedOk && <Button large label="Ouvrir la carte" onPress={() => openCard(normalize(typed))} />}
|
{typedOk && <Button large label="Ouvrir la carte" onPress={() => openCard(normalize(typed))} />}
|
||||||
{!typedOk && /^MEP/i.test(term) && <T style={{ color: c.text3, fontSize: 13 }}>{normalize(typed).length} / 19 caractères</T>}
|
{!typedOk && /^MEP/i.test(term) && <T style={{ color: c.text3, fontSize: 13 }}>{normalize(typed).length} / 11 caractères</T>}
|
||||||
{isSearch && (
|
{isSearch && (
|
||||||
<ScrollView style={{ maxHeight: 320 }} keyboardShouldPersistTaps="handled">
|
<ScrollView style={{ maxHeight: 320 }} keyboardShouldPersistTaps="handled">
|
||||||
{searching && !found && <ActivityIndicator style={{ marginVertical: 12 }} />}
|
{searching && !found && <ActivityIndicator style={{ marginVertical: 12 }} />}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue