-- 财务系统 APP 充值详情：payment_orders 补 Google Play Orders API 实付明细列。
-- 与 wallet-service 启动迁移 ensureGooglePaymentPaidDetailsSchema 等价，供手工升级线上库使用。

ALTER TABLE payment_orders
  ADD COLUMN paid_currency_code VARCHAR(8) NOT NULL DEFAULT '' COMMENT '用户实付币种，来自 Google Orders API' AFTER amount_micro,
  ADD COLUMN paid_amount_micro BIGINT NOT NULL DEFAULT 0 COMMENT '用户实付总额微单位（实付币种）' AFTER paid_currency_code,
  ADD COLUMN paid_tax_micro BIGINT NOT NULL DEFAULT 0 COMMENT '订单税额微单位（实付币种）' AFTER paid_amount_micro,
  ADD COLUMN paid_net_micro BIGINT NOT NULL DEFAULT 0 COMMENT 'Google 扣费后开发者净收入微单位（实付币种）' AFTER paid_tax_micro,
  ADD COLUMN paid_synced_at_ms BIGINT NOT NULL DEFAULT 0 COMMENT '实付明细同步时间，UTC epoch ms；0 表示未同步' AFTER paid_net_micro;

ALTER TABLE payment_orders
  ADD INDEX idx_payment_orders_wallet_tx (app_code, wallet_transaction_id);
