SavWorkflowService
in package
Table of Contents
Properties
- $chatbotUserId : mixed
- $container : mixed
- $logger : mixed
- $planningService : mixed
- $refundService : mixed
- $saleSavService : mixed
- $saleService : mixed
- $shippingService : mixed
- $slugMapping : mixed
- $userService : mixed
Methods
- __construct() : mixed
- calculateFinalFinalActionForType() : float|null
- Calculate final_final_action amount based on typePb, notation, final_action, and refundable amount
- createStandardSav() : array<string|int, mixed>
- Crée un SAV standard. Les propositions sont optionnelles.
- executeCancellation() : array<string|int, mixed>
- Exécute l'annulation d'une commande ou de produits spécifiques Cette méthode effectue uniquement l'annulation, sans calculer les montants
- executeCancellationWithSav() : array<string|int, mixed>
- Gère l'annulation complète avec création SAV et pré-remboursement Scénario : Annulation avant expédition
- getProductPrice() : array<string|int, mixed>
- Calcule le prix final d'un produit (Prix produit + Livraison) selon la logique Menzzo.
- buildSavObservation() : string
- Construit l'observation client pour le SAV
- calculateRefundableAmount() : float
- Calculate refundable amount (grand_total - existing refunds)
- calculateRefundableAmountForProducts() : float
- Calculate refundable amount for specific sale products (excluding shipping) Uses getRefundedAmountForProduct() to get per-product refunds with proper distribution
- configureSavPropositions() : void
- Configure deux propositions pour un SAV créé par le chatbot Proposition 1: Bon d'achat 115% + Chatbot IA + Refusé (0) Proposition 2: Remboursement intégral/partiel + Chatbot IA + Accepté (1)
- configureSavPropositionsForGiftCard() : void
- Configure une seule proposition pour un SAV créé avec bon d'achat 115% Proposition: Bon d'achat 115% + Chatbot IA + Accepté (1)
- createSavForCancellation() : mixed
- Crée un SAV pour l'annulation avec deux propositions configurées Proposition 1: Bon d'achat 115% (refusé par défaut) + Communication Chatbot IA Proposition 2: Remboursement totale/partiel + Communication Chatbot IA + Accepté (1)
- createSavForGiftCard() : mixed
- Crée un SAV pour l'annulation avec bon d'achat 115% Une seule proposition: Bon d'achat 115% + Chatbot IA + Accepté (1)
- executeFullSaleCancellation() : array<string|int, mixed>
- Exécute l'annulation complète de la commande
- executeProductsCancellation() : array<string|int, mixed>
- Exécute l'annulation de produits spécifiques
- extractDefectFields() : array<string|int, mixed>
- Extract and validate defect fields from payload
- generatePropositionId() : string
- Génère un ID unique pour une proposition
- getExistingPreRefundAmount() : float
- Calcule le montant total des pré-remboursements existants pour une commande
- getRefundedAmountForProduct() : float
- Get refunded amount for a specific SaleProduct Distributes refunds proportionally when a SaleSav has multiple products
- handleProductsCancellationWithGiftCard() : array<string|int, mixed>
- Gère l'annulation de produits spécifiques avec création SAV et bon d'achat 115%
- handleProductsCancellationWithSav() : array<string|int, mixed>
- Gère l'annulation de produits spécifiques avec création SAV
- handleSaleCancellationWithGiftCard() : array<string|int, mixed>
- Gère l'annulation d'une commande complète avec création SAV et bon d'achat 115%
- handleSaleCancellationWithSav() : array<string|int, mixed>
- Gère l'annulation d'une commande complète avec création SAV
Properties
$chatbotUserId
private
mixed
$chatbotUserId
$container
private
mixed
$container
$logger
private
mixed
$logger
$planningService
private
mixed
$planningService
$refundService
private
mixed
$refundService
$saleSavService
private
mixed
$saleSavService
$saleService
private
mixed
$saleService
$shippingService
private
mixed
$shippingService
$slugMapping
private
mixed
$slugMapping
= ['geste-co-5-percent' => 'geste co 5%', 'geste-co-10-percent' => 'geste co 10%', 'geste-co-15-percent' => 'geste co 15%', 'geste-co-20-percent' => 'geste co 20%', 'geste-co-25-percent' => 'geste co 25%', 'geste-co-30-percent' => 'geste co 30%', 'geste-co-35-percent' => 'geste co 35%', 'geste-co-40-percent' => 'geste co 40%', 'geste-co-45-percent' => 'geste co 45%', 'geste-co-50-percent' => 'geste co 50%', 'geste-co-55-percent' => 'geste co 55%', 'geste-co-60-percent' => 'geste co 60%', 'geste-co-65-percent' => 'geste co 65%', 'geste-co-70-percent' => 'geste co 70%', 'geste-co-75-percent' => 'geste co 75%', 'geste-co-80-percent' => 'geste co 80%', 'remboursement-integral' => 'remboursement intégral', 'remboursement-partiel' => 'remboursement partiel', 'remboursement-hors-frais-de-port' => 'remboursement hors frais de port', 'remboursement-des-fdp' => 'remboursement des fdp ', 'piece-detachee' => 'piece detachée', 're-expedition' => 're-expédition', 'bon-d-achat' => 'bon d achat', 'bon-d-achat-5-percent' => 'bon d achat 5%', 'bon-d-achat-10-percent' => 'bon d achat 10% ', 'bon-d-achat-15-percent' => 'bon d achat 15%', 'bon-d-achat-20-percent' => 'bon d achat 20%', 'bon-d-achat-25-percent' => 'bon d achat 25%', 'bon-d-achat-30-percent' => 'bon d achat 30%', 'bon-d-achat-35-percent' => 'bon d achat 35%', 'bon-d-achat-40-percent' => 'bon d achat 40%', 'bon-d-achat-45-percent' => 'bon d achat 45%', 'bon-d-achat-50-percent' => 'bon d achat 50%', 'bon-d-achat-55-percent' => 'bon d achat 55%', 'bon-d-achat-60-percent' => 'bon d achat 60% ', 'bon-d-achat-65-percent' => 'bon d achat 65%', 'bon-d-achat-70-percent' => 'bon d achat 70%', 'bon-d-achat-75-percent' => 'bon d achat 75%', 'bon-d-achat-80-percent' => 'bon d achat 80%']
$userService
private
mixed
$userService
Methods
__construct()
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
calculateFinalFinalActionForType()
Calculate final_final_action amount based on typePb, notation, final_action, and refundable amount
public
calculateFinalFinalActionForType(string $typePb, int|null $notation, string|null $finalAction, float $refundableAmount) : float|null
Supported types:
- défaut fabrication: percentage based on notation (1-5) and action type
- Notation 1: 30% (bon d'achat) or 25% (remboursement)
- Notation 2-3: 25% (bon d'achat) or 15% (remboursement)
- Notation 4-5: 20% (bon d'achat) or 10% (remboursement)
- erreur produit logidav: fixed percentages
- 30% bon d'achat
- 20% remboursement (Remboursement partiel, Geste co)
Applicable final_action: Bon d'achat, Geste co, Remboursement partiel
Parameters
- $typePb : string
-
The type of problem (défaut fabrication, erreur produit logidav)
- $notation : int|null
-
Severity rating (1-5) - only used for défaut fabrication
- $finalAction : string|null
-
The final action (Bon d'achat, Geste co, Remboursement partiel)
- $refundableAmount : float
-
The refundable amount (grand_total - existing_refunds)
Return values
float|null —The calculated amount to store in final_final_action
createStandardSav()
Crée un SAV standard. Les propositions sont optionnelles.
public
createStandardSav(mixed $sale, array<string|int, mixed> $saleProductIds, string $typePb, string $clientObservation, string|null $tag, array<string|int, mixed> $propositionsApi[, array<string|int, mixed> $payload = null ]) : array<string|int, mixed>
Si fournies : gestion des doublons et validation stricte (exactement 1 acceptée).
Parameters
- $sale : mixed
-
L'entité Sale
- $saleProductIds : array<string|int, mixed>
-
Les IDs des produits
- $typePb : string
-
Le type de problème
- $clientObservation : string
-
L'observation client
- $tag : string|null
-
Le tag
- $propositionsApi : array<string|int, mixed>
-
Tableau des propositions [{"value": "geste-co-5-percent", "accepted": true}, ...]
- $payload : array<string|int, mixed> = null
-
The full API payload for manufacturing defect processing (optional)
Return values
array<string|int, mixed> —Résultat de l'opération
executeCancellation()
Exécute l'annulation d'une commande ou de produits spécifiques Cette méthode effectue uniquement l'annulation, sans calculer les montants
public
executeCancellation(mixed $sale[, array<string|int, mixed> $saleProductIds = [] ]) : array<string|int, mixed>
Parameters
- $sale : mixed
-
L'entité Sale
- $saleProductIds : array<string|int, mixed> = []
-
Les IDs des produits à annuler (vide pour annulation globale)
Return values
array<string|int, mixed> —Résultat de l'annulation
executeCancellationWithSav()
Gère l'annulation complète avec création SAV et pré-remboursement Scénario : Annulation avant expédition
public
executeCancellationWithSav(mixed $sale[, array<string|int, mixed> $saleProductIds = [] ][, array<string|int, mixed> $additionalData = [] ]) : array<string|int, mixed>
Parameters
- $sale : mixed
-
L'entité Sale
- $saleProductIds : array<string|int, mixed> = []
-
Les IDs des produits à annuler (vide = annulation commande complète)
- $additionalData : array<string|int, mixed> = []
-
Données supplémentaires (motifs, fichiers, etc.)
Return values
array<string|int, mixed> —Résultat de l'opération
getProductPrice()
Calcule le prix final d'un produit (Prix produit + Livraison) selon la logique Menzzo.
public
getProductPrice(int $saleProductId, mixed $sale[, bool $includeShipping = true ]) : array<string|int, mixed>
Parameters
- $saleProductId : int
-
The sale product ID
- $sale : mixed
-
The Sale entity
- $includeShipping : bool = true
-
Whether to include shipping in the total (default: true)
Return values
array<string|int, mixed> —Price calculation result
buildSavObservation()
Construit l'observation client pour le SAV
private
buildSavObservation(array<string|int, mixed> $additionalData) : string
Parameters
- $additionalData : array<string|int, mixed>
Return values
stringcalculateRefundableAmount()
Calculate refundable amount (grand_total - existing refunds)
private
calculateRefundableAmount(mixed $sale) : float
Parameters
- $sale : mixed
-
The Sale entity
Return values
float —The refundable amount
calculateRefundableAmountForProducts()
Calculate refundable amount for specific sale products (excluding shipping) Uses getRefundedAmountForProduct() to get per-product refunds with proper distribution
private
calculateRefundableAmountForProducts(Sale $sale, array<string|int, mixed> $saleProductIds) : float
Parameters
- $sale : Sale
-
The sale entity
- $saleProductIds : array<string|int, mixed>
-
The specific product IDs being claimed
Return values
float —Product-only refundable amount for the claimed products
configureSavPropositions()
Configure deux propositions pour un SAV créé par le chatbot Proposition 1: Bon d'achat 115% + Chatbot IA + Refusé (0) Proposition 2: Remboursement intégral/partiel + Chatbot IA + Accepté (1)
private
configureSavPropositions(mixed $sav, mixed $action[, mixed $isCompleteCancellation = false ]) : void
Parameters
- $sav : mixed
- $action : mixed
- $isCompleteCancellation : mixed = false
configureSavPropositionsForGiftCard()
Configure une seule proposition pour un SAV créé avec bon d'achat 115% Proposition: Bon d'achat 115% + Chatbot IA + Accepté (1)
private
configureSavPropositionsForGiftCard(mixed $sav) : void
Parameters
- $sav : mixed
createSavForCancellation()
Crée un SAV pour l'annulation avec deux propositions configurées Proposition 1: Bon d'achat 115% (refusé par défaut) + Communication Chatbot IA Proposition 2: Remboursement totale/partiel + Communication Chatbot IA + Accepté (1)
private
createSavForCancellation(mixed $user, mixed $sale, array<string|int, mixed> $saleProductIds, string $typePb, string $clientObservation, mixed $tag[, mixed $refund = null ][, mixed $action = null ][, mixed $isCompleteCancellation = false ]) : mixed
Parameters
- $user : mixed
- $sale : mixed
- $saleProductIds : array<string|int, mixed>
- $typePb : string
- $clientObservation : string
- $tag : mixed
- $refund : mixed = null
- $action : mixed = null
- $isCompleteCancellation : mixed = false
createSavForGiftCard()
Crée un SAV pour l'annulation avec bon d'achat 115% Une seule proposition: Bon d'achat 115% + Chatbot IA + Accepté (1)
private
createSavForGiftCard(mixed $user, mixed $sale, array<string|int, mixed> $saleProductIds, string $typePb, string $clientObservation, mixed $tag, mixed $refund, mixed $action, mixed $giftCardAmount) : mixed
Parameters
- $user : mixed
- $sale : mixed
- $saleProductIds : array<string|int, mixed>
- $typePb : string
- $clientObservation : string
- $tag : mixed
- $refund : mixed
- $action : mixed
- $giftCardAmount : mixed
executeFullSaleCancellation()
Exécute l'annulation complète de la commande
private
executeFullSaleCancellation(mixed $sale, mixed $user) : array<string|int, mixed>
Parameters
- $sale : mixed
- $user : mixed
Return values
array<string|int, mixed>executeProductsCancellation()
Exécute l'annulation de produits spécifiques
private
executeProductsCancellation(mixed $sale, array<string|int, mixed> $saleProductIds, mixed $user) : array<string|int, mixed>
Parameters
- $sale : mixed
- $saleProductIds : array<string|int, mixed>
- $user : mixed
Return values
array<string|int, mixed>extractDefectFields()
Extract and validate defect fields from payload
private
extractDefectFields(array<string|int, mixed> $payload, string $typePb) : array<string|int, mixed>
Supports:
- défaut fabrication: requires numeric notation (1-5)
- erreur produit logidav: requires evidence.photos >= 1 and notation.value = "accepted"
Parameters
- $payload : array<string|int, mixed>
-
The API request payload
- $typePb : string
-
The type of problem
Return values
array<string|int, mixed> —['final_resolution' => string|null, 'notation' => int|null, 'error' => string|null]
generatePropositionId()
Génère un ID unique pour une proposition
private
generatePropositionId() : string
Return values
stringgetExistingPreRefundAmount()
Calcule le montant total des pré-remboursements existants pour une commande
private
getExistingPreRefundAmount(mixed $sale) : float
Parameters
- $sale : mixed
-
L'objet Sale
Return values
float —Le montant total des pré-remboursements
getRefundedAmountForProduct()
Get refunded amount for a specific SaleProduct Distributes refunds proportionally when a SaleSav has multiple products
private
getRefundedAmountForProduct(SaleProduct $saleProduct, Sale $sale) : float
This solves the double-counting bug where a single Refund associated with a SaleSav that has multiple products was being counted for EACH product.
Example:
- SaleSav #1 has Product A (100) and Product B (100)
- Refund of 50 is issued for SaleSav #1
- Product A should get 25 refunded (50% of 50)
- Product B should get 25 refunded (50% of 50)
Parameters
- $saleProduct : SaleProduct
-
The product to get refunded amount for
- $sale : Sale
-
The sale entity (needed for getProductPrice)
Return values
float —Total amount already refunded for this product
handleProductsCancellationWithGiftCard()
Gère l'annulation de produits spécifiques avec création SAV et bon d'achat 115%
private
handleProductsCancellationWithGiftCard(mixed $sale, array<string|int, mixed> $saleProductIds, mixed $user, array<string|int, mixed> $additionalData) : array<string|int, mixed>
Parameters
- $sale : mixed
- $saleProductIds : array<string|int, mixed>
- $user : mixed
- $additionalData : array<string|int, mixed>
Return values
array<string|int, mixed>handleProductsCancellationWithSav()
Gère l'annulation de produits spécifiques avec création SAV
private
handleProductsCancellationWithSav(mixed $sale, array<string|int, mixed> $saleProductIds, mixed $user, array<string|int, mixed> $additionalData) : array<string|int, mixed>
Parameters
- $sale : mixed
- $saleProductIds : array<string|int, mixed>
- $user : mixed
- $additionalData : array<string|int, mixed>
Return values
array<string|int, mixed>handleSaleCancellationWithGiftCard()
Gère l'annulation d'une commande complète avec création SAV et bon d'achat 115%
private
handleSaleCancellationWithGiftCard(mixed $sale, mixed $user, array<string|int, mixed> $additionalData) : array<string|int, mixed>
Parameters
- $sale : mixed
- $user : mixed
- $additionalData : array<string|int, mixed>
Return values
array<string|int, mixed>handleSaleCancellationWithSav()
Gère l'annulation d'une commande complète avec création SAV
private
handleSaleCancellationWithSav(mixed $sale, mixed $user, array<string|int, mixed> $additionalData) : array<string|int, mixed>
Parameters
- $sale : mixed
- $user : mixed
- $additionalData : array<string|int, mixed>