154 行
12 KiB
JavaScript
154 行
12 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
console.log('========================================================');
|
|
console.log(' 管理后台全模块查询与展示对齐防误导专项测试');
|
|
console.log('========================================================\n');
|
|
|
|
let passCount = 0;
|
|
let failCount = 0;
|
|
|
|
function assert(condition, message) {
|
|
if (condition) {
|
|
console.log(` [\x1b[32mPASS\x1b[0m] ${message}`);
|
|
passCount++;
|
|
} else {
|
|
console.error(` [\x1b[31mFAIL\x1b[0m] ${message}`);
|
|
failCount++;
|
|
}
|
|
}
|
|
|
|
const rootDir = path.resolve(__dirname, '../..');
|
|
|
|
// --- 1. Reward.php 模型追加属性与解析验证 ---
|
|
console.log('--- 1. Reward.php 模型追加属性与入账账户解析验证 ---');
|
|
const rewardModelPath = path.join(rootDir, 'application/admin/model/shopro/partner/Reward.php');
|
|
assert(fs.existsSync(rewardModelPath), 'application/admin/model/shopro/partner/Reward.php 文件存在');
|
|
const rewardModelContent = fs.readFileSync(rewardModelPath, 'utf8');
|
|
assert(rewardModelContent.includes("'wallet_type'"), 'Reward 模型 $append 追加 wallet_type');
|
|
assert(rewardModelContent.includes("'wallet_type_text'"), 'Reward 模型 $append 追加 wallet_type_text');
|
|
assert(rewardModelContent.includes('function getWalletTypeAttr'), '包含 getWalletTypeAttr 属性获取器');
|
|
assert(rewardModelContent.includes('function getWalletTypeTextAttr'), '包含 getWalletTypeTextAttr 属性获取器');
|
|
assert(rewardModelContent.includes("PartnerConfig::rewardWalletType()"), '现金分润缺省联动 PartnerConfig::rewardWalletType()');
|
|
assert(rewardModelContent.includes("'钱包余额'"), 'wallet_type_text 映射包含 钱包余额');
|
|
assert(rewardModelContent.includes("'佣金钱包'"), 'wallet_type_text 映射包含 佣金钱包');
|
|
assert(rewardModelContent.includes("'分红dmepa'"), 'wallet_type_text 映射包含 分红dmepa');
|
|
|
|
// --- 2. Order.php 订单分成构建与入账账户对齐验证 ---
|
|
console.log('\n--- 2. Order.php 订单分成构建与入账账户对齐验证 ---');
|
|
const orderControllerPath = path.join(rootDir, 'application/admin/controller/shopro/order/Order.php');
|
|
assert(fs.existsSync(orderControllerPath), 'Order.php 文件存在');
|
|
const orderControllerContent = fs.readFileSync(orderControllerPath, 'utf8');
|
|
assert(orderControllerContent.includes("'wallet_type' => (string) ($row->wallet_type"), '即时奖励数据行注入 wallet_type');
|
|
assert(orderControllerContent.includes("'wallet_type_text' => (string) ($row->wallet_type_text"), '即时奖励数据行注入 wallet_type_text');
|
|
assert(orderControllerContent.includes("'wallet_type' => 'commission'"), '传统分销数据行标识为 commission');
|
|
assert(orderControllerContent.includes("'wallet_type_text' => '佣金钱包'"), '传统分销数据行标识为 佣金钱包');
|
|
assert(orderControllerContent.includes("'wallet_type' => 'system'"), '平台留存数据行标识为 system');
|
|
assert(orderControllerContent.includes("'wallet_type_text' => '平台留存'"), '平台留存数据行标识为 平台留存');
|
|
assert(orderControllerContent.includes("PartnerConfig::rewardWalletType()"), '日结均分奖池注入动态入账钱包');
|
|
|
|
// --- 3. 订单详情视图 (order/detail.html) 验证 ---
|
|
console.log('\n--- 3. 订单详情视图 (order/detail.html) 验证 ---');
|
|
const orderDetailViewPath = path.join(rootDir, 'application/admin/view/shopro/order/order/detail.html');
|
|
assert(fs.existsSync(orderDetailViewPath), 'order/detail.html 文件存在');
|
|
const orderDetailViewContent = fs.readFileSync(orderDetailViewPath, 'utf8');
|
|
assert(orderDetailViewContent.includes('直入钱包余额'), '分成顶部横幅包含「直入钱包余额」专属 Tag 提示');
|
|
assert(orderDetailViewContent.includes('label="入账账户"'), '分成明细表格包含「入账账户」列');
|
|
assert(orderDetailViewContent.includes('scope.row.wallet_type_text'), '入账账户列展示 scope.row.wallet_type_text');
|
|
|
|
// --- 4. 收益明细控制器与视图 (partner/reward) 验证 ---
|
|
console.log('\n--- 4. 收益明细控制器与视图 (partner/reward) 验证 ---');
|
|
const partnerRewardControllerPath = path.join(rootDir, 'application/admin/controller/shopro/partner/Reward.php');
|
|
assert(fs.existsSync(partnerRewardControllerPath), 'partner/Reward.php 文件存在');
|
|
const partnerRewardControllerContent = fs.readFileSync(partnerRewardControllerPath, 'utf8');
|
|
assert(partnerRewardControllerContent.includes("'wallet_type_text' => '入账账户'"), '导出表头新增「入账账户」列');
|
|
assert(partnerRewardControllerContent.includes("'wallet_type' => $r->wallet_type"), 'orderTree 订单透视树注入 wallet_type');
|
|
assert(partnerRewardControllerContent.includes("'wallet_type_text' => $r->wallet_type_text"), 'orderTree 订单透视树注入 wallet_type_text');
|
|
|
|
const partnerRewardViewPath = path.join(rootDir, 'application/admin/view/shopro/partner/reward/index.html');
|
|
assert(fs.existsSync(partnerRewardViewPath), 'partner/reward/index.html 文件存在');
|
|
const partnerRewardViewContent = fs.readFileSync(partnerRewardViewPath, 'utf8');
|
|
assert(partnerRewardViewContent.includes('label="入账账户"'), '收益流水主列表包含「入账账户」列');
|
|
assert(partnerRewardViewContent.includes('orderTreeDialog'), '包含订单透视弹窗');
|
|
assert(partnerRewardViewContent.match(/orderTreeDialog[\s\S]*label="入账账户"/), '订单透视明细树表格包含「入账账户」列');
|
|
|
|
// --- 5. 会员详情与会员列表 (user/user) 验证 ---
|
|
console.log('\n--- 5. 会员详情与会员列表 (user/user) 验证 ---');
|
|
const userControllerPath = path.join(rootDir, 'application/admin/controller/shopro/user/User.php');
|
|
assert(fs.existsSync(userControllerPath), 'User.php 文件存在');
|
|
const userControllerContent = fs.readFileSync(userControllerPath, 'utf8');
|
|
assert(userControllerContent.includes('alignedTotalIncome = max($agentTotalIncome, (float) $totalCash)'), 'User.php 累计收益取分销与二开收益中心最大值对齐');
|
|
assert(userControllerContent.includes("$data['total_income'] = number_format($alignedTotalIncome"), 'User.php 输出格式化 total_income');
|
|
assert(userControllerContent.includes("$data['income_total_cash'] = number_format($alignedTotalIncome"), 'User.php 输出格式化 income_total_cash');
|
|
assert(userControllerContent.includes("$data['money'] = number_format"), 'User.php 输出格式化 money');
|
|
assert(userControllerContent.includes("$data['commission'] = number_format"), 'User.php 输出格式化 commission');
|
|
|
|
const userDetailViewPath = path.join(rootDir, 'application/admin/view/shopro/user/user/detail.html');
|
|
assert(fs.existsSync(userDetailViewPath), 'user/detail.html 文件存在');
|
|
const userDetailViewContent = fs.readFileSync(userDetailViewPath, 'utf8');
|
|
assert(userDetailViewContent.includes('当前钱包余额: ¥{{ state.detail.money'), '会员详情卡片1明确为「当前钱包余额」');
|
|
assert(userDetailViewContent.includes('历史未转佣金: ¥{{ state.detail.commission'), '会员详情卡片1明确为「历史未转佣金」');
|
|
assert(userDetailViewContent.includes('state.detail.total_income || state.detail.income_total_cash'), '卡片1优先绑定统一对齐的 total_income');
|
|
assert(userDetailViewContent.match(/log\.tabActive == 'partner_reward'[\s\S]*label="入账账户"/), 'Tab 1 收益中心流水包含「入账账户」列');
|
|
|
|
const userIndexViewPath = path.join(rootDir, 'application/admin/view/shopro/user/user/index.html');
|
|
assert(fs.existsSync(userIndexViewPath), 'user/index.html 文件存在');
|
|
const userIndexViewContent = fs.readFileSync(userIndexViewPath, 'utf8');
|
|
assert(!userIndexViewContent.includes('可提现收益:'), '会员列表已彻底移除误导性文案「可提现收益」');
|
|
assert(userIndexViewContent.includes('累计收益:'), '会员列表展示「累计收益」');
|
|
assert(userIndexViewContent.includes('钱包余额: ¥{{ scope.row.money'), '会员列表展示「钱包余额」');
|
|
assert(userIndexViewContent.includes('未转佣金: ¥{{ scope.row.commission'), '会员列表展示「未转佣金」');
|
|
|
|
// --- 6. 分销商详情与佣金明细 (commission) 验证 ---
|
|
console.log('\n--- 6. 分销商详情与佣金明细 (commission) 验证 ---');
|
|
const agentControllerPath = path.join(rootDir, 'application/admin/controller/shopro/commission/Agent.php');
|
|
assert(fs.existsSync(agentControllerPath), 'commission/Agent.php 文件存在');
|
|
const agentControllerContent = fs.readFileSync(agentControllerPath, 'utf8');
|
|
assert(agentControllerContent.includes('alignedIncome = number_format(max(floatval($detail->total_income ?? 0), (float) $totalCash)'), 'Agent.php detail 累计收益严格对齐收益中心');
|
|
assert(agentControllerContent.includes('$detail->user_money = number_format'), 'Agent.php 注入 user_money');
|
|
assert(agentControllerContent.includes('$detail->user_commission = number_format'), 'Agent.php 注入 user_commission');
|
|
|
|
const agentDetailViewPath = path.join(rootDir, 'application/admin/view/shopro/commission/agent/detail.html');
|
|
assert(fs.existsSync(agentDetailViewPath), 'commission/agent/detail.html 文件存在');
|
|
const agentDetailViewContent = fs.readFileSync(agentDetailViewPath, 'utf8');
|
|
assert(agentDetailViewContent.includes('直入钱包余额'), '分销商详情收益卡片带有「直入钱包余额」Tag');
|
|
assert(agentDetailViewContent.includes('钱包可用余额:'), '分销商资产信息包含「钱包可用余额」');
|
|
assert(agentDetailViewContent.includes('历史未转佣金:'), '分销商资产信息包含「历史未转佣金」');
|
|
assert(agentDetailViewContent.includes('label="历史分销佣金"'), 'Tab 3 明确标注为「历史分销佣金」');
|
|
|
|
const commRewardViewPath = path.join(rootDir, 'application/admin/view/shopro/commission/reward/index.html');
|
|
assert(fs.existsSync(commRewardViewPath), 'commission/reward/index.html 文件存在');
|
|
const commRewardViewContent = fs.readFileSync(commRewardViewPath, 'utf8');
|
|
assert(commRewardViewContent.includes('当前收益分成已全额直入钱包余额'), '历史佣金明细顶部包含直入钱包余额提示说明');
|
|
|
|
const commRewardControllerPath = path.join(rootDir, 'application/admin/controller/shopro/commission/Reward.php');
|
|
assert(fs.existsSync(commRewardControllerPath), 'commission/Reward.php 文件存在');
|
|
const commRewardControllerContent = fs.readFileSync(commRewardControllerPath, 'utf8');
|
|
assert(commRewardControllerContent.includes('历史分销佣金列表'), '导出文件名称更新为「历史分销佣金列表」');
|
|
|
|
// --- 7. 底层分润服务 ext.wallet_type 与日志兜底防误导验证 ---
|
|
console.log('\n--- 7. 底层分润服务 ext.wallet_type 与日志兜底防误导验证 ---');
|
|
const partnerRewardServicePath = path.join(rootDir, 'addons/shopro/service/partner/PartnerRewardService.php');
|
|
assert(fs.existsSync(partnerRewardServicePath), 'PartnerRewardService.php 文件存在');
|
|
const partnerRewardServiceContent = fs.readFileSync(partnerRewardServicePath, 'utf8');
|
|
assert(partnerRewardServiceContent.includes("$ext['wallet_type'] = $walletType;"), 'PartnerRewardService::account 显式持久化 ext.wallet_type 确保自说明性');
|
|
|
|
const dailySettleServicePath = path.join(rootDir, 'addons/shopro/service/partner/DailySettleService.php');
|
|
assert(fs.existsSync(dailySettleServicePath), 'DailySettleService.php 文件存在');
|
|
const dailySettleServiceContent = fs.readFileSync(dailySettleServicePath, 'utf8');
|
|
assert(dailySettleServiceContent.includes("'wallet_type' => $walletType,"), 'DailySettleService 均分分润显式持久化 ext.wallet_type');
|
|
assert(dailySettleServiceContent.includes("'wallet_type' => 'system',"), 'DailySettleService 平台尾差与分母为0显式持久化 ext.wallet_type 为 system');
|
|
|
|
const walletLogModelPath = path.join(rootDir, 'application/admin/model/shopro/user/WalletLog.php');
|
|
assert(fs.existsSync(walletLogModelPath), 'WalletLog.php 文件存在');
|
|
const walletLogModelContent = fs.readFileSync(walletLogModelPath, 'utf8');
|
|
assert(walletLogModelContent.includes("$eventMap['money'][$event] ?? ($eventMap['commission'][$event] ?? ($event ?: ''))"), 'WalletLog::getEventTextAttr 包含跨钱包与事件编码三级非空兜底保护');
|
|
|
|
console.log('\n========================================================');
|
|
console.log(`测试完成!通过: ${passCount}, 失败: ${failCount}`);
|
|
console.log('========================================================');
|
|
|
|
if (failCount > 0) {
|
|
process.exit(1);
|
|
}
|