feat(imports): add real pricing and subscription collectors

Add plan catalog and subscription schema support, seed baselines, and real importers for core domestic subscriptions plus stable official pricing sources.

This commit also hardens the shared fetch layers so the importers can support live collection and database writes instead of relying on manual placeholders alone.
This commit is contained in:
phamnazage-jpg
2026-05-15 22:32:57 +08:00
parent dd58c18fe3
commit 958245537a
91 changed files with 10474 additions and 1 deletions

View File

@@ -0,0 +1,119 @@
//go:build llm_script
package main
import (
"fmt"
"regexp"
"strings"
)
const (
defaultBytedanceCodingPlanURL = "https://developer.volcengine.com/articles/7574419773204004906"
defaultBytedanceCodingPlanNotice = "https://developer.volcengine.com/articles/7604465649330749490"
)
func parseBytedanceSubscriptionCatalog(pricingRaw string, noticeRaw string) ([]subscriptionImportRecord, error) {
publishedAt, known := publishedAtFromText(firstNonEmptyText(pricingRaw, noticeRaw))
liteSection := sliceSection(pricingRaw, "Lite 套餐", "Pro 套餐")
proSection := sliceSection(pricingRaw, "Pro 套餐", "")
if strings.TrimSpace(liteSection) == "" || strings.TrimSpace(proSection) == "" {
return nil, fmt.Errorf("unexpected bytedance coding plan sections")
}
promoNote := "新用户首购优惠。"
if strings.Contains(noticeRaw, "每日 10:30") {
promoNote = "新用户首购优惠,每日 10:30 限量开放。"
}
records := make([]subscriptionImportRecord, 0, 4)
for _, tierSection := range []struct {
Tier string
Content string
}{
{Tier: "Lite", Content: liteSection},
{Tier: "Pro", Content: proSection},
} {
tier := tierSection.Tier
section := strings.TrimSpace(tierSection.Content)
lines := strings.Split(section, "\n")
scene := ""
for _, line := range lines {
line = strings.TrimSpace(line)
if line != "" {
scene = line
break
}
}
pricePattern := regexp.MustCompile(`([\d.]+)\s+元\s+([\d.]+)\s+元/月`)
priceMatch := pricePattern.FindStringSubmatch(section)
if len(priceMatch) != 3 {
return nil, fmt.Errorf("missing bytedance %s prices", tier)
}
quotaPattern := regexp.MustCompile(`每月约\s+([\d,]+)\s+次请求`)
quotaMatch := quotaPattern.FindStringSubmatch(section)
if len(quotaMatch) != 2 {
return nil, fmt.Errorf("missing bytedance %s monthly quota", tier)
}
promoPrice := mustParseSubscriptionPrice(priceMatch[1])
standardPrice := mustParseSubscriptionPrice(priceMatch[2])
monthlyQuota := mustParseSubscriptionInt64(quotaMatch[1])
tierCode := strings.ToLower(tier)
records = append(records, subscriptionImportRecord{
ProviderName: "ByteDance",
ProviderNameCn: "字节跳动",
ProviderCountry: "CN",
ProviderWebsite: "https://www.volcengine.com",
OperatorName: "ByteDance Volcano",
OperatorNameCn: "火山引擎",
OperatorCountry: "CN",
OperatorWebsite: "https://developer.volcengine.com",
OperatorType: "cloud",
PlanFamily: "coding_plan",
PlanCode: "bytedance-coding-plan-" + tierCode,
PlanName: "方舟 Coding Plan " + tier,
Tier: tier,
BillingCycle: "monthly",
Currency: "CNY",
ListPrice: standardPrice,
PriceUnit: "CNY/month",
QuotaValue: monthlyQuota,
QuotaUnit: "requests/month",
PlanScope: "方舟 Coding Plan",
SourceURL: defaultBytedanceCodingPlanURL,
PublishedAt: publishedAt,
EffectiveDate: effectiveDateFromPublishedAt(publishedAt),
Notes: scene + ";续费标准价。",
PublishedAtKnown: known,
})
records = append(records, subscriptionImportRecord{
ProviderName: "ByteDance",
ProviderNameCn: "字节跳动",
ProviderCountry: "CN",
ProviderWebsite: "https://www.volcengine.com",
OperatorName: "ByteDance Volcano",
OperatorNameCn: "火山引擎",
OperatorCountry: "CN",
OperatorWebsite: "https://developer.volcengine.com",
OperatorType: "cloud",
PlanFamily: "coding_plan",
PlanCode: "bytedance-coding-plan-" + tierCode + "-first-month",
PlanName: "方舟 Coding Plan " + tier + " 首月活动版",
Tier: tier + " Promo",
BillingCycle: "monthly",
Currency: "CNY",
ListPrice: promoPrice,
PriceUnit: "CNY/month",
QuotaValue: monthlyQuota,
QuotaUnit: "requests/month",
PlanScope: "方舟 Coding Plan",
SourceURL: defaultBytedanceCodingPlanURL,
PublishedAt: publishedAt,
EffectiveDate: effectiveDateFromPublishedAt(publishedAt),
Notes: scene + "" + promoNote,
PublishedAtKnown: known,
})
}
return records, nil
}