chore: 同步历史结转脚本与注释中文案统一

这个提交包含在:
chen
2026-09-21 15:13:32 +08:00
父节点 dbd0ac5e02
当前提交 d664c7eb85
共有 4 个文件被更改,包括 23 次插入 和 23 次删除

查看文件

@@ -9,7 +9,7 @@ use think\console\input\Option;
use addons\shopro\service\partner\WalletMigrationService; use addons\shopro\service\partner\WalletMigrationService;
/** /**
* 历史收益全量结转至商城余额控制台命令 * 历史收益全量结转至钱包余额控制台命令
*/ */
class PartnerTransferCommission extends Command class PartnerTransferCommission extends Command
{ {
@@ -18,7 +18,7 @@ class PartnerTransferCommission extends Command
$this->setName('shopro:partner:transfer-commission') $this->setName('shopro:partner:transfer-commission')
->addOption('dry-run', 'd', Option::VALUE_NONE, '只读试算预览,不真实扣减与增加资金') ->addOption('dry-run', 'd', Option::VALUE_NONE, '只读试算预览,不真实扣减与增加资金')
->addOption('force', 'f', Option::VALUE_NONE, '强制执行,不提示二次确认') ->addOption('force', 'f', Option::VALUE_NONE, '强制执行,不提示二次确认')
->setDescription('将所有会员账户已有佣金收益全量结转至商城余额'); ->setDescription('将所有会员账户已有佣金收益全量结转至钱包余额');
} }
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
@@ -27,7 +27,7 @@ class PartnerTransferCommission extends Command
$force = (bool) $input->getOption('force'); $force = (bool) $input->getOption('force');
$output->writeln("========================================================"); $output->writeln("========================================================");
$output->writeln(" 恒联数通 · 历史收益全量结转至商城余额工具"); $output->writeln(" 恒联数通 · 历史收益全量结转至钱包余额工具");
$output->writeln("========================================================"); $output->writeln("========================================================");
$service = new WalletMigrationService(); $service = new WalletMigrationService();
@@ -44,7 +44,7 @@ class PartnerTransferCommission extends Command
$output->writeln("\n部分待结转会员抽样(前 10 名):"); $output->writeln("\n部分待结转会员抽样(前 10 名):");
foreach (array_slice($preview['samples'], 0, 10) as $i => $s) { foreach (array_slice($preview['samples'], 0, 10) as $i => $s) {
$idx = $i + 1; $idx = $i + 1;
$output->writeln(" [{$idx}] 会员ID: {$s['id']} | 手机: {$s['mobile']} | 当前佣金: ¥{$s['current_commission']} -> 商城余额: ¥{$s['current_money']} (结转后预计: ¥{$s['target_money']})"); $output->writeln(" [{$idx}] 会员ID: {$s['id']} | 手机: {$s['mobile']} | 当前佣金: ¥{$s['current_commission']} -> 钱包余额: ¥{$s['current_money']} (结转后预计: ¥{$s['target_money']})");
} }
if ($dryRun) { if ($dryRun) {
@@ -53,7 +53,7 @@ class PartnerTransferCommission extends Command
} }
if (!$force) { if (!$force) {
$output->writeln("\n【安全警告】即将对全量 {$preview['total_users']} 名会员执行结转,将 ¥{$preview['total_commission']} 元佣金划入商城余额!"); $output->writeln("\n【安全警告】即将对全量 {$preview['total_users']} 名会员执行结转,将 ¥{$preview['total_commission']} 元佣金划入钱包余额!");
$output->writeln("若确认执行,请增加参数 --force 或 -f,例如:"); $output->writeln("若确认执行,请增加参数 --force 或 -f,例如:");
$output->writeln("php think shopro:partner:transfer-commission --force"); $output->writeln("php think shopro:partner:transfer-commission --force");
return 1; return 1;
@@ -66,7 +66,7 @@ class PartnerTransferCommission extends Command
if ($err) { if ($err) {
$output->writeln(" [{$current}/{$total}] 会员 {$userId} 结转失败: {$err}"); $output->writeln(" [{$current}/{$total}] 会员 {$userId} 结转失败: {$err}");
} else { } else {
$output->writeln(" [{$current}/{$total}] 会员 {$userId} 成功结转 ¥" . number_format($amount, 2, '.', '') . " 元至商城余额"); $output->writeln(" [{$current}/{$total}] 会员 {$userId} 成功结转 ¥" . number_format($amount, 2, '.', '') . " 元至钱包余额");
} }
}); });

查看文件

@@ -98,7 +98,7 @@ class User extends Common
} }
} }
$data = array_merge($user->toArray(), $partner); $data = array_merge($user->toArray(), $partner);
// 对齐用户余额字段:统一映射商城余额,避免前端不同字段读取出现口径偏差 // 对齐用户余额字段:统一映射钱包余额,避免前端不同字段读取出现口径偏差
$data['balance'] = $user->money; $data['balance'] = $user->money;
$this->success('个人详情', $data); $this->success('个人详情', $data);

查看文件

@@ -2,10 +2,10 @@
/** /**
* 修正提现订单 W202601240278270146002000 钱包扣款类型 * 修正提现订单 W202601240278270146002000 钱包扣款类型
* 业务目标: * 业务目标:
* 1. 扣减用户 20 的商城余额 money 1060.00 元(提现本金 1000 + 手续费 60) * 1. 扣减用户 20 的钱包余额 money 1060.00 元(提现本金 1000 + 手续费 60)
* 2. 返还用户 20 被误扣的佣金 commission 1060.00 元 * 2. 返还用户 20 被误扣的佣金 commission 1060.00 元
* 3. 记录标准审计流水(WalletLog) * 3. 记录标准审计流水(WalletLog)
* 4. 更新提现订单 withdraw_info 标记为商城余额提现 * 4. 更新提现订单 withdraw_info 标记为钱包余额提现
*/ */
define('APP_PATH', __DIR__ . '/../application/'); define('APP_PATH', __DIR__ . '/../application/');
@@ -68,11 +68,11 @@ try {
$currentCommission = (string)$user['commission']; $currentCommission = (string)$user['commission'];
echo "用户校正前资金:\n"; echo "用户校正前资金:\n";
echo "- 商城余额 money: ¥{$currentMoney}\n"; echo "- 钱包余额 money: ¥{$currentMoney}\n";
echo "- 佣金钱包 commission: ¥{$currentCommission}\n\n"; echo "- 佣金钱包 commission: ¥{$currentCommission}\n\n";
if (bccomp($currentMoney, $totalNeedDeduct, 2) < 0) { if (bccomp($currentMoney, $totalNeedDeduct, 2) < 0) {
throw new \Exception("用户商城余额不足扣减 ¥{$totalNeedDeduct}(当前余额:¥{$currentMoney})"); throw new \Exception("用户钱包余额不足扣减 ¥{$totalNeedDeduct}(当前余额:¥{$currentMoney})");
} }
// 检查是否已经校正过(防重幂等) // 检查是否已经校正过(防重幂等)
@@ -101,7 +101,7 @@ try {
$now = time(); $now = time();
// 4. 写入商城余额扣减日志 // 4. 写入钱包余额扣减日志
Db::name('shopro_user_wallet_log')->insert([ Db::name('shopro_user_wallet_log')->insert([
'user_id' => $userId, 'user_id' => $userId,
'type' => 'money', 'type' => 'money',
@@ -109,13 +109,13 @@ try {
'amount' => -floatval($totalNeedDeduct), 'amount' => -floatval($totalNeedDeduct),
'before' => $currentMoney, 'before' => $currentMoney,
'after' => $newMoney, 'after' => $newMoney,
'memo' => '修正提现单W202601240278270146002000扣除商城余额', 'memo' => '修正提现单W202601240278270146002000扣除钱包余额',
'ext' => json_encode([ 'ext' => json_encode([
'withdraw_id' => (string)$withdraw['id'], 'withdraw_id' => (string)$withdraw['id'],
'withdraw_sn' => $withdrawSn, 'withdraw_sn' => $withdrawSn,
'amount' => (string)$amount, 'amount' => (string)$amount,
'charge_fee' => (string)$chargeFee, 'charge_fee' => (string)$chargeFee,
'fix_reason' => '修正扣错佣金为扣商城余额', 'fix_reason' => '修正扣错佣金为扣钱包余额',
], JSON_UNESCAPED_UNICODE), ], JSON_UNESCAPED_UNICODE),
'oper_type' => 'admin', 'oper_type' => 'admin',
'oper_id' => 1, 'oper_id' => 1,
@@ -146,7 +146,7 @@ try {
// 6. 更新提现单 withdraw_info // 6. 更新提现单 withdraw_info
$withdrawInfo = json_decode($withdraw['withdraw_info'], true) ?: []; $withdrawInfo = json_decode($withdraw['withdraw_info'], true) ?: [];
$withdrawInfo['wallet_type'] = 'money'; $withdrawInfo['wallet_type'] = 'money';
$withdrawInfo['提现资产'] = '商城余额'; $withdrawInfo['提现资产'] = '钱包余额';
Db::name('shopro_withdraw')->where('id', $withdraw['id'])->update([ Db::name('shopro_withdraw')->where('id', $withdraw['id'])->update([
'withdraw_info' => json_encode($withdrawInfo, JSON_UNESCAPED_UNICODE), 'withdraw_info' => json_encode($withdrawInfo, JSON_UNESCAPED_UNICODE),
'updatetime' => $now, 'updatetime' => $now,
@@ -155,7 +155,7 @@ try {
// 7. 写入提现单操作日志 // 7. 写入提现单操作日志
Db::name('shopro_withdraw_log')->insert([ Db::name('shopro_withdraw_log')->insert([
'withdraw_id' => $withdraw['id'], 'withdraw_id' => $withdraw['id'],
'content' => '系统财务校正:已将提现扣款由佣金钱包更正为商城可用余额(扣除余额 ¥' . $totalNeedDeduct . ',退回佣金 ¥' . $totalNeedDeduct . ')', 'content' => '系统财务校正:已将提现扣款由佣金钱包更正为钱包可用余额(扣除余额 ¥' . $totalNeedDeduct . ',退回佣金 ¥' . $totalNeedDeduct . ')',
'oper_type' => 'admin', 'oper_type' => 'admin',
'oper_id' => 1, 'oper_id' => 1,
'createtime' => $now, 'createtime' => $now,
@@ -164,9 +164,9 @@ try {
Db::commit(); Db::commit();
echo "【成功】账目校正完成:\n"; echo "【成功】账目校正完成:\n";
echo "- 商城余额 money: ¥{$currentMoney} -> ¥{$newMoney}(已成功扣除 ¥{$totalNeedDeduct})\n"; echo "- 钱包余额 money: ¥{$currentMoney} -> ¥{$newMoney}(已成功扣除 ¥{$totalNeedDeduct})\n";
echo "- 佣金钱包 commission: ¥{$currentCommission} -> ¥{$newCommission}(已退还误扣 ¥{$totalNeedDeduct})\n"; echo "- 佣金钱包 commission: ¥{$currentCommission} -> ¥{$newCommission}(已退还误扣 ¥{$totalNeedDeduct})\n";
echo "- 提现订单已标记为「商城余额」提现\n"; echo "- 提现订单已标记为「钱包余额」提现\n";
echo "- 钱包流水与提现操作日志已写入\n"; echo "- 钱包流水与提现操作日志已写入\n";
} catch (\Exception $e) { } catch (\Exception $e) {

查看文件

@@ -1,7 +1,7 @@
<?php <?php
/** /**
* 恒联数通 · 全量历史收益结转至商城余额独立执行脚本 * 恒联数通 · 全量历史收益结转至钱包余额独立执行脚本
* *
* 生产环境执行命令: * 生产环境执行命令:
* 1. 试算预览(不改动数据): * 1. 试算预览(不改动数据):
@@ -44,7 +44,7 @@ require_once ROOT_PATH . 'addons/shopro/helper/helper.php';
use addons\shopro\service\partner\WalletMigrationService; use addons\shopro\service\partner\WalletMigrationService;
echo "========================================================\n"; echo "========================================================\n";
echo " 恒联数通 · 历史收益全量结转至商城余额独立脚本\n"; echo " 恒联数通 · 历史收益全量结转至钱包余额独立脚本\n";
echo "========================================================\n"; echo "========================================================\n";
$args = $argv ?? []; $args = $argv ?? [];
@@ -65,7 +65,7 @@ if ($preview['total_users'] === 0) {
echo "\n待结转会员抽样(前 10 名):\n"; echo "\n待结转会员抽样(前 10 名):\n";
foreach (array_slice($preview['samples'], 0, 10) as $i => $s) { foreach (array_slice($preview['samples'], 0, 10) as $i => $s) {
$idx = $i + 1; $idx = $i + 1;
echo " [{$idx}] 会员ID: {$s['id']} | 手机: {$s['mobile']} | 当前佣金: ¥{$s['current_commission']} -> 商城余额: ¥{$s['current_money']} (预计转后: ¥{$s['target_money']})\n"; echo " [{$idx}] 会员ID: {$s['id']} | 手机: {$s['mobile']} | 当前佣金: ¥{$s['current_commission']} -> 钱包余额: ¥{$s['current_money']} (预计转后: ¥{$s['target_money']})\n";
} }
if ($dryRun) { if ($dryRun) {
@@ -74,7 +74,7 @@ if ($dryRun) {
} }
if (!$force) { if (!$force) {
echo "\n【安全警告】即将对 {$preview['total_users']} 名会员执行结转,将 ¥{$preview['total_commission']} 元转入商城余额!\n"; echo "\n【安全警告】即将对 {$preview['total_users']} 名会员执行结转,将 ¥{$preview['total_commission']} 元转入钱包余额!\n";
echo "若确认执行,请增加参数 --force 或 -f,例如:\n"; echo "若确认执行,请增加参数 --force 或 -f,例如:\n";
echo "php scripts/transfer_all_commission_to_money.php --force\n"; echo "php scripts/transfer_all_commission_to_money.php --force\n";
exit(1); exit(1);
@@ -87,7 +87,7 @@ $res = $service->transferAll(false, function ($current, $total, $userId, $amount
if ($err) { if ($err) {
echo " [{$current}/{$total}] 会员 {$userId} 结转失败: {$err}\n"; echo " [{$current}/{$total}] 会员 {$userId} 结转失败: {$err}\n";
} else { } else {
echo " [{$current}/{$total}] 会员 {$userId} 成功结转 ¥" . number_format($amount, 2, '.', '') . " 元至商城余额\n"; echo " [{$current}/{$total}] 会员 {$userId} 成功结转 ¥" . number_format($amount, 2, '.', '') . " 元至钱包余额\n";
} }
}); });