a5adbf347b
- GET /v1/pay/orders 订单列表(Store.ListByUser,本地台账倒序) - catalog 增 PriceUsdtMicro(USDT 一口价展示) + SettlementCurrency/DisplayAmountMinor - 下单按支付方式落展示金额/结算币种(crypto→USDT / 法币→CNY),webhook 覆盖实际 - GetOrder 详情回带 sku/plan/method/amount/currency/created_at/paid_at - 新增 List 越权/倒序/富字段 + 分币种展示金额 + 详情富字段测试 - 修 3 个 pre-existing 迁移测试(renumber 后 21→23 遗留) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
53 lines
2.1 KiB
Go
53 lines
2.1 KiB
Go
package pay
|
|
|
|
import "github.com/wangjia/pangolin/server/internal/codes"
|
|
|
|
// CatalogItem 是可购档位。SKU 与 pay 侧 products.biz_code 一一对应
|
|
// (webhook product_biz_code 原样回带);价格字段**仅展示**(实际扣款以 pay 侧
|
|
// per-currency ProductPrice 为准——一致性列入联调 checklist):
|
|
// - PriceMinor:CNY 分(支付宝/哪吒等法币渠道)
|
|
// - PriceUsdtMicro:USDT 微元(6 位精度,加密货币渠道)
|
|
type CatalogItem struct {
|
|
SKU string `json:"sku"`
|
|
Plan string `json:"plan"`
|
|
Days int `json:"days"`
|
|
PriceMinor int64 `json:"price_minor"` // CNY 分(展示)
|
|
Currency string `json:"currency"` // CNY
|
|
PriceUsdtMicro int64 `json:"price_usdt_micro"` // USDT 微元(展示;各币种一口价、非汇率换算)
|
|
}
|
|
|
|
// Catalog 三档单源。时长取宽松口径(31/92/366 覆盖大月与最长季)。
|
|
// USDT 展示价与 pay 侧 products 一口价对齐($4.99/$12.99/$34.99),不做实时汇率换算。
|
|
var Catalog = []CatalogItem{
|
|
{SKU: "pro_month", Plan: string(codes.PlanPro), Days: 31, PriceMinor: 2999, Currency: "CNY", PriceUsdtMicro: 4990000},
|
|
{SKU: "pro_quarter", Plan: string(codes.PlanPro), Days: 92, PriceMinor: 6888, Currency: "CNY", PriceUsdtMicro: 12990000},
|
|
{SKU: "pro_year", Plan: string(codes.PlanPro), Days: 366, PriceMinor: 19999, Currency: "CNY", PriceUsdtMicro: 34990000},
|
|
}
|
|
|
|
func CatalogBySKU(sku string) (CatalogItem, bool) {
|
|
for _, it := range Catalog {
|
|
if it.SKU == sku {
|
|
return it, true
|
|
}
|
|
}
|
|
return CatalogItem{}, false
|
|
}
|
|
|
|
// SettlementCurrency 按支付方式给出结算币种(展示/落台账用;实际以 pay 侧为准)。
|
|
// crypto→USDT;其余法币渠道(alipay/nezha/…)→CNY。
|
|
func SettlementCurrency(method string) string {
|
|
if method == "crypto" {
|
|
return "USDT"
|
|
}
|
|
return "CNY"
|
|
}
|
|
|
|
// DisplayAmountMinor 按支付方式给出该档「展示金额」(下单时预估、落台账,
|
|
// webhook 到账后由实际结算金额覆盖)。crypto→USDT 微元;法币→CNY 分。
|
|
func DisplayAmountMinor(it CatalogItem, method string) int64 {
|
|
if method == "crypto" {
|
|
return it.PriceUsdtMicro
|
|
}
|
|
return it.PriceMinor
|
|
}
|