- 新增商品服务定价配置表,支持多规格服务价格体系 - 新增步梯搬运费配置功能,可按楼层阶梯收费 - 重构支付订单台账,新增核心数据统计卡片 - 优化下单流程,支持定价配置校验与增项计算 - 整合财务配置,移除独立充值配置菜单
53 行
1.8 KiB
PHP
53 行
1.8 KiB
PHP
<?php
|
|
|
|
define('APP_PATH', __DIR__ . '/../server/application/');
|
|
require __DIR__ . '/../server/thinkphp/base.php';
|
|
\think\App::initCommon();
|
|
|
|
use app\api\controller\Home;
|
|
use app\admin\controller\Service;
|
|
use think\Request;
|
|
|
|
$controller = new ReflectionClass(Service::class);
|
|
$serviceAdmin = $controller->newInstanceWithoutConstructor();
|
|
$request = $controller->getProperty('request');
|
|
$request->setAccessible(true);
|
|
$request->setValue($serviceAdmin, Request::create('/service/add', 'POST', ['floor_fee_mode' => 'paid']));
|
|
$normalizeFloorFees = $controller->getMethod('normalizeFloorFees');
|
|
$normalizeFloorFees->setAccessible(true);
|
|
try {
|
|
$free = $normalizeFloorFees->invoke($serviceAdmin, ['floor_fee' => '0', 'free_floor' => '2']);
|
|
} catch (\think\exception\ValidateException $error) {
|
|
fwrite(STDERR, "Entering 0 yuan should enable free carry: " . $error->getMessage() . "\n");
|
|
exit(1);
|
|
}
|
|
if ((float)$free['floor_fee'] !== 0.0 || (int)$free['free_floor'] !== 0) {
|
|
fwrite(STDERR, "Entering 0 yuan should store free carry for all floors.\n");
|
|
exit(1);
|
|
}
|
|
|
|
$product = ['price_type' => 'fixed', 'base_price' => '80.00', 'floor_fee' => '0.00', 'free_floor' => 2];
|
|
$address = ['floor' => 5, 'has_elevator' => 0, 'urgent' => 0];
|
|
|
|
function assertFloorFee(array $product, array $address, float $expected)
|
|
{
|
|
$amount = Home::calcAmount($product, $address);
|
|
if ($amount['floor_amount'] !== $expected || $amount['total_amount'] !== 80.0 + $expected) {
|
|
fwrite(STDERR, "Expected floor fee {$expected}; calculated {$amount['floor_amount']}\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
assertFloorFee($product, $address, 0.0);
|
|
|
|
$product['floor_fee'] = '8.50';
|
|
assertFloorFee($product, $address, 25.5);
|
|
|
|
$product['free_floor'] = 0;
|
|
assertFloorFee($product, $address, 42.5);
|
|
|
|
$address['has_elevator'] = 1;
|
|
assertFloorFee($product, $address, 0.0);
|
|
|
|
echo "Checkout floor fee tests passed\n";
|