feat(goods): 商品详情接口增加复购立减提示与完善单元测试

这个提交包含在:
wikiboss
2026-09-12 17:15:08 +08:00
父节点 02f69f9beb
当前提交 92622fc9b1
共有 2 个文件被更改,包括 55 次插入 和 0 次删除

查看文件

@@ -27,6 +27,7 @@ class RepurchaseDiscountTest
$this->testRepurchaseRateDiscount();
$this->testDiscountCapProtection();
$this->testMixedOrderDiscounts();
$this->testGoodsDetailRepurchaseTip();
echo "\n----------------------------------------\n";
echo "测试结果: {$this->passed} 通过, {$this->failed} 失败\n";
@@ -265,6 +266,31 @@ class RepurchaseDiscountTest
$this->assert($newGoodsList[0]['repurchase_discount_money'] === 10.00, "商品 201 立减应为 10.00 (实际: {$newGoodsList[0]['repurchase_discount_money']})");
$this->assert($newGoodsList[1]['repurchase_discount_money'] === 0.00, "商品 202 立减应为 0.00 (实际: {$newGoodsList[1]['repurchase_discount_money']})");
}
/**
* 测试场景 7: 商详复购立减提示文案与状态
*/
public function testGoodsDetailRepurchaseTip()
{
echo "\n场景 7: 商详页复购立减提示逻辑\n";
$config = [
'enable' => true,
'self_enable' => true,
'self_type' => 'fixed',
'self_amount' => 15.00,
'self_rate' => 0
];
// 模拟已购买老客
$discountDesc = ($config['self_type'] ?? 'fixed') === 'rate' ? ($config['self_rate'] . '%') : ('¥' . $config['self_amount']);
$tipRepurchase = '您曾购买过本商品,再次下单立减' . $discountDesc;
$tipNew = '老客复购享立减' . $discountDesc;
$this->assert($tipRepurchase === '您曾购买过本商品,再次下单立减¥15', "老客专享提示文案匹配 (实际: {$tipRepurchase})");
$this->assert($tipNew === '老客复购享立减¥15', "新客引导提示文案匹配 (实际: {$tipNew})");
}
}
(new RepurchaseDiscountTest())->run();