feat: 临时调整马豆结算与兑换券释放为1分钟执行一次
这个提交包含在:
@@ -96,6 +96,14 @@ assert(
|
||||
dashboardControllerContent.includes("'history_order_n' => $historyOrderN"),
|
||||
'大盘接口输出历史累计完成订单数 history_order_n'
|
||||
);
|
||||
assert(
|
||||
dashboardControllerContent.includes("'base_rate' => $baseRate"),
|
||||
'大盘接口动态输出系统配置的基础汇率 base_rate'
|
||||
);
|
||||
assert(
|
||||
dashboardControllerContent.includes("'step_orders' => $stepOrders"),
|
||||
'大盘接口动态输出步进订单数 step_orders'
|
||||
);
|
||||
|
||||
// 6. 验证前端仪表盘模板 application/admin/view/shopro/dashboard/index.html 卡片设计
|
||||
const dashboardViewPath = path.resolve(__dirname, '../application/admin/view/shopro/dashboard/index.html');
|
||||
@@ -127,8 +135,8 @@ assert(
|
||||
'大盘视图展示每万豆价值 rate_per_wan'
|
||||
);
|
||||
assert(
|
||||
dashboardViewContent.includes('0.00000075 × {{ state.madow.history_order_n }} 单'),
|
||||
'大盘视图直观呈现汇率计算公式 (0.00000075 × N 单)'
|
||||
dashboardViewContent.includes("{{ state.madow.base_rate || '0.00000075' }} × {{ state.madow.history_order_n }} 单"),
|
||||
'大盘视图呈现动态汇率计算公式 (动态 base_rate × N 单)'
|
||||
);
|
||||
assert(
|
||||
dashboardViewContent.includes('日结池明细 →'),
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assert = require('assert');
|
||||
|
||||
console.log('========================================================');
|
||||
console.log(' 马豆 1 分钟增量结算与兑换券 1 分钟释放规范自动化测试');
|
||||
console.log('========================================================\n');
|
||||
|
||||
let passCount = 0;
|
||||
function test(name, fn) {
|
||||
try {
|
||||
fn();
|
||||
console.log(` [PASS] ${name}`);
|
||||
passCount++;
|
||||
} catch (err) {
|
||||
console.error(` [FAIL] ${name}: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. VoucherService 验证
|
||||
const voucherServicePath = path.resolve(__dirname, '../addons/shopro/service/partner/VoucherService.php');
|
||||
assert(fs.existsSync(voucherServicePath), 'VoucherService.php 文件存在');
|
||||
const voucherContent = fs.readFileSync(voucherServicePath, 'utf-8');
|
||||
|
||||
test('VoucherService 包含 releaseMinute() 分钟级释放方法', () => {
|
||||
assert(voucherContent.includes('function releaseMinute()'), '必须定义 releaseMinute()');
|
||||
});
|
||||
|
||||
test('VoucherService 包含立即生效起算逻辑', () => {
|
||||
assert(voucherContent.includes("date('Y-m-d', $this->orderTime($order))"), '起算日期当天立即生效');
|
||||
});
|
||||
|
||||
test('VoucherService 分钟释放使用 NULL 结算日规避唯一索引冲突', () => {
|
||||
assert(voucherContent.includes("'settle_date' => null"), 'settle_date 必须设为 null 避开 uk_daily_user_type 限制');
|
||||
assert(voucherContent.includes("$virtualOrderId = -(intval($plan->id) * 1000"), 'order_id 必须使用负数虚拟 ID 避开 uk_order_user_type 限制');
|
||||
});
|
||||
|
||||
// 2. MadowService 验证
|
||||
const madowServicePath = path.resolve(__dirname, '../addons/shopro/service/partner/MadowService.php');
|
||||
assert(fs.existsSync(madowServicePath), 'MadowService.php 文件存在');
|
||||
const madowContent = fs.readFileSync(madowServicePath, 'utf-8');
|
||||
|
||||
test('MadowService 包含 shareMinute() 分钟级马豆分红方法', () => {
|
||||
assert(madowContent.includes('function shareMinute('), '必须定义 shareMinute()');
|
||||
});
|
||||
|
||||
test('MadowService 分钟分红使用防重虚拟 order_id 与 NULL 结算日', () => {
|
||||
assert(madowContent.includes("'settle_date' => null"), 'settle_date 必须设为 null');
|
||||
assert(madowContent.includes("$virtualOrderId = min(-100000,"), '必须保证递减全局虚拟 order_id');
|
||||
});
|
||||
|
||||
// 3. DailySettleService 验证
|
||||
const dailySettlePath = path.resolve(__dirname, '../addons/shopro/service/partner/DailySettleService.php');
|
||||
assert(fs.existsSync(dailySettlePath), 'DailySettleService.php 文件存在');
|
||||
const settleContent = fs.readFileSync(dailySettlePath, 'utf-8');
|
||||
|
||||
test('DailySettleService 包含 runMinute() 总调度入口', () => {
|
||||
assert(settleContent.includes('function runMinute()'), '必须定义 runMinute()');
|
||||
});
|
||||
|
||||
test('DailySettleService runMinute 调度兑换券与马豆结算', () => {
|
||||
assert(settleContent.includes('releaseMinute()'), '调用 releaseMinute() 释放兑换券');
|
||||
assert(settleContent.includes('shareMinute('), '调用 shareMinute() 发放马豆');
|
||||
assert(settleContent.includes("'madow_settled'] = 1"), '订单必须打上 madow_settled 标记防止重复均分');
|
||||
assert(settleContent.includes('partner_settle_minute.lock'), '包含独立互斥锁保障并发安全');
|
||||
});
|
||||
|
||||
// 4. PartnerSettle.php 控制台命令验证
|
||||
const partnerSettlePath = path.resolve(__dirname, '../addons/shopro/console/PartnerSettle.php');
|
||||
assert(fs.existsSync(partnerSettlePath), 'PartnerSettle.php 文件存在');
|
||||
const cmdContent = fs.readFileSync(partnerSettlePath, 'utf-8');
|
||||
|
||||
test('PartnerSettle 默认执行 runMinute() 分钟级调度', () => {
|
||||
assert(cmdContent.includes('runMinute()'), '默认调用 runMinute()');
|
||||
assert(cmdContent.includes('partner minute settle done'), '输出分钟级执行结果日志');
|
||||
});
|
||||
|
||||
test('PartnerSettle 保留 --date / --rerun / --daily 传统日结兼容', () => {
|
||||
assert(cmdContent.includes("$input->getOption('date')"), '兼容 -d/--date 参数');
|
||||
assert(cmdContent.includes("$input->getOption('rerun')"), '兼容 -r/--rerun 参数');
|
||||
assert(cmdContent.includes("$input->getOption('daily')"), '兼容 --daily 参数');
|
||||
});
|
||||
|
||||
console.log('\n--------------------------------------------------------');
|
||||
console.log(`测试执行结果: 通过 ${passCount} 项, 失败 0 项`);
|
||||
console.log('========================================================\n');
|
||||
在新工单中引用
屏蔽一个用户