fix(partner): 修复30天保活倒计时方案A精确秒级顺延并实现HL规范昵称生成规则
这个提交包含在:
@@ -51,6 +51,17 @@ it('IdentityService.php 导出 expire_time / expire_seconds / days_remaining', (
|
||||
assert(identityContent.includes("'days_remaining'"), "缺少 days_remaining");
|
||||
});
|
||||
|
||||
it('IdentityService.php 符合方案 A:以订单时间戳精确顺延30天,严禁抹平为零点', () => {
|
||||
assert(identityContent.includes('$expireTime = $lastTime + $windowDays * 86400;'), '未采用方案A精确顺延');
|
||||
assert(!identityContent.includes("date('Y-m-d 00:00:00', $lastTime)"), '仍残留错误抹平为零点的逻辑');
|
||||
});
|
||||
|
||||
const activeServicePath = path.resolve(__dirname, '../addons/shopro/service/partner/ActiveService.php');
|
||||
const activeContent = fs.readFileSync(activeServicePath, 'utf8');
|
||||
it('ActiveService.php 活跃判定支持方案 A 秒级 30 天有效', () => {
|
||||
assert(activeContent.includes('$at <= $lastTime + $days * 86400'), 'ActiveService 缺少方案A秒级判定');
|
||||
});
|
||||
|
||||
// 2. 模拟前端状态计算与倒计时逻辑
|
||||
function calculateActiveState(agent, user, nowSec) {
|
||||
const lastTime = Number(agent.last_self_order_time || user.last_self_order_time || 0);
|
||||
@@ -130,6 +141,23 @@ it('正常场景:剩余28天 -> 状态为 active 且倒计时天数格式为 2
|
||||
assert.strictEqual(cd.seconds, '30');
|
||||
});
|
||||
|
||||
// 3.1 真实业务场景复现(用户截图:09-19 14:39:00 下单,09-26 13:42:14 查看)
|
||||
it('真实截图场景:09-19 14:39 下单,09-26 13:42:14 查看 -> 准确剩余 23天 00时 56分 46秒', () => {
|
||||
const orderTime = new Date('2026-09-19T14:39:00+08:00').getTime() / 1000;
|
||||
const viewTime = new Date('2026-09-26T13:42:14+08:00').getTime() / 1000;
|
||||
// 方案 A:精确顺延 30 天
|
||||
const expire = orderTime + 30 * 86400;
|
||||
const state = calculateActiveState({ expire_time: expire, last_self_order_time: orderTime }, {}, viewTime);
|
||||
const cd = calculateCountdown(expire, viewTime);
|
||||
|
||||
assert.strictEqual(state.status, 'active');
|
||||
assert.strictEqual(state.badge, '正常活跃');
|
||||
assert.strictEqual(cd.days, '23', '方案A下天数应准确为 23 天,绝不能是 22 天');
|
||||
assert.strictEqual(cd.hours, '00', '方案A下小时应准确为 00 时,绝不能是 10 时');
|
||||
assert.strictEqual(cd.minutes, '56', '方案A下分钟应准确为 56 分');
|
||||
assert.strictEqual(cd.seconds, '46', '方案A下秒数应准确为 46 秒');
|
||||
});
|
||||
|
||||
// 4. 临期场景:剩余 3 天(<= 5 天) -> 临期预警
|
||||
it('临期预警场景:剩余3天 -> 状态为 expiring,提示立即自购保活', () => {
|
||||
const now = 1700000000;
|
||||
|
||||
在新工单中引用
屏蔽一个用户