chore: build

This commit is contained in:
2026-06-13 14:23:23 +02:00
parent 6f699bea6a
commit 446b15d29c
13 changed files with 137 additions and 34 deletions
@@ -123,6 +123,7 @@ func GetMyCommandsWithTracking(c *gin.Context) {
"status_message": getStatusMessage(cmd["status"].(string)),
"adresse": cmd["adresse"],
"total_prix": cmd["total_prix"],
"referral_used": cmd["referral_used"],
"created_at": cmd["created_at"],
"livreur": livreurInfo,
"eta": etaData,
+14
View File
@@ -302,6 +302,20 @@ func ValidateBasket(c *gin.Context) {
return
}
// Vérifier qu'il y a au moins un article normal (non-récompense)
hasNormalItem := false
for _, item := range items {
if isReward, ok := item["is_reward"].(bool); !ok || !isReward {
hasNormalItem = true
break
}
}
if !hasNormalItem {
log.Printf("❌ [CHECKOUT] Panier contient uniquement des récompenses pour %s", usernameStr)
c.JSON(http.StatusBadRequest, gin.H{"error": "Vous devez commander au moins un produit de la boutique pour bénéficier de votre récompense"})
return
}
log.Printf("🛒 [CHECKOUT] Panier: %d articles", len(items))
// ============================================
+17
View File
@@ -3,6 +3,7 @@ package handlers
import (
"gestion/db"
"gestion/utils"
"log"
"net/http"
"strings"
@@ -191,10 +192,26 @@ func ClaimMyReward(c *gin.Context) {
return
}
// Ajouter le produit récompense au panier si configuré
productAdded := false
var productName string
if reward.RewardProductID > 0 && reward.RewardQuantity > 0 {
qty := reward.RewardQuantity
if item, addErr := database.AddRewardToBasket(username, reward.RewardProductID, qty); addErr == nil {
productAdded = true
productName = item.ProductName
log.Printf("✅ [CLAIM] Produit récompense id=%d (%.2f) ajouté au panier de %s", reward.RewardProductID, qty, username)
} else {
log.Printf("⚠️ [CLAIM] Impossible d'ajouter produit récompense: %v", addErr)
}
}
c.JSON(http.StatusOK, gin.H{
"success": true,
"description": reward.Description,
"remaining_rewards": remaining,
"product_added": productAdded,
"product_name": productName,
})
}