CaiWuXiTong/tests/Unit/EcommerceFinance/ShengsuanOrderProfitRowMapperTest.php
renshen 3a97bf942c feat: 订单利润接入聚胜算页面费用结果 (#987)
订单利润的包材费、快递费、账单费用直接读取聚胜算页面接口结果;新增抓取脚本与导入命令。
2026-11-07 17:34:38 +08:00

52 lines
2.1 KiB
PHP

<?php
namespace Tests\Unit\EcommerceFinance;
use Modules\EcommerceFinance\Services\ShengsuanOrderProfitRowMapper;
use Tests\TestCase;
class ShengsuanOrderProfitRowMapperTest extends TestCase
{
public function test_maps_page_headers_and_keeps_the_three_matched_fees(): void
{
$mapper = new ShengsuanOrderProfitRowMapper();
$rows = $mapper->rows([
'data' => [
'fldHeads' => [
['fld' => 'c_1', 'title' => '店铺名称'],
['fld' => 'c_2', 'title' => '线上单号'],
['fld' => 'c_3', 'title' => '内部单号'],
['fld' => 'c_4', 'title' => '包材费(自动匹配)'],
['fld' => 'c_5', 'title' => '快递费(自动匹配)'],
['fld' => 'c_6', 'title' => '账单费用(自动匹配)'],
['fld' => 'c_7', 'title' => '人工维护'],
['fld' => 'c_8', 'title' => '订单费用'],
],
'dataList' => [[
'c_1' => '天猫-卓禾家具旗舰店',
'c_2' => '5127581702031023636',
'c_3' => '10097143',
'c_4' => 0,
'c_5' => 7.05,
'c_6' => -0.5,
'c_7' => 3.6,
'c_8' => 10.15,
]],
],
]);
$this->assertCount(1, $rows);
$row = $rows[0];
$this->assertSame('天猫-卓禾家具旗舰店', $row['shop_name']);
$this->assertSame('5127581702031023636', $row['online_order_no']);
$this->assertSame('10097143', $row['internal_order_no']);
$this->assertSame('天猫-卓禾家具旗舰店|5127581702031023636', $row['order_key']);
$this->assertSame(0.0, $row['matched_package_fee']);
$this->assertSame(7.05, $row['matched_freight_fee']);
$this->assertSame(-0.5, $row['matched_bill_fee']);
$this->assertSame(3.6, $row['manual_fee']);
$this->assertSame(10.15, $row['order_fee']);
$this->assertArrayHasKey('source_payload', $row);
}
}