import { z } from 'zod';

/**
 * [BIZ_SUP_15] 多源供应比价与路由契约 (Sourcing Contract)
 * AI-1 (Kernel) 实现 Service, AI-3 (Biz) 调用逻辑
 */

export const SourcingSuggestionSchema = z.object({
  productId: z.string(),
  currentPrice: z.number(),
  suggestedSource: z.enum(['1688', 'TEMU', 'ALIEXPRESS']),
  suggestedPrice: z.number(),
  expectedProfitDelta: z.number(),
  confidence: z.number().min(0).max(1),
  causalChain: z.string(), // AGI 决策因果链描述
});

export type SourcingSuggestion = z.infer<typeof SourcingSuggestionSchema>;

/**
 * [BIZ_FIN_08] 实时毛利计算契约 (Settlement Contract)
 */
export const OrderProfitSnapshotSchema = z.object({
  orderId: z.string(),
  revenue: z.number(),
  cost: z.number(),
  logisticsFee: z.number(),
  platformFee: z.number(),
  netProfit: z.number(),
  margin: z.number(),
  timestamp: z.date(),
});

export type OrderProfitSnapshot = z.infer<typeof OrderProfitSnapshotSchema>;
