feat(server): /v1/pay 下单代理端点 + 购买台账(JWT 鉴权,user→biz_ref 映射)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
wangjia
2026-07-10 22:32:43 +08:00
parent db2461ed1d
commit 932953bafe
6 changed files with 614 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package pay
import "github.com/wangjia/pangolin/server/internal/codes"
// CatalogItem 是可购档位。SKU 与 pay 侧 products.biz_code 一一对应
// (webhook product_biz_code 原样回带);PriceMinor 仅展示(CNY 分),
// 实际扣款以 pay 侧 ProductPrice/price 为准——一致性列入联调 checklist。
type CatalogItem struct {
SKU string `json:"sku"`
Plan string `json:"plan"`
Days int `json:"days"`
PriceMinor int64 `json:"price_minor"`
Currency string `json:"currency"`
}
// Catalog 三档单源。时长取宽松口径(31/92/366 覆盖大月与最长季)。
var Catalog = []CatalogItem{
{SKU: "pro_month", Plan: string(codes.PlanPro), Days: 31, PriceMinor: 2999, Currency: "CNY"},
{SKU: "pro_quarter", Plan: string(codes.PlanPro), Days: 92, PriceMinor: 6888, Currency: "CNY"},
{SKU: "pro_year", Plan: string(codes.PlanPro), Days: 366, PriceMinor: 19999, Currency: "CNY"},
}
func CatalogBySKU(sku string) (CatalogItem, bool) {
for _, it := range Catalog {
if it.SKU == sku {
return it, true
}
}
return CatalogItem{}, false
}