feat(enakgame): spin as an EnakGame game; remove the old game flow
EnakGame phase 10 of docs/tasks-enakgame.md (EG-1001 to EG-1003). Spin (EG-1001) - PROBABILITY entries take an optional label (a wheel segment). The customer game list shows a PROBABILITY game's prizes (entry, label, amount, never weights), and completing returns the drawn prize, so the client can draw the wheel and stop it on the server's draw. - docs/enakgame-spin.md: the admin steps to set up spin per organization (no seeder) and the customer app flow. An HTTP test plays it end to end. Old game flow removed (EG-1002) - Routes POST /customer/spin, GET /customer/games, GET /customer/ferris-wheel, and admin /marketing/games, /marketing/game-prizes, /marketing/rewards, with their handlers, services, processors, repositories, validators, models, contracts, mappers and tests (GamePlayProcessor, SpinGameService, rewards, ...). This also closes RFC §15 findings 1 and 2 (double charge, spinning another org's game). - Tables games, game_prizes, game_plays and rewards stay for ledger history. entities.StringSlice moves to its own file; the omset tracker (unrouted) keeps game_id but no longer embeds the old game response. games.is_active dropped (EG-1003) - Migration 000115; nothing reads metadata.coin_cost any more. The EnakPoint integration docs now point at /customer/enakgame. The Postgres tests were not run: no test database here. Migration 000115 has not been run anywhere. The customer app must stop calling the removed endpoints before this is deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
296708244e
commit
18e87398bb
@@ -43,11 +43,9 @@ type Router struct {
|
||||
accountHandler *handler.AccountHandler
|
||||
orderIngredientTransactionHandler *handler.OrderIngredientTransactionHandler
|
||||
gamificationHandler *handler.GamificationHandler
|
||||
rewardHandler *handler.RewardHandler
|
||||
campaignHandler *handler.CampaignHandler
|
||||
customerAuthHandler *handler.CustomerAuthHandler
|
||||
customerPointsHandler *handler.CustomerPointsHandler
|
||||
spinGameHandler *handler.SpinGameHandler
|
||||
userDeviceHandler *handler.UserDeviceHandler
|
||||
notificationHandler *handler.NotificationHandler
|
||||
selfOrderHandler *handler.SelfOrderHandler
|
||||
@@ -68,7 +66,7 @@ type Router struct {
|
||||
redisClient *redis.Client
|
||||
}
|
||||
|
||||
func NewRouter(cfg *config.Config, healthHandler *handler.HealthHandler, authService service.AuthService, authMiddleware *middleware.AuthMiddleware, userService *service.UserServiceImpl, userValidator *validator.UserValidatorImpl, organizationService service.OrganizationService, organizationValidator validator.OrganizationValidator, outletService service.OutletService, outletValidator validator.OutletValidator, outletSettingService service.OutletSettingService, categoryService service.CategoryService, categoryValidator validator.CategoryValidator, productService service.ProductService, productValidator validator.ProductValidator, productVariantService service.ProductVariantService, productVariantValidator validator.ProductVariantValidator, inventoryService service.InventoryService, inventoryValidator validator.InventoryValidator, orderService service.OrderService, orderValidator validator.OrderValidator, fileService service.FileService, fileValidator validator.FileValidator, customerService service.CustomerService, customerValidator validator.CustomerValidator, paymentMethodService service.PaymentMethodService, paymentMethodValidator validator.PaymentMethodValidator, analyticsService *service.AnalyticsServiceImpl, reportService service.ReportService, tableService *service.TableServiceImpl, tableValidator *validator.TableValidator, unitService handler.UnitService, ingredientService handler.IngredientService, productRecipeService service.ProductRecipeService, vendorService service.VendorService, vendorValidator validator.VendorValidator, purchaseOrderService service.PurchaseOrderService, purchaseOrderValidator validator.PurchaseOrderValidator, purchaseCategoryService service.PurchaseCategoryService, purchaseCategoryValidator validator.PurchaseCategoryValidator, unitConverterService service.IngredientUnitConverterService, unitConverterValidator validator.IngredientUnitConverterValidator, chartOfAccountTypeService service.ChartOfAccountTypeService, chartOfAccountTypeValidator validator.ChartOfAccountTypeValidator, chartOfAccountService service.ChartOfAccountService, chartOfAccountValidator validator.ChartOfAccountValidator, accountService service.AccountService, accountValidator validator.AccountValidator, orderIngredientTransactionService service.OrderIngredientTransactionService, orderIngredientTransactionValidator validator.OrderIngredientTransactionValidator, gamificationService service.GamificationService, gamificationValidator validator.GamificationValidator, rewardService service.RewardService, rewardValidator validator.RewardValidator, campaignService service.CampaignService, campaignValidator validator.CampaignValidator, customerAuthService service.CustomerAuthService, customerAuthValidator validator.CustomerAuthValidator, customerPointsService service.CustomerPointsService, spinGameService service.SpinGameService, customerAuthMiddleware *middleware.CustomerAuthMiddleware, userDeviceService service.UserDeviceService, userDeviceValidator validator.UserDeviceValidator, notificationService service.NotificationService, notificationValidator validator.NotificationValidator, productOutletPriceService service.ProductOutletPriceService, productOutletPriceValidator validator.ProductOutletPriceValidator, selfOrderHandler *handler.SelfOrderHandler, expenseService *service.ExpenseServiceImpl, expenseValidator *validator.ExpenseValidatorImpl, cashAdvanceService service.CashAdvanceService, cashAdvanceValidator validator.CashAdvanceValidator, walletAdminService service.WalletAdminService, walletValidator validator.WalletValidator, loyaltySettingsService service.LoyaltySettingsService, customerPinService service.CustomerPinService, customerWalletService service.CustomerWalletService, customerDeviceService service.CustomerDeviceService, customerOutletService service.CustomerOutletService, customerOrderService service.CustomerOrderService, enakGameAdminService service.EnakGameAdminService, enakGameCustomerService service.EnakGameCustomerService, redisClient *redis.Client) *Router {
|
||||
func NewRouter(cfg *config.Config, healthHandler *handler.HealthHandler, authService service.AuthService, authMiddleware *middleware.AuthMiddleware, userService *service.UserServiceImpl, userValidator *validator.UserValidatorImpl, organizationService service.OrganizationService, organizationValidator validator.OrganizationValidator, outletService service.OutletService, outletValidator validator.OutletValidator, outletSettingService service.OutletSettingService, categoryService service.CategoryService, categoryValidator validator.CategoryValidator, productService service.ProductService, productValidator validator.ProductValidator, productVariantService service.ProductVariantService, productVariantValidator validator.ProductVariantValidator, inventoryService service.InventoryService, inventoryValidator validator.InventoryValidator, orderService service.OrderService, orderValidator validator.OrderValidator, fileService service.FileService, fileValidator validator.FileValidator, customerService service.CustomerService, customerValidator validator.CustomerValidator, paymentMethodService service.PaymentMethodService, paymentMethodValidator validator.PaymentMethodValidator, analyticsService *service.AnalyticsServiceImpl, reportService service.ReportService, tableService *service.TableServiceImpl, tableValidator *validator.TableValidator, unitService handler.UnitService, ingredientService handler.IngredientService, productRecipeService service.ProductRecipeService, vendorService service.VendorService, vendorValidator validator.VendorValidator, purchaseOrderService service.PurchaseOrderService, purchaseOrderValidator validator.PurchaseOrderValidator, purchaseCategoryService service.PurchaseCategoryService, purchaseCategoryValidator validator.PurchaseCategoryValidator, unitConverterService service.IngredientUnitConverterService, unitConverterValidator validator.IngredientUnitConverterValidator, chartOfAccountTypeService service.ChartOfAccountTypeService, chartOfAccountTypeValidator validator.ChartOfAccountTypeValidator, chartOfAccountService service.ChartOfAccountService, chartOfAccountValidator validator.ChartOfAccountValidator, accountService service.AccountService, accountValidator validator.AccountValidator, orderIngredientTransactionService service.OrderIngredientTransactionService, orderIngredientTransactionValidator validator.OrderIngredientTransactionValidator, gamificationService service.GamificationService, gamificationValidator validator.GamificationValidator, campaignService service.CampaignService, campaignValidator validator.CampaignValidator, customerAuthService service.CustomerAuthService, customerAuthValidator validator.CustomerAuthValidator, customerPointsService service.CustomerPointsService, customerAuthMiddleware *middleware.CustomerAuthMiddleware, userDeviceService service.UserDeviceService, userDeviceValidator validator.UserDeviceValidator, notificationService service.NotificationService, notificationValidator validator.NotificationValidator, productOutletPriceService service.ProductOutletPriceService, productOutletPriceValidator validator.ProductOutletPriceValidator, selfOrderHandler *handler.SelfOrderHandler, expenseService *service.ExpenseServiceImpl, expenseValidator *validator.ExpenseValidatorImpl, cashAdvanceService service.CashAdvanceService, cashAdvanceValidator validator.CashAdvanceValidator, walletAdminService service.WalletAdminService, walletValidator validator.WalletValidator, loyaltySettingsService service.LoyaltySettingsService, customerPinService service.CustomerPinService, customerWalletService service.CustomerWalletService, customerDeviceService service.CustomerDeviceService, customerOutletService service.CustomerOutletService, customerOrderService service.CustomerOrderService, enakGameAdminService service.EnakGameAdminService, enakGameCustomerService service.EnakGameCustomerService, redisClient *redis.Client) *Router {
|
||||
|
||||
return &Router{
|
||||
config: cfg,
|
||||
@@ -100,11 +98,9 @@ func NewRouter(cfg *config.Config, healthHandler *handler.HealthHandler, authSer
|
||||
accountHandler: handler.NewAccountHandler(accountService, accountValidator),
|
||||
orderIngredientTransactionHandler: handler.NewOrderIngredientTransactionHandler(&orderIngredientTransactionService, orderIngredientTransactionValidator),
|
||||
gamificationHandler: handler.NewGamificationHandler(gamificationService, gamificationValidator),
|
||||
rewardHandler: handler.NewRewardHandler(rewardService, rewardValidator),
|
||||
campaignHandler: handler.NewCampaignHandler(campaignService, campaignValidator),
|
||||
customerAuthHandler: handler.NewCustomerAuthHandler(customerAuthService, customerAuthValidator),
|
||||
customerPointsHandler: handler.NewCustomerPointsHandler(customerPointsService),
|
||||
spinGameHandler: handler.NewSpinGameHandler(spinGameService),
|
||||
authMiddleware: authMiddleware,
|
||||
customerAuthMiddleware: customerAuthMiddleware,
|
||||
productVariantHandler: handler.NewProductVariantHandler(productVariantService, productVariantValidator),
|
||||
@@ -191,11 +187,8 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
|
||||
customer.POST("/pin", r.customerPinHandler.CreatePin)
|
||||
customer.PUT("/pin", r.customerPinHandler.ChangePin)
|
||||
customer.POST("/pin/reset", r.customerPinHandler.ResetPin)
|
||||
customer.GET("/games", r.customerPointsHandler.GetCustomerGames)
|
||||
customer.GET("/ferris-wheel", r.customerPointsHandler.GetFerrisWheelGame)
|
||||
customer.POST("/spin", r.spinGameHandler.PlaySpinGame)
|
||||
|
||||
// EnakGame (docs/rfc-enakgame.md §11). /enakgame because /customer/games is
|
||||
// EnakGame (docs/rfc-enakgame.md §11). /enakgame because /customer/games was
|
||||
// the old spin.
|
||||
enakGame := customer.Group("/enakgame")
|
||||
{
|
||||
@@ -570,38 +563,6 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
|
||||
tiers.GET("/by-points/:points", r.gamificationHandler.GetTierByPoints)
|
||||
}
|
||||
|
||||
// Games
|
||||
games := gamification.Group("/games")
|
||||
{
|
||||
games.POST("", r.gamificationHandler.CreateGame)
|
||||
games.GET("", r.gamificationHandler.ListGames)
|
||||
games.GET("/active", r.gamificationHandler.GetActiveGames)
|
||||
games.GET("/:id", r.gamificationHandler.GetGame)
|
||||
games.PUT("/:id", r.gamificationHandler.UpdateGame)
|
||||
games.DELETE("/:id", r.gamificationHandler.DeleteGame)
|
||||
}
|
||||
|
||||
// Game Prizes
|
||||
gamePrizes := gamification.Group("/game-prizes")
|
||||
{
|
||||
gamePrizes.POST("", r.gamificationHandler.CreateGamePrize)
|
||||
gamePrizes.GET("", r.gamificationHandler.ListGamePrizes)
|
||||
gamePrizes.GET("/:id", r.gamificationHandler.GetGamePrize)
|
||||
gamePrizes.PUT("/:id", r.gamificationHandler.UpdateGamePrize)
|
||||
gamePrizes.DELETE("/:id", r.gamificationHandler.DeleteGamePrize)
|
||||
gamePrizes.GET("/game/:game_id", r.gamificationHandler.GetGamePrizesByGameID)
|
||||
gamePrizes.GET("/game/:game_id/available", r.gamificationHandler.GetAvailablePrizes)
|
||||
}
|
||||
|
||||
//// Game Plays
|
||||
//gamePlays := gamification.Group("/game-plays")
|
||||
//{
|
||||
// gamePlays.POST("", r.gamificationHandler.CreateGamePlay)
|
||||
// gamePlays.GET("", r.gamificationHandler.ListGamePlays)
|
||||
// gamePlays.GET("/:id", r.gamificationHandler.GetGamePlay)
|
||||
// gamePlays.POST("/play", r.gamificationHandler.PlayGame)
|
||||
//}
|
||||
|
||||
// Omset Tracker
|
||||
//omsetTracker := gamification.Group("/omset-tracker")
|
||||
//{
|
||||
@@ -612,18 +573,6 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
|
||||
// omsetTracker.DELETE("/:id", r.gamificationHandler.DeleteOmsetTracker)
|
||||
//}
|
||||
|
||||
// Rewards
|
||||
rewards := gamification.Group("/rewards")
|
||||
{
|
||||
rewards.POST("", r.rewardHandler.CreateReward)
|
||||
rewards.GET("", r.rewardHandler.ListRewards)
|
||||
rewards.GET("/:id", r.rewardHandler.GetReward)
|
||||
rewards.PUT("/:id", r.rewardHandler.UpdateReward)
|
||||
rewards.DELETE("/:id", r.rewardHandler.DeleteReward)
|
||||
rewards.PUT("/:id/stock/:stock", r.rewardHandler.UpdateRewardStock)
|
||||
rewards.GET("/type/:type", r.rewardHandler.GetRewardsByType)
|
||||
}
|
||||
|
||||
// Campaigns
|
||||
campaigns := gamification.Group("/campaigns")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user