refactor: simplify pricing tables to USD-only

- Remove KRW pricing calculations from all pricing tables
- Simplify pricing table to store only wholesale USD prices
- Simplify anvil_pricing to store only retail USD prices
- Remove KRW environment variables (KRW_EXCHANGE_RATE, KRW_MARGIN_RATE)
- Remove KRW functions from constants.ts
- Update GPU/G8/VPU pricing repositories to match
- Add Anvil tables and repositories for branded product support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-25 21:16:25 +09:00
parent a2133ae5c9
commit 9f3d3a245a
21 changed files with 1952 additions and 197 deletions

View File

@@ -4,9 +4,9 @@
*/
import { BaseRepository } from './base';
import { GpuPricing, GpuPricingInput, RepositoryError, ErrorCodes, Env } from '../types';
import { GpuPricing, GpuPricingInput, RepositoryError, ErrorCodes } from '../types';
import { createLogger } from '../utils/logger';
import { calculateKRWHourly, calculateKRWMonthly } from '../constants';
import { calculateRetailHourly, calculateRetailMonthly } from '../constants';
export class GpuPricingRepository extends BaseRepository<GpuPricing> {
protected tableName = 'gpu_pricing';
@@ -16,13 +16,13 @@ export class GpuPricingRepository extends BaseRepository<GpuPricing> {
'region_id',
'hourly_price',
'monthly_price',
'hourly_price_krw',
'monthly_price_krw',
'hourly_price_retail',
'monthly_price_retail',
'currency',
'available',
];
constructor(db: D1Database, private env?: Env) {
constructor(db: D1Database) {
super(db);
}
@@ -113,20 +113,21 @@ export class GpuPricingRepository extends BaseRepository<GpuPricing> {
try {
const statements = pricingData.map((pricing) => {
const hourlyKrw = calculateKRWHourly(pricing.hourly_price, this.env);
const monthlyKrw = calculateKRWMonthly(pricing.monthly_price, this.env);
const hourlyRetail = calculateRetailHourly(pricing.hourly_price);
const monthlyRetail = calculateRetailMonthly(pricing.monthly_price);
return this.db.prepare(
`INSERT INTO gpu_pricing (
gpu_instance_id, region_id, hourly_price, monthly_price,
hourly_price_krw, monthly_price_krw, currency, available
hourly_price_retail, monthly_price_retail,
currency, available
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(gpu_instance_id, region_id)
DO UPDATE SET
hourly_price = excluded.hourly_price,
monthly_price = excluded.monthly_price,
hourly_price_krw = excluded.hourly_price_krw,
monthly_price_krw = excluded.monthly_price_krw,
hourly_price_retail = excluded.hourly_price_retail,
monthly_price_retail = excluded.monthly_price_retail,
currency = excluded.currency,
available = excluded.available`
).bind(
@@ -134,8 +135,8 @@ export class GpuPricingRepository extends BaseRepository<GpuPricing> {
pricing.region_id,
pricing.hourly_price,
pricing.monthly_price,
hourlyKrw,
monthlyKrw,
hourlyRetail,
monthlyRetail,
pricing.currency,
pricing.available
);