36 lines
930 B
Go
36 lines
930 B
Go
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)
|
|
}
|
|
|
|
orderID := 4695
|
|
fmt.Printf("--- Order Coupons for Order %d ---\n", orderID)
|
|
var results []map[string]interface{}
|
|
db.Table("order_coupons").Where("order_id = ?", orderID).Find(&results)
|
|
for _, r := range results {
|
|
fmt.Printf("UserCouponID: %v, Applied: %v\n", r["user_coupon_id"], r["applied_amount"])
|
|
}
|
|
|
|
var uc []map[string]interface{}
|
|
db.Table("user_coupons").Where("id = ?", 260).Find(&uc)
|
|
if len(uc) > 0 {
|
|
fmt.Printf("\n--- UserCoupon 260 Final State ---\n")
|
|
fmt.Printf("Status: %v, Balance: %v, UsedAt: %v\n", uc[0]["status"], uc[0]["balance_amount"], uc[0]["used_at"])
|
|
}
|
|
}
|