fix(export): 修复Excel导出zipstream库PHP8兼容性与临时文件安全流式输出

这个提交包含在:
chen
2026-09-21 15:19:30 +08:00
父节点 d664c7eb85
当前提交 452c2f22a2
共有 15 个文件被更改,包括 132 次插入 和 100 次删除

查看文件

@@ -2,8 +2,8 @@
/**
* 方案 B 提现 API 核心场景模拟测试(端到端)
* 覆盖:
* 1. 正常场景:申请提现扣除商城余额 money,驳回原路退还 money
* 2. 业务失败场景:申请提现金额超过商城余额,捕获【商城可用余额不足】
* 1. 正常场景:申请提现扣除钱包余额 money,驳回原路退还 money
* 2. 业务失败场景:申请提现金额超过钱包余额,捕获【钱包可用余额不足】
* 3. 参数错误场景:申请金额低于最低限额 100 元,捕获【提现金额不能少于 100元】
*/
@@ -83,22 +83,22 @@ try {
}
// -------------------------------------------------------------------
// 场景 2:业务失败场景(提现金额超出商城可用余额)
// 场景 2:业务失败场景(提现金额超出钱包可用余额)
// -------------------------------------------------------------------
echo "\n--- 2. 业务失败场景:提现金额超出商城可用余额 --- \n";
echo "\n--- 2. 业务失败场景:提现金额超出钱包可用余额 --- \n";
try {
$withdrawService->apply(array_merge($bankInfo, [
'money' => 800, // 800+48=848,在单笔限额 1000 内,但当前可用余额为 554.65,必触发余额不足
]));
assertCondition(false, '未能拦截余额不足的提现请求');
} catch (ShoproException $e) {
assertCondition(strpos($e->getMessage(), '商城可用余额不足') !== false, "成功拦截超额业务拒绝: " . $e->getMessage());
assertCondition(strpos($e->getMessage(), '钱包可用余额不足') !== false, "成功拦截超额业务拒绝: " . $e->getMessage());
}
// -------------------------------------------------------------------
// 场景 3:正常提现场景(内扣模式:提现 100 元,仅扣除 100 元商城余额,手续费内扣)
// 场景 3:正常提现场景(内扣模式:提现 100 元,仅扣除 100 元钱包余额,手续费内扣)
// -------------------------------------------------------------------
echo "\n--- 3. 正常业务场景:提现 100 元并校验商城余额内扣 --- \n";
echo "\n--- 3. 正常业务场景:提现 100 元并校验钱包余额内扣 --- \n";
// 为确保测试环境用户余额充足,临时补充 200 元测试金(测试完成后全额扣回)
$originalMoney = floatval($user->money);
@@ -129,23 +129,23 @@ if ($testWithdraw) {
$afterCommission = floatval($afterUser->commission);
$expectedMoney = round($beforeMoney - 100.00, 2);
assertCondition(round($afterMoney, 2) === $expectedMoney, "【内扣】商城余额仅扣除本金 ¥100.00(¥{$beforeMoney} -> ¥{$afterMoney})");
assertCondition(round($afterMoney, 2) === $expectedMoney, "【内扣】钱包余额仅扣除本金 ¥100.00(¥{$beforeMoney} -> ¥{$afterMoney})");
assertCondition($afterCommission === $beforeCommission, "佣金钱包分毫不差,保持 ¥{$beforeCommission}");
assertCondition($testWithdraw->withdraw_info['wallet_type'] === 'money', "提现订单记录标记为 wallet_type: money");
assertCondition($testWithdraw->withdraw_info['提现资产'] === '商城余额', "提现订单记录提现资产: 商城余额");
assertCondition($testWithdraw->withdraw_info['提现资产'] === '钱包余额', "提现订单记录提现资产: 钱包余额");
// 校验内扣净到账金额 (amount - charge_fee = 100 - 6 = 94.00)
$expectedPaid = bcsub((string)$testWithdraw->amount, (string)$testWithdraw->charge_fee, 2);
assertCondition($expectedPaid === '94.00', "内扣手续费 6.00 元后实际打款金额为 ¥{$expectedPaid}");
// 测试完成后原路驳回并退还余额,恢复环境数据
echo "\n--- 4. 容灾闭环测试:审核驳回退还商城余额本金 --- \n";
echo "\n--- 4. 容灾闭环测试:审核驳回退还钱包余额本金 --- \n";
Db::startTrans();
try {
$withdrawService->handleRefuse($testWithdraw, 'API自动化测试驳回退还');
Db::commit();
$restoredUser = \app\admin\model\shopro\user\User::get($userId);
assertCondition(round(floatval($restoredUser->money), 2) === round($beforeMoney, 2), "驳回后商城余额原路退还本金 ¥100.00 至 ¥{$beforeMoney}");
assertCondition(round(floatval($restoredUser->money), 2) === round($beforeMoney, 2), "驳回后钱包余额原路退还本金 ¥100.00 至 ¥{$beforeMoney}");
assertCondition(floatval($restoredUser->commission) === $beforeCommission, "佣金钱包继续保持 ¥{$beforeCommission}");
} catch (\Exception $e) {
Db::rollback();