package main import ( "fmt" "log" "gorm.io/driver/mysql" "gorm.io/gorm" ) const ( DbDSN = "root:bindbox2025kdy@tcp(150.158.78.154:3306)/dev_game?charset=utf8mb4&parseTime=True&loc=Local" ) func main() { db, err := gorm.Open(mysql.Open(DbDSN), &gorm.Config{}) if err != nil { log.Fatalf("DB connection failed: %v", err) } fmt.Println("--- User 9090 Deep Audit (Cloud DB) ---") var userCoupons []struct { ID int64 CouponID int64 BalanceAmount int64 Status int32 ValidEnd string } db.Raw("SELECT id, coupon_id, balance_amount, status, valid_end FROM user_coupons WHERE user_id = 9090").Scan(&userCoupons) for _, uc := range userCoupons { fmt.Printf("\n[Coupon %d] Status: %v, Balance: %v, ValidEnd: %v\n", uc.ID, uc.Status, uc.BalanceAmount, uc.ValidEnd) // Trace Ledger var ledger []struct { ChangeAmount int64 OrderID int64 Action string CreatedAt string } db.Raw("SELECT change_amount, order_id, action, created_at FROM user_coupon_ledger WHERE user_coupon_id = ?", uc.ID).Scan(&ledger) for _, l := range ledger { fmt.Printf(" -> Action: %s, Change: %d, Order: %d, Created: %s\n", l.Action, l.ChangeAmount, l.OrderID, l.CreatedAt) } } }