bindbox-game/scripts/verify_coupon_fix.go
2026-01-27 01:33:32 +08:00

43 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/go-sql-driver/mysql"
)
func main() {
// 连接数据库
dsn := "root:bindbox2025kdy@tcp(150.158.78.154:3306)/dev_game?parseTime=true"
db, err := sql.Open("mysql", dsn)
if err != nil {
log.Fatal("连接失败:", err)
}
defer db.Close()
// 1. 重置优惠券状态用于测试
// 注意:这里为了不破坏现场,我们创建一个新的优惠券用于测试
// 或者,如果用户允许,我们可以修复已经超额的优惠券?
// 这里我们只观察,不测试下单(因为需要调用 API
// 但我们可以手动验证 "Mock" ApplyCouponWithCap 逻辑。
fmt.Println("此脚本仅打印当前优惠券 275 的状态,请手动进行下单测试验证修复效果。")
// 查询优惠券状态
var bal int64
var status int32
err = db.QueryRow("SELECT balance_amount, status FROM user_coupons WHERE id = 275").Scan(&bal, &status)
if err != nil {
log.Fatal(err)
}
fmt.Printf("当前优惠券余额: %d 分, 状态: %d\n", bal, status)
if bal > 0 {
fmt.Println("余额 > 0正常情况。请尝试下单直到余额耗尽再次下单应失败或不使用优惠券。")
} else {
fmt.Println("余额 <= 0修复前这会导致重新使用 5000 面值。修复后应该无法使用。")
}
}