import { db } from "../src/db"; import { decryptJson, encryptJson } from "../src/security"; const gatewayId = process.argv[2] || "alipay"; const product = process.argv[3] || "page"; if (!['page', 'precreate'].includes(product)) throw new Error("产品必须是 page 或 precreate"); const row = db.query("SELECT config_encrypted FROM gateways WHERE id=? AND channel='alipay'").get(gatewayId) as { config_encrypted: string } | null; if (!row) throw new Error(`找不到支付宝网关:${gatewayId}`); const config = decryptJson>(row.config_encrypted || ""); config.paymentProduct = product; db.query("UPDATE gateways SET config_encrypted=?, updated_at=? WHERE id=?") .run(encryptJson(config), new Date().toISOString(), gatewayId); console.log(JSON.stringify({ gatewayId, paymentProduct: product, updated: true }));