fix(withdraw): 修复提现台账导出PHP8兼容性与页面崩溃问题,统一大余额与导出体验

这个提交包含在:
chen
2026-09-21 15:11:58 +08:00
父节点 3bd0954df1
当前提交 dbd0ac5e02
共有 21 个文件被更改,包括 255 次插入 和 165 次删除

查看文件

@@ -72,112 +72,109 @@ class Withdraw extends Common
'updatetime' => '操作时间',
];
$total = $this->model->sheepFilter()->count();
if ($total <= 0) {
$this->error('导出数据为空');
try {
$total = (new WithdrawModel)->sheepFilter()->count();
if ($total <= 0) {
$this->error('导出数据为空');
}
$export = new \addons\shopro\library\Export();
$params = [
'file_name' => '提现管理台账',
'cell_titles' => $cellTitles,
'total' => $total,
'is_sub_cell' => false,
];
$totalAmount = 0;
$totalPaidFee = 0;
$totalChargeFee = 0;
$result = $export->export($params, function ($pages) use (&$totalAmount, &$totalPaidFee, &$totalChargeFee, $total) {
$datas = (new WithdrawModel)->sheepFilter()->with(['user'])
->limit((($pages['page'] - 1) * $pages['list_rows']), $pages['list_rows'])
->select();
$newDatas = [];
foreach ($datas as $withdraw) {
$user = $withdraw['user'] ?? null;
$displayInfo = $withdraw['withdraw_info_display'] ?? ($withdraw['withdraw_info'] ?? []);
// 收款账户信息
$payeeName = $displayInfo['真实姓名'] ?? ($displayInfo['姓名'] ?? ($displayInfo['微信用户'] ?? ''));
$bankName = $displayInfo['开户行'] ?? ($displayInfo['开户银行'] ?? '');
$cardNo = $displayInfo['银行卡号'] ?? ($displayInfo['卡号'] ?? ($displayInfo['支付宝账户'] ?? ($displayInfo['支付宝账号'] ?? ($displayInfo['微信ID'] ?? ''))));
if ($cardNo !== '') {
$cardNo = "\t" . $cardNo;
}
// 提现资产类型
$assetType = !empty($withdraw['is_madow_withdraw']) ? 'DMEPA' : (!empty($withdraw['is_money_withdraw']) ? '钱包余额' : ($displayInfo['提现资产'] ?? '钱包余额'));
// 资产折算明细
$assetDetailParts = [];
if (!empty($displayInfo['扣除DMEPA'])) {
$assetDetailParts[] = '扣除: ' . $displayInfo['扣除DMEPA'];
}
if (!empty($displayInfo['市值汇率'])) {
$assetDetailParts[] = $displayInfo['市值汇率'];
}
if (!empty($displayInfo['换算市值'])) {
$assetDetailParts[] = '市值: ' . $displayInfo['换算市值'];
}
$assetDetail = implode('; ', $assetDetailParts);
$amount = floatval($withdraw['amount'] ?? 0);
$paidFee = floatval($withdraw['paid_fee'] ?? 0) > 0 ? floatval($withdraw['paid_fee']) : floatval($withdraw['real_amount'] ?? $amount);
$chargeFee = floatval($withdraw['charge_fee'] ?? 0);
$totalAmount = function_exists('bcadd') ? bcadd((string)$totalAmount, (string)$amount, 2) : ($totalAmount + $amount);
$totalPaidFee = function_exists('bcadd') ? bcadd((string)$totalPaidFee, (string)$paidFee, 2) : ($totalPaidFee + $paidFee);
$totalChargeFee = function_exists('bcadd') ? bcadd((string)$totalChargeFee, (string)$chargeFee, 2) : ($totalChargeFee + $chargeFee);
$createTime = is_numeric($withdraw['createtime'] ?? null) && intval($withdraw['createtime']) > 0
? date('Y-m-d H:i:s', intval($withdraw['createtime']))
: ($withdraw['createtime'] ?: '-');
$updateTime = is_numeric($withdraw['updatetime'] ?? null) && intval($withdraw['updatetime']) > 0
? date('Y-m-d H:i:s', intval($withdraw['updatetime']))
: ($withdraw['updatetime'] ?: '-');
$newDatas[] = [
'id' => $withdraw['id'],
'withdraw_sn' => "\t" . (string)($withdraw['withdraw_sn'] ?? ''),
'user_nickname' => $user['nickname'] ?? ('用户 ' . $withdraw['user_id']),
'user_mobile' => "\t" . (string)($user['mobile'] ?? ''),
'asset_type' => $assetType,
'amount' => number_format($amount, 2, '.', ''),
'paid_fee' => number_format($paidFee, 2, '.', ''),
'charge_rate_format' => $withdraw['charge_rate_format'] ?? '0.0%',
'charge_fee' => number_format($chargeFee, 2, '.', ''),
'withdraw_type_text' => $withdraw['withdraw_type_text'] ?? '-',
'payee_name' => $payeeName ?: '-',
'bank_name' => $bankName ?: '-',
'card_no' => $cardNo ?: '-',
'asset_detail' => $assetDetail ?: '-',
'status_text' => $withdraw['status_text'] ?? '-',
'createtime' => $createTime,
'updatetime' => $updateTime,
];
}
if ($pages['is_last_page']) {
$newDatas[] = [
'id' => '合计: 共 ' . $total . ' 条记录;提现总额:¥' . number_format((float)$totalAmount, 2, '.', '') . ';实际到账总额:¥' . number_format((float)$totalPaidFee, 2, '.', '') . ';手续费总额:¥' . number_format((float)$totalChargeFee, 2, '.', '')
];
}
return $newDatas;
});
$this->success('导出成功' . (isset($result['file_path']) && $result['file_path'] ? ',请在服务器: “' . $result['file_path'] . '” 查看' : ''), null, $result);
} catch (HttpResponseException $e) {
throw $e;
} catch (\Throwable $e) {
$this->error('导出处理失败: ' . $e->getMessage());
}
$export = new \addons\shopro\library\Export();
$params = [
'file_name' => '提现管理台账',
'cell_titles' => $cellTitles,
'total' => $total,
'is_sub_cell' => false,
];
$totalAmount = 0;
$totalPaidFee = 0;
$totalChargeFee = 0;
$result = $export->export($params, function ($pages) use (&$totalAmount, &$totalPaidFee, &$totalChargeFee, $total) {
$datas = $this->model->sheepFilter()->with(['user'])
->limit((($pages['page'] - 1) * $pages['list_rows']), $pages['list_rows'])
->select();
$newDatas = [];
foreach ($datas as $withdraw) {
$user = $withdraw['user'] ?? null;
$displayInfo = $withdraw['withdraw_info_display'] ?? ($withdraw['withdraw_info'] ?? []);
// 收款账户信息
$payeeName = $displayInfo['真实姓名'] ?? ($displayInfo['姓名'] ?? ($displayInfo['微信用户'] ?? ''));
$bankName = $displayInfo['开户行'] ?? ($displayInfo['开户银行'] ?? '');
$cardNo = $displayInfo['银行卡号'] ?? ($displayInfo['卡号'] ?? ($displayInfo['支付宝账户'] ?? ($displayInfo['支付宝账号'] ?? ($displayInfo['微信ID'] ?? ''))));
if ($cardNo !== '') {
$cardNo = "\t" . $cardNo;
}
// 提现资产类型
$assetType = $withdraw['is_madow_withdraw'] ? 'DMEPA' : ($withdraw['is_money_withdraw'] ? '商城余额' : ($displayInfo['提现资产'] ?? '商城余额'));
// 资产折算明细
$assetDetailParts = [];
if (!empty($displayInfo['扣除DMEPA'])) {
$assetDetailParts[] = '扣除: ' . $displayInfo['扣除DMEPA'];
}
if (!empty($displayInfo['市值汇率'])) {
$assetDetailParts[] = $displayInfo['市值汇率'];
}
if (!empty($displayInfo['换算市值'])) {
$assetDetailParts[] = '市值: ' . $displayInfo['换算市值'];
}
$assetDetail = implode('; ', $assetDetailParts);
$amount = floatval($withdraw['amount'] ?? 0);
$paidFee = floatval($withdraw['paid_fee'] ?? 0) > 0 ? floatval($withdraw['paid_fee']) : floatval($withdraw['real_amount'] ?? $amount);
$chargeFee = floatval($withdraw['charge_fee'] ?? 0);
$totalAmount = function_exists('bcadd') ? bcadd((string)$totalAmount, (string)$amount, 2) : ($totalAmount + $amount);
$totalPaidFee = function_exists('bcadd') ? bcadd((string)$totalPaidFee, (string)$paidFee, 2) : ($totalPaidFee + $paidFee);
$totalChargeFee = function_exists('bcadd') ? bcadd((string)$totalChargeFee, (string)$chargeFee, 2) : ($totalChargeFee + $chargeFee);
$newDatas[] = [
'id' => $withdraw['id'],
'withdraw_sn' => "\t" . (string)($withdraw['withdraw_sn'] ?? ''),
'user_nickname' => $user['nickname'] ?? ('用户 ' . $withdraw['user_id']),
'user_mobile' => "\t" . (string)($user['mobile'] ?? ''),
'asset_type' => $assetType,
'amount' => number_format($amount, 2, '.', ''),
'paid_fee' => number_format($paidFee, 2, '.', ''),
'charge_rate_format' => $withdraw['charge_rate_format'] ?? '0.0%',
'charge_fee' => number_format($chargeFee, 2, '.', ''),
'withdraw_type_text' => $withdraw['withdraw_type_text'] ?? '-',
'payee_name' => $payeeName ?: '-',
'bank_name' => $bankName ?: '-',
'card_no' => $cardNo ?: '-',
'asset_detail' => $assetDetail ?: '-',
'status_text' => $withdraw['status_text'] ?? '-',
'createtime' => $withdraw['createtime'] ?? '-',
'updatetime' => $withdraw['updatetime'] ?? '-',
];
}
if ($pages['is_last_page']) {
$newDatas[] = [
'id' => '合计: 共 ' . $total . ' 条记录',
'withdraw_sn' => '',
'user_nickname' => '',
'user_mobile' => '',
'asset_type' => '',
'amount' => number_format((float)$totalAmount, 2, '.', ''),
'paid_fee' => number_format((float)$totalPaidFee, 2, '.', ''),
'charge_rate_format' => '',
'charge_fee' => number_format((float)$totalChargeFee, 2, '.', ''),
'withdraw_type_text' => '',
'payee_name' => '',
'bank_name' => '',
'card_no' => '',
'asset_detail' => '',
'status_text' => '',
'createtime' => '',
'updatetime' => '',
];
}
return $newDatas;
});
return $result;
}

查看文件

@@ -275,7 +275,7 @@ class Order extends Common
'formula' => (string) ($row->formula ?? ''),
'skip_reason_text' => (string) ($row->skip_reason_text ?? ''),
'wallet_type' => (string) ($row->wallet_type ?? ($amount > 0 ? \addons\shopro\service\partner\PartnerConfig::rewardWalletType() : 'system')),
'wallet_type_text' => (string) ($row->wallet_type_text ?: ($amount > 0 ? (\addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '商城余额' : '佣金钱包') : '平台留存')),
'wallet_type_text' => (string) ($row->wallet_type_text ?: ($amount > 0 ? (\addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '钱包余额' : '佣金钱包') : '平台留存')),
];
}
@@ -385,7 +385,7 @@ class Order extends Common
'unit' => '元',
'order_contrib' => $venueRuleContrib,
'wallet_type' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType(),
'wallet_type_text' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '商城余额' : '佣金钱包',
'wallet_type_text' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '钱包余额' : '佣金钱包',
'settled_key' => 'venue_settled',
'default_user_count' => $activeVenueCount,
],
@@ -396,7 +396,7 @@ class Order extends Common
'unit' => '元',
'order_contrib' => $countyRuleContrib,
'wallet_type' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType(),
'wallet_type_text' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '商城余额' : '佣金钱包',
'wallet_type_text' => \addons\shopro\service\partner\PartnerConfig::rewardWalletType() === 'money' ? '钱包余额' : '佣金钱包',
'settled_key' => 'county_settled',
'default_user_count' => $activeCountyCount,
],
@@ -586,7 +586,7 @@ class Order extends Common
return [
'items' => $items,
'total_cash' => number_format($totalInstantCash, 2, '.', ''), // 直入商城余额的即时现金
'total_cash' => number_format($totalInstantCash, 2, '.', ''), // 直入钱包余额的即时现金
'total_instant_cash' => number_format($totalInstantCash, 2, '.', ''),
'total_share_cash' => number_format($totalShareCash, 2, '.', ''),
'total_all_cash' => number_format($totalAllCash, 2, '.', ''),

查看文件

@@ -84,7 +84,7 @@ class Reward extends Common
'reward_type_text' => $reward['reward_type_text'],
'role_text' => $reward['role_text'] ?? $reward['role'],
'amount' => $reward['amount'],
'wallet_type_text' => $reward['wallet_type_text'] ?? '商城余额',
'wallet_type_text' => $reward['wallet_type_text'] ?? '钱包余额',
'madow' => \addons\shopro\service\partner\IdentityService::formatMadow($reward['madow']),
'base_amount' => $reward['base_amount'],
'status_text' => $reward['status_text'],
@@ -282,7 +282,7 @@ class Reward extends Common
}
/**
* 执行全量结转收益至商城余额
* 执行全量结转收益至钱包余额
*/
public function transferAllCommission()
{