Chuyển đến nội dung chính

Lesson 10: Pricing Engine & Revenue Model — Cost Calculation, Dynamic Pricing & Margin Optimization

Pricing engine architecture for POD, cost breakdown (base cost + print + shipping + fees), dynamic pricing, margin calculator, multi-currency support, discount/coupon system, revenue split (designer + platform), AI-powered pricing.

🏗️ Architecture — Lesson 10 Lesson 10: Pricing Engine & Revenue Model — Cost Calculation, Dynamic Pricing & Margin Optimization

Fashion Design & Print-on-Demand System Architecture — From Domain Analysis to Production

Part 3: Product & E-Commerce Platform

xdev.asia

1. POD Cost Structure

Retail Price Breakdown
┌──────────────────────────────────────────────────┐
│                 $29.99 Retail Price               │
│                                                  │
│  ┌──────────────┐  $8.50  Base product cost      │
│  │ Base Cost    │  (from supplier: blank + print) │
│  ├──────────────┤                                │
│  │ Print Cost   │  $3.50  Printing cost          │
│  │              │  (DTG: $2.50, DTF: $1.80, etc.)│
│  ├──────────────┤                                │
│  │ Shipping     │  $4.99  Standard shipping      │
│  │              │  (passed to customer or absorbed)│
│  ├──────────────┤                                │
│  │ Platform Fee │  $2.00  POD platform commission │
│  │              │  (5-15% of retail)             │
│  ├──────────────┤                                │
│  │ Channel Fee  │  $1.95  Marketplace commission │
│  │              │  (Etsy 6.5%, Amazon 15%)       │
│  ├──────────────┤                                │
│  │ Payment Fee  │  $1.17  Payment processing     │
│  │              │  (Stripe 2.9% + $0.30)         │
│  ├──────────────┤                                │
│  │ Designer     │  $3.00  Designer royalty        │
│  │ Royalty      │  (fixed or % of profit)        │
│  ├──────────────┤                                │
│  │ NET PROFIT   │  $4.88  Seller profit margin   │
│  │              │  (16.3% margin)                │
│  └──────────────┘                                │
└──────────────────────────────────────────────────┘

2. Pricing Engine Architecture

interface PricingEngine {
  // Calculate full cost breakdown
  calculateCost(params: CostParams): CostBreakdown;
  
  // Suggest optimal retail price
  suggestPrice(params: PriceSuggestionParams): PriceSuggestion;
  
  // Calculate margin
  calculateMargin(retailPrice: Money, costs: CostBreakdown): MarginResult;
  
  // Apply discounts/coupons
  applyDiscount(price: Money, discount: Discount): Money;
  
  // Multi-currency conversion
  convertCurrency(amount: Money, targetCurrency: Currency): Money;
}

interface CostParams {
  baseProductId: string;
  variantSku: string;
  printMethod: PrintMethod;
  printAreas: number;            // Number of print locations (front only vs front+back)
  quantity: number;              // Usually 1 for POD
  shippingZone: ShippingZone;
  salesChannel: ChannelType;
  paymentMethod: string;
}

interface CostBreakdown {
  baseCost: Money;               // Product blank cost
  printCost: Money;              // Printing cost (method-dependent)
  additionalPrintCost: Money;    // Extra print areas cost
  subtotalProductCost: Money;    // = baseCost + printCost + additional
  
  shippingCost: Money;           // Carrier shipping cost
  
  platformFee: Money;            // Our platform fee
  channelFee: Money;             // Marketplace commission
  paymentProcessingFee: Money;   // Stripe/PayPal fee
  taxAmount: Money;              // Sales tax / VAT
  
  designerRoyalty: Money;        // Designer earnings
  
  totalCost: Money;              // Sum of all costs
  suggestedRetailPrice: Money;   // Suggested price for target margin
}

function calculateCost(params: CostParams): CostBreakdown {
  // 1. Base product cost from supplier
  const baseCost = getSupplierCost(params.baseProductId, params.variantSku);
  
  // 2. Print cost based on method and areas
  const printCost = calculatePrintCost(params.printMethod, params.printAreas);
  
  // 3. Shipping cost
  const shippingCost = calculateShipping(
    params.baseProductId,
    params.shippingZone,
    params.quantity,
  );
  
  // 4. Platform fee (percentage-based tiers)
  const platformFee = calculatePlatformFee(baseCost.add(printCost));
  
  // 5. Channel-specific marketplace commission
  const channelFee = calculateChannelFee(params.salesChannel);
  
  // 6. Payment processing (Stripe: 2.9% + $0.30)
  const paymentFee = calculatePaymentFee(params.paymentMethod);
  
  // 7. Designer royalty
  const designerRoyalty = calculateRoyalty(params.baseProductId);

  const totalCost = baseCost
    .add(printCost)
    .add(shippingCost)
    .add(platformFee)
    .add(channelFee)
    .add(paymentFee)
    .add(designerRoyalty);

  // Suggest price for 30% margin
  const targetMargin = 0.30;
  const suggestedPrice = totalCost.divide(1 - targetMargin);

  return {
    baseCost,
    printCost,
    additionalPrintCost: Money.zero(),
    subtotalProductCost: baseCost.add(printCost),
    shippingCost,
    platformFee,
    channelFee,
    paymentProcessingFee: paymentFee,
    taxAmount: Money.zero(),
    designerRoyalty,
    totalCost,
    suggestedRetailPrice: suggestedPrice.roundUp(0.99), // $24.99 ending
  };
}

3. Print Cost Matrix

// Print cost varies by method, size, and color count
const PRINT_COST_MATRIX: Record<PrintMethod, PrintCostConfig> = {
  dtg: {
    baseCost: 2.50,                    // 1 location, white garment
    darkGarmentSurcharge: 1.50,        // Needs white underbase
    additionalLocationCost: 2.00,      // Per extra print area
    maxPrintArea: '15x18 inches',
    setupFee: 0,                       // No setup for POD
    suitableFor: ['cotton', 'cotton_blend'],
  },
  dtf: {
    baseCost: 1.80,
    darkGarmentSurcharge: 0,           // DTF works on any color
    additionalLocationCost: 1.50,
    maxPrintArea: '13x19 inches',
    setupFee: 0,
    suitableFor: ['cotton', 'polyester', 'nylon', 'blend'],
  },
  sublimation: {
    baseCost: 3.00,
    darkGarmentSurcharge: 0,           // Only works on white/light polyester
    additionalLocationCost: 0,         // All-over print = 1 area
    maxPrintArea: 'all-over',
    setupFee: 0,
    suitableFor: ['polyester', 'polymer_coated'],
  },
  screen_print: {
    baseCost: 5.00,                    // Per color per location
    darkGarmentSurcharge: 2.00,
    additionalLocationCost: 3.00,
    maxPrintArea: '14x16 inches',
    setupFee: 25.00,                   // Per screen
    perColorCost: 1.50,               // Each additional color
    minOrderQuantity: 24,              // Not suitable for single POD
    suitableFor: ['cotton', 'cotton_blend'],
  },
};

4. Dynamic Pricing & AI Optimization

// AI-powered pricing suggestions
interface DynamicPricingService {
  suggestOptimalPrice(product: SellableProduct): Promise<PricingSuggestion>;
}

interface PricingSuggestion {
  recommendedPrice: Money;
  priceRange: { min: Money; max: Money };
  confidence: number;                    // 0-1
  factors: PricingFactor[];
  competitorPrices: CompetitorPrice[];
  elasticity: number;                    // Price elasticity estimate
}

interface PricingFactor {
  name: string;
  impact: 'positive' | 'negative';
  weight: number;
  description: string;
}

async function suggestOptimalPrice(
  product: SellableProduct,
): Promise<PricingSuggestion> {
  // 1. Competitor analysis
  const competitors = await analyzeCompetitorPrices(product.category, product.tags);
  
  // 2. Historical sales data (similar products)
  const salesData = await getSalesHistory(product.category, product.tags);
  
  // 3. Demand signals
  const demand = await analyzeDemand({
    searchVolume: await getSearchVolume(product.tags),
    trendScore: await getTrendScore(product.tags),
    seasonality: await getSeasonalFactor(product.category),
  });

  // 4. Cost floor
  const costs = calculateCost({
    baseProductId: product.baseProductId,
    variantSku: product.variants[0].sku,
    printMethod: 'dtg',
    printAreas: 1,
    quantity: 1,
    shippingZone: 'domestic',
    salesChannel: 'shopify',
    paymentMethod: 'stripe',
  });

  // 5. ML model prediction
  const prediction = await pricingModel.predict({
    costFloor: costs.totalCost.amount,
    competitorMedian: median(competitors.map(c => c.price)),
    demandScore: demand.score,
    designQuality: product.aiQualityScore,
    brandStrength: product.designerReputation,
    seasonalMultiplier: demand.seasonality,
  });

  return {
    recommendedPrice: Money.fromAmount(prediction.optimalPrice, 'USD'),
    priceRange: {
      min: costs.totalCost.multiply(1.2),   // 20% minimum margin
      max: Money.fromAmount(prediction.maxPrice, 'USD'),
    },
    confidence: prediction.confidence,
    factors: prediction.factors,
    competitorPrices: competitors,
    elasticity: prediction.elasticity,
  };
}

5. Revenue Split Model

// Revenue distribution: Platform + Designer + Supplier
interface RevenueSplit {
  totalRevenue: Money;           // Customer pays
  
  supplierPayout: Money;         // Base cost + print = supplier
  platformRevenue: Money;        // Platform commission
  designerRoyalty: Money;        // Designer earnings
  channelFee: Money;             // Marketplace keeps
  paymentFee: Money;             // Payment processor keeps
  sellerProfit: Money;           // Remaining for seller
}

// Royalty models
type RoyaltyModel =
  | { type: 'fixed'; amount: Money }              // Fixed $ per sale
  | { type: 'percentage'; rate: number }           // % of retail price
  | { type: 'profit_share'; rate: number }         // % of profit (after costs)
  | { type: 'tiered'; tiers: RoyaltyTier[] };      // Tiered based on volume

interface RoyaltyTier {
  minSales: number;
  maxSales: number;
  rate: number;                  // Percentage
}

// Example tiered royalty:
// 0-100 sales:   10% of profit
// 101-500 sales: 15% of profit
// 500+ sales:    20% of profit

6. Multi-currency & Tax

// Currency conversion with real-time rates
interface CurrencyService {
  convert(amount: Money, from: Currency, to: Currency): Promise<Money>;
  getRates(base: Currency): Promise<ExchangeRates>;
}

// Tax calculation per jurisdiction
interface TaxService {
  calculateTax(params: TaxParams): Promise<TaxResult>;
}

interface TaxParams {
  subtotal: Money;
  shippingAddress: Address;
  productType: string;
  sellerNexus: string[];         // States/countries where seller has nexus
}

interface TaxResult {
  taxable: boolean;
  rate: number;                  // e.g., 0.0825 for 8.25%
  amount: Money;
  jurisdiction: string;          // "California, US" or "EU VAT"
  breakdown: TaxBreakdown[];
}

7. Summary

ComponentKey FeaturesImpact
Cost EngineMulti-factor cost breakdownAccurate margin calculation
Print Cost MatrixMethod × color × area pricingOptimal print method selection
Dynamic PricingML-based price optimizationRevenue maximization
Revenue SplitPlatform + Designer + SupplierFair compensation model
Multi-currencyReal-time FX ratesGlobal market reach
Tax EngineJurisdiction-based tax calcCompliance worldwide