CaiWuXiTong/tests/Unit/EcommerceFinance/ShengsuanOrderProfitRowMapperTest.php
renshen 1b6ff0bb75 feat: 新增成本运费异常监控 (#992)
成本/运费异常页监控商品成本和快递费同时缺失的订单。
2026-11-07 18:04:44 +08:00

58 lines
2.4 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_8', 'title' => '发货时间'],
['fld' => 'c_9', 'title' => '商品成本'],
['fld' => 'c_4', 'title' => '包材费(自动匹配)'],
['fld' => 'c_5', 'title' => '快递费(自动匹配)'],
['fld' => 'c_6', 'title' => '账单费用(自动匹配)'],
['fld' => 'c_10', 'title' => '人工维护'],
['fld' => 'c_11', 'title' => '订单费用'],
],
'dataList' => [[
'c_1' => '天猫-卓禾家具旗舰店',
'c_2' => '5127581702031023636',
'c_3' => '10097143',
'c_8' => '2026/11/5 12:58:35',
'c_9' => 0,
'c_4' => 0,
'c_5' => 7.05,
'c_6' => -0.5,
'c_10' => 3.6,
'c_11' => 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('2026-11-05 12:58:35', $row['ship_time']);
$this->assertSame(0.0, $row['product_cost']);
$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);
}
}