Part 1: Given a CSV transaction string, return a CSV string containing id, transaction_type, payment_provider, and fee. Calculate payment, refund, and dispute fees using the fixed rules.
Part 2: Update payment fees so their variable rate depends on payment_provider and buyer_country; if no rate exists, fall back to Part 1’s 2.1% rate. Dispute rules remain unchanged.
这道题要求你处理一组以 CSV 表示的交易记录,并按规则计算每笔交易的手续费,再输出为新的 CSV。第一部分需要根据交易类型分别计算 payment、refund 和 dispute 的费用,重点是对每行数据做解析、按规则映射并格式化输出。第二部分在 payment 费用上加入更细的定价逻辑:手续费率取决于 payment_provider 和 buyer_country;如果找不到匹配费率,则回退到第一部分默认的 2.1%。题目考察的是 CSV 解析、哈希表查表、条件分支以及字符串重组能力,适合用一次遍历完成处理。